Skip to content

Execute span processor OnEnd in reverse order #1174

@NathanBaulch

Description

@NathanBaulch

If span processors are intended for more than just exporters, then it would be nice if OnEnd was called on the processors in reverse order. This makes it possible to create a span filter that removes short spans for example since EndTime is obviously only available on end and it's critical that the filter runs before the exporter.

I was able to hack it into span.End like so:

i := len(sps)
rev := make([]SpanProcessor, i)
for sp := range sps {
	i--
	rev[i] = sp
}
for _, sp := range rev {
	sp.OnEnd(sd)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:tracePart of OpenTelemetry tracingpkg:SDKRelated to an SDK package

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions