Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 packages/traceloop-sdk/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dependencies = [
"opentelemetry-sdk>=1.38.0,<2",
"opentelemetry-exporter-otlp-proto-http>=1.38.0,<2",
"opentelemetry-exporter-otlp-proto-grpc>=1.38.0,<2",
"opentelemetry-instrumentation-httpx>=0.59b0",
"opentelemetry-instrumentation-logging>=0.59b0",
"opentelemetry-instrumentation-requests>=0.59b0",
"opentelemetry-instrumentation-sqlalchemy>=0.59b0",
Expand Down
1 change: 1 addition & 0 deletions packages/traceloop-sdk/traceloop/sdk/instruments.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Instruments(Enum):
GOOGLE_GENERATIVEAI = "google_generativeai"
GROQ = "groq"
HAYSTACK = "haystack"
HTTPX = "httpx"
LANCEDB = "lancedb"
LANGCHAIN = "langchain"
LLAMA_INDEX = "llama_index"
Expand Down
19 changes: 19 additions & 0 deletions packages/traceloop-sdk/traceloop/sdk/tracing/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,9 @@ def init_instrumentations(
elif instrument == Instruments.HAYSTACK:
if init_haystack_instrumentor():
instrument_set = True
elif instrument == Instruments.HTTPX:
if init_httpx_instrumentor():
instrument_set = True
elif instrument == Instruments.LANCEDB:
if init_lancedb_instrumentor():
instrument_set = True
Expand Down Expand Up @@ -735,6 +738,22 @@ def init_haystack_instrumentor():
return False


def init_httpx_instrumentor():
try:
if is_package_installed("httpx"):
from opentelemetry.instrumentation.httpx import HTTPXClientInstrumentor

instrumentor = HTTPXClientInstrumentor()
if not instrumentor.is_instrumented_by_opentelemetry:
# Note: HTTPXClientInstrumentor doesn't accept excluded_urls param.
# Use OTEL_PYTHON_HTTPX_EXCLUDED_URLS env var instead.
instrumentor.instrument()
return True
except Exception as e:
logging.error(f"Error initializing HTTPX instrumentor: {e}")
return False


def init_langchain_instrumentor():
try:
if is_package_installed("langchain") or is_package_installed("langgraph"):
Expand Down