diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/README.md b/instrumentation/elastic-opentelemetry-instrumentation-openai/README.md index eb6832d..1e1008b 100644 --- a/instrumentation/elastic-opentelemetry-instrumentation-openai/README.md +++ b/instrumentation/elastic-opentelemetry-instrumentation-openai/README.md @@ -19,10 +19,16 @@ pip install elastic-opentelemetry-instrumentation-openai ## Usage -This instrumentation supports *0-code* / *auto* instrumentation: +This instrumentation supports *0-code* / *autoinstrumentation*: ``` opentelemetry-instrument python use_openai.py + +# You can record more information about prompts as span events by enabling content capture. +OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true opentelemetry-instrument python use_openai.py + +# You can record more information about prompts as log events by enabling content capture. +OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true ELASTIC_OTEL_GENAI_EVENTS=log opentelemetry-instrument python use_openai.py ``` Or manual instrumentation: @@ -48,8 +54,8 @@ chat_completion = client.chat.completions.create(model="gpt-4o-mini", messages=m ### Instrumentation specific environment variable configuration -- `ELASTIC_OTEL_GENAI_CAPTURE_CONTENT` (default: `false`): when sets to `true` collect more -informations about prompts and responses by enabling content capture +- `ELASTIC_OTEL_GENAI_EVENTS` (default: `span`): when set to `log` exports GenAI events as +log events instead of span events. ### Elastic specific semantic conventions diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/__init__.py b/instrumentation/elastic-opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/__init__.py index 6a5bcee..6a12e27 100644 --- a/instrumentation/elastic-opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/__init__.py +++ b/instrumentation/elastic-opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/__init__.py @@ -26,8 +26,8 @@ from opentelemetry.instrumentation.instrumentor import BaseInstrumentor from opentelemetry.instrumentation.utils import unwrap from opentelemetry.instrumentation.openai.environment_variables import ( - ELASTIC_OTEL_GENAI_CAPTURE_CONTENT, ELASTIC_OTEL_GENAI_EVENTS, + OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT, ) from opentelemetry.instrumentation.openai.helpers import ( _get_embeddings_span_attributes_from_wrapper, @@ -78,10 +78,13 @@ def _instrument(self, **kwargs): ``tracer_provider``: a TracerProvider, defaults to global ``meter_provider``: a MeterProvider, defaults to global ``event_logger_provider``: a EventLoggerProvider, defaults to global - ``capture_content``: to enable content capturing, defaults to False + ``capture_message_content``: to enable content capturing, defaults to False """ - capture_content = "true" if kwargs.get("capture_content") else "false" - self.capture_content = os.environ.get(ELASTIC_OTEL_GENAI_CAPTURE_CONTENT, capture_content).lower() == "true" + capture_message_content = "true" if kwargs.get("capture_message_content") else "false" + self.capture_message_content = ( + os.environ.get(OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT, capture_message_content).lower() + == "true" + ) # we support 3 values for deciding how to send events: # - "latest" to match latest semconv, as 1.27.0 it's span @@ -135,7 +138,7 @@ def _patch(self, _module): ) def _uninstrument(self, **kwargs): - # unwrap only supports uninstrementing real module references so we + # unwrap only supports uninstrumenting real module references so we # import here. import openai @@ -159,7 +162,7 @@ def _chat_completion_wrapper(self, wrapped, instance, args, kwargs): end_on_exit=False, ) as span: # TODO: more fine grained depending on the message.role? - if self.capture_content: + if self.capture_message_content: messages = kwargs.get("messages", []) if self.event_kind == "log": @@ -184,7 +187,7 @@ def _chat_completion_wrapper(self, wrapped, instance, args, kwargs): return StreamWrapper( stream=result, span=span, - capture_content=self.capture_content, + capture_message_content=self.capture_message_content, event_kind=self.event_kind, event_attributes=event_attributes, event_logger=self.event_logger, @@ -201,7 +204,7 @@ def _chat_completion_wrapper(self, wrapped, instance, args, kwargs): _record_token_usage_metrics(self.token_usage_metric, span, result.usage) _record_operation_duration_metric(self.operation_duration_metric, span, start_time) - if self.capture_content: + if self.capture_message_content: if self.event_kind == "log": _send_log_events_from_choices( self.event_logger, choices=result.choices, attributes=event_attributes @@ -234,7 +237,7 @@ async def _async_chat_completion_wrapper(self, wrapped, instance, args, kwargs): # this is important to avoid having the span closed before ending the stream end_on_exit=False, ) as span: - if self.capture_content: + if self.capture_message_content: messages = kwargs.get("messages", []) if self.event_kind == "log": @@ -259,7 +262,7 @@ async def _async_chat_completion_wrapper(self, wrapped, instance, args, kwargs): return StreamWrapper( stream=result, span=span, - capture_content=self.capture_content, + capture_message_content=self.capture_message_content, event_kind=self.event_kind, event_attributes=event_attributes, event_logger=self.event_logger, @@ -276,7 +279,7 @@ async def _async_chat_completion_wrapper(self, wrapped, instance, args, kwargs): _record_token_usage_metrics(self.token_usage_metric, span, result.usage) _record_operation_duration_metric(self.operation_duration_metric, span, start_time) - if self.capture_content: + if self.capture_message_content: if self.event_kind == "log": _send_log_events_from_choices( self.event_logger, choices=result.choices, attributes=event_attributes diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/environment_variables.py b/instrumentation/elastic-opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/environment_variables.py index 20f6280..5c02d77 100644 --- a/instrumentation/elastic-opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/environment_variables.py +++ b/instrumentation/elastic-opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/environment_variables.py @@ -14,6 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -ELASTIC_OTEL_GENAI_CAPTURE_CONTENT = "ELASTIC_OTEL_GENAI_CAPTURE_CONTENT" +OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT = "OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT" ELASTIC_OTEL_GENAI_EVENTS = "ELASTIC_OTEL_GENAI_EVENTS" diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/wrappers.py b/instrumentation/elastic-opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/wrappers.py index cf4cfa9..4321512 100644 --- a/instrumentation/elastic-opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/wrappers.py +++ b/instrumentation/elastic-opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/wrappers.py @@ -45,7 +45,7 @@ def __init__( self, stream, span: Span, - capture_content: bool, + capture_message_content: bool, event_kind: Literal["log", "span"], event_attributes: Attributes, event_logger: EventLogger, @@ -55,7 +55,7 @@ def __init__( ): self.stream = stream self.span = span - self.capture_content = capture_content + self.capture_message_content = capture_message_content self.event_kind = event_kind self.event_attributes = event_attributes self.event_logger = event_logger @@ -84,7 +84,7 @@ def end(self, exc=None): if self.usage: _record_token_usage_metrics(self.token_usage_metric, self.span, self.usage) - if self.capture_content: + if self.capture_message_content: if self.event_kind == "log": _send_log_events_from_stream_choices( self.event_logger, choices=self.choices, span=self.span, attributes=self.event_attributes diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_basic_with_capture_content[azure_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_basic_with_capture_message_content[azure_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_basic_with_capture_content[azure_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_basic_with_capture_message_content[azure_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_basic_with_capture_content[ollama_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_basic_with_capture_message_content[ollama_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_basic_with_capture_content[ollama_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_basic_with_capture_message_content[ollama_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_basic_with_capture_content[openai_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_basic_with_capture_message_content[openai_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_basic_with_capture_content[openai_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_basic_with_capture_message_content[openai_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_basic_with_capture_content_log_events[azure_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_basic_with_capture_message_content_log_events[azure_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_basic_with_capture_content_log_events[azure_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_basic_with_capture_message_content_log_events[azure_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_basic_with_capture_content_log_events[ollama_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_basic_with_capture_message_content_log_events[ollama_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_basic_with_capture_content_log_events[ollama_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_basic_with_capture_message_content_log_events[ollama_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_basic_with_capture_content_log_events[openai_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_basic_with_capture_message_content_log_events[openai_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_basic_with_capture_content_log_events[openai_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_basic_with_capture_message_content_log_events[openai_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_stream_with_capture_content[azure_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_stream_with_capture_message_content[azure_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_stream_with_capture_content[azure_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_stream_with_capture_message_content[azure_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_stream_with_capture_content[ollama_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_stream_with_capture_message_content[ollama_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_stream_with_capture_content[ollama_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_stream_with_capture_message_content[ollama_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_stream_with_capture_content[openai_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_stream_with_capture_message_content[openai_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_stream_with_capture_content[openai_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_stream_with_capture_message_content[openai_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_stream_with_capture_content_log_events[azure_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_stream_with_capture_message_content_log_events[azure_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_stream_with_capture_content_log_events[azure_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_stream_with_capture_message_content_log_events[azure_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_stream_with_capture_content_log_events[ollama_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_stream_with_capture_message_content_log_events[ollama_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_stream_with_capture_content_log_events[ollama_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_stream_with_capture_message_content_log_events[ollama_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_stream_with_capture_content_log_events[openai_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_stream_with_capture_message_content_log_events[openai_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_stream_with_capture_content_log_events[openai_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_stream_with_capture_message_content_log_events[openai_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_tools_with_capture_content[azure_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_tools_with_capture_message_content[azure_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_tools_with_capture_content[azure_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_tools_with_capture_message_content[azure_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_tools_with_capture_content[openai_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_tools_with_capture_message_content[openai_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_tools_with_capture_content[openai_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_tools_with_capture_message_content[openai_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_tools_with_capture_content_log_events[azure_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_tools_with_capture_message_content_log_events[azure_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_tools_with_capture_content_log_events[azure_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_tools_with_capture_message_content_log_events[azure_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_tools_with_capture_content_log_events[openai_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_tools_with_capture_message_content_log_events[openai_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_tools_with_capture_content_log_events[openai_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_async_tools_with_capture_message_content_log_events[openai_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_basic_with_capture_content[azure_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_basic_with_capture_message_content[azure_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_basic_with_capture_content[azure_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_basic_with_capture_message_content[azure_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_basic_with_capture_content[ollama_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_basic_with_capture_message_content[ollama_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_basic_with_capture_content[ollama_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_basic_with_capture_message_content[ollama_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_basic_with_capture_content[openai_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_basic_with_capture_message_content[openai_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_basic_with_capture_content[openai_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_basic_with_capture_message_content[openai_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_basic_with_capture_content_log_events[azure_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_basic_with_capture_message_content_log_events[azure_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_basic_with_capture_content_log_events[azure_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_basic_with_capture_message_content_log_events[azure_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_basic_with_capture_content_log_events[ollama_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_basic_with_capture_message_content_log_events[ollama_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_basic_with_capture_content_log_events[ollama_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_basic_with_capture_message_content_log_events[ollama_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_basic_with_capture_content_log_events[openai_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_basic_with_capture_message_content_log_events[openai_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_basic_with_capture_content_log_events[openai_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_basic_with_capture_message_content_log_events[openai_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_multiple_choices_with_capture_content_log_events[azure_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_multiple_choices_with_capture_message_content_log_events[azure_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_multiple_choices_with_capture_content_log_events[azure_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_multiple_choices_with_capture_message_content_log_events[azure_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_multiple_choices_with_capture_content_log_events[openai_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_multiple_choices_with_capture_message_content_log_events[openai_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_multiple_choices_with_capture_content_log_events[openai_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_multiple_choices_with_capture_message_content_log_events[openai_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_parallel_tools_and_capture_content[ollama_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_parallel_tools_and_capture_message_content[ollama_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_parallel_tools_and_capture_content[ollama_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_parallel_tools_and_capture_message_content[ollama_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_parallel_tools_and_capture_content[openai_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_parallel_tools_and_capture_message_content[openai_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_parallel_tools_and_capture_content[openai_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_parallel_tools_and_capture_message_content[openai_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_parallel_tools_and_capture_content_log_events[ollama_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_parallel_tools_and_capture_message_content_log_events[ollama_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_parallel_tools_and_capture_content_log_events[ollama_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_parallel_tools_and_capture_message_content_log_events[ollama_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_parallel_tools_and_capture_content_log_events[openai_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_parallel_tools_and_capture_message_content_log_events[openai_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_parallel_tools_and_capture_content_log_events[openai_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_parallel_tools_and_capture_message_content_log_events[openai_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_tools_and_capture_content[azure_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_tools_and_capture_message_content[azure_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_tools_and_capture_content[azure_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_tools_and_capture_message_content[azure_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_tools_and_capture_content[ollama_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_tools_and_capture_message_content[ollama_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_tools_and_capture_content[ollama_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_tools_and_capture_message_content[ollama_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_tools_and_capture_content[openai_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_tools_and_capture_message_content[openai_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_tools_and_capture_content[openai_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_tools_and_capture_message_content[openai_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_tools_and_capture_content_log_events[azure_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_tools_and_capture_message_content_log_events[azure_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_tools_and_capture_content_log_events[azure_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_tools_and_capture_message_content_log_events[azure_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_tools_and_capture_content_log_events[ollama_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_tools_and_capture_message_content_log_events[ollama_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_tools_and_capture_content_log_events[ollama_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_tools_and_capture_message_content_log_events[ollama_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_tools_and_capture_content_log_events[openai_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_tools_and_capture_message_content_log_events[openai_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_tools_and_capture_content_log_events[openai_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_stream_with_tools_and_capture_message_content_log_events[openai_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_capture_content[azure_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_capture_message_content[azure_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_capture_content[azure_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_capture_message_content[azure_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_capture_content[ollama_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_capture_message_content[ollama_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_capture_content[ollama_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_capture_message_content[ollama_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_capture_content[openai_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_capture_message_content[openai_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_capture_content[openai_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_capture_message_content[openai_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_capture_content_log_events[azure_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_capture_message_content_log_events[azure_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_capture_content_log_events[azure_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_capture_message_content_log_events[azure_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_capture_content_log_events[ollama_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_capture_message_content_log_events[ollama_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_capture_content_log_events[ollama_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_capture_message_content_log_events[ollama_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_capture_content_log_events[openai_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_capture_message_content_log_events[openai_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_capture_content_log_events[openai_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_capture_message_content_log_events[openai_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_followup_and_capture_content_log_events[azure_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_followup_and_capture_message_content_log_events[azure_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_followup_and_capture_content_log_events[azure_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_followup_and_capture_message_content_log_events[azure_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_followup_and_capture_content_log_events[ollama_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_followup_and_capture_message_content_log_events[ollama_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_followup_and_capture_content_log_events[ollama_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_followup_and_capture_message_content_log_events[ollama_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_followup_and_capture_content_log_events[openai_provider_chat_completions].yaml b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_followup_and_capture_message_content_log_events[openai_provider_chat_completions].yaml similarity index 100% rename from instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_followup_and_capture_content_log_events[openai_provider_chat_completions].yaml rename to instrumentation/elastic-opentelemetry-instrumentation-openai/tests/cassettes/.test_chat_completions/test_tools_with_followup_and_capture_message_content_log_events[openai_provider_chat_completions].yaml diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/test_chat_completions.py b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/test_chat_completions.py index 26bd9a3..c92de4e 100644 --- a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/test_chat_completions.py +++ b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/test_chat_completions.py @@ -313,7 +313,7 @@ def test_all_the_client_options( ] -test_multiple_choices_capture_content_log_events_test_data = [ +test_multiple_choices_capture_message_content_log_events_test_data = [ ( "openai_provider_chat_completions", "gpt-4o-mini", @@ -341,9 +341,9 @@ def test_all_the_client_options( @pytest.mark.vcr() @pytest.mark.parametrize( "provider_str,model,response_model,content,response_id,input_tokens,output_tokens,duration", - test_multiple_choices_capture_content_log_events_test_data, + test_multiple_choices_capture_message_content_log_events_test_data, ) -def test_multiple_choices_with_capture_content_log_events( +def test_multiple_choices_with_capture_message_content_log_events( provider_str, model, response_model, @@ -364,7 +364,7 @@ def test_multiple_choices_with_capture_content_log_events( # Redo the instrumentation dance to be affected by the environment variable OpenAIInstrumentor().uninstrument() with mock.patch.dict( - "os.environ", {"ELASTIC_OTEL_GENAI_CAPTURE_CONTENT": "true", "ELASTIC_OTEL_GENAI_EVENTS": "log"} + "os.environ", {"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT": "true", "ELASTIC_OTEL_GENAI_EVENTS": "log"} ): OpenAIInstrumentor().instrument() @@ -545,7 +545,7 @@ def test_function_calling_with_tools( ) -test_tools_with_capture_content_test_data = [ +test_tools_with_capture_message_content_test_data = [ ( "openai_provider_chat_completions", "gpt-4o-mini", @@ -585,9 +585,9 @@ def test_function_calling_with_tools( @pytest.mark.vcr() @pytest.mark.parametrize( "provider_str,model,response_model,content,response_id,function_call_id,input_tokens,output_tokens,duration", - test_tools_with_capture_content_test_data, + test_tools_with_capture_message_content_test_data, ) -def test_tools_with_capture_content( +def test_tools_with_capture_message_content( provider_str, model, response_model, @@ -606,7 +606,7 @@ def test_tools_with_capture_content( # Redo the instrumentation dance to be affected by the environment variable OpenAIInstrumentor().uninstrument() - with mock.patch.dict("os.environ", {"ELASTIC_OTEL_GENAI_CAPTURE_CONTENT": "true"}): + with mock.patch.dict("os.environ", {"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT": "true"}): OpenAIInstrumentor().instrument() tools = [ @@ -697,7 +697,7 @@ def test_tools_with_capture_content( ) -test_tools_with_capture_content_log_events_test_data = [ +test_tools_with_capture_message_content_log_events_test_data = [ ( "openai_provider_chat_completions", "gpt-4o-mini", @@ -737,9 +737,9 @@ def test_tools_with_capture_content( @pytest.mark.vcr() @pytest.mark.parametrize( "provider_str,model,response_model,content,response_id,function_call_id,input_tokens,output_tokens,duration", - test_tools_with_capture_content_log_events_test_data, + test_tools_with_capture_message_content_log_events_test_data, ) -def test_tools_with_capture_content_log_events( +def test_tools_with_capture_message_content_log_events( provider_str, model, response_model, @@ -760,7 +760,7 @@ def test_tools_with_capture_content_log_events( # Redo the instrumentation dance to be affected by the environment variable OpenAIInstrumentor().uninstrument() with mock.patch.dict( - "os.environ", {"ELASTIC_OTEL_GENAI_CAPTURE_CONTENT": "true", "ELASTIC_OTEL_GENAI_EVENTS": "log"} + "os.environ", {"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT": "true", "ELASTIC_OTEL_GENAI_EVENTS": "log"} ): OpenAIInstrumentor().instrument() @@ -885,7 +885,7 @@ def test_tools_with_capture_content_log_events( ), ], ) -def test_tools_with_capture_content_log_events_integration( +def test_tools_with_capture_message_content_log_events_integration( provider_str, model, response_model, @@ -900,7 +900,7 @@ def test_tools_with_capture_content_log_events_integration( # Redo the instrumentation dance to be affected by the environment variable OpenAIInstrumentor().uninstrument() with mock.patch.dict( - "os.environ", {"ELASTIC_OTEL_GENAI_CAPTURE_CONTENT": "true", "ELASTIC_OTEL_GENAI_EVENTS": "log"} + "os.environ", {"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT": "true", "ELASTIC_OTEL_GENAI_EVENTS": "log"} ): OpenAIInstrumentor().instrument() @@ -1081,7 +1081,7 @@ def test_connection_error(provider_str, model, duration, trace_exporter, metrics ) -test_basic_with_capture_content_test_data = [ +test_basic_with_capture_message_content_test_data = [ ( "openai_provider_chat_completions", "gpt-4o-mini", @@ -1118,9 +1118,9 @@ def test_connection_error(provider_str, model, duration, trace_exporter, metrics @pytest.mark.vcr() @pytest.mark.parametrize( "provider_str,model,response_model,content,response_id,input_tokens,output_tokens,duration", - test_basic_with_capture_content_test_data, + test_basic_with_capture_message_content_test_data, ) -def test_basic_with_capture_content( +def test_basic_with_capture_message_content( provider_str, model, response_model, @@ -1138,7 +1138,7 @@ def test_basic_with_capture_content( # Redo the instrumentation dance to be affected by the environment variable OpenAIInstrumentor().uninstrument() - with mock.patch.dict("os.environ", {"ELASTIC_OTEL_GENAI_CAPTURE_CONTENT": "true"}): + with mock.patch.dict("os.environ", {"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT": "true"}): OpenAIInstrumentor().instrument() messages = [ @@ -1210,7 +1210,7 @@ def test_basic_with_capture_content( ) ], ) -def test_basic_with_capture_content_integration( +def test_basic_with_capture_message_content_integration( provider_str, model, response_model, @@ -1222,7 +1222,7 @@ def test_basic_with_capture_content_integration( # Redo the instrumentation dance to be affected by the environment variable OpenAIInstrumentor().uninstrument() - with mock.patch.dict("os.environ", {"ELASTIC_OTEL_GENAI_CAPTURE_CONTENT": "true"}): + with mock.patch.dict("os.environ", {"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT": "true"}): OpenAIInstrumentor().instrument() client = provider.get_client() @@ -1285,7 +1285,7 @@ def test_basic_with_capture_content_integration( ) -test_basic_with_capture_content_log_events_test_data = [ +test_basic_with_capture_message_content_log_events_test_data = [ ( "openai_provider_chat_completions", "gpt-4o-mini", @@ -1322,9 +1322,9 @@ def test_basic_with_capture_content_integration( @pytest.mark.vcr() @pytest.mark.parametrize( "provider_str,model,response_model,content,response_id,input_tokens,output_tokens,duration", - test_basic_with_capture_content_log_events_test_data, + test_basic_with_capture_message_content_log_events_test_data, ) -def test_basic_with_capture_content_log_events( +def test_basic_with_capture_message_content_log_events( provider_str, model, response_model, @@ -1344,7 +1344,7 @@ def test_basic_with_capture_content_log_events( # Redo the instrumentation dance to be affected by the environment variable OpenAIInstrumentor().uninstrument() with mock.patch.dict( - "os.environ", {"ELASTIC_OTEL_GENAI_CAPTURE_CONTENT": "true", "ELASTIC_OTEL_GENAI_EVENTS": "log"} + "os.environ", {"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT": "true", "ELASTIC_OTEL_GENAI_EVENTS": "log"} ): OpenAIInstrumentor().instrument() @@ -1604,7 +1604,7 @@ def test_stream_with_include_usage_option( ) ], ) -def test_stream_with_include_usage_option_and_capture_content_integration( +def test_stream_with_include_usage_option_and_capture_message_content_integration( provider_str, model, response_model, @@ -1616,7 +1616,7 @@ def test_stream_with_include_usage_option_and_capture_content_integration( # Redo the instrumentation dance to be affected by the environment variable OpenAIInstrumentor().uninstrument() - with mock.patch.dict("os.environ", {"ELASTIC_OTEL_GENAI_CAPTURE_CONTENT": "true"}): + with mock.patch.dict("os.environ", {"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT": "true"}): OpenAIInstrumentor().instrument() client = provider.get_client() @@ -1684,7 +1684,7 @@ def test_stream_with_include_usage_option_and_capture_content_integration( ) -test_stream_with_tools_and_capture_content_test_data = [ +test_stream_with_tools_and_capture_message_content_test_data = [ ( "openai_provider_chat_completions", "gpt-4o-mini", @@ -1731,9 +1731,9 @@ def test_stream_with_include_usage_option_and_capture_content_integration( @pytest.mark.vcr() @pytest.mark.parametrize( "provider_str,model,response_model,content,completion_content,response_id,finish_reason,duration", - test_stream_with_tools_and_capture_content_test_data, + test_stream_with_tools_and_capture_message_content_test_data, ) -def test_stream_with_tools_and_capture_content( +def test_stream_with_tools_and_capture_message_content( provider_str, model, response_model, @@ -1751,7 +1751,7 @@ def test_stream_with_tools_and_capture_content( # Redo the instrumentation dance to be affected by the environment variable OpenAIInstrumentor().uninstrument() - with mock.patch.dict("os.environ", {"ELASTIC_OTEL_GENAI_CAPTURE_CONTENT": "true"}): + with mock.patch.dict("os.environ", {"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT": "true"}): OpenAIInstrumentor().instrument() tools = [ @@ -1829,7 +1829,7 @@ def test_stream_with_tools_and_capture_content( ) -test_stream_with_tools_and_capture_content_log_events_test_data = [ +test_stream_with_tools_and_capture_message_content_log_events_test_data = [ ( "openai_provider_chat_completions", "gpt-4o-mini", @@ -1871,9 +1871,9 @@ def test_stream_with_tools_and_capture_content( @pytest.mark.vcr() @pytest.mark.parametrize( "provider_str,model,response_model,content,completion_content,response_id,finish_reason,function_call_id,duration", - test_stream_with_tools_and_capture_content_log_events_test_data, + test_stream_with_tools_and_capture_message_content_log_events_test_data, ) -def test_stream_with_tools_and_capture_content_log_events( +def test_stream_with_tools_and_capture_message_content_log_events( provider_str, model, response_model, @@ -1894,7 +1894,7 @@ def test_stream_with_tools_and_capture_content_log_events( # Redo the instrumentation dance to be affected by the environment variable OpenAIInstrumentor().uninstrument() with mock.patch.dict( - "os.environ", {"ELASTIC_OTEL_GENAI_CAPTURE_CONTENT": "true", "ELASTIC_OTEL_GENAI_EVENTS": "log"} + "os.environ", {"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT": "true", "ELASTIC_OTEL_GENAI_EVENTS": "log"} ): OpenAIInstrumentor().instrument() @@ -2015,7 +2015,7 @@ def test_stream_with_tools_and_capture_content_log_events( # Azure is not tested because only gpt-4o version 2024-08-06 supports structured output: # openai.BadRequestError: Error code: 400 - {'error': {'message': 'Structured output is not allowed.', 'type': 'invalid_request_error', 'param': None, 'code': None}} -test_stream_with_parallel_tools_and_capture_content_test_data = [ +test_stream_with_parallel_tools_and_capture_message_content_test_data = [ ( "openai_provider_chat_completions", "gpt-4o-mini", @@ -2046,9 +2046,9 @@ def test_stream_with_tools_and_capture_content_log_events( @pytest.mark.vcr() @pytest.mark.parametrize( "provider_str,model,response_model,content,completion_content,response_id,finish_reason,duration", - test_stream_with_parallel_tools_and_capture_content_test_data, + test_stream_with_parallel_tools_and_capture_message_content_test_data, ) -def test_stream_with_parallel_tools_and_capture_content( +def test_stream_with_parallel_tools_and_capture_message_content( provider_str, model, response_model, @@ -2066,7 +2066,7 @@ def test_stream_with_parallel_tools_and_capture_content( # Redo the instrumentation dance to be affected by the environment variable OpenAIInstrumentor().uninstrument() - with mock.patch.dict("os.environ", {"ELASTIC_OTEL_GENAI_CAPTURE_CONTENT": "true"}): + with mock.patch.dict("os.environ", {"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT": "true"}): OpenAIInstrumentor().instrument() tools = [ @@ -2138,7 +2138,7 @@ def test_stream_with_parallel_tools_and_capture_content( # Azure is not tested because only gpt-4o version 2024-08-06 supports structured output: # openai.BadRequestError: Error code: 400 - {'error': {'message': 'Structured output is not allowed.', 'type': 'invalid_request_error', 'param': None, 'code': None}} -test_stream_with_parallel_tools_and_capture_content_log_events_test_data = [ +test_stream_with_parallel_tools_and_capture_message_content_log_events_test_data = [ ( "openai_provider_chat_completions", "gpt-4o-mini", @@ -2173,9 +2173,9 @@ def test_stream_with_parallel_tools_and_capture_content( @pytest.mark.vcr() @pytest.mark.parametrize( "provider_str,model,response_model,content,completion_content,response_id,finish_reason,duration", - test_stream_with_parallel_tools_and_capture_content_log_events_test_data, + test_stream_with_parallel_tools_and_capture_message_content_log_events_test_data, ) -def test_stream_with_parallel_tools_and_capture_content_log_events( +def test_stream_with_parallel_tools_and_capture_message_content_log_events( provider_str, model, response_model, @@ -2195,7 +2195,7 @@ def test_stream_with_parallel_tools_and_capture_content_log_events( # Redo the instrumentation dance to be affected by the environment variable OpenAIInstrumentor().uninstrument() with mock.patch.dict( - "os.environ", {"ELASTIC_OTEL_GENAI_CAPTURE_CONTENT": "true", "ELASTIC_OTEL_GENAI_EVENTS": "log"} + "os.environ", {"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT": "true", "ELASTIC_OTEL_GENAI_EVENTS": "log"} ): OpenAIInstrumentor().instrument() @@ -2303,7 +2303,7 @@ def test_stream_with_parallel_tools_and_capture_content_log_events( ) -test_tools_with_followup_and_capture_content_log_events_test_data = [ +test_tools_with_followup_and_capture_message_content_log_events_test_data = [ ( "openai_provider_chat_completions", "gpt-4o-mini", @@ -2329,9 +2329,9 @@ def test_stream_with_parallel_tools_and_capture_content_log_events( @pytest.mark.vcr() @pytest.mark.parametrize( "provider_str,model,response_model,content,completion_content,finish_reason,duration", - test_tools_with_followup_and_capture_content_log_events_test_data, + test_tools_with_followup_and_capture_message_content_log_events_test_data, ) -def test_tools_with_followup_and_capture_content_log_events( +def test_tools_with_followup_and_capture_message_content_log_events( provider_str, model, response_model, @@ -2350,7 +2350,7 @@ def test_tools_with_followup_and_capture_content_log_events( # Redo the instrumentation dance to be affected by the environment variable OpenAIInstrumentor().uninstrument() with mock.patch.dict( - "os.environ", {"ELASTIC_OTEL_GENAI_CAPTURE_CONTENT": "true", "ELASTIC_OTEL_GENAI_EVENTS": "log"} + "os.environ", {"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT": "true", "ELASTIC_OTEL_GENAI_EVENTS": "log"} ): OpenAIInstrumentor().instrument() @@ -2624,7 +2624,7 @@ async def test_async_basic( ) -test_async_basic_with_capture_content_test_data = [ +test_async_basic_with_capture_message_content_test_data = [ ( "openai_provider_chat_completions", "gpt-4o-mini", @@ -2662,9 +2662,9 @@ async def test_async_basic( @pytest.mark.vcr() @pytest.mark.parametrize( "provider_str,model,response_model,content,response_id,input_tokens,output_tokens,duration", - test_async_basic_with_capture_content_test_data, + test_async_basic_with_capture_message_content_test_data, ) -async def test_async_basic_with_capture_content( +async def test_async_basic_with_capture_message_content( provider_str, model, response_model, @@ -2682,7 +2682,7 @@ async def test_async_basic_with_capture_content( # Redo the instrumentation dance to be affected by the environment variable OpenAIInstrumentor().uninstrument() - with mock.patch.dict("os.environ", {"ELASTIC_OTEL_GENAI_CAPTURE_CONTENT": "true"}): + with mock.patch.dict("os.environ", {"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT": "true"}): OpenAIInstrumentor().instrument() messages = [ @@ -2742,7 +2742,7 @@ async def test_async_basic_with_capture_content( ) -test_async_basic_with_capture_content_log_events_test_data = [ +test_async_basic_with_capture_message_content_log_events_test_data = [ ( "openai_provider_chat_completions", "gpt-4o-mini", @@ -2780,9 +2780,9 @@ async def test_async_basic_with_capture_content( @pytest.mark.vcr() @pytest.mark.parametrize( "provider_str,model,response_model,content,response_id,input_tokens,output_tokens,duration", - test_async_basic_with_capture_content_log_events_test_data, + test_async_basic_with_capture_message_content_log_events_test_data, ) -async def test_async_basic_with_capture_content_log_events( +async def test_async_basic_with_capture_message_content_log_events( provider_str, model, response_model, @@ -2802,7 +2802,7 @@ async def test_async_basic_with_capture_content_log_events( # Redo the instrumentation dance to be affected by the environment variable OpenAIInstrumentor().uninstrument() with mock.patch.dict( - "os.environ", {"ELASTIC_OTEL_GENAI_CAPTURE_CONTENT": "true", "ELASTIC_OTEL_GENAI_EVENTS": "log"} + "os.environ", {"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT": "true", "ELASTIC_OTEL_GENAI_EVENTS": "log"} ): OpenAIInstrumentor().instrument() @@ -2884,7 +2884,7 @@ async def test_async_basic_with_capture_content_log_events( ), ], ) -async def test_async_basic_with_capture_content_log_events_integration( +async def test_async_basic_with_capture_message_content_log_events_integration( provider_str, model, response_model, @@ -2899,7 +2899,7 @@ async def test_async_basic_with_capture_content_log_events_integration( # Redo the instrumentation dance to be affected by the environment variable OpenAIInstrumentor().uninstrument() with mock.patch.dict( - "os.environ", {"ELASTIC_OTEL_GENAI_CAPTURE_CONTENT": "true", "ELASTIC_OTEL_GENAI_EVENTS": "log"} + "os.environ", {"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT": "true", "ELASTIC_OTEL_GENAI_EVENTS": "log"} ): OpenAIInstrumentor().instrument() @@ -3048,7 +3048,7 @@ async def test_async_stream( ) -test_async_stream_with_capture_content_test_data = [ +test_async_stream_with_capture_message_content_test_data = [ ( "openai_provider_chat_completions", "gpt-4o-mini", @@ -3080,9 +3080,9 @@ async def test_async_stream( @pytest.mark.asyncio @pytest.mark.parametrize( "provider_str,model,response_model,content,response_id,duration", - test_async_stream_with_capture_content_test_data, + test_async_stream_with_capture_message_content_test_data, ) -async def test_async_stream_with_capture_content( +async def test_async_stream_with_capture_message_content( provider_str, model, response_model, @@ -3098,7 +3098,7 @@ async def test_async_stream_with_capture_content( # Redo the instrumentation dance to be affected by the environment variable OpenAIInstrumentor().uninstrument() - with mock.patch.dict("os.environ", {"ELASTIC_OTEL_GENAI_CAPTURE_CONTENT": "true"}): + with mock.patch.dict("os.environ", {"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT": "true"}): OpenAIInstrumentor().instrument() messages = [ { @@ -3149,7 +3149,7 @@ async def test_async_stream_with_capture_content( ) -test_async_stream_with_capture_content_log_events_test_data = [ +test_async_stream_with_capture_message_content_log_events_test_data = [ ( "openai_provider_chat_completions", "gpt-4o-mini", @@ -3181,9 +3181,9 @@ async def test_async_stream_with_capture_content( @pytest.mark.asyncio @pytest.mark.parametrize( "provider_str,model,response_model,content,response_id,duration", - test_async_stream_with_capture_content_log_events_test_data, + test_async_stream_with_capture_message_content_log_events_test_data, ) -async def test_async_stream_with_capture_content_log_events( +async def test_async_stream_with_capture_message_content_log_events( provider_str, model, response_model, @@ -3201,7 +3201,7 @@ async def test_async_stream_with_capture_content_log_events( # Redo the instrumentation dance to be affected by the environment variable OpenAIInstrumentor().uninstrument() with mock.patch.dict( - "os.environ", {"ELASTIC_OTEL_GENAI_CAPTURE_CONTENT": "true", "ELASTIC_OTEL_GENAI_EVENTS": "log"} + "os.environ", {"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT": "true", "ELASTIC_OTEL_GENAI_EVENTS": "log"} ): OpenAIInstrumentor().instrument() messages = [ @@ -3268,7 +3268,7 @@ async def test_async_stream_with_capture_content_log_events( # FIXME: ollama has empty tool_calls -test_async_tools_with_capture_content_test_data = [ +test_async_tools_with_capture_message_content_test_data = [ ( "openai_provider_chat_completions", "gpt-4o-mini", @@ -3296,9 +3296,9 @@ async def test_async_stream_with_capture_content_log_events( @pytest.mark.asyncio @pytest.mark.parametrize( "provider_str,model,response_model,response_id,function_call_id,input_tokens,output_tokens,duration", - test_async_tools_with_capture_content_test_data, + test_async_tools_with_capture_message_content_test_data, ) -async def test_async_tools_with_capture_content( +async def test_async_tools_with_capture_message_content( provider_str, model, response_model, @@ -3316,7 +3316,7 @@ async def test_async_tools_with_capture_content( # Redo the instrumentation dance to be affected by the environment variable OpenAIInstrumentor().uninstrument() - with mock.patch.dict("os.environ", {"ELASTIC_OTEL_GENAI_CAPTURE_CONTENT": "true"}): + with mock.patch.dict("os.environ", {"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT": "true"}): OpenAIInstrumentor().instrument() tools = [ @@ -3408,7 +3408,7 @@ async def test_async_tools_with_capture_content( # FIXME: ollama has empty tool_calls -test_async_tools_with_capture_content_log_events_test_data = [ +test_async_tools_with_capture_message_content_log_events_test_data = [ ( "openai_provider_chat_completions", "gpt-4o-mini", @@ -3438,9 +3438,9 @@ async def test_async_tools_with_capture_content( @pytest.mark.asyncio @pytest.mark.parametrize( "provider_str,model,response_model,response_id,function_call_id,choice_content,input_tokens,output_tokens,duration", - test_async_tools_with_capture_content_log_events_test_data, + test_async_tools_with_capture_message_content_log_events_test_data, ) -async def test_async_tools_with_capture_content_log_events( +async def test_async_tools_with_capture_message_content_log_events( provider_str, model, response_model, @@ -3461,7 +3461,7 @@ async def test_async_tools_with_capture_content_log_events( # Redo the instrumentation dance to be affected by the environment variable OpenAIInstrumentor().uninstrument() with mock.patch.dict( - "os.environ", {"ELASTIC_OTEL_GENAI_CAPTURE_CONTENT": "true", "ELASTIC_OTEL_GENAI_EVENTS": "log"} + "os.environ", {"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT": "true", "ELASTIC_OTEL_GENAI_EVENTS": "log"} ): OpenAIInstrumentor().instrument() diff --git a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/test_instrumentor.py b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/test_instrumentor.py index 54fa4c2..72d7064 100644 --- a/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/test_instrumentor.py +++ b/instrumentation/elastic-opentelemetry-instrumentation-openai/tests/test_instrumentor.py @@ -17,14 +17,14 @@ from opentelemetry.instrumentation.openai import OpenAIInstrumentor -def test_capture_content_false_by_default(instrument): +def test_capture_message_content_false_by_default(instrument): instrument.uninstrument() - assert not instrument.capture_content + assert not instrument.capture_message_content -def test_can_override_capture_content_programmatically(instrument): +def test_can_override_capture_message_content_programmatically(instrument): instrument.uninstrument() instrumentor = OpenAIInstrumentor() - instrumentor.instrument(capture_content=True) - assert instrumentor.capture_content + instrumentor.instrument(capture_message_content=True) + assert instrumentor.capture_message_content instrumentor.uninstrument()