Tracing PoC#49706
Draft
jpalvarezl wants to merge 3 commits into
Draft
Conversation
Proof of concept re-implementing agent tracing the azure-core way, modeled on azure-ai-inference's ChatCompletionClientTracer: - New implementation.telemetry.AgentsClientTracer emits OpenTelemetry GenAI semantic-convention spans for createAgentVersion (sync + async). - Per-client Tracer built by AgentsClientBuilder from ClientOptions.getTracingOptions() via TracerProvider (no global static state, no public opt-in API). - Content gated by AZURE_TRACING_GEN_AI_CONTENT_RECORDING_ENABLED (off by default). - Library version sourced from azure-ai-agents.properties (not hardcoded). - Endpoint injected via constructor (immutable), consistent across clients. - Unit tests use an in-memory OpenTelemetry SDK; assert span attributes, content gating, and error propagation without swallowing exceptions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Port the full tracing feature set from PR #49434 into the idiomatic per-client architecture (implementation.telemetry), keeping features close to the original while fixing the repo best-practice issues: Telemetry engine (per-client, no global static): - GenAiInstrumentation holds the azure-core Tracer + Meter (built by the builder from ClientOptions tracing/metrics options), content flag, host/port, and the GenAI duration/token histograms. - GenAiTracingScope is a per-op span with the close()/nanoTime metric bugs fixed. - GenAiMessageFormatter gates content via a parameter (formatToolCallOutput fixed). Coverage: - create_agent (prompt/hosted/workflow attributes, gen_ai.agent.workflow event, agent id/version enrichment) - sync + async. - chat / invoke_agent response tracing - sync + streaming (TracedStreamIterable + ResponseAccumulator), with model/token/message/finish-reason/conversation attrs and gen_ai.workflow.action events. - create_conversation span. - Metrics: gen_ai.client.operation.duration and gen_ai.client.token.usage. - Content gated by AZURE_TRACING_GEN_AI_CONTENT_RECORDING_ENABLED (off by default). Also: GenAiAgentTracingTest + GenAiMessageFormatterTest (14 tests, in-memory OTel, no exception swallowing); TracingSample + CI-verified README snippet; CHANGELOG. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- ResponsesAsyncClient: trace createAzureResponse (Mono) and createStreamingAzureResponse (Flux) via new GenAiResponseTracing async methods (Mono/Flux.usingWhen); add createConversation/deleteConversation. - GenAiResponseTracing: add traceResponseAsync + traceStreamingResponseAsync, share request-attribute extraction (ResponseSpanParams/startResponseScope), and reuse recordResponseAttributes for both sync-streaming and async-streaming finalization (TracedStreamIterable simplified). - Samples: port TracingConsoleSample and TracingAzureMonitorSample to the idiomatic API - no enableGenAiTracing()/disableGenAiTracing() opt-in; tracing activates from the configured OpenTelemetry. Added test-scope deps (opentelemetry-exporter-logging, opentelemetry-sdk-extension-autoconfigure, azure-monitor-opentelemetry-autoconfigure). - TRACING_NOTES.md: document design decisions and open questions - toggle vs config-driven activation, customized-generated-methods vs traced* variants vs codegen-customization weaving, async HTTP-span parenting, gen_ai.system vs provider.name, metrics/response-path test gaps, and more. Validated: compile (Java 8 + 21), 14 telemetry tests, 0 checkstyle violations, samples test-compile. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.