Skip to content

Allow Adding Custom Span Attributes Before startSpan() #63

@tboonIV

Description

@tboonIV

Describe the feature

In order to use OpenTelemetry Head Sampling based on specific data information, I can extract the data upfront and set into Span Attribute before startSpan() for Head Sampling working with my custom Attribute.

tracer.spanBuilder("my.class")
      .setAttribute("custom", "123")
      .startSpan();

But in Vertx OpenTelemetry Tracing, there is no way for me to configure or intercept how to insert my own Attributes into Span before startSpan().

Using Span.current() is not working for me as the Span only initialize in Vertx low level implementation when request is received.

For what I observe, the TagExtractor used for Attributes building and it's fixed from Vert.x core.
https://github.com/eclipse-vertx/vertx-tracing/blob/master/vertx-opentelemetry/src/main/java/io/vertx/tracing/opentelemetry/OpenTelemetryTracer.java#L148-L154
https://github.com/eclipse-vertx/vert.x/blob/3e9d5d151e0bb91825fb214d94e72f645c0d6e60/src/main/java/io/vertx/core/http/impl/HttpUtils.java#L69-L163

Will be greats if we can have some control the Span Attributes before it start, so Head Sampling can be much useful.

Use cases

We have the data before it sent out as request and wanted to use it to perform OpenTelemetry Trace filtering.

Contribution

I may try to contribute but need some insight which is best approach to implement this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions