diff --git a/instrumentation-genai/opentelemetry-instrumentation-openai-v2/examples/manual/.env b/instrumentation-genai/opentelemetry-instrumentation-openai-v2/examples/manual/.env index 1014066d28..f23df3c4fc 100644 --- a/instrumentation-genai/opentelemetry-instrumentation-openai-v2/examples/manual/.env +++ b/instrumentation-genai/opentelemetry-instrumentation-openai-v2/examples/manual/.env @@ -6,9 +6,9 @@ OPENAI_API_KEY=sk-YOUR_API_KEY # OPENAI_API_KEY=unused # CHAT_MODEL=qwen2.5:0.5b -# Uncomment and change to your OTLP endpoint -# OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 -# OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf +# Uncomment and change to your OTLP endpoint and/or +# OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317 +# OTEL_EXPORTER_OTLP_PROTOCOL=grpc OTEL_SERVICE_NAME=opentelemetry-python-openai # Change to 'false' to hide prompt and completion content diff --git a/instrumentation-genai/opentelemetry-instrumentation-openai-v2/examples/manual/README.rst b/instrumentation-genai/opentelemetry-instrumentation-openai-v2/examples/manual/README.rst index 5a351d30bb..73e4d1bb0c 100644 --- a/instrumentation-genai/opentelemetry-instrumentation-openai-v2/examples/manual/README.rst +++ b/instrumentation-genai/opentelemetry-instrumentation-openai-v2/examples/manual/README.rst @@ -9,12 +9,18 @@ duration of the chat request. Logs capture the chat request and the generated response, providing a comprehensive view of the performance and behavior of your OpenAI requests. +Note: `.env <.env>`_ file configures additional environment variables: + +- `OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true` configures +OpenAI instrumentation to capture prompt and completion contents on +events. + Setup ----- Minimally, update the `.env <.env>`_ file with your "OPENAI_API_KEY". An OTLP compatible endpoint should be listening for traces and logs on -http://localhost:4318. If not, update "OTEL_EXPORTER_OTLP_ENDPOINT" as well. +http://localhost:4317. If not, update "OTEL_EXPORTER_OTLP_ENDPOINT" as well. Next, set up a virtual environment like this: diff --git a/instrumentation-genai/opentelemetry-instrumentation-openai-v2/examples/manual/requirements.txt b/instrumentation-genai/opentelemetry-instrumentation-openai-v2/examples/manual/requirements.txt index 72513ad7d4..436f63e1d5 100644 --- a/instrumentation-genai/opentelemetry-instrumentation-openai-v2/examples/manual/requirements.txt +++ b/instrumentation-genai/opentelemetry-instrumentation-openai-v2/examples/manual/requirements.txt @@ -1,5 +1,5 @@ openai~=1.54.4 opentelemetry-sdk~=1.28.2 -opentelemetry-exporter-otlp-proto-http~=1.28.2 +opentelemetry-exporter-otlp-proto-grpc~=1.28.2 opentelemetry-instrumentation-openai-v2~=2.0b0 diff --git a/instrumentation-genai/opentelemetry-instrumentation-openai-v2/examples/zero-code/.env b/instrumentation-genai/opentelemetry-instrumentation-openai-v2/examples/zero-code/.env index d6afa66723..f690e1a606 100644 --- a/instrumentation-genai/opentelemetry-instrumentation-openai-v2/examples/zero-code/.env +++ b/instrumentation-genai/opentelemetry-instrumentation-openai-v2/examples/zero-code/.env @@ -6,13 +6,15 @@ OPENAI_API_KEY=sk-YOUR_API_KEY # OPENAI_API_KEY=unused # CHAT_MODEL=qwen2.5:0.5b -OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 -OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf +# Uncomment and change to your OTLP endpoint and/or +# OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317 +# OTEL_EXPORTER_OTLP_PROTOCOL=grpc + OTEL_SERVICE_NAME=opentelemetry-python-openai # Change to 'false' to disable logging OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true # Change to 'console' if your OTLP endpoint doesn't support logs -OTEL_LOGS_EXPORTER=otlp_proto_http +OTEL_LOGS_EXPORTER=otlp # Change to 'false' to hide prompt and completion content OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true diff --git a/instrumentation-genai/opentelemetry-instrumentation-openai-v2/examples/zero-code/README.rst b/instrumentation-genai/opentelemetry-instrumentation-openai-v2/examples/zero-code/README.rst index 4bef3c3c3e..f1b9e9847e 100644 --- a/instrumentation-genai/opentelemetry-instrumentation-openai-v2/examples/zero-code/README.rst +++ b/instrumentation-genai/opentelemetry-instrumentation-openai-v2/examples/zero-code/README.rst @@ -10,12 +10,21 @@ duration of the chat request. Logs capture the chat request and the generated response, providing a comprehensive view of the performance and behavior of your OpenAI requests. +Note: `.env <.env>`_ file configures additional environment variables: + +- `OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true` configures +OpenTelemetry SDK to export logs and events. +- `OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true` configures +OpenAI instrumentation to capture prompt and completion contents on +events. +- `OTEL_LOGS_EXPORTER=otlp` to specify exporter type. + Setup ----- Minimally, update the `.env <.env>`_ file with your "OPENAI_API_KEY". An OTLP compatible endpoint should be listening for traces and logs on -http://localhost:4318. If not, update "OTEL_EXPORTER_OTLP_ENDPOINT" as well. +http://localhost:4317. If not, update "OTEL_EXPORTER_OTLP_ENDPOINT" as well. Next, set up a virtual environment like this: diff --git a/instrumentation-genai/opentelemetry-instrumentation-openai-v2/examples/zero-code/requirements.txt b/instrumentation-genai/opentelemetry-instrumentation-openai-v2/examples/zero-code/requirements.txt index 9ec9bff320..77ed112ebb 100644 --- a/instrumentation-genai/opentelemetry-instrumentation-openai-v2/examples/zero-code/requirements.txt +++ b/instrumentation-genai/opentelemetry-instrumentation-openai-v2/examples/zero-code/requirements.txt @@ -1,6 +1,6 @@ openai~=1.54.4 opentelemetry-sdk~=1.28.2 -opentelemetry-exporter-otlp-proto-http~=1.28.2 +opentelemetry-exporter-otlp-proto-grpc~=1.28.2 opentelemetry-distro~=0.49b2 opentelemetry-instrumentation-openai-v2~=2.0b0 diff --git a/opentelemetry-distro/src/opentelemetry/distro/__init__.py b/opentelemetry-distro/src/opentelemetry/distro/__init__.py index ad61f01ca7..25dfe2526f 100644 --- a/opentelemetry-distro/src/opentelemetry/distro/__init__.py +++ b/opentelemetry-distro/src/opentelemetry/distro/__init__.py @@ -17,6 +17,7 @@ from opentelemetry.environment_variables import ( OTEL_METRICS_EXPORTER, OTEL_TRACES_EXPORTER, + OTEL_LOGS_EXPORTER ) from opentelemetry.instrumentation.distro import BaseDistro from opentelemetry.sdk._configuration import _OTelSDKConfigurator @@ -37,4 +38,5 @@ class OpenTelemetryDistro(BaseDistro): def _configure(self, **kwargs): os.environ.setdefault(OTEL_TRACES_EXPORTER, "otlp") os.environ.setdefault(OTEL_METRICS_EXPORTER, "otlp") + os.environ.setdefault(OTEL_LOGS_EXPORTER, "otlp") os.environ.setdefault(OTEL_EXPORTER_OTLP_PROTOCOL, "grpc")