Skip to content

Commit

Permalink
Merge pull request #282 from movio/bug/breaking-telemetry-with-schemaURL
Browse files Browse the repository at this point in the history
fix: added test to ensure the semconv package matches otel
  • Loading branch information
pkqk authored Sep 23, 2024
2 parents 787bb79 + 9e99c11 commit ed6a802
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
14 changes: 9 additions & 5 deletions telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,7 @@ func InitTelemetry(ctx context.Context, cfg TelemetryConfig) (func(context.Conte
}

// Set up resource.
res, err := resource.Merge(resource.Default(),
resource.NewWithAttributes(semconv.SchemaURL,
semconv.ServiceName(cfg.ServiceName),
semconv.ServiceVersion(Version),
))
res, err := resources(cfg)
if err != nil {
return nil, handleErr(err)
}
Expand Down Expand Up @@ -227,3 +223,11 @@ func newMeterProvider(exp sdkmetric.Exporter, res *resource.Resource) (*sdkmetri

return meterProvider, nil
}

func resources(cfg TelemetryConfig) (*resource.Resource, error) {
return resource.Merge(resource.Default(),
resource.NewWithAttributes(semconv.SchemaURL,
semconv.ServiceName(cfg.ServiceName),
semconv.ServiceVersion(Version),
))
}
13 changes: 13 additions & 0 deletions telemetry_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package bramble

import (
"testing"

"github.com/stretchr/testify/require"
)

func TestResources(t *testing.T) {
cfg := TelemetryConfig{Enabled: true}
_, err := resources(cfg)
require.NoError(t, err)
}

0 comments on commit ed6a802

Please sign in to comment.