Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Add possibility to set the operation name after the span has been created #48

Closed
felixbarny opened this issue Sep 6, 2016 · 8 comments · Fixed by #50
Closed

Add possibility to set the operation name after the span has been created #48

felixbarny opened this issue Sep 6, 2016 · 8 comments · Fixed by #50

Comments

@felixbarny
Copy link
Contributor

I'm currently evaluating to use opentracing/jaeger as the foundation of stagemonitor and this is one of the things I've stumbled upon:

As of now, the operation name has to be provided in order to create a span:

Span http = tracer.buildSpan("HandleHTTPRequest")

The problem is that you often don't know the operation name when a HTTP request has just arrived. Setting the operation name to the URL may be sufficient in some cases but as soon as you have url schemes like /item/{itemNumber} you probably want to group them together.

Stagemonitor instruments Spring MVC and JAX-RS to derive the operation name from the controller method. For example

@RequestMapping("/item/{itemNumber})
public void showItemDetail(@PathVaiable String itemNumber) {...}

Results in an operation name like Show Item Details or ItemControler#showItemDetails. Users also may choose to set the operation name at any time in stagemonitor. Note that the Span does not start at the controller method but as soon as the HTTP request hits the topmost servlet Filter.

So I think it would be a useful addition to be able to set the operation name after the start of the span.

@yurishkuro
Copy link
Member

@felixbarny the APIs in the other languages do have span.setOperationName() methods, so I don't see why we shouldn't have one in Java. Do you care to create a pull request?

@felixbarny
Copy link
Contributor Author

Is it possible to create a span without a name in other languages like tracer.buildSpan() or do you always have to set a default name which can then be overridden?

Yes, I'd like to craft a pull request for that.

@yurishkuro
Copy link
Member

Span name is always required, but if it needs to be set later you can pass empty string to the builder.

felixbarny pushed a commit to felixbarny/opentracing-java that referenced this issue Sep 7, 2016
@felixbarny
Copy link
Contributor Author

Some more questions:

Why are there no getters defined in span? For example to get the operation name and to get logs.

Can jaeger-core be seen as something like basictracer-java?

@yurishkuro
Copy link
Member

Why are there no getters defined in span? For example to get the operation name and to get logs.

Because there is no production use case for this. Think about slf4j, does it have getters? Same with span, it's essentially a write-only API (except for baggage).

The only time you need getters is in unit tests, and for that the mock tracers do support getters. In fact many implementations might support getters (e.g. basictracer-go), but you need to downcast from the top-level Span interface.

Can jaeger-core be seen as something like basictracer-java?

Umm, this is a very broad statement so I am inclined to say no. jaeger-core is Uber's implementation of OpenTracing API. It's production quality and is a part of our overall Jaeger tracing system that we will be open-sourcing shortly. Whereas basictracer-xxx repos can be seen more like reference implementations of the API, but not for production use (although I think lightstep and appdash implementations both extend basictracer-go).

@felixbarny
Copy link
Contributor Author

One use case where the client might want to access the tags the tracing library has created is when the lib parses the User-Agent header and the client wants to access the information whether the request was initiated from a mobile device.

@felixbarny
Copy link
Contributor Author

Also, when implementing a reporter, you always have downcast to a specific implementation.

@felixbarny
Copy link
Contributor Author

I've just realized that reporting a span is always implementation specific because there is no Reporter interface defined in the opentracing API. Is that something you are considering adding to the API?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants