Skip to content

Commit a761858

Browse files
committed
Add more TODOs and documentation to clarify the intended work scope.
1 parent 117c811 commit a761858

File tree

4 files changed

+81
-0
lines changed

4 files changed

+81
-0
lines changed

instrumentation-genai/opentelemetry-instrumentation-google-genai/README.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ It adds trace spans for GenAI operations, events/logs for recording prompts/resp
1212
GenAI operations in aggregate.
1313

1414

15+
Experimental
16+
------------
17+
18+
This package is still experimental. The instrumentation may not be complete or correct just yet.
19+
20+
Please see "TODOS.md" for a list of known defects/TODOs that are blockers to package stability.
21+
22+
1523
Installation
1624
------------
1725

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# TODOs
2+
3+
## Fundamentals
4+
5+
Here are some TODO items required to achieve stability for this package:
6+
7+
1. Add support for streaming interfaces
8+
2. Add support for async interfaces
9+
3. Add more span-level attributes for request configuration
10+
4. Add more span-level attributes for response information
11+
5. Verify and correct formatting of events:
12+
- Including the 'role' field for message events
13+
- Including tool invocation information
14+
6. Emit events for safety ratings when they block responses
15+
7. Additional cleanup/improvement tasks such as:
16+
- Adoption of 'wrapt' instead of 'functools.wraps'
17+
- Bolstering test coverage
18+
19+
## Future
20+
21+
Beyond the above TODOs, it would also be desireable to extend the
22+
instrumentation beyond `generate_content` to other API surfaces.

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

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,17 @@ def _get_top_p(config: Optional[GenerateContentConfigOrDict]):
164164
return _get_config_property(config, "top_p")
165165

166166

167+
# A map from define attributes to the function that can obtain
168+
# the relevant information from the request object.
169+
#
170+
# TODO: expand this to cover a larger set of the available
171+
# span attributes from GenAI semantic conventions.
172+
#
173+
# TODO: define semantic conventions for attributes that
174+
# are relevant for the Google GenAI SDK which are not
175+
# currently covered by the existing semantic conventions.
176+
#
177+
# See also: TODOS.md
167178
_SPAN_ATTRIBUTE_TO_CONFIG_EXTRACTOR = {
168179
gen_ai_attributes.GEN_AI_REQUEST_TEMPERATURE: _get_temperature,
169180
gen_ai_attributes.GEN_AI_REQUEST_TOP_K: _get_top_k,
@@ -217,6 +228,10 @@ def process_request(
217228
self._maybe_log_user_prompt(contents)
218229

219230
def process_response(self, response: GenerateContentResponse):
231+
# TODO: Determine if there are other response properties that
232+
# need to be reflected back into the span attributes.
233+
#
234+
# See also: TODOS.md.
220235
self._maybe_update_token_counts(response)
221236
self._maybe_update_error_type(response)
222237
self._maybe_log_response(response)
@@ -265,6 +280,17 @@ def _maybe_update_error_type(self, response: GenerateContentResponse):
265280
):
266281
self._error_type = "NO_CANDIDATES"
267282
return
283+
# TODO: in the case where there are no candidate responses due to
284+
# safety settings like this, it might make sense to emit an event
285+
# that contains more details regarding the safety settings, their
286+
# thresholds, etc. However, this requires defining an associated
287+
# semantic convention to capture this. Follow up with SemConv to
288+
# establish appropriate data modelling to capture these details,
289+
# and then emit those details accordingly. (For the time being,
290+
# we use the defined 'error.type' semantic convention to relay
291+
# just the minimum amount of error information here).
292+
#
293+
# See also: "TODOS.md"
268294
block_reason = response.prompt_feedback.block_reason.name.upper()
269295
self._error_type = f"BLOCKED_{block_reason}"
270296

@@ -276,6 +302,12 @@ def _maybe_log_system_instruction(
276302
system_instruction = _get_config_property(config, "system_instruction")
277303
if not system_instruction:
278304
return
305+
# TODO: determine if "role" should be reported here or not. It is unclear
306+
# since the caller does not supply a "role" and since this comes through
307+
# a property named "system_instruction" which would seem to align with
308+
# the default "role" that is allowed to be omitted by default.
309+
#
310+
# See also: "TODOS.md"
279311
self._otel_wrapper.log_system_prompt(
280312
attributes={
281313
gen_ai_attributes.GEN_AI_SYSTEM: self._genai_system,
@@ -290,6 +322,12 @@ def _maybe_log_user_prompt(
290322
):
291323
if not self._content_recording_enabled:
292324
return
325+
# TODO: determine if "role" should be reported here or not and, if so,
326+
# what the value ought to be. It is not clear whether there is always
327+
# a role supplied (and it looks like there could be cases where there
328+
# is more than one role present in the supplied contents)?
329+
#
330+
# See also: "TODOS.md"
293331
self._otel_wrapper.log_user_prompt(
294332
attributes={
295333
gen_ai_attributes.GEN_AI_SYSTEM: self._genai_system,
@@ -302,6 +340,14 @@ def _maybe_log_user_prompt(
302340
def _maybe_log_response(self, response: GenerateContentResponse):
303341
if not self._content_recording_enabled:
304342
return
343+
# TODO: determine if "role" should be reported here or not and, if so,
344+
# what the value ought to be.
345+
#
346+
# TODO: extract tool information into a separate tool message.
347+
#
348+
# TODO: determine if/when we need to emit a 'gen_ai.choice' event.
349+
#
350+
# See also: "TODOS.md"
305351
self._otel_wrapper.log_response_content(
306352
attributes={
307353
gen_ai_attributes.GEN_AI_SYSTEM: self._genai_system,

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

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

15+
# **IMPORTANT**:
16+
#
17+
# This version should stay below "1.0" until the fundamentals
18+
# in "TODOS.md" have been addressed. Please revisit the TODOs
19+
# listed there before bumping to a stable version.
1520
__version__ = "0.0.1.dev"

0 commit comments

Comments
 (0)