Skip to content

Add Python LangChain local OTLP mode - #87

Open
RitwijParmar wants to merge 2 commits into
The-Context-Company:mainfrom
RitwijParmar:codex/observatory-python-langchain-local-mode
Open

Add Python LangChain local OTLP mode#87
RitwijParmar wants to merge 2 commits into
The-Context-Company:mainfrom
RitwijParmar:codex/observatory-python-langchain-local-mode

Conversation

@RitwijParmar

Copy link
Copy Markdown

Summary

Part of #20.

This adds a scoped local-development path for the Python LangChain integration:

from contextcompany.langchain import instrument_langchain

instrument_langchain(local=True)

In local mode, the SDK no longer requires TCC_API_KEY. It configures the LangChain OpenTelemetry exporter against a local OTLP HTTP endpoint instead:

  • default: http://localhost:4318/v1/traces
  • override with tcc_url=...
  • or set TCC_LOCAL_OTLP_ENDPOINT

This does not attempt to solve the full local UI/collector story in one PR, but it removes the current cloud-auth hard stop for Python LangChain/LangGraph local development and makes it possible to run against a local collector/proxy without patching env vars or passing a fake API key.

Changes

  • Add local: bool = False to instrument_langchain(...)
  • Allow create_otlp_exporter(...) to omit the Authorization header when no API key is provided
  • Add TCC_LOCAL_OTLP_ENDPOINT / default local OTLP endpoint resolution
  • Document Python LangChain local mode in packages/python/README.md
  • Add regression tests for local mode, explicit local endpoint override, cloud-mode API key behavior, and auth-header omission

Validation

  • /tmp/codex-observatory-venv/bin/python -m pytest packages/python/tests/test_langchain_local.py -> 4 passed
  • python -m ruff check packages/python/contextcompany/config.py packages/python/contextcompany/langchain/base.py packages/python/contextcompany/langchain/__init__.py packages/python/tests/test_langchain_local.py
  • python -m ruff format --check packages/python/contextcompany/config.py packages/python/contextcompany/langchain/base.py packages/python/contextcompany/langchain/__init__.py packages/python/tests/test_langchain_local.py
  • git diff --check

@changeset-bot

changeset-bot Bot commented May 26, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b66884d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@capy-ai

capy-ai Bot commented May 26, 2026

Copy link
Copy Markdown

Capy auto-review is paused for this organization because the monthly auto-review limit has been reached. Increase the limit or turn it off in billing settings to resume automatic reviews.

@RitwijParmar

Copy link
Copy Markdown
Author

Added an explicit changeset note in b66884d for the Python LangChain local OTLP mode, following the changeset-bot guidance. Since this PR only touches the Python package/docs/tests and not a JS workspace package, the changeset keeps the version frontmatter empty while documenting the change.

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.

1 participant