fix: Use standard env variables for opentelemtry (#2194)
Opentelemetry defines standard variables which are supported by multiple observability platforms. [1] https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/sdk-environment-variables.md [2] https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md By defining support for standard env vars, Fission open telemetry support can be leveraged with different platforms such as NewRelic, SigNoz, DataDog etc. Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
@@ -17,6 +17,7 @@ limitations under the License.
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
@@ -225,6 +226,7 @@ Options:
|
||||
logger.Fatal("Could not parse command line arguments", zap.Error(err))
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
openTracingEnabled := tracing.TracingEnabled(logger)
|
||||
if openTracingEnabled {
|
||||
err = tracing.RegisterTraceExporter(logger, os.Getenv("TRACE_JAEGER_COLLECTOR_ENDPOINT"), getServiceName(arguments))
|
||||
@@ -232,12 +234,12 @@ Options:
|
||||
logger.Fatal("Could not register trace exporter", zap.Error(err), zap.Any("argument", arguments))
|
||||
}
|
||||
} else {
|
||||
shutdown, err := otel.InitProvider(logger, getServiceName(arguments))
|
||||
shutdown, err := otel.InitProvider(ctx, logger, getServiceName(arguments))
|
||||
if err != nil {
|
||||
logger.Fatal("error initializing provider for OTLP", zap.Error(err), zap.Any("argument", arguments))
|
||||
}
|
||||
if shutdown != nil {
|
||||
defer shutdown()
|
||||
defer shutdown(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user