Azure / azure-sdk-for-python

This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.
MIT License
4.37k stars 2.71k forks source link

SpanKind.Client not supported #36328

Open king-11 opened 6 days ago

king-11 commented 6 days ago

Describe the bug setting the kind of span to SpanKind.CLIENT results in it being shown as of type N/A in app insights dependency table and end-to-end transaction detail

To Reproduce Create a span and set the kind as client.

tracer = get_tracer(__name__)

@tracer.start_as_current_span(name="update_inference_run", kind=SpanKind.CLIENT)
def update_inference_run():
  print("hello world")

Expected behavior Client kind should have a proper type instead of being N/A

Screenshots image

image

xiangyan99 commented 6 days ago

Thanks for the feedback, we’ll investigate asap.

lzchen commented 6 days ago

@king-11

SpanKind maps to itemType not type field in AppInsights. SpanKind.Cient maps to dependency type telemetry and SpanKind.Server maps to requests telemetry.

king-11 commented 6 days ago

@lzchen but in the end to end transaction history it's being shown as N/A and not dependency

image

lzchen commented 4 days ago

The reason you are getting "N/A" for the TYPE field is because application insights expects manually created spans (spans that are created using start_as_current_span) to be of type "InProc", which is the default if you do not set a span kind. ApplicationInsights only expects SpanKind.Client spans created automatically from instrumentations.

tracer = get_tracer(__name__)

@tracer.start_as_current_span(name="update_inference_run")
def update_inference_run():
  print("hello world")

We do not recommend setting the spankind manually, as this is an unsupported scenario for our SDK.

king-11 commented 1 day ago

What would it take to support this particular scenario, I can try implementing it if it makes sense to have this feature?

My specific use case is that am familiar that the provided function makes multiple call to Azure SQL which are shown as dependency but then the overall function being a single span can be declared as type Client.

lzchen commented 1 day ago

My specific use case is that am familiar that the provided function makes multiple call to Azure SQL which are shown as dependency but then the overall function being a single span can be declared as type Client.

I am not fully understanding the use case here. InProc spans are exported as dependencies type telemetry as well. If the ask is to be able to manually modify the data.type field to a specific value, this scenario is not supported.

If you would like to group together your telemetry, there are a lot of other ways you can achieve this, most nobly using span attibutes

github-actions[bot] commented 10 hours ago

Hi @king-11. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.