Skip to content

Commit

Permalink
Fix nil reference error when starting Tempo (#2444)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbdias authored Apr 26, 2023
1 parent ae43aef commit 897e8a8
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 3 deletions.
1 change: 1 addition & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ This is the entire checklist on what we should do to assert that Tracetest is wo
- [ ] [Lightstep example](https://github.com/kubeshop/tracetest/tree/main/examples/tracetest-lightstep)
- [ ] [New Relic example](https://github.com/kubeshop/tracetest/tree/main/examples/tracetest-new-relic)
- [ ] [SignalFX example](https://github.com/kubeshop/tracetest/tree/main/examples/tracetest-signalfx)
- [ ] [Tempo Cloud example](https://github.com/kubeshop/tracetest/tree/main/examples/quick-start-grafana-cloud-tempo-nodejs)

- Test specific features added/changed on this release:

Expand Down
27 changes: 27 additions & 0 deletions local-config/tempo-cloud/collector.config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
receivers:
otlp:
protocols:
grpc:
http:

processors:
batch:
timeout: 100ms

exporters:
logging:
loglevel: debug
otlp:
endpoint: tempo-us-central1.grafana.net:443
headers:
authorization: Basic <tempo-cloud-base64-key>
# https://grafana.com/blog/2021/04/13/how-to-send-traces-to-grafana-clouds-tempo-service-with-opentelemetry-collector/
tls:
insecure: false

service:
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [otlp]
24 changes: 24 additions & 0 deletions local-config/tempo-cloud/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: "3"
services:
postgres:
image: postgres:14
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
healthcheck:
test: pg_isready -U "$$POSTGRES_USER" -d "$$POSTGRES_DB"
interval: 1s
timeout: 5s
retries: 60
ports:
- 5432:5432

otel-collector:
image: otel/opentelemetry-collector-contrib:0.73.0
command:
- "--config"
- "/otel-local-config.yaml"
volumes:
- ./collector.config.yaml:/otel-local-config.yaml
ports:
- 4317:4317
21 changes: 21 additions & 0 deletions local-config/tempo-cloud/tracetest.config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
postgres:
host: localhost
user: postgres
password: postgres
port: 5432
dbname: postgres
params: sslmode=disable

telemetry:
exporters:
collector:
serviceName: tracetest
sampling: 100 # 100%
exporter:
type: collector
collector:
endpoint: localhost:4317

server:
telemetry:
exporter: collector
12 changes: 12 additions & 0 deletions local-config/tempo-cloud/tracetest.provision.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
type: DataStore
spec:
name: Grafana Tempo Cloud
type: tempo
tempo:
type: http
http:
url: https://tempo-us-central1.grafana.net/tempo
headers:
Authorization: Basic <tempo-cloud-base64-key>
# https://grafana.com/blog/2021/04/13/how-to-send-traces-to-grafana-clouds-tempo-service-with-opentelemetry-collector/
16 changes: 13 additions & 3 deletions server/tracedb/datasource/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func NewHttpClient(name string, config *datastoreresource.HttpClientConfig, call
endpoint, _ := url.Parse(config.Url)
client := &http.Client{
Transport: &http.Transport{
TLSClientConfig: getTlsConfig(config.TLS.Settings.CAFile, config.TLS.Insecure),
TLSClientConfig: getTlsConfig(config.TLS),
},
}

Expand Down Expand Up @@ -118,13 +118,23 @@ func (client *HttpClient) Request(ctx context.Context, path, method, body string
return response, nil
}

func getTlsConfig(caCertFile string, skipVerify bool) *tls.Config {
func getTlsConfig(dataStoreTls *datastoreresource.TLS) *tls.Config {
tlsConfig := tls.Config{}

if skipVerify {
if dataStoreTls == nil {
return &tlsConfig
}

if dataStoreTls.Insecure {
tlsConfig.InsecureSkipVerify = true
}

if dataStoreTls.Settings == nil {
return &tlsConfig
}

caCertFile := dataStoreTls.Settings.CAFile

if caCertFile != "" {
caCertPool := x509.NewCertPool()
caCertPool.AppendCertsFromPEM([]byte(caCertFile))
Expand Down

0 comments on commit 897e8a8

Please sign in to comment.