Skip to Content
IntegrationsDual Export

Dual Export

Introspection is designed to work alongside tools like Logfire, Langfuse, Braintrust, and Arize / Phoenix.

Use dual export when you already have another backend in place and want Introspection without replacing it immediately.

Logfire

This is the recommended default integration path for Python applications.

Basic Pattern

from introspection_sdk import IntrospectionSpanProcessor import logfire logfire.configure( additional_span_processors=[IntrospectionSpanProcessor()], )

More Complete Example

import logfire import openai from introspection_sdk import IntrospectionSpanProcessor logfire.configure( send_to_logfire="if-token-present", additional_span_processors=[ IntrospectionSpanProcessor(service_name="logfire-openai-example") ], ) logfire.instrument_openai() client = openai.OpenAI() response = client.chat.completions.create( model="gpt-4o", messages=[{"role": "user", "content": "Hello!"}], ) print(response.choices[0].message.content) logfire.shutdown()

Langfuse

Attach both exporters or processors to the same tracing pipeline.

import base64 import os import openai from langfuse import get_client from opentelemetry import trace from opentelemetry.sdk.trace import TracerProvider from opentelemetry.sdk.trace.export import BatchSpanProcessor from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter from openinference.instrumentation.openai import OpenAIInstrumentor from introspection_sdk import IntrospectionSpanProcessor LANGFUSE_AUTH = base64.b64encode( f"{os.environ['LANGFUSE_PUBLIC_KEY']}:{os.environ['LANGFUSE_SECRET_KEY']}".encode() ).decode() os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = ( os.environ.get("LANGFUSE_BASE_URL", "https://cloud.langfuse.com") + "/api/public/otel" ) os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = f"Authorization=Basic {LANGFUSE_AUTH}" provider = TracerProvider() get_client() provider.add_span_processor(BatchSpanProcessor(OTLPSpanExporter())) provider.add_span_processor(IntrospectionSpanProcessor()) trace.set_tracer_provider(provider) OpenAIInstrumentor().instrument(tracer_provider=provider)

Braintrust

Use this when you already send traces to Braintrust and want to add Introspection alongside it.

from opentelemetry.sdk.trace import TracerProvider from introspection_sdk import IntrospectionSpanProcessor from introspection_sdk.config import AdvancedOptions provider = TracerProvider() braintrust_processor = IntrospectionSpanProcessor( token=os.environ["BRAINTRUST_API_KEY"], advanced=AdvancedOptions( base_url="https://api.braintrust.dev/otel/v1/traces", additional_headers={"x-bt-parent": "project_name:my-project"}, ), ) provider.add_span_processor(braintrust_processor) provider.add_span_processor(IntrospectionSpanProcessor())

LangSmith

Use this when you already send traces to LangSmith and want to add Introspection alongside it.

With OpenAI Agents, both LangSmith and Introspection implement the TracingProcessor interface — register both and traces go to both in parallel.

from agents import Agent, Runner, set_trace_processors from langsmith.integrations.openai_agents_sdk import OpenAIAgentsTracingProcessor from introspection_sdk import IntrospectionTracingProcessor langsmith_processor = OpenAIAgentsTracingProcessor() introspection_processor = IntrospectionTracingProcessor() set_trace_processors([langsmith_processor, introspection_processor]) agent = Agent( name="Assistant", instructions="You are a helpful assistant.", ) result = Runner.run_sync(agent, "Hello!") print(result.final_output) langsmith_processor.force_flush() langsmith_processor.shutdown() introspection_processor.shutdown()

Arize / Phoenix

Use this when you already instrument your application with OpenInference and want Introspection in the same pipeline.

import os from phoenix.otel import register from openinference.instrumentation.openai import OpenAIInstrumentor from introspection_sdk import IntrospectionSpanProcessor tracer_provider = register( project_name="my-project", endpoint="https://otlp.arize.com/v1/traces", headers={ "space_id": os.environ["ARIZE_SPACE_KEY"], "api_key": os.environ["ARIZE_API_KEY"], }, batch=False, ) tracer_provider.add_span_processor( IntrospectionSpanProcessor(), replace_default_processor=False, ) OpenAIInstrumentor().instrument(tracer_provider=tracer_provider)
Last updated on