Azure-docs: Opencensus Python SDK support

Created on 30 Apr 2020  Â·  11Comments  Â·  Source: MicrosoftDocs/azure-docs

Is this cross-resource correlation supported when using Opencensus Python SDK on the client? I have a Python client calling a .NET Core server (using a different Application Insights resource), and the client Application Insights view doesn't include the server Application Insights data.

It looks like for this feature to work, the client library has to parse the "Request-Context: appId=cid-v1:..." header from the server response and append the server application id to the "target" field when sending the RemoteDependencyData object to Application Insights.

However this doesn't seem to be happening when using opencensus-ext-azure, opencensus-ext-requests and opencensus-ext-httplib. Is there some other Application Insights-specific package that has to be included for this to work?


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Azure-Monitosvc Pri2 application-insightsubsvc cxp in-progress product-question triaged

All 11 comments

adding @lzchen

OpenCensus Python SDK supports the W3C Trace Context protocol for correlation. To achieve cross resource correlation, the receiving application must also be supporting W3C trace context, which sends back correlation information (traceId and spanId in W3C) in the span attributes.

@dennis-yemelyanov Thank you for the feedback! We are investigating this and will get back to you shortly.

@lzchen , yes, traceId and spanId seem to be sent correctly. I double checked, and both server and client telemetry have the same operation ID in Application Insights. And server's parentId is the same as client's dependencyId, which also looks right to me.

However, for cross-resource correlation to work, it looks like one more thing needs to be present in the telemetry, which is the ApplicationId value in the remote dependency data target field. Although I couldn't find any official documentation about this topic, this blog post seems to confirm this theory: https://brettmckenzie.net/2019/10/02/things-i-wish-i-knew-earlier-about-distributed-tracing-in-azure-application-insights/

Basically the target field sent to Application Insights from the client should have this format: {server URL} | cid-v1:{server's AppId}

But currently Opencensus Python SDK doesn't seem to save this ApplicationId info in the telemetry data. Is it officially supported? Or maybe I missed some package import/configuration step?

@dennis-yemelyanov
Is there some dashboard you are using for cross-resource correlation or are you simply checking whether the required fields are populated in App Insights telemetry?

@lzchen , no, I'm just looking at dependency call details in Application Insights UI, and, as described on this page, it should work fine and should show correlated logs from multiple AI resources: https://docs.microsoft.com/en-us/azure/azure-monitor/app/transaction-diagnostics

And I noticed that for other projects that use Application Insights .NET SDK on both caller and receiver cross-resource correlation works fine. And the dependency "Base name" in Application Insights Dependency Properties is set to a value like {server URL} | cid-v1:{server's AppId}. But when using Opencensus Python SDK, the Base name is just {server URL}.

It kind of makes sense to me, since "cid-v1" is specific to Application Insights and Opencensus Python SDK is mostly provider-agnostic. But I think it would be nice if cross-resource correlation in Application Insights UI worked out of the box even with Opencensus Python SDK (maybe opencensus-ext-azure should be aware of this field).

@dennis-benzinger-hybris
Does correlation work with OpenCensus Python even with base name just url on App Insights UI? App Insights UI might be using a different field if the source is coming from an SDK using w3C (since the traceId can be used as a global unique id for correlation instead) instead of target. I am not sure if this is the case however. The service team is also looking to remove the use of target functionality for correlation in replace of the indexer service but I am not sure of the timeline for this.

@lzchen , I only tried Opencensus Python on the client and Application Insights .NET Core on the server, haven't tried Opencensus Python on the server. But I'm not sure what fields Application Insights backend expects, couldn't find any documentation...

If there is ongoing work to remove the target field requirement, I think will be great and should fix this issue. I think it's better if Application Insights can combine telemetry from multiple sources based on standard correlation fields like OperationId, DependencyId and ParentId without the need to pass custom metadata through other data fields like target.

For now I don't think there is any work on the OpenCensus side. Can we close this issue?

Not sure if it might be helpful to keep this (or some other) issue open for tracking until the service side fix is released? If not, I'm fine to close it

@dennis-yemelyanov We are going to close this thread as resolved but if there are any further questions regarding the documentation, please tag me in your reply and we will be happy to continue the conversation.

Was this page helpful?
0 / 5 - 0 ratings