Skip to main content

LangChain OpenTelemetry Integration

Overview

This integration provides support for using OpenTelemetry with the LangChain framework. It enables tracing and monitoring of applications built with LangChain.

Installation

  1. Install traceAI LangChain
pip install traceAI-langchain
  1. Install LangChain OpenAI
pip install langchain-openai

Set Environment Variables

Set up your environment variables to authenticate with FutureAGI.

import os

os.environ["FI_API_KEY"] = FI_API_KEY
os.environ["FI_SECRET_KEY"] = FI_SECRET_KEY
os.environ["OPENAI_API_KEY"] = OPENAI_API_KEY

Quickstart

Register Tracer Provider

Set up the trace provider to establish the observability pipeline. The trace provider:

from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType

trace_provider = register(
    project_type=ProjectType.OBSERVE,
    project_name="langchain_app",
    project_version_name="v1",  
    session_name="chat-bot"
)

Configure LangChain Instrumentation

Instrument the LangChain client to enable telemetry collection. This step ensures that all interactions with the LangChain SDK are tracked and monitored.

from traceai_langchain import LangChainInstrumentor

LangChainInstrumentor().instrument(tracer_provider=trace_provider)

Create LangChain Components

Set up your LangChain client with built-in observability.

from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate

prompt = ChatPromptTemplate.from_template("{x} {y} {z}?").partial(x="why is", z="blue")
chain = prompt | ChatOpenAI(model_name="gpt-3.5-turbo")

def run_chain():
    try:
        result = chain.invoke({"y": "sky"})
        print(f"Response: {result}")
    except Exception as e:
        print(f"Error executing chain: {e}")

if __name__ == "__main__":
    run_chain()

Metadata

Release files for traceAI-langchain 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for traceAI-langchain 0.1.6
File Size Uploaded Provenance Actions
traceai_langchain-0.1.6.tar.gz 12.8 kB Without provenance Details for traceai_langchain-0.1.6.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for traceAI-langchain 0.1.6
File Interpreter ABI Platform Actions
traceai_langchain-0.1.6-py3-none-any.whl Python 3 none any Details for traceai_langchain-0.1.6-py3-none-any.whl
traceai_langchain-0.1.6-1-py3-none-any.whl Python 3 none any Details for traceai_langchain-0.1.6-1-py3-none-any.whl

Total release size: 40.0 kB

Release files / traceai_langchain-0.1.6.tar.gz

Download URL traceai_langchain-0.1.6.tar.gz
Size 12.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7b3704da8a7d9526e6982f5fb93891c6974a81cc94e4214b7c15f9fdb128e050
BLAKE2b-256 checksum
How to use checksums
a6e6e8a7735be98ffc5667b951d3e5dafe4dcc93fb5f94a29c4bc35605ce4be9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.0 CPython/3.13.0 Darwin/24.1.0

Release files / traceai_langchain-0.1.6-py3-none-any.whl

Download URL traceai_langchain-0.1.6-py3-none-any.whl
Size 13.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
80f3d037072e2b439d6a3592804ff67a2f56a9c2ceaa80922715297485441d71
BLAKE2b-256 checksum
How to use checksums
e4eadd3c432162e6f903bf66ec4bedec48dceb948ff2150e0ab3c01f0ffa4453
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.0 CPython/3.13.0 Darwin/24.1.0

Release files / traceai_langchain-0.1.6-1-py3-none-any.whl

Download URL traceai_langchain-0.1.6-1-py3-none-any.whl
Size 13.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c0b48263fd1625d5d05e59e304c1e39d343c5bcfe0ae6560e0fe6419c38ed7da
BLAKE2b-256 checksum
How to use checksums
ef1804305ba2b506de5d4dad6d2f50ce4d4d8c036a06acf5ccfe8becf8c39c62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.0 CPython/3.13.0 Darwin/24.1.0

Security for traceAI-langchain 0.1.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page