You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-07-13 01:00:22 +02:00
Add instrumentation scope attributes (#3131)
* Add WithScopeAttributes TracerOption to trace API * Add Attributes field to instrumentation Scope * Use scope attributes for new Tracer * Fix stdouttrace expected test output * Allow unexported Set fields in sdk/trace test * Export instrumentation scope attrs in OTLP * Add changes to the changelog * Fix imports with make lint * Add unit tests for WithScopeAttributes * Fix English in Scope documentation
This commit is contained in:
@ -24,7 +24,8 @@ import (
|
||||
type TracerConfig struct {
|
||||
instrumentationVersion string
|
||||
// Schema URL of the telemetry emitted by the Tracer.
|
||||
schemaURL string
|
||||
schemaURL string
|
||||
attributes attribute.Set
|
||||
}
|
||||
|
||||
// InstrumentationVersion returns the version of the library providing instrumentation.
|
||||
@ -37,6 +38,11 @@ func (t *TracerConfig) SchemaURL() string {
|
||||
return t.schemaURL
|
||||
}
|
||||
|
||||
// Attributes returns the scope attribute set of the Tracer.
|
||||
func (t *TracerConfig) Attributes() attribute.Set {
|
||||
return t.attributes
|
||||
}
|
||||
|
||||
// NewTracerConfig applies all the options to a returned TracerConfig.
|
||||
func NewTracerConfig(options ...TracerOption) TracerConfig {
|
||||
var config TracerConfig
|
||||
@ -314,3 +320,13 @@ func WithSchemaURL(schemaURL string) TracerOption {
|
||||
return cfg
|
||||
})
|
||||
}
|
||||
|
||||
// WithScopeAttributes sets the attributes for the scope of a Tracer. The
|
||||
// attributes are stored as an attribute set. Duplicate values are removed, the
|
||||
// last value is used.
|
||||
func WithScopeAttributes(attr ...attribute.KeyValue) TracerOption {
|
||||
return tracerOptionFunc(func(cfg TracerConfig) TracerConfig {
|
||||
cfg.attributes = attribute.NewSet(attr...)
|
||||
return cfg
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user