From 035a9183ad78333857ab980f4e516880eab42719 Mon Sep 17 00:00:00 2001 From: James Stockton <14148070+jamesstocktonj1@users.noreply.github.com> Date: Tue, 8 Oct 2024 15:49:46 +0100 Subject: [PATCH] feat: tidy verbose telemetry service name (#45) * refactor: tidy verbose service name Signed-off-by: jamesstocktonj1 * refactor: rename attribute keys Signed-off-by: jamesstocktonj1 --------- Signed-off-by: jamesstocktonj1 --- observability.go | 8 +++++--- provider.go | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/observability.go b/observability.go index 0b3cedc..ffc1fea 100644 --- a/observability.go +++ b/observability.go @@ -124,7 +124,7 @@ func newLoggerProvider(ctx context.Context, config OtelConfig, serviceResource * return loggerProvider, nil } -func newServiceResource(ctx context.Context, name string) (*resource.Resource, error) { +func newServiceResource(ctx context.Context, hostData HostData) (*resource.Resource, error) { providerBinary, err := os.Executable() if err != nil { return nil, err @@ -132,8 +132,10 @@ func newServiceResource(ctx context.Context, name string) (*resource.Resource, e return resource.New(ctx, resource.WithAttributes( - semconv.ServiceNameKey.String(filepath.Base(providerBinary)), - semconv.ServiceInstanceIDKey.String(name), + semconv.ServiceNameKey.String(hostData.ProviderKey), + semconv.HostIDKey.String(hostData.HostID), + semconv.ServiceInstanceIDKey.String(hostData.InstanceID), + semconv.ProcessExecutableNameKey.String(filepath.Base(providerBinary)), ), ) } diff --git a/provider.go b/provider.go index 19418f3..2357578 100644 --- a/provider.go +++ b/provider.go @@ -120,7 +120,7 @@ func NewWithHostDataSource(source io.Reader, options ...ProviderHandler) (*Wasmc propagator := newPropagator() otel.SetTextMapPropagator(propagator) - serviceResource, err := newServiceResource(context.Background(), hostData.ProviderKey) + serviceResource, err := newServiceResource(context.Background(), hostData) if err != nil { return nil, err }