open-telemetry / opentelemetry-dotnet

The OpenTelemetry .NET Client
https://opentelemetry.io
Apache License 2.0
3.23k stars 764 forks source link

In Jaeger I get "unknown_service:dotnet" and "Duplicate tag "peer.service:" #2027

Open SVronskiy opened 3 years ago

SVronskiy commented 3 years ago

List of NuGet packages and version that you are using: "OpenTelemetry.Exporter.Console" Version="1.1.0-beta1" /> "OpenTelemetry.Exporter.Jaeger" Version="1.0.1" /> "OpenTelemetry.Exporter.Zipkin" Version="1.0.1" /> "OpenTelemetry.Extensions.Hosting" Version="1.0.0-rc4" /> "OpenTelemetry.Instrumentation.AspNetCore" Version="1.0.0-rc4" /> "OpenTelemetry.Instrumentation.Http" Version="1.0.0-rc4" /> "OpenTelemetry.Instrumentation.SqlClient" Version="1.0.0-rc4" />

Runtime version netcoreapp2.2

Question

In Jaeger I get "unknown_service:dotnet" and "Duplicate tag "peer.service:"

image

Describe your environment.

Startup.cs:

services.AddOpenTelemetryTracing((builder) => builder
    .AddAspNetCoreInstrumentation()
    .AddHttpClientInstrumentation()
    .AddSqlClientInstrumentation()
    .AddZipkinExporter(options =>
    {
        options.Endpoint = new Uri("http://zipkin.istio-system:9411/api/v2/spans");
    })
    );

Run application under kubernetes 1.18, jaegertracing/all-in-one:1.20, istio 1.9.2.

What are you trying to achieve?

What did you expect to see?

I'de like to have name situated in "peer.service" instead of unknown_service:dotnet, on my screen it should be "content".

Additional Context

Problem is similar to described here: #2584 span.kind & peer.service

I still do not have any idea how to fix it. Could you help me, please.

robrich commented 3 years ago

To set the name from unknown_service to something descriptive:

public void ConfigureServices(IServiceCollection services)
{
    // ... snip ...
    services.AddOpenTelemetryTracing((builder) => {
        builder
            .SetResourceBuilder(ResourceBuilder
                .CreateDefault()
                .AddService(env.ApplicationName)) // <-- sets service name
            .AddAspNetCoreInstrumentation();
            // .AddMoreThings :D
    // ... snip ...
}
SVronskiy commented 3 years ago

Hello, @robrich!

Thank you for reply! Anfortunitely this is not a solution.

Above source code will return "env.ApplicationName" anythere, but we need to get text "google.com", "yandex.ru" etc according to url in httpclient, Take a look at at second screenshots at #2584 span.kind & peer.service - this is how it should work.

ElectricVampire commented 3 years ago

I am having exact same issue, getting warning for duplicate tag "peer.service". @SVronskiy Can we mark this as bug rather than question. I just want to get rid of warning message.

SVronskiy commented 3 years ago

@ElectricVampire I do not have option to change issue kind ((

cijothomas commented 3 years ago

Can anyone share a repro code which results in duplicate peer.service tags?

ElectricVampire commented 3 years ago

@cijothomas Any trace going to DB or another API will show the warning of duplicate peer.service tag on jaeger UI if we use Zipkin exporter with http(s) endpoint on 9411 port. .AddZipkinExporter(options => { options.Endpoint = new Uri("http://zipkin.istio-system:9411/api/v2/spans"); })

luizhlelis commented 3 years ago

Can anyone share a repro code which results in duplicate peer.service tags?

@cijothomas, I reproduced the Duplicate tag "peer.service:localhost:5001" in this example. Maybe that's not an issue, but it could be a wrong setup. It happened with me when I used the AddZipkinExporter method instead of using AddJaegerExporter:

with-zipkin-exporter

changing to AddJaegerExporter the duplicate tag warning stopped to appear:

with-jaeger-exporter

@ElectricVampire and @SVronskiy, as you're using the Jaeger UI, did you tried to use the AddJaegerExporter method?

ElectricVampire commented 3 years ago

@luizhlelis it works with JaegerExporter but jaegerExporter has limitation that it doesn't support Http or grpc(https://github.com/open-telemetry/opentelemetry-dotnet/issues/2054) hence using ZipkinExporter which does support Http.

Jaeger has a port open for Zipkin traces as well (https://www.jaegertracing.io/docs/1.17/features/#backwards-compatibility-with-zipkin), hence we can still use ZipkinExporter for JaegerUI, so I would not say this as invalid configuration.

julealgon commented 2 years ago

To set the name from unknown_service to something descriptive:

public void ConfigureServices(IServiceCollection services)
{
    // ... snip ...
    services.AddOpenTelemetryTracing((builder) => {
        builder
            .SetResourceBuilder(ResourceBuilder
                .CreateDefault()
                .AddService(env.ApplicationName)) // <-- sets service name
            .AddAspNetCoreInstrumentation();
            // .AddMoreThings :D
    // ... snip ...
}

@robrich , is there any particular reason why using the application name is not already the default when calling the OTel hosting extensions?

I've configured the instrumentation in a couple services here and only realized later how bad the default name really is.

robrich commented 2 years ago

@julealgon I agree, I think making the name more descriptive by default would be wonderful.

pellared commented 2 years ago

I just quickly scrolled through the issue and it looks related to this one https://github.com/open-telemetry/opentelemetry-dotnet/issues/2781