Skip to content

Commit 2f62564

Browse files
committed
Remove env vars that are not a part of semantic convention
1 parent a14881a commit 2f62564

File tree

5 files changed

+32
-99
lines changed

5 files changed

+32
-99
lines changed

instrumentation-genai/opentelemetry-instrumentation-openai-agents/README.rst

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
OpenTelemetry OpenAI Agents Instrumentation
2-
==========================================
2+
===========================================
33

44
|pypi|
55

@@ -44,12 +44,10 @@ API
4444
The `opentelemetry-instrumentation-openai-agents` package provides automatic instrumentation for the OpenAI Agents framework.
4545

4646
Configuration
47-
-------------
47+
--------------
4848

49-
The following environment variables can be used to configure the instrumentation:
50-
51-
- ``OTEL_INSTRUMENTATION_OPENAI_AGENTS_CAPTURE_CONTENT``: Set to ``true`` to capture the content of the requests and responses. Default is ``false``.
52-
- ``OTEL_INSTRUMENTATION_OPENAI_AGENTS_CAPTURE_METRICS``: Set to ``true`` to capture metrics. Default is ``true``.
49+
This instrumentation captures content, metrics, and events by default with no additional configuration required.
50+
If you are installing and setting up this tracing library, the assumption is you want full capture.
5351

5452
References
5553
----------

instrumentation-genai/opentelemetry-instrumentation-openai-agents/src/opentelemetry/instrumentation/openai_agents/__init__.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,8 @@
4848
Configuration
4949
-------------
5050
51-
Environment variables:
52-
53-
- ``OTEL_INSTRUMENTATION_OPENAI_AGENTS_CAPTURE_CONTENT``: ``true`` to
54-
capture request/response content (default ``false``).
55-
- ``OTEL_INSTRUMENTATION_OPENAI_AGENTS_CAPTURE_METRICS``: ``true`` to
56-
capture metrics (default ``true``).
51+
Content, metrics, and events are captured by default with no environment configuration.
52+
This library assumes full capture is desired when installed.
5753
"""
5854

5955
import logging

instrumentation-genai/opentelemetry-instrumentation-openai-agents/src/opentelemetry/instrumentation/openai_agents/events.py

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,18 @@
77
- gen_ai.evaluation.result (helper only; actual evaluation may happen
88
externally – e.g. offline evaluator script)
99
10-
Environment toggles:
11-
- OTEL_GENAI_EMIT_OPERATION_DETAILS (default: true)
12-
- OTEL_GENAI_EMIT_EVALUATION_RESULTS (default: true)
10+
All GenAI events are emitted by default.
1311
"""
1412

1513
from __future__ import annotations
1614

17-
import os
1815
from typing import Any, Dict, Optional
1916

2017
from opentelemetry._events import Event
2118

2219
OP_DETAILS_EVENT = "gen_ai.client.inference.operation.details"
2320
EVAL_RESULT_EVENT = "gen_ai.evaluation.result"
2421

25-
_OP_DETAILS_ENABLED_ENV = "OTEL_GENAI_EMIT_OPERATION_DETAILS"
26-
_EVAL_RESULTS_ENABLED_ENV = "OTEL_GENAI_EMIT_EVALUATION_RESULTS"
27-
2822
# Attribute allowlist subset to avoid dumping huge blobs blindly.
2923
# (Large content already controlled by capture-content env var.)
3024
_OPERATION_DETAILS_CORE_KEYS = {
@@ -45,13 +39,6 @@
4539
_MAX_VALUE_LEN = 4000 # defensive truncation
4640

4741

48-
def _enabled(env_name: str, default_true: bool = True) -> bool:
49-
raw = os.getenv(env_name)
50-
if raw is None:
51-
return default_true
52-
return raw.lower() not in {"0", "false", "no"}
53-
54-
5542
def emit_operation_details_event(
5643
event_logger,
5744
span_attributes: Dict[str, Any],
@@ -66,8 +53,7 @@ def emit_operation_details_event(
6653
"""
6754
if not event_logger:
6855
return
69-
if not _enabled(_OP_DETAILS_ENABLED_ENV, True):
70-
return
56+
# Always enabled
7157

7258
attrs: Dict[str, Any] = {}
7359
for k in _OPERATION_DETAILS_CORE_KEYS:
@@ -114,8 +100,7 @@ def emit_evaluation_result_event(
114100
"""
115101
if not event_logger:
116102
return
117-
if not _enabled(_EVAL_RESULTS_ENABLED_ENV, True):
118-
return
103+
# Always enabled
119104

120105
attrs: Dict[str, Any] = {"gen_ai.evaluation.name": name}
121106
if score_value is not None:

instrumentation-genai/opentelemetry-instrumentation-openai-agents/src/opentelemetry/instrumentation/openai_agents/genai_semantic_processor.py

Lines changed: 23 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,8 @@
9898

9999
# Import utilities and event helpers
100100
from .utils import (
101-
is_content_enabled,
102-
is_metrics_enabled,
103101
normalize_output_type,
104102
normalize_provider,
105-
should_emit_operation_details,
106103
validate_tool_type,
107104
)
108105

@@ -260,26 +257,16 @@ def __init__(
260257
self._otel_spans: dict[str, OtelSpan] = {}
261258
self._tokens: dict[str, object] = {}
262259

263-
# Metrics configuration
264-
self._metrics_enabled = is_metrics_enabled()
260+
# Metrics configuration (always enabled)
261+
self._metrics_enabled = True
265262
self._meter = None
266263
self._duration_histogram: Optional[Histogram] = None
267264
self._token_usage_histogram: Optional[Histogram] = None
268265

269-
# Configuration for opt-in attributes
270-
self._capture_system_instructions = (
271-
os.getenv(
272-
"OTEL_GENAI_CAPTURE_SYSTEM_INSTRUCTIONS", "false"
273-
).lower()
274-
== "true"
275-
)
276-
self._capture_messages = (
277-
os.getenv("OTEL_GENAI_CAPTURE_MESSAGES", "false").lower() == "true"
278-
)
279-
self._capture_tool_definitions = (
280-
os.getenv("OTEL_GENAI_CAPTURE_TOOL_DEFINITIONS", "false").lower()
281-
== "true"
282-
)
266+
# Configuration for attribute capture (always enabled)
267+
self._capture_system_instructions = True
268+
self._capture_messages = True
269+
self._capture_tool_definitions = True
283270

284271
# Initialize metrics if enabled
285272
if self._metrics_enabled:
@@ -577,7 +564,7 @@ def on_span_end(self, span: Span[Any]) -> None:
577564
attributes[key] = value
578565

579566
# Emit operation details event if configured
580-
if should_emit_operation_details() and self._event_logger:
567+
if self._event_logger:
581568
emit_operation_details_event(
582569
self._event_logger, attributes, otel_span
583570
)
@@ -758,9 +745,9 @@ def _get_attributes_from_generation_span_data(
758745
if k in mc and mc[k] is not None:
759746
yield attr, mc[k]
760747

761-
# Sensitive data (opt-in)
762-
if self.include_sensitive_data and is_content_enabled():
763-
# Input messages (opt-in)
748+
# Sensitive data capture
749+
if self.include_sensitive_data:
750+
# Input messages
764751
if self._capture_messages and span_data.input:
765752
yield GEN_AI_INPUT_MESSAGES, safe_json_dumps(span_data.input)
766753
if self.emit_legacy:
@@ -769,7 +756,7 @@ def _get_attributes_from_generation_span_data(
769756
safe_json_dumps(span_data.input),
770757
)
771758

772-
# System instructions (opt-in)
759+
# System instructions
773760
if self._capture_system_instructions and span_data.input:
774761
sys_instr = self._collect_system_instructions(span_data.input)
775762
if sys_instr:
@@ -778,7 +765,7 @@ def _get_attributes_from_generation_span_data(
778765
safe_json_dumps(sys_instr),
779766
)
780767

781-
# Output messages (opt-in)
768+
# Output messages
782769
if self._capture_messages and span_data.output:
783770
yield GEN_AI_OUTPUT_MESSAGES, safe_json_dumps(span_data.output)
784771
if self.emit_legacy:
@@ -817,7 +804,7 @@ def _get_attributes_from_agent_span_data(
817804
if hasattr(span_data, "conversation_id") and span_data.conversation_id:
818805
yield GEN_AI_CONVERSATION_ID, span_data.conversation_id
819806

820-
# Agent definitions (opt-in)
807+
# Agent definitions
821808
if self._capture_tool_definitions and hasattr(
822809
span_data, "agent_definitions"
823810
):
@@ -826,7 +813,7 @@ def _get_attributes_from_agent_span_data(
826813
safe_json_dumps(span_data.agent_definitions),
827814
)
828815

829-
# System instructions from agent definitions (opt-in)
816+
# System instructions from agent definitions
830817
if self._capture_system_instructions and hasattr(
831818
span_data, "agent_definitions"
832819
):
@@ -876,7 +863,7 @@ def _get_attributes_from_function_span_data(
876863
if hasattr(span_data, "description") and span_data.description:
877864
yield GEN_AI_TOOL_DESCRIPTION, span_data.description
878865

879-
# Tool definitions (opt-in)
866+
# Tool definitions
880867
if self._capture_tool_definitions and hasattr(
881868
span_data, "tool_definitions"
882869
):
@@ -885,8 +872,8 @@ def _get_attributes_from_function_span_data(
885872
safe_json_dumps(span_data.tool_definitions),
886873
)
887874

888-
# Tool input/output (sensitive, opt-in via include_sensitive_data)
889-
if self.include_sensitive_data and is_content_enabled():
875+
# Tool input/output (sensitive)
876+
if self.include_sensitive_data:
890877
if span_data.input is not None:
891878
arg_val = (
892879
safe_json_dumps(span_data.input)
@@ -967,8 +954,8 @@ def _get_attributes_from_response_span_data(
967954
):
968955
yield GEN_AI_USAGE_TOTAL_TOKENS, usage.total_tokens
969956

970-
# Input/output messages (opt-in)
971-
if self.include_sensitive_data and is_content_enabled():
957+
# Input/output messages
958+
if self.include_sensitive_data:
972959
# Input messages
973960
if self._capture_messages and span_data.input:
974961
yield GEN_AI_INPUT_MESSAGES, safe_json_dumps(span_data.input)
@@ -1032,8 +1019,8 @@ def _get_attributes_from_transcription_span_data(
10321019
if hasattr(span_data, "format") and span_data.format:
10331020
yield "gen_ai.audio.input.format", span_data.format
10341021

1035-
# Transcript (sensitive, opt-in)
1036-
if self.include_sensitive_data and is_content_enabled():
1022+
# Transcript (sensitive)
1023+
if self.include_sensitive_data:
10371024
if self._capture_messages and hasattr(span_data, "transcript"):
10381025
yield "gen_ai.transcription.text", span_data.transcript
10391026

@@ -1057,8 +1044,8 @@ def _get_attributes_from_speech_span_data(
10571044
if hasattr(span_data, "format") and span_data.format:
10581045
yield "gen_ai.audio.output.format", span_data.format
10591046

1060-
# Input text (sensitive, opt-in)
1061-
if self.include_sensitive_data and is_content_enabled():
1047+
# Input text (sensitive)
1048+
if self.include_sensitive_data:
10621049
if self._capture_messages and hasattr(span_data, "input_text"):
10631050
yield "gen_ai.speech.input_text", span_data.input_text
10641051

instrumentation-genai/opentelemetry-instrumentation-openai-agents/src/opentelemetry/instrumentation/openai_agents/utils.py

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,10 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from os import environ
1615
from typing import Optional
1716

1817
from .constants import GenAIOutputType, GenAIProvider, GenAIToolType
1918

20-
_EMIT_OP_DETAILS_ENV = "OTEL_GENAI_EMIT_OPERATION_DETAILS"
21-
22-
23-
OTEL_INSTRUMENTATION_OPENAI_AGENTS_CAPTURE_CONTENT = (
24-
"OTEL_INSTRUMENTATION_OPENAI_AGENTS_CAPTURE_CONTENT"
25-
)
26-
OTEL_INSTRUMENTATION_OPENAI_AGENTS_CAPTURE_METRICS = (
27-
"OTEL_INSTRUMENTATION_OPENAI_AGENTS_CAPTURE_METRICS"
28-
)
29-
30-
31-
def is_content_enabled() -> bool:
32-
"""Check if content capture is enabled."""
33-
capture_content = environ.get(
34-
OTEL_INSTRUMENTATION_OPENAI_AGENTS_CAPTURE_CONTENT, "false"
35-
)
36-
return capture_content.lower() == "true"
37-
38-
39-
def is_metrics_enabled() -> bool:
40-
"""Check if metrics capture is enabled."""
41-
capture_metrics = environ.get(
42-
OTEL_INSTRUMENTATION_OPENAI_AGENTS_CAPTURE_METRICS, "true"
43-
)
44-
return capture_metrics.lower() == "true"
45-
4619

4720
def get_agent_operation_name(operation: str) -> str:
4821
"""Get the operation name for agent operations."""
@@ -102,9 +75,3 @@ def normalize_output_type(output_type: Optional[str]) -> str:
10275
}:
10376
return o
10477
return GenAIOutputType.TEXT # default for unknown
105-
106-
107-
def should_emit_operation_details() -> bool:
108-
"""Check if operation details event should be emitted."""
109-
raw = environ.get(_EMIT_OP_DETAILS_ENV, "true")
110-
return raw.lower() not in {"0", "false", "no"}

0 commit comments

Comments
 (0)