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

service.name is not propagate to Jaeger using trace HTTP exporter #4486

Closed
marcmolla opened this issue Sep 8, 2023 · 8 comments
Closed

service.name is not propagate to Jaeger using trace HTTP exporter #4486

marcmolla opened this issue Sep 8, 2023 · 8 comments
Labels
bug Something isn't working

Comments

@marcmolla
Copy link

marcmolla commented Sep 8, 2023

Description

It seems that service.name is not propagated to jaeger when we integrate open telemetry-go using otlptracehttp. At jaeger ui, we see OTLPResourceNoServiceName instead of the service name.

We checked the contexts of the service post to jaeger and the label "my_service" is not in the protobuf message.

Environment

  • OS: Ubuntu 22.04.1 LTS
  • Architecture: x86_64
  • Go Version: 1.21
  • opentelemetry-go version: v1.17.0

Steps To Reproduce

  1. Add basic setup of HTTP exporter to the process:
        //traces
	client := otlptracehttp.NewClient(otlptracehttp.WithEndpoint("10.20.30.40:4318"), otlptracehttp.WithInsecure(), otlptracehttp.WithCompression(otlptracehttp.NoCompression))
	exp, err := otlptrace.New(context.Background(), client)
	if err != nil {
		log.Fatalf("creating OTLP trace exporter: %s", err.Error())
	}
	if err != nil {
		log.Fatal(err)
	}

	r, _ := resource.Merge(
		resource.Default(),
		resource.NewWithAttributes(
			semconv.SchemaURL,
			semconv.ServiceName("my_service"),
			semconv.ServiceVersion("v0.1"),
		),
	)

	tp := trace.NewTracerProvider(
		trace.WithBatcher(exp),
		trace.WithResource(r),
	)
	defer func() {
		if err := tp.Shutdown(context.Background()); err != nil {
			log.Fatal(err)
		}
	}()
	otel.SetTracerProvider(tp)
  1. Setup jaeger-all-in-one
  2. Check jaeger ui

Expected behavior

We expect that service.name is propagated to jaeger.

@marcmolla marcmolla added the bug Something isn't working label Sep 8, 2023
@dmathieu
Copy link
Member

dmathieu commented Sep 8, 2023

I've just tried booting the jaeger-all-in-one docker container on my machine, and running the otel-collector example: https://github.com/open-telemetry/opentelemetry-go/tree/main/example/otel-collector

I am properly getting the service name.
Screenshot 2023-09-08 at 14 14 51

@marcmolla
Copy link
Author

Yes, Otel-collector example also works for me
Captura de pantalla 2023-09-08 a las 15 10 52

I will try to reproduce my issue using the otel-collector example as base....

thanks
Marc

@dmathieu
Copy link
Member

dmathieu commented Sep 8, 2023

If this is an issue between the collector and jaeger, shouldn't it be in the opentelemetry-collector repository ?

@marcmolla
Copy link
Author

I manage to create a minimum example with the error:
main.txt

and this is the capture:
Captura de pantalla 2023-09-11 a las 10 20 09

I solved the issue by changing the way I create the resource, using the one in the otel-collector example:

r, _ := resource.New(context.Background(),
           resource.WithAttributes(
	// the service name used to display traces in backends
	semconv.ServiceName("test-service"),
       ),
)

with this the service.name is propagated correctly to jaeger.

@dmathieu
Copy link
Member

From your original example, it's possible/likely you have a resource merge error, giving you an empty resource.

Try the following:

r, err := resource.Merge(
	resource.Default(),
	resource.NewWithAttributes(
		semconv.SchemaURL,
		semconv.ServiceName("my_service"),
		semconv.ServiceVersion("v0.1"),
	),
)
if err != nil {
	log.Fatal(err)
}

Resource merges being problematic is a known issue. See #2341

With the example above, I'm getting resource merge errors if I use the latest library with semconv < 1.21.0.
It works fine if I use semconv 1.21.0.

@marcmolla
Copy link
Author

yes, that is the issue:

2023/09/12 09:33:16 cannot merge resource due to conflicting Schema URL

The way of creating the resource is in the Getting Started doc, maybe it can be updated for avoiding this error:
https://opentelemetry.io/docs/instrumentation/go/getting-started/

thanks for your support!

@dmathieu
Copy link
Member

The getting started doc documents the proper way of doing it. The problem here is the larger issue of resource versions which are hard to tackle/upgrade.
I'll close this issue. The broader problem is already tracked in #2341.

@pellared
Copy link
Member

The way of creating the resource is in the Getting Started doc, maybe it can be updated for avoiding this error:
https://opentelemetry.io/docs/instrumentation/go/getting-started/

Already part of open-telemetry/opentelemetry.io#3235

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants