Skip to content

Commit

Permalink
instrumentation: use resource.New() instead of Merge().
Browse files Browse the repository at this point in the history
Use resource.New*() to create our OpenTelemetry resource as
opposed to Merge()ing with resource.Default(). This should
avoid hitting the annoying semconv schema snafu
(open-telemetry/opentelemetry-go#4476)
which we'd otherwise hit if/when the default semconv version
is bumped.

Signed-off-by: Krisztian Litkey <[email protected]>
  • Loading branch information
klihub committed Jan 15, 2024
1 parent acba171 commit 53d4607
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions pkg/instrumentation/tracing/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,25 +127,19 @@ func (t *tracing) start(options ...Option) error {
log.Info("starting tracing exporter...")

hostname, _ := os.Hostname()
resource, err := resource.Merge(
resource.Default(),
resource.NewWithAttributes(
semconv.SchemaURL,
append(
[]attribute.KeyValue{
semconv.ServiceName(t.service),
semconv.HostNameKey.String(hostname),
semconv.ProcessPIDKey.Int64(int64(os.Getpid())),
attribute.String("Version", version.Version),
attribute.String("Build", version.Build),
},
t.identity...,
)...,
),
resource := resource.NewWithAttributes(
semconv.SchemaURL,
append(
[]attribute.KeyValue{
semconv.ServiceName(t.service),
semconv.HostNameKey.String(hostname),
semconv.ProcessPIDKey.Int64(int64(os.Getpid())),
attribute.String("Version", version.Version),
attribute.String("Build", version.Build),
},
t.identity...,
)...,
)
if err != nil {
return fmt.Errorf("failed to create tracing resource: %w", err)
}

exporter, err := getExporter(t.endpoint)
if err != nil {
Expand Down

0 comments on commit 53d4607

Please sign in to comment.