Skip to content

Commit

Permalink
feat: allow connecting to insecure OpenTelemetry endpoints with STEAM…
Browse files Browse the repository at this point in the history
…PIPE_OTEL_INSECURE environment variable

Especially useful when connecting to a local OpenTelemetry ingesting server
  • Loading branch information
pdecat committed Oct 26, 2023
1 parent 3d900c1 commit 00778f8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion telemetry/init_telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
sdktrace "go.opentelemetry.io/otel/sdk/trace"
semconv "go.opentelemetry.io/otel/semconv/v1.4.0"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)

func Init(serviceName string) (func(), error) {
Expand All @@ -45,7 +46,12 @@ func Init(serviceName string) (func(), error) {
otelAgentAddr = "localhost:4317"
}

grpcConn, err := grpc.DialContext(ctx, otelAgentAddr)
var opts grpc.DialOption
if _, ok := os.LookupEnv(EnvOtelInsecure); ok {
log.Printf("[TRACE] STEAMPIPE_OTEL_INSECURE is set - disable security checks")
opts = grpc.WithTransportCredentials(insecure.NewCredentials())
}
grpcConn, err := grpc.DialContext(ctx, otelAgentAddr, opts)
if err != nil {
return nil, err
}
Expand Down
1 change: 1 addition & 0 deletions telemetry/telemetry_levels.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package telemetry

const EnvOtelInsecure = "STEAMPIPE_OTEL_INSECURE"
const EnvOtelLevel = "STEAMPIPE_OTEL_LEVEL"
const EnvOtelEndpoint = "OTEL_EXPORTER_OTLP_ENDPOINT"

Expand Down

0 comments on commit 00778f8

Please sign in to comment.