Skip to content

Commit

Permalink
feat: tidy verbose telemetry service name (#45)
Browse files Browse the repository at this point in the history
* refactor: tidy verbose service name

Signed-off-by: jamesstocktonj1 <[email protected]>

* refactor: rename attribute keys

Signed-off-by: jamesstocktonj1 <[email protected]>

---------

Signed-off-by: jamesstocktonj1 <[email protected]>
  • Loading branch information
jamesstocktonj1 authored Oct 8, 2024
1 parent 6d99444 commit 035a918
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.ServiceInstanceIDKey.String(hostData.InstanceID),
semconv.ProcessExecutableNameKey.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 035a918

Please sign in to comment.