Skip to content

Set otel servicename and servicenamespace #276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/gcp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func main() {
flag.Parse()
ctx := context.Background()

shutdownOTel := initOTel(ctx, *traceFraction)
shutdownOTel := initOTel(ctx, *traceFraction, *origin)
defer shutdownOTel(ctx)

signer, err := NewSecretManagerSigner(ctx, *signerPublicKeySecretName, *signerPrivateKeySecretName)
Expand Down
5 changes: 3 additions & 2 deletions cmd/gcp/otel.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
//
// Tracing is enabled with statistical sampling, with the probability passed in.
// Returns a shutdown function which should be called just before exiting the process.
func initOTel(ctx context.Context, traceFraction float64) func(context.Context) {
func initOTel(ctx context.Context, traceFraction float64, origin string) func(context.Context) {
var shutdownFuncs []func(context.Context) error
// shutdown combines shutdown functions from multiple OpenTelemetry
// components into a single function.
Expand All @@ -54,7 +54,8 @@ func initOTel(ctx context.Context, traceFraction float64) func(context.Context)
resource.WithFromEnv(), // unpacks OTEL_RESOURCE_ATTRIBUTES
// Add your own custom attributes to identify your application
resource.WithAttributes(
semconv.ServiceNameKey.String("tesseract"),
semconv.ServiceNameKey.String(origin),
semconv.ServiceNamespaceKey.String("tesseract"),
),
resource.WithDetectors(gcp.NewDetector()),
)
Expand Down
Loading