Azure / azure-sdk-for-java

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

[FEATURE REQ] Support context propagation with TokenCredential #38389

Open lmolkova opened 7 months ago

lmolkova commented 7 months ago

Context is used to pass parent span and correlate traces/logs among other properties (e.g. feature flags). Without context propagation, log/traces correlation becomes impossible.

TokenCredential.getTokenSync does not allow to pass context (and async method does not have to since context is propagated in reactor context.

TokenCredential should either accept context in getTokenSync (alternative could be to pass it in the TokenRequestContext). Implementations should pass context all the way to the underlying HTTP client pipeline (when applicable). Async code path should leverage FluxUtil.withContext to make sure reactor context is converted into azure core Context

joshfree commented 3 weeks ago

@g2vinay could you please work with @lmolkova on this before MQ?