Skip to content

Commit 7d4662e

Browse files
committed
Set service.name better than the AWS example
1 parent e75d715 commit 7d4662e

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

cmd/randomizer-lambda/main.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
2828
xraypropagator "go.opentelemetry.io/contrib/propagators/aws/xray"
2929
"go.opentelemetry.io/otel"
30-
"go.opentelemetry.io/otel/attribute"
3130
"go.opentelemetry.io/otel/sdk/resource"
3231
"go.opentelemetry.io/otel/sdk/trace"
3332
semconv "go.opentelemetry.io/otel/semconv/v1.37.0"
@@ -98,9 +97,9 @@ func initTracerProvider(ctx context.Context, logger *slog.Logger) *trace.TracerP
9897
}
9998

10099
func initTraceResource(ctx context.Context, logger *slog.Logger) *resource.Resource {
101-
baseResource := resource.NewWithAttributes(semconv.SchemaURL, attribute.KeyValue{
102-
Key: semconv.ServiceNameKey,
103-
Value: attribute.StringValue(os.Getenv("AWS_LAMBDA_FUNCTION_NAME"))})
100+
baseResource := resource.NewWithAttributes(
101+
semconv.SchemaURL,
102+
semconv.ServiceName(os.Getenv("AWS_LAMBDA_FUNCTION_NAME")))
104103

105104
if !xrayTracingEnabled {
106105
return baseResource

0 commit comments

Comments
 (0)