You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-11-29 23:07:45 +02:00
Update span limits to conform with OpenTelemetry specification (#1535)
* Change the default span limit values to 128 * Rename and move MaxEventsPerSpan, MaxAttributesPerSpan, MaxLinksPerSpan into SpanLimits * Add AttributePerEventCountLimit and AttributePerLinkCountLimit * Update CHANGELOG * Apply suggestions from code review Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com> * Discard over limited attributes of links in `span.addLink` * Change the type of droppedAttributeCount to int64 * Fix tests * Fix label -> attribute package rename from merge Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com> Co-authored-by: Tyler Yahn <codingalias@gmail.com>
This commit is contained in:
@@ -65,11 +65,15 @@ func NewTracerProvider(opts ...TracerProviderOption) *TracerProvider {
|
||||
namedTracer: make(map[instrumentation.Library]*tracer),
|
||||
}
|
||||
tp.config.Store(&Config{
|
||||
DefaultSampler: ParentBased(AlwaysSample()),
|
||||
IDGenerator: defaultIDGenerator(),
|
||||
MaxAttributesPerSpan: DefaultMaxAttributesPerSpan,
|
||||
MaxEventsPerSpan: DefaultMaxEventsPerSpan,
|
||||
MaxLinksPerSpan: DefaultMaxLinksPerSpan,
|
||||
DefaultSampler: ParentBased(AlwaysSample()),
|
||||
IDGenerator: defaultIDGenerator(),
|
||||
SpanLimits: SpanLimits{
|
||||
AttributeCountLimit: DefaultAttributeCountLimit,
|
||||
EventCountLimit: DefaultEventCountLimit,
|
||||
LinkCountLimit: DefaultLinkCountLimit,
|
||||
AttributePerEventCountLimit: DefaultAttributePerEventCountLimit,
|
||||
AttributePerLinkCountLimit: DefaultAttributePerLinkCountLimit,
|
||||
},
|
||||
})
|
||||
|
||||
for _, sp := range o.processors {
|
||||
@@ -170,14 +174,20 @@ func (p *TracerProvider) ApplyConfig(cfg Config) {
|
||||
if cfg.IDGenerator != nil {
|
||||
c.IDGenerator = cfg.IDGenerator
|
||||
}
|
||||
if cfg.MaxEventsPerSpan > 0 {
|
||||
c.MaxEventsPerSpan = cfg.MaxEventsPerSpan
|
||||
if cfg.SpanLimits.EventCountLimit > 0 {
|
||||
c.SpanLimits.EventCountLimit = cfg.SpanLimits.EventCountLimit
|
||||
}
|
||||
if cfg.MaxAttributesPerSpan > 0 {
|
||||
c.MaxAttributesPerSpan = cfg.MaxAttributesPerSpan
|
||||
if cfg.SpanLimits.AttributeCountLimit > 0 {
|
||||
c.SpanLimits.AttributeCountLimit = cfg.SpanLimits.AttributeCountLimit
|
||||
}
|
||||
if cfg.MaxLinksPerSpan > 0 {
|
||||
c.MaxLinksPerSpan = cfg.MaxLinksPerSpan
|
||||
if cfg.SpanLimits.LinkCountLimit > 0 {
|
||||
c.SpanLimits.LinkCountLimit = cfg.SpanLimits.LinkCountLimit
|
||||
}
|
||||
if cfg.SpanLimits.AttributePerEventCountLimit > 0 {
|
||||
c.SpanLimits.AttributePerEventCountLimit = cfg.SpanLimits.AttributePerEventCountLimit
|
||||
}
|
||||
if cfg.SpanLimits.AttributePerLinkCountLimit > 0 {
|
||||
c.SpanLimits.AttributePerLinkCountLimit = cfg.SpanLimits.AttributePerLinkCountLimit
|
||||
}
|
||||
c.Resource = cfg.Resource
|
||||
if c.Resource == nil {
|
||||
|
||||
Reference in New Issue
Block a user