0

I'm trying to implement apm traces instrumentation in datadog using golang and opentelemetry in fiber, but my code is not creating the child spans, it only creates the first one with the middleware. In my case I don't have direct access to datadog and the connection strings, it is managed by another team and I was instructed to use it this way:

   func (z *AppTracer) Start(ctx context.Context, wg *sync.WaitGroup) {
    grpcClient := otlptracegrpc.NewClient()
    exporter, err := newOTLPTracerExporter(ctx, grpcClient)
    if err != nil {
    log.Printf("failed to create OTLP exporter: %v", err)
    return
    }

    batchSpanProcessor := sdkTrace.NewBatchSpanProcessor(exporter)

    sdkTraceProvider := sdkTrace.NewTracerProvider(
    sdkTrace.WithSpanProcessor(batchSpanProcessor), sdkTrace.WithResource(z.resouce),
    sdkTrace.WithSampler(sdkTrace.AlwaysSample()),
   )

   otel.SetTracerProvider(sdkTraceProvider)
   otel.SetTextMapPropagator(
    propagation.NewCompositeTextMapPropagator(propagation.TraceC  ontext{},
    propagation. Baggagee{}))

   log.Print("Starting OpenTelemetry Tracer")
   wg.Add(1)
   go func() {
   defer wg.Done()
   <-ctx.Done()
   if err := sdkTraceProvider.Shutdown(ctx); err != nil {
    log.Printf("failed to shutdown OpenTelemetry Tracer: %v", err)
   }
   if err := exporter.Shutdown(ctx); err != nil {
    log.Printf("failed to shutdown OpenTelemetry Exporter: %v", err)
   }
    log.Print("OpenTelemetry Tracer shutdown")
   }()
   }

I trynna get the context from span parent and pass to create my childs but not happens, I expect can propagte traces for all request path

2
  • Not having access to datadog is not an issue with OpenTelemetry, you can use a different target while developing (OTel collector, Jaeger, ...) and then when all the things work point your telemetry to your vendor backend. Commented May 8 at 10:30
  • Currently, I'm using Grafana, but we've been change to Datadog, in Grafana works well, in Datadog not create a child span, only root span Commented May 9 at 11:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.