Skip to content

Commit

Permalink
chore: test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
moshloop committed Aug 18, 2024
1 parent 6fcb11c commit a08032b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 8 additions & 0 deletions telemetry/otel.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/flanksource/commons/collections"
"github.com/flanksource/commons/logger"
"github.com/samber/lo"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
Expand All @@ -24,6 +25,13 @@ var OtelAttributes []attribute.KeyValue
var OtelInsecure bool

func InitTracer() func(context.Context) error {
OtelCollectorURL = lo.CoalesceOrEmpty(OtelCollectorURL, os.Getenv("OTEL_EXPORTER_OTLP_ENDPOINT"))

if OtelCollectorURL == "" {
return func(_ context.Context) error {
return nil
}
}
var secureOption otlptracegrpc.Option
if !OtelInsecure {
secureOption = otlptracegrpc.WithTLSCredentials(credentials.NewClientTLSFromCert(nil, ""))
Expand Down
6 changes: 1 addition & 5 deletions tests/setup/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ func MustDB() *sql.DB {
var WithoutDummyData = "without_dummy_data"
var WithExistingDatabase = "with_existing_database"
var recreateDatabase = os.Getenv("DUTY_DB_CREATE") != "false"
var otel = os.Getenv("OTEL_EXPORTER_OTLP_ENDPOINT")

var ShutdownHooks []func(ctx gocontext.Context) error

Expand Down Expand Up @@ -96,11 +95,8 @@ func BeforeSuiteFn(args ...interface{}) context.Context {
logger.Errorf("Failed to load test properties: %v", err)
}

if otel != "" {
logger.Infof("Sending traces to %s", otel)
ShutdownHooks = append(ShutdownHooks, telemetry.InitTracer())

ShutdownHooks = append(ShutdownHooks, telemetry.InitTracer("tests", otel, true))
}
var err error
importDummyData := true

Expand Down

0 comments on commit a08032b

Please sign in to comment.