Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ktor: make spanNameExtractor configurable #12842

Closed
SIMULATAN opened this issue Dec 7, 2024 · 2 comments
Closed

Ktor: make spanNameExtractor configurable #12842

SIMULATAN opened this issue Dec 7, 2024 · 2 comments
Labels
contribution welcome Request makes sense, maintainers probably won't have time, contribution would be welcome

Comments

@SIMULATAN
Copy link
Contributor

SIMULATAN commented Dec 7, 2024

Whilst the semconv doesn't explicitly require the URL to be part of the span name, I would like to see more information than just the request method there.

Thus, I propose to add a simple setSpanNameExtractor method to the AbstractKtorClientTracingBuilder, similar to what #8255 did. Something like this would do just fine:

fun setSpanNameExtractor(spanNameExtractor: SpanNameExtractor<in HttpRequestData>) {
	clientBuilder.setSpanNameExtractor { spanNameExtractor }
}

#9607 already brought this topic up, but the semconv has changed since then to include the url.template if enabled. In my opinion, my proposal would allow users to implement this, should they choose to, whilst preserving the original, non-experimental default.

SIMULATAN added a commit to SnotyMe/snoty-backend that referenced this issue Dec 7, 2024
It now has support for Ktor 3.0. A workaround is included for the HTTP client span naming.

Closes #65

The added `KtorClientTracing` stuff will be obsolete once open-telemetry/opentelemetry-java-instrumentation#12842 is implemented
@trask
Copy link
Member

trask commented Dec 7, 2024

we would definitely accept a hook similar to what OkHttpTelemetryBuilder already has:

/** Sets custom {@link SpanNameExtractor} via transform function. */
@CanIgnoreReturnValue
public OkHttpTelemetryBuilder setSpanNameExtractor(
Function<
SpanNameExtractor<? super Interceptor.Chain>,
? extends SpanNameExtractor<? super Interceptor.Chain>>
spanNameExtractorTransformer) {
builder.setSpanNameExtractor(spanNameExtractorTransformer);
return this;
}

@trask trask added the contribution welcome Request makes sense, maintainers probably won't have time, contribution would be welcome label Dec 7, 2024
SIMULATAN added a commit to SIMULATAN/opentelemetry-java-instrumentation that referenced this issue Dec 8, 2024
@SIMULATAN SIMULATAN changed the title Ktor 3.0: (client) make spanNameExtractor configurable Ktor: make spanNameExtractor configurable Dec 8, 2024
@laurit
Copy link
Contributor

laurit commented Dec 19, 2024

Resolved with #12850

@laurit laurit closed this as completed Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution welcome Request makes sense, maintainers probably won't have time, contribution would be welcome
Projects
None yet
Development

No branches or pull requests

3 participants