Skip to content

OpenAI instrumentation - #14

Merged
Hector Hernandez (hectorhdzg) merged 6 commits into
microsoft:mainfrom
hectorhdzg:openai-instrumentation
Apr 17, 2026
Merged

Hector Hernandez (hectorhdzg) merged 6 commits into
microsoft:mainfrom
hectorhdzg:openai-instrumentation

Conversation

@hectorhdzg

Copy link
Copy Markdown
Member

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds OpenAI Agents SDK instrumentation to the GenAI module so OpenAI Agents spans can be converted into OpenTelemetry spans with GenAI semantic-convention attributes, with accompanying unit/functional tests and a usage sample.

Changes:

  • Introduces OpenAI Agents trace processor + instrumentor (registration via @openai/agents trace processors).
  • Adds OpenAI-specific utils/semconv helpers for span naming, attribute extraction, and content-gating.
  • Adds unit + functional tests and a new sample demonstrating instrumentation usage; updates changelog and dependencies.

Reviewed changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
test/internal/unit/genai/openai/utils.test.ts Unit coverage for OpenAI utils/semconv attribute extraction & helpers.
test/internal/unit/genai/openai/openAIAgentsTraceProcessor.test.ts Unit coverage for processor span lifecycle + attribute stamping.
test/internal/unit/genai/openai/openAIAgentsTraceInstrumentor.test.ts Unit coverage for instrumentor singleton lifecycle and config acceptance.
test/internal/functional/openai.test.ts End-to-end functional test using InMemorySpanExporter validating emitted spans/attributes.
src/genai/instrumentations/openai/utils.ts Adds OpenAI Agents span parsing utilities and content-key remapping helpers.
src/genai/instrumentations/openai/semconv.ts Defines OpenAI-specific constants (span-kind classifiers and content keys).
src/genai/instrumentations/openai/openAIAgentsTraceProcessor.ts Core processor mapping Agents SDK callbacks to OTel spans + GenAI attributes.
src/genai/instrumentations/openai/openAIAgentsTraceInstrumentor.ts Instrumentation wrapper to register/enable/disable the processor with @openai/agents.
src/genai/instrumentations/openai/index.ts Exposes OpenAI instrumentation entry points.
samples/src/openaiInstrumentation.ts Sample demonstrating enabling OpenAI Agents instrumentation in the distro.
samples/README.md Links the new OpenAI sample in the samples index.
samples/package.json Adds @openai/agents dependency for running the sample.
package.json Adds @openai/agents dev dependency for repo builds/tests.
package-lock.json Locks newly added OpenAI Agents dependency tree.
CHANGELOG.md Notes the new OpenAI Agents SDK instrumentation feature.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/genai/instrumentations/openai/openAIAgentsTraceProcessor.ts
Comment thread src/genai/instrumentations/openai/openAIAgentsTraceProcessor.ts
Comment thread src/genai/instrumentations/openai/openAIAgentsTraceProcessor.ts Outdated
Comment thread src/genai/instrumentations/openai/openAIAgentsTraceProcessor.ts Outdated
Comment thread src/genai/instrumentations/openai/openAIAgentsTraceInstrumentor.ts Outdated
Comment thread test/internal/unit/genai/openai/openAIAgentsTraceProcessor.test.ts Outdated
Comment thread test/internal/unit/genai/openai/openAIAgentsTraceInstrumentor.test.ts Outdated
Comment thread CHANGELOG.md
Comment thread src/genai/instrumentations/openai/utils.ts

this.processor = new OpenAIAgentsTraceProcessor(this.otelTracer, {
suppressInvokeAgentInput: this._config.suppressInvokeAgentInput ?? false,
isContentRecordingEnabled: this._config.isContentRecordingEnabled ?? false,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the equivalent of the env variable that python sets - OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT

@rads-1996 Radhika Gupta (rads-1996) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hectorhdzg
Hector Hernandez (hectorhdzg) merged commit ac0b255 into microsoft:main Apr 17, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants