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

uploadTrace by grpc has something wrong #4728

Closed
bai-ming opened this issue Nov 21, 2023 · 4 comments
Closed

uploadTrace by grpc has something wrong #4728

bai-ming opened this issue Nov 21, 2023 · 4 comments
Labels
bug Something isn't working invalid This doesn't seem right pkg:exporter:otlp Related to the OTLP exporter package

Comments

@bai-ming
Copy link

Description

I send the trace to tempo, the code works without any error, but I can't find the trace in tempo.

Environment

  • Go Version: 1.19
  • opentelemetry-go version: v1.14.0

Steps To Reproduce

I set tp with code below

func InitTracerProvider() error {
	exp, err := newExporter(utils.OsSignalHandler.SubContext())
	// exp, err := newStdOutExporter()
	if err != nil {
		return errors.Wrap(err, "")
	}
	tp = sdk.NewTracerProvider(
		sdk.WithBatcher(exp),
		sdk.WithIDGenerator(newTempIDGenerator()),
		sdk.WithResource(newResource()),
	)
	otel.SetTracerProvider(tp)
	return nil
}

func newExporter(ctx context.Context) (*otlptrace.Exporter, error) {
		tempo := "localhost:4317"
		exp, err := otlptracegrpc.New(ctx, otlptracegrpc.WithInsecure(), otlptracegrpc.WithEndpoint(tempo))
		return exp, errors.Wrap(err, "exporter init failed")
}

when I use v1.14.0
image
It works well, It sends message without error and I can find the trace in tempo which I send.
image
image
But when I use v1.21.0,
image
It still sends message without any error but I can't find it in tempo.
image
image
And tempo dose not have any error log.

the difference about two version mod is the picture below
image

So perhaps It has something about the package?

@bai-ming bai-ming added the bug Something isn't working label Nov 21, 2023
@pellared
Copy link
Member

From the description I do not see any proof that something is wrong with the exporter.
Also the reproduction steps are not precise (not working code, missing info about Grafana Tempo version and its configuration). Please provide Minimal, Reproducible Example.

However, I personally suggest creating an issue in https://github.com/grafana/tempo. If there is a bug in our exporter, their maintainers should be able to locate the problem.

@pellared pellared added invalid This doesn't seem right pkg:exporter:otlp Related to the OTLP exporter package labels Nov 21, 2023
@Tsuribori
Copy link

I have run into the same issue when going from v1.16.0 library versions to v1.19.0, and the issue persists in v1.21.0. It doesn't seem to be a Tempo issue as it affects also Jaeger. I tested with Tempo 2.1.1, Tempo 2.3.1 and Jager jaegertracing/all-in-one:1.52 and the issue is present in all of them, they can't show traces correctly after the upgrade.

With v1.16.0 in Jaeger:
working

With v1.21.0 in Jaeger:
not_working

Something funky seem to be going on...

The tracing setup code used is as following (with the grpc path):

func Initialize() error {
	if !config.GetTracingEnabled() {
		return nil
	}

	insecure := config.GetTracingInsecureTransport()

	var tpo trace.TracerProviderOption
	switch config.GetTracingTransport() {
	case "grpc":
		opts := []otlptracegrpc.Option{
			otlptracegrpc.WithEndpoint(config.GetTracingEndpoint()),
		}
		if insecure {
			opts = append(opts, otlptracegrpc.WithInsecure())
		}
		exp, err := otlptracegrpc.New(context.Background(), opts...)
		if err != nil {
			return fmt.Errorf("building tracing exporter: %w", err)
		}
		tpo = trace.WithBatcher(exp)
	case "http":
		opts := []otlptracehttp.Option{
			otlptracehttp.WithEndpoint(config.GetTracingEndpoint()),
		}
		if insecure {
			opts = append(opts, otlptracehttp.WithInsecure())
		}
		exp, err := otlptracehttp.New(context.Background(), opts...)
		if err != nil {
			return fmt.Errorf("building tracing exporter: %w", err)
		}
		tpo = trace.WithBatcher(exp)
	default:
		return fmt.Errorf("invalid tracing transport: %s", config.GetTracingTransport())
	}
	r, _ := resource.Merge(
		resource.Default(),
		resource.NewWithAttributes(
			semconv.SchemaURL,
			semconv.ServiceName("GoToSocial"),
		),
	)

	tp := trace.NewTracerProvider(
		tpo,
		trace.WithResource(r),
	)
	otel.SetTracerProvider(tp)
	propagator := propagation.NewCompositeTextMapPropagator(
		propagation.TraceContext{},
		propagation.Baggage{},
	)
	otel.SetTextMapPropagator(propagator)
	log.Hook(func(ctx context.Context, kvs []kv.Field) []kv.Field {
		span := oteltrace.SpanFromContext(ctx)
		if span != nil && span.SpanContext().HasTraceID() {
			return append(kvs, kv.Field{K: "traceID", V: span.SpanContext().TraceID().String()})
		}
		return kvs
	})
	return nil
}

OpenTelemetry libraries used:

	go.opentelemetry.io/otel v1.21.0
	go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0
	go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.21.0
	go.opentelemetry.io/otel/exporters/prometheus v0.44.0
	go.opentelemetry.io/otel/sdk v1.21.0
	go.opentelemetry.io/otel/sdk/metric v1.21.0
	go.opentelemetry.io/otel/trace v1.21.0
	github.com/uptrace/opentelemetry-go-extra/otelsql v0.2.2 // indirect
	go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 // indirect
	go.opentelemetry.io/otel/metric v1.21.0 // indirect
	go.opentelemetry.io/proto/otlp v1.0.0 // indirect

Go version used is 1.21

@pellared
Copy link
Member

pellared commented Dec 27, 2023

You miss error handling for r, _ := resource.Merge

My guess is that you have forgotten to bump the semconv in your import path to semconv "go.opentelemetry.io/otel/semconv/v1.21.0" when bumping OTel Go.

We are perfectly aware that this issue is annoying. Already tracked under: #2341

@Tsuribori
Copy link

You miss error handling for r, _ := resource.Merge

My guess is that you have forgotten to bump the semconv in your import path to semconv "go.opentelemetry.io/otel/semconv/v1.21.0" when bumping OTel Go.

We are perfectly aware that this issue is annoying. Already tracked under: #2341

Ah! That was the problem, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working invalid This doesn't seem right pkg:exporter:otlp Related to the OTLP exporter package
Projects
None yet
Development

No branches or pull requests

3 participants