Skip to content

Enable sensitive data for langchain programmatically#201

Merged
rads-1996 merged 5 commits into
microsoft:mainfrom
rads-1996:enable_sensitive_data_for_langchain
Jun 23, 2026
Merged

Enable sensitive data for langchain programmatically#201
rads-1996 merged 5 commits into
microsoft:mainfrom
rads-1996:enable_sensitive_data_for_langchain

Conversation

@rads-1996

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings June 12, 2026 17:49
@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown

Performance comparison

Threshold: regressions >15.0% on gating scenarios fail the build. Higher ops/s is better; positive Δ means the PR is slower.

Scenario Gating Baseline (ops/s) Candidate (ops/s) Δ % Status
azure_monitor_log yes 27,929.8 28,198.4 -0.95%
azure_monitor_span yes 158,730.2 161,550.9 -1.75%
otel_log no 32,769.7 33,184.0 -1.25%
otel_span no 43,715.8 44,120.9 -0.92%

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

This PR adds programmatic support in use_microsoft_opentelemetry(...) for enabling LangChain/GenAI message content capture by wiring new kwargs (enable_experimental_mode, capture_message_content) to the upstream environment variables read by opentelemetry-util-genai and the in-repo LangChain helpers.

Changes:

  • Add new public kwargs to use_microsoft_opentelemetry(...) that set OTEL_SEMCONV_STABILITY_OPT_IN and (when valid) OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT.
  • Introduce shared constants for the env var names and allowed capture modes.
  • Add unit/integration tests and update the LangChain sample README to document the kwarg-based configuration.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/microsoft/opentelemetry/_distro.py Implements kwarg → env-var wiring and warning behavior for invalid/ignored values.
src/microsoft/opentelemetry/_constants.py Adds kwarg names, env var keys, and allowed capture-mode values.
tests/test_distro.py Adds tests validating env-var propagation semantics and non-overwrite behavior.
tests/test_langchain_integration.py Adds integration coverage verifying the wiring matches what LangChain content-capture utilities read.
samples/langchain/README.md Documents using kwargs instead of exporting env vars, plus accepted values.

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

Comment thread src/microsoft/opentelemetry/_distro.py Outdated
Comment thread src/microsoft/opentelemetry/_distro.py Outdated
Comment thread src/microsoft/opentelemetry/_distro.py Outdated
JacksonWeber
JacksonWeber previously approved these changes Jun 12, 2026

@JacksonWeber JacksonWeber 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.

LGTM

@rads-1996 rads-1996 force-pushed the enable_sensitive_data_for_langchain branch from d4cc005 to 3b09907 Compare June 17, 2026 15:41
Comment thread samples/langchain/README.md Outdated
Comment thread src/microsoft/opentelemetry/_constants.py Outdated
Comment thread src/microsoft/opentelemetry/_genai/_langchain/_tracer_instrumentor.py Outdated
@rads-1996 rads-1996 force-pushed the enable_sensitive_data_for_langchain branch from 1b2cfb1 to a027029 Compare June 22, 2026 19:27
JacksonWeber
JacksonWeber previously approved these changes Jun 22, 2026
Comment thread samples/langchain/README.md
@rads-1996 rads-1996 force-pushed the enable_sensitive_data_for_langchain branch from 86f31d4 to d6912ac Compare June 23, 2026 22:03
Comment thread src/microsoft/opentelemetry/_genai/_langchain/_tracer.py
@rads-1996 rads-1996 force-pushed the enable_sensitive_data_for_langchain branch from d6912ac to 187b097 Compare June 23, 2026 22:19
@rads-1996 rads-1996 requested a review from hectorhdzg June 23, 2026 22:34
@rads-1996 rads-1996 merged commit 3fbef4b into microsoft:main Jun 23, 2026
11 checks passed
@rads-1996 rads-1996 deleted the enable_sensitive_data_for_langchain branch June 23, 2026 22:42
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