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

[WIP] Span name provider #5

Closed

Conversation

iaintshine
Copy link
Contributor

In current implementation the generated operation name corresponds to the request's http method e.g. GET, POST etc. It's not perfect when you look at UI (I use Jaeger) and want to quickly understand what was called. You need to dig into the trace to understand with what url it's
related.

This change introduces a capability to specify a custom span name provider, and defaults to http method plus host of the url.

@indrekj I still need to add documentation and tests, but wanted to verify the concept and if you think that might be useful to others.

In current implementation the generated operation name
corresponds to the request's http method e.g. GET, POST etc. It's not
perfect when you look at UI and want to quickly understand what was
called. You need to dig into the trace to understand with what url it's
related.

This change introduces a capability to specify a custom span name
provider, and defaults to http method and host of the url.
@indrekj
Copy link
Collaborator

indrekj commented Aug 10, 2017

There are some docs about the operation name here https://github.com/opentracing/specification/blob/master/specification.md#tracer

I've looked some other libraries as well. Most of them have just the http method. There are few exceptions.

I do agree that just the method name doesn't provide much information. The PR looks ok, but I'm even thinking that maybe the more detailed name should replace the legacy one.

@bhs Do you have any recommendations here?

@iaintshine
Copy link
Contributor Author

iaintshine commented Aug 10, 2017

Potentially for backwards compatibility we could leave the MethodOnly span name provider. But for cases where when you make external calls using a registered name (e.g. a hostname) instead of IP, MethodWithHost might be useful. You could even want to have a normalized url like GET http://users-service/users/:id, or a custom one like FindUserById as the operation name. That would be doable with the change.

@iaintshine
Copy link
Contributor Author

iaintshine commented Aug 10, 2017

Maybe the better idea would be to introduce decorators, as it was done in java e.g. https://github.com/opentracing-contrib/java-jaxrs/blob/master/opentracing-jaxrs2/src/main/java/io/opentracing/contrib/jaxrs2/client/ClientSpanDecorator.java. The implementation includes a decorator for http path operation name see https://github.com/opentracing-contrib/java-jaxrs/blob/master/opentracing-jaxrs2/src/main/java/io/opentracing/contrib/jaxrs2/client/ClientSpanDecorator.java#L60.

Decorators allow for composition, and custom logic. You would be able to inject custom code during request, response, and on error, decorate current span, set custom operation name, add custom tags, logs etc. Wdyt ?

@mabn
Copy link

mabn commented Aug 10, 2017

FYI: opentracing-contrib/meta#25 (Meaningful operation names when using framework integrations)

@iaintshine
Copy link
Contributor Author

@mabn thanks for the reference.

I agree with the following comment:

Provide a reasonable interceptor abstraction so that frameworks which are using the protocol library can override method name with something more semantically meaningful.

this is what i meant in the last comment, and suggest to implement the abstraction using decorators, as it was done in Java. The default/standard decorator might generate operation name in the current form for backwards compatibility.

@iaintshine
Copy link
Contributor Author

Closing the PR, as I'm willing to go with decorators approach

@iaintshine iaintshine closed this Aug 12, 2017
@iaintshine iaintshine deleted the span-name-provider branch August 12, 2017 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants