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

opentelemetry-otlp how to name service: OTLPResourceNoAttributes #475

Closed
clux opened this issue Mar 9, 2021 · 7 comments
Closed

opentelemetry-otlp how to name service: OTLPResourceNoAttributes #475

clux opened this issue Mar 9, 2021 · 7 comments
Labels
question Further information is requested

Comments

@clux
Copy link
Contributor

clux commented Mar 9, 2021

Currently, all my traces show up as top level OTLPResourceNoAttributes:

trace viewer screenshot

Is there a way to inject the service name with opentelemetry-otlp like in opentelemetry-jaeger?

@clux clux changed the title opentelemetr-otlp how to name OTLPResourceNoAttributes opentelemetry-otlp how to name service: OTLPResourceNoAttributes Mar 9, 2021
@TommyCpp
Copy link
Contributor

TommyCpp commented Mar 10, 2021

There isn't a service name concept in OTEL. So the convention here(and in opentelemetry-jaeger) is to use service.name resource to represent the service name. But it depends on the backend to correctly identify the service.name resource.

@TommyCpp TommyCpp added the question Further information is requested label Mar 10, 2021
@clux
Copy link
Contributor Author

clux commented Mar 10, 2021

Hm, ok. Thank you. I should probably open a bug against Tempo in that case, as service.name does not work there.

Btw, in golang the way I see this is done is by naming the tracer:
https://github.com/joe-elliott/tempo-otel-example/blob/492add7ad56769c0b0bbc80499f42dcb8cde8131/main.go#L47-L50
which gets picked up by Tempo.

@TommyCpp
Copy link
Contributor

Btw, in golang the way I see this is done is by naming the tracer:
https://github.com/joe-elliott/tempo-otel-example/blob/492add7ad56769c0b0bbc80499f42dcb8cde8131/main.go#L47-L50
which gets picked up by Tempo.

Actually, that is the instrument library name, which will appear as a tag otlp.instrumentation.library.name in Jaeger. The service name is setup here https://github.com/joe-elliott/tempo-otel-example/blob/492add7ad56769c0b0bbc80499f42dcb8cde8131/main.go#L115-L119. You should see the service name as demo-service instead of demo-app.

So I think Tempo does check the service.name. Mind share an example of how do you set up the service.name resource in Rust?

@clux
Copy link
Contributor Author

clux commented Mar 10, 2021

Oh, yes, you are right, sorry, I do see demo-service.

The way I did it in rust was to set the fields with #[instrument]:

#[instrument(skip(ctx), fields(traceID, service.name = "foo-controller"))]
async fn reconcile(foo: Foo, ctx: Context<Data>) -> Result<ReconcilerAction, Error> {
    Span::current().record("traceID", &field::display(&telemetry::get_trace_id()));

which shows up on the interface, but as a tag rather than the service name:
Screenshot from 2021-03-10 18-01-09

@TommyCpp
Copy link
Contributor

Usually, resources will be set when init the tracer provider. You can refer here to see how to do it

@clux
Copy link
Contributor Author

clux commented Mar 10, 2021

Ahhh, it's a Resource. Thank you.

Added:

.with_trace_config(opentelemetry::sdk::trace::config().with_resource(
    opentelemetry::sdk::Resource::new(vec![opentelemetry::KeyValue::new("service.name", "foo-controller")]),
))

and it worked.

clux added a commit to clux/opentelemetry-rust that referenced this issue Mar 10, 2021

Verified

This commit was signed with the committer’s verified signature.
cjihrig Colin Ihrig
@TommyCpp
Copy link
Contributor

Good to know. Since this was defined in spec, we do have a const value for service.name. You can find it here

pub const SERVICE_NAME: Key = Key::from_static_str("service.name");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants