Skip to content

Commit

Permalink
changed serviceResource definition (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilijad1 authored Nov 10, 2023
1 parent d1e72c6 commit e449359
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,27 +75,19 @@ func newTraceExporter(ctx context.Context) (*otlptrace.Exporter, error) {
}

func newServiceResource(name string) *resource.Resource {
res, err := resource.Merge(
resource.Default(),
resource.NewWithAttributes(semconv.SchemaURL, semconv.ServiceNameKey.String(name)),
)
if err != nil {
log.Fatalf("The SchemaURL of the resources is not merged.")
}
versionInfo := buildVersion
if serviceVersion, found := os.LookupEnv("OTEL_SERVICE_VERSION"); found {
log.Println("Warning: build time version overriden by environment variable")
versionInfo = serviceVersion

}
res, err = resource.Merge(
res,
resource.NewWithAttributes(semconv.SchemaURL, semconv.ServiceVersionKey.String(versionInfo)),
res, err := resource.Merge(
resource.Default(),
resource.NewWithAttributes(semconv.SchemaURL, semconv.ServiceName(name), semconv.ServiceVersion(versionInfo)),
)
if err != nil {
log.Fatalf("The SchemaURL of the resources is not merged.")
}

}
return res
}

Expand Down

0 comments on commit e449359

Please sign in to comment.