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

Get span.current().getSpanContext() in Azure eventhub consumer returning empty span context #1892

Closed
imdad-ms opened this issue Sep 27, 2021 · 4 comments

Comments

@imdad-ms
Copy link

Expected behavior

Describe what you expected to happen.

var context = Span.current() != null && Span.current().getSpanContext() != null ? Span.current().getSpanContext().getTraceId() : null;

Actual behavior

returning default empty span context

To Reproduce

Steps to reproduce the behavior:

  1. create Spring boot non-web event hub consumer worker based on spring cloud stream
  2. inside spring cloud consumer function , get current span context
    var spanContext = getCurrentSpanContext();

Sample Application

If applicable, provide a sample application which reproduces the issue.

System information

Please provide the following information:

  • SDK Version: com.microsoft.azure:applicationinsights-agent:3.1.1; com.microsoft.azure:applicationinsights-web:2.6.3
  • OS type and version: Mac and Linux
  • Application Server type and version (if applicable):
  • Using spring-boot? yes non-web
  • Additional relevant libraries (with version, if applicable): io.opentelemetry:opentelemetry-api:1.5.0; com.azure.spring:azure-spring-cloud-stream-binder-eventhubs:2.5.0

Logs

Turn on SDK logs and attach/paste them to the issue. If using an application server, also attach any relevant server logs.
Logs can be provided if required.

Be sure to remove any private information from the logs before posting!

Screenshots

If applicable, add screenshots to help explain your problem.

@ghost ghost added the Needs: Triage 🔍 label Sep 27, 2021
@lmolkova
Copy link
Member

lmolkova commented Sep 28, 2021

@imdad-ms
can you please share a few details

  • if used, version of azure-core-tracing-opentelemetry (it's should be ok if you don't have it in the POM)
  • Is it a Springboot starter? or EventHubProcessorClient?
  • can you please share consume callback/event handler code snippet?

We're working on solving issues with Span.current() in reactor callbacks. To my best knowledge, they affect event hub consumers much less than producers, so I hope we can find mitigation while the proper fix is on the way.

Thanks!

@cicorias
Copy link
Member

A repo is here:
https://github.com/cicorias/opentelemetry-span-empty-issue-1892

  • it's a spring boot app
  • spring cloud stream

We are not seeing any correlationid from the below code - or actually, it's showing up as all "0"s..

We adorned the Web REST controller with similar code --- see the repro repo for the details, and there too in the Web REST controller context we get all "0"s too.

my internal is scicoria

    public String getCorrelationId() {

        Span current = null;
        SpanContext context = null;
        String traceid = null;

        current = Span.current();

        if (null != current)
            context = current.getSpanContext();

        if (null != current && null != context)
            traceid = context.getTraceId();
        

        return traceid;


        // return Span.current() != null && Span.current().getSpanContext() != null ? Span.current().getSpanContext().getTraceId() : null;

        // Span.current()
    // PropagatedSpan@231 "PropagatedSpan{ImmutableSpanContext{traceId=00000000000000000000000000000000, 
    //spanId=0000000000000000, traceFlags=00, traceState=ArrayBasedTraceState{entries=[]}, remote=false, valid=false}}"
      }

@cicorias
Copy link
Member

FYI, we missed setting the applicationinsights.json preview flag OpenTelemetry API support (3.0)

I believe this issue can be closed.

"preview" :  
     {
         "openTelemetryApiSupport": true
     }
...

@trask
Copy link
Member

trask commented Sep 30, 2021

3.2.0-BETA.4 was just released, and this option is now enabled by default, so no need to remember to set it anymore 👍

@trask trask closed this as completed Sep 30, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Nov 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants