diff --git a/core/trace/agent.go b/core/trace/agent.go index 19ae59cde..2a2e8c372 100644 --- a/core/trace/agent.go +++ b/core/trace/agent.go @@ -113,11 +113,13 @@ func createExporter(c Config) (sdktrace.SpanExporter, error) { } func startAgent(c Config) error { + AddResources(semconv.ServiceNameKey.String(c.Name)) + opts := []sdktrace.TracerProviderOption{ // Set the sampling rate based on the parent span to 100% sdktrace.WithSampler(sdktrace.ParentBased(sdktrace.TraceIDRatioBased(c.Sampler))), // Record information about this application in a Resource. - sdktrace.WithResource(resource.NewSchemaless(semconv.ServiceNameKey.String(c.Name))), + sdktrace.WithResource(resource.NewSchemaless(attrResources...)), } if len(c.Endpoint) > 0 { diff --git a/core/trace/resource.go b/core/trace/resource.go new file mode 100644 index 000000000..84d4d4535 --- /dev/null +++ b/core/trace/resource.go @@ -0,0 +1,10 @@ +package trace + +import "go.opentelemetry.io/otel/attribute" + +var attrResources = make([]attribute.KeyValue, 0) + +// AddResources add more resources in addition to configured trace name. +func AddResources(attrs ...attribute.KeyValue) { + attrResources = append(attrResources, attrs...) +}