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()

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

traceai_langchain-0.1.6.tar.gz (12.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

traceai_langchain-0.1.6-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

traceai_langchain-0.1.6-1-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file traceai_langchain-0.1.6.tar.gz.

File metadata

  • Download URL: traceai_langchain-0.1.6.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.0 CPython/3.13.0 Darwin/24.1.0

File hashes

Hashes for traceai_langchain-0.1.6.tar.gz
Algorithm Hash digest
SHA256 7b3704da8a7d9526e6982f5fb93891c6974a81cc94e4214b7c15f9fdb128e050
MD5 306255baadf0710258e972abce8c6891
BLAKE2b-256 a6e6e8a7735be98ffc5667b951d3e5dafe4dcc93fb5f94a29c4bc35605ce4be9

See more details on using hashes here.

File details

Details for the file traceai_langchain-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: traceai_langchain-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.0 CPython/3.13.0 Darwin/24.1.0

File hashes

Hashes for traceai_langchain-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 80f3d037072e2b439d6a3592804ff67a2f56a9c2ceaa80922715297485441d71
MD5 7c734f51544ccab0f155d09a6d547dc4
BLAKE2b-256 e4eadd3c432162e6f903bf66ec4bedec48dceb948ff2150e0ab3c01f0ffa4453

See more details on using hashes here.

File details

Details for the file traceai_langchain-0.1.6-1-py3-none-any.whl.

File metadata

File hashes

Hashes for traceai_langchain-0.1.6-1-py3-none-any.whl
Algorithm Hash digest
SHA256 c0b48263fd1625d5d05e59e304c1e39d343c5bcfe0ae6560e0fe6419c38ed7da
MD5 d2a8b924c0dab760b2fc8eea04ce8644
BLAKE2b-256 ef1804305ba2b506de5d4dad6d2f50ce4d4d8c036a06acf5ccfe8becf8c39c62

See more details on using hashes here.

Release history Release notifications | RSS feed

0.2.0

2 files

0.1.12

2 files

0.1.11

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

This release

0.1.6 This release

3 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

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