Skip to content

Commit aaaa017

Browse files
committed
Add more documentation comments requested in the pull request.
1 parent 6b8c599 commit aaaa017

File tree

1 file changed

+12
-0
lines changed
  • instrumentation-genai/opentelemetry-instrumentation-google-genai/src/opentelemetry/instrumentation/google_genai

1 file changed

+12
-0
lines changed

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

+12
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,17 @@ def _add_request_options_to_span(
146146
return
147147
span_context = span.get_span_context()
148148
if not span_context.trace_flags.sampled:
149+
# Avoid potentially costly traversal of config
150+
# options if the span will be dropped, anyway.
149151
return
152+
# Automatically derive attributes from the contents of the
153+
# config object. This ensures that all relevant parameters
154+
# are captured in the telemetry data (except for those
155+
# that are excluded via "exclude_keys").
150156
attributes = flatten_dict(
151157
_to_dict(config),
158+
# A custom prefix is used, because the names/structure of the
159+
# configuration is likely to be specific to Google Gen AI SDK.
152160
key_prefix=CUSTOM_LLM_REQUEST_PREFIX,
153161
exclude_keys=[
154162
# System instruction can be overly long for a span attribute.
@@ -158,6 +166,10 @@ def _add_request_options_to_span(
158166
# best that we not record these options.
159167
"gen_ai.gcp.request.http_options.headers",
160168
],
169+
# Although a custom prefix is used by default, some of the attributes
170+
# are captured in common, standard, Semantic Conventions. For the
171+
# well-known properties whose values align with Semantic Conventions,
172+
# we ensure that the key name matches the standard SemConv name.
161173
rename_keys={
162174
# TODO: add more entries here as more semantic conventions are
163175
# generalized to cover more of the available config options.

0 commit comments

Comments
 (0)