eclipse-vertx / eclipse-vertx/vertx-tracing

Allow Adding Custom Span Attributes Before `startSpan()`

Open
#63 2 comments 0 reactions 0 assignees View on GitHub
enhancement help wanted
Dominant language
Java
Stars
45
Forks
32
PR merge metrics
No merged PRs in 30d

Description

#### 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.