Skip to content

Commit 49f7bd2

Browse files
committed
Update name to reflect requested changes in Semantic Conventions pull request #2125.
1 parent 3458eab commit 49f7bd2

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

instrumentation-genai/opentelemetry-instrumentation-google-genai/src/opentelemetry/instrumentation/google_genai/custom_semconv.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
# limitations under the License.
1414

1515

16-
# Prefix to use for LLM model request attributes that are unique GCP
17-
# (or that have not yet been formally defined in the GenAI/LLM SIG).
18-
CUSTOM_LLM_REQUEST_PREFIX = "gcp.gen_ai.request"
16+
# Semantic Convention still being defined in:
17+
# https://github.com/open-telemetry/semantic-conventions/pull/2125
18+
GCP_GENAI_OPERATION_CONFIG = "gcp.gen_ai.operation.config"

instrumentation-genai/opentelemetry-instrumentation-google-genai/src/opentelemetry/instrumentation/google_genai/generate_content.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
from opentelemetry.semconv.attributes import error_attributes
4141

4242
from .allowlist_util import AllowList
43-
from .custom_semconv import CUSTOM_LLM_REQUEST_PREFIX
43+
from .custom_semconv import GCP_GENAI_OPERATION_CONFIG
4444
from .dict_util import flatten_dict
4545
from .flags import is_content_recording_enabled
4646
from .otel_wrapper import OTelWrapper
@@ -160,11 +160,11 @@ def _add_request_options_to_span(
160160
_to_dict(config),
161161
# A custom prefix is used, because the names/structure of the
162162
# configuration is likely to be specific to Google Gen AI SDK.
163-
key_prefix=CUSTOM_LLM_REQUEST_PREFIX,
163+
key_prefix=GCP_GENAI_OPERATION_CONFIG,
164164
exclude_keys=[
165165
# System instruction can be overly long for a span attribute.
166166
# Additionally, it is recorded as an event (log), instead.
167-
"gcp.gen_ai.request.system_instruction",
167+
"gcp.gen_ai.operation.config.system_instruction",
168168
],
169169
# Although a custom prefix is used by default, some of the attributes
170170
# are captured in common, standard, Semantic Conventions. For the
@@ -173,20 +173,20 @@ def _add_request_options_to_span(
173173
rename_keys={
174174
# TODO: add more entries here as more semantic conventions are
175175
# generalized to cover more of the available config options.
176-
"gcp.gen_ai.request.temperature": gen_ai_attributes.GEN_AI_REQUEST_TEMPERATURE,
177-
"gcp.gen_ai.request.top_k": gen_ai_attributes.GEN_AI_REQUEST_TOP_K,
178-
"gcp.gen_ai.request.top_p": gen_ai_attributes.GEN_AI_REQUEST_TOP_P,
179-
"gcp.gen_ai.request.candidate_count": gen_ai_attributes.GEN_AI_REQUEST_CHOICE_COUNT,
180-
"gcp.gen_ai.request.max_output_tokens": gen_ai_attributes.GEN_AI_REQUEST_MAX_TOKENS,
181-
"gcp.gen_ai.request.stop_sequences": gen_ai_attributes.GEN_AI_REQUEST_STOP_SEQUENCES,
182-
"gcp.gen_ai.request.frequency_penalty": gen_ai_attributes.GEN_AI_REQUEST_FREQUENCY_PENALTY,
183-
"gcp.gen_ai.request.presence_penalty": gen_ai_attributes.GEN_AI_REQUEST_PRESENCE_PENALTY,
184-
"gcp.gen_ai.request.seed": gen_ai_attributes.GEN_AI_REQUEST_SEED,
176+
"gcp.gen_ai.operation.config.temperature": gen_ai_attributes.GEN_AI_REQUEST_TEMPERATURE,
177+
"gcp.gen_ai.operation.config.top_k": gen_ai_attributes.GEN_AI_REQUEST_TOP_K,
178+
"gcp.gen_ai.operation.config.top_p": gen_ai_attributes.GEN_AI_REQUEST_TOP_P,
179+
"gcp.gen_ai.operation.config.candidate_count": gen_ai_attributes.GEN_AI_REQUEST_CHOICE_COUNT,
180+
"gcp.gen_ai.operation.config.max_output_tokens": gen_ai_attributes.GEN_AI_REQUEST_MAX_TOKENS,
181+
"gcp.gen_ai.operation.config.stop_sequences": gen_ai_attributes.GEN_AI_REQUEST_STOP_SEQUENCES,
182+
"gcp.gen_ai.operation.config.frequency_penalty": gen_ai_attributes.GEN_AI_REQUEST_FREQUENCY_PENALTY,
183+
"gcp.gen_ai.operation.config.presence_penalty": gen_ai_attributes.GEN_AI_REQUEST_PRESENCE_PENALTY,
184+
"gcp.gen_ai.operation.config.seed": gen_ai_attributes.GEN_AI_REQUEST_SEED,
185185
},
186186
)
187187
for key, value in attributes.items():
188188
if key.startswith(
189-
CUSTOM_LLM_REQUEST_PREFIX
189+
GCP_GENAI_OPERATION_CONFIG
190190
) and not allow_list.allowed(key):
191191
# The allowlist is used to control inclusion of the dynamic keys.
192192
continue

instrumentation-genai/opentelemetry-instrumentation-google-genai/tests/generate_content/test_config_span_attributes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def test_option_not_reflected_to_span_attribute_system_instruction(self):
106106
config={"system_instruction": "Yadda yadda yadda"}
107107
)
108108
self.assertNotIn(
109-
"gcp.gen_ai.request.system_instruction", span.attributes
109+
"gcp.gen_ai.operation.config.system_instruction", span.attributes
110110
)
111111
self.assertNotIn("gen_ai.request.system_instruction", span.attributes)
112112
for key in span.attributes:
@@ -127,7 +127,7 @@ def test_option_reflected_to_span_attribute_automatic_func_calling(self):
127127
)
128128
self.assertTrue(
129129
span.attributes[
130-
"gcp.gen_ai.request.automatic_function_calling.ignore_call_history"
130+
"gcp.gen_ai.operation.config.automatic_function_calling.ignore_call_history"
131131
]
132132
)
133133

@@ -140,7 +140,7 @@ def test_dynamic_config_options_not_included_without_allow_list(self):
140140
}
141141
)
142142
self.assertNotIn(
143-
"gcp.gen_ai.request.automatic_function_calling.ignore_call_history",
143+
"gcp.gen_ai.operation.config.automatic_function_calling.ignore_call_history",
144144
span.attributes,
145145
)
146146

@@ -157,6 +157,6 @@ def test_can_supply_allow_list_via_instrumentor_constructor(self):
157157
)
158158
self.assertTrue(
159159
span.attributes[
160-
"gcp.gen_ai.request.automatic_function_calling.ignore_call_history"
160+
"gcp.gen_ai.operation.config.automatic_function_calling.ignore_call_history"
161161
]
162162
)

0 commit comments

Comments
 (0)