Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
344e2d7
chore: bump otel deps to 0.58b0
nagkumar91 Oct 7, 2025
c1c74ff
feat: enrich langchain spans with genai metadata
nagkumar91 Oct 7, 2025
33ead3a
refactor: support chat span without request model
nagkumar91 Oct 7, 2025
669ace4
test: cover azure span provider metadata
nagkumar91 Oct 7, 2025
8b6937c
test: add callback handler unit coverage
nagkumar91 Oct 7, 2025
489ff2d
Merge branch 'main' into feature/genai-genai-spec-updates
nagkumar91 Oct 7, 2025
96889d7
docs: note langchain genai schema update
nagkumar91 Oct 7, 2025
3ae8264
update with precommit fixes
nagkumar91 Oct 7, 2025
eb20620
Merge branch 'main' into feature/genai-genai-spec-updates
nagkumar91 Oct 8, 2025
0e05bef
feat: capture langchain message content by default
nagkumar91 Oct 8, 2025
48f5e3a
Merge branch 'main' into feature/genai-genai-spec-updates
nagkumar91 Oct 9, 2025
b82dd71
Merge branch 'main' into feature/genai-genai-spec-updates
nagkumar91 Oct 10, 2025
f97ef77
Merge branch 'main' into feature/genai-genai-spec-updates
nagkumar91 Oct 13, 2025
cdd3487
Merge branch 'main' into feature/genai-genai-spec-updates
nagkumar91 Oct 13, 2025
476c86e
Fix pyright typing for LangChain instrumentation
nagkumar91 Oct 14, 2025
3ac649a
Merge branch 'main' into feature/genai-genai-spec-updates
nagkumar91 Oct 14, 2025
e55b1b3
Improve LangChain stub typing and typecheck config
nagkumar91 Oct 14, 2025
fa1f16d
Merge branch 'main' into feature/genai-genai-spec-updates
nagkumar91 Oct 14, 2025
5e28f79
Merge branch 'main' into feature/genai-genai-spec-updates
nagkumar91 Oct 15, 2025
fadcf7d
Rename LangChain instrumentation package to v2
nagkumar91 Oct 16, 2025
2343707
Merge branch 'main' into feature/genai-genai-spec-updates
nagkumar91 Oct 16, 2025
b028c75
Register LangChain v2 bootstrap mapping
nagkumar91 Oct 16, 2025
af3bc15
Merge branch 'main' into feature/genai-genai-spec-updates
nagkumar91 Oct 16, 2025
0d4cfd7
tox -e generate
nagkumar91 Oct 16, 2025
aef0792
chore: update configs and docs
nagkumar91 Oct 16, 2025
4c81201
tox generate
nagkumar91 Oct 16, 2025
8930c0d
ignore the typecheck as its failing only on 3.9
nagkumar91 Oct 16, 2025
1c1e875
Merge branch 'main' into feature/genai-genai-spec-updates
nagkumar91 Oct 16, 2025
81e3241
Merge branch 'main' into feature/genai-genai-spec-updates
nagkumar91 Oct 17, 2025
992dfff
Revert "tox generate"
nagkumar91 Oct 20, 2025
a632d3b
Revert "chore: update configs and docs"
nagkumar91 Oct 20, 2025
4cef9b0
Revert "Register LangChain v2 bootstrap mapping"
nagkumar91 Oct 20, 2025
32c7320
Revert "Rename LangChain instrumentation package to v2"
nagkumar91 Oct 20, 2025
abd719f
feat: add multi-agent sample and tool spans
nagkumar91 Oct 20, 2025
c626a5e
Update LangChain instrumentation and samples for 1.x
nagkumar91 Oct 21, 2025
44f4c1d
Switch tests and samples to gpt-4.1 and refresh VCR cassettes
nagkumar91 Oct 21, 2025
06bcda0
tox -e generate
nagkumar91 Oct 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,4 @@ target

# Benchmark result files
*-benchmark.json
instrumentation-genai/opentelemetry-instrumentation-langchain/examples/multi_agent_travel_planner/.env
2 changes: 1 addition & 1 deletion instrumentation-genai/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
| Instrumentation | Supported Packages | Metrics support | Semconv status |
| --------------- | ------------------ | --------------- | -------------- |
| [opentelemetry-instrumentation-google-genai](./opentelemetry-instrumentation-google-genai) | google-genai >= 1.0.0 | No | development
| [opentelemetry-instrumentation-langchain](./opentelemetry-instrumentation-langchain) | langchain >= 0.3.21 | No | development
| [opentelemetry-instrumentation-langchain](./opentelemetry-instrumentation-langchain) | langchain >= 1.0.0 | No | development
| [opentelemetry-instrumentation-openai-agents-v2](./opentelemetry-instrumentation-openai-agents-v2) | openai-agents >= 0.3.3 | No | development
| [opentelemetry-instrumentation-openai-v2](./opentelemetry-instrumentation-openai-v2) | openai >= 1.26.0 | Yes | development
| [opentelemetry-instrumentation-vertexai](./opentelemetry-instrumentation-vertexai) | google-cloud-aiplatform >= 1.64 | No | development
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased

- Added span support for genAI langchain llm invocation.
([#3665](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3665))
([#3665](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3665))
- Align LangChain instrumentation with GenAI schema 1.37.0 and add unit coverage for updated metadata.
([#3813](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3813))
- Capture GenAI input/output messages on spans by default with opt-out control.
([#3813](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3813))
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def main():

# ChatOpenAI
llm = ChatOpenAI(
model="gpt-3.5-turbo",
model="gpt-4.1",
temperature=0.1,
max_tokens=100,
top_p=0.9,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
langchain==0.3.21
langchain_openai
langchain==1.0.1
langchain-openai==1.0.0
opentelemetry-sdk>=1.31.0
opentelemetry-exporter-otlp-proto-grpc>=1.31.0

# Uncomment after lanchain instrumetation is released
# opentelemetry-instrumentation-langchain~=2.0b0.dev
# opentelemetry-instrumentation-langchain~=2.0b0.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copy this file to .env and update values before running the sample.

# Required OpenAI API key
OPENAI_API_KEY=sk-YOUR_API_KEY

# Optional: override default model (defaults to gpt-4o-mini)
# OPENAI_MODEL=gpt-4o-mini

# OTLP exporter configuration (update for your collector)
# OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
# OTEL_EXPORTER_OTLP_PROTOCOL=grpc

# Traces will use this service.name
OTEL_SERVICE_NAME=opentelemetry-python-langchain-multi-agent
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copy this file to `.env` and update values before running the sample.

# Required OpenAI API key
OPENAI_API_KEY=sk-YOUR_API_KEY

# Optional: override default model (defaults to gpt-4.1)
# OPENAI_MODEL=gpt-4.1

# OTLP exporter configuration (update for your collector)
# OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
# OTEL_EXPORTER_OTLP_PROTOCOL=grpc

# Traces will use this service.name
OTEL_SERVICE_NAME=opentelemetry-python-langchain-multi-agent
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
Multi-Agent Travel Planner Sample
=================================

This example shows how to orchestrate a small team of LangChain agents with
`LangGraph <https://python.langchain.com/docs/langgraph/>`_ while the
OpenTelemetry LangChain instrumentation captures GenAI spans and forwards them
to an OTLP collector.

The graph contains four specialists (coordinator, flights, hotels, activities)
and a final synthesiser node that produces an itinerary. Each specialist relies
on a simple, deterministic tool so you can run the example without any external
travel APIs while still observing tool spans wired up to the agent calls.

Prerequisites
-------------

* Python 3.10+
* An OpenAI API key with access to ``gpt-4o-mini`` (or set ``OPENAI_MODEL`` to a
model that is available to your account)
* A running OTLP collector (gRPC on ``localhost:4317`` by default)

Setup
-----

.. code-block:: bash

cd instrumentation-genai/opentelemetry-instrumentation-langchain/examples/multi_agent_travel_planner
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

# Copy the sample environment file and update values as needed.
cp .env.example .env
source .env

Run the sample
--------------

.. code-block:: bash

# From this directory, after activating the virtual environment and sourcing
# your environment variables:
python main.py

The script prints each agent's contribution followed by the final itinerary.
At the same time it streams OTLP traces. You should see:

* A root span named ``invoke_agent travel_multi_agent_planner`` that captures
the overall orchestration, including ``gen_ai.input.messages`` and a preview
of the final plan.
* LangChain instrumentation spans for each agent's LLM invocation with
``gen_ai.provider.name=openai`` and ``service.name`` derived from
``OTEL_SERVICE_NAME``.

Tear down
---------

Deactivate the virtual environment when you are done:

.. code-block:: bash

deactivate
Loading