From e449359863af90dda2113cebb2971eafbd166238 Mon Sep 17 00:00:00 2001 From: Ilija Dimitrovski <36102926+ilijad1@users.noreply.github.com> Date: Fri, 10 Nov 2023 16:46:53 +0100 Subject: [PATCH] changed serviceResource definition (#40) --- cmd/root.go | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 9c48166..f54c38d 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -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 }