Skip to content

Commit

Permalink
refactor: tidy verbose service name
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesstocktonj1 committed Oct 5, 2024
1 parent 56a33cf commit 08bc2fc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions observability.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,18 @@ 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
}

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.ContainerIDKey.String(hostData.InstanceID),
semconv.ContainerImageNameKey.String(filepath.Base(providerBinary)),
),
)
}
2 changes: 1 addition & 1 deletion provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 08bc2fc

Please sign in to comment.