WIP RFC: Open Telemetry Standardization#5384
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds comprehensive documentation for Genkit's OpenTelemetry specification and provides an overview of existing instrumentation strategies. The documentation defines naming conventions, instrumentation scope, and specific span attributes for flows, agents, models, and tools to ensure cross-language consistency. Review feedback correctly identified that attribute types in the specification must align with OpenTelemetry standards, specifically recommending the use of JSON-stringified strings instead of 'any' types for complex data structures.
| | Gen AI | `gen_ai.input.messages` | Opt-In | any[] | Structured conversation history. | `[...]` | | ||
| | Gen AI | `gen_ai.output.messages` | Opt-In | any[] | Structured completion messages. | `[...]` | | ||
| | Gen AI | `gen_ai.system_instructions` | Opt-In | any[] | System-level instructions. | `[...]` | | ||
| | Gen AI | `gen_ai.tool.definitions` | Opt-In | any[] | List of tool definitions available to the model. | `[...]` | |
There was a problem hiding this comment.
The types any[] and any are not valid OpenTelemetry attribute types. According to the OpenTelemetry specification, attribute values must be a primitive type (string, boolean, double, or int64) or an array of primitive types. For complex structures like messages or tool definitions, these should be defined as string (JSON-stringified) to be compliant with OTel standards.
| | Gen AI | `gen_ai.input.messages` | Opt-In | any[] | Structured conversation history. | `[...]` | | |
| | Gen AI | `gen_ai.output.messages` | Opt-In | any[] | Structured completion messages. | `[...]` | | |
| | Gen AI | `gen_ai.system_instructions` | Opt-In | any[] | System-level instructions. | `[...]` | | |
| | Gen AI | `gen_ai.tool.definitions` | Opt-In | any[] | List of tool definitions available to the model. | `[...]` | | |
| | Gen AI | `gen_ai.input.messages` | Opt-In | string | Structured conversation history (JSON). | `[...]` | | |
| | Gen AI | `gen_ai.output.messages` | Opt-In | string | Structured completion messages (JSON). | `[...]` | | |
| | Gen AI | `gen_ai.system_instructions` | Opt-In | string | System-level instructions (JSON). | `[...]` | | |
| | Gen AI | `gen_ai.tool.definitions` | Opt-In | string | List of tool definitions available to the model (JSON). | `[...]` | |
| | Gen AI | `gen_ai.tool.call.arguments` | Opt-In | any | Parameters passed to the tool. | `{"city": "Paris"}` | | ||
| | Gen AI | `gen_ai.tool.call.result` | Opt-In | any | Result returned by the tool. | `{"temp": 72}` | |
There was a problem hiding this comment.
As noted previously, any is not a valid type for OpenTelemetry attributes. These should be specified as string (JSON-stringified) to ensure compatibility with OTel collectors and backends.
| | Gen AI | `gen_ai.tool.call.arguments` | Opt-In | any | Parameters passed to the tool. | `{"city": "Paris"}` | | |
| | Gen AI | `gen_ai.tool.call.result` | Opt-In | any | Result returned by the tool. | `{"temp": 72}` | | |
| | Gen AI | `gen_ai.tool.call.arguments` | Opt-In | string | Parameters passed to the tool (JSON). | `{"city": "Paris"}` | | |
| | Gen AI | `gen_ai.tool.call.result` | Opt-In | string | Result returned by the tool (JSON). | `{"temp": 72}` | |
WIP