diff --git a/python/instrumentation/openinference-instrumentation-langchain/examples/openai_chat_stream.py b/python/instrumentation/openinference-instrumentation-langchain/examples/openai_chat_stream.py index 376ffd5be..9442346b0 100644 --- a/python/instrumentation/openinference-instrumentation-langchain/examples/openai_chat_stream.py +++ b/python/instrumentation/openinference-instrumentation-langchain/examples/openai_chat_stream.py @@ -1,5 +1,3 @@ -import os - from langchain_openai import ChatOpenAI from openinference.instrumentation.langchain import LangChainInstrumentor from opentelemetry import trace as trace_api @@ -11,15 +9,10 @@ resource = Resource(attributes={}) tracer_provider = trace_sdk.TracerProvider(resource=resource) trace_api.set_tracer_provider(tracer_provider=tracer_provider) - -# Logs to the Phoenix Collector if running locally -if os.environ.get("PHOENIX_COLLECTOR_ENDPOINT"): - endpoint = os.environ["PHOENIX_COLLECTOR_ENDPOINT"] + "/v1/traces" - span_otlp_exporter = OTLPSpanExporter(endpoint=endpoint) - tracer_provider.add_span_processor(SimpleSpanProcessor(span_exporter=span_otlp_exporter)) -else: - span_console_exporter = ConsoleSpanExporter() - tracer_provider.add_span_processor(SimpleSpanProcessor(span_exporter=span_console_exporter)) +span_otlp_exporter = OTLPSpanExporter(endpoint="http://127.0.0.1:6006/v1/traces") +tracer_provider.add_span_processor(SimpleSpanProcessor(span_exporter=span_otlp_exporter)) +span_console_exporter = ConsoleSpanExporter() +tracer_provider.add_span_processor(SimpleSpanProcessor(span_exporter=span_console_exporter)) LangChainInstrumentor().instrument() diff --git a/python/instrumentation/openinference-instrumentation-langchain/examples/requirements.txt b/python/instrumentation/openinference-instrumentation-langchain/examples/requirements.txt new file mode 100644 index 000000000..ac433c014 --- /dev/null +++ b/python/instrumentation/openinference-instrumentation-langchain/examples/requirements.txt @@ -0,0 +1,4 @@ +langchain_openai +opentelemetry-sdk +opentelemetry-exporter-otlp +openinference-instrumentation-langchain