Skip to content

Commit c4086d6

Browse files
authored
feat(ai): Add gen_ai.response.tokens_per_second attribute (#66)
1 parent fbb4397 commit c4086d6

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

generated/attributes/gen_ai.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- [gen_ai.response.id](#gen_airesponseid)
2323
- [gen_ai.response.model](#gen_airesponsemodel)
2424
- [gen_ai.response.text](#gen_airesponsetext)
25+
- [gen_ai.response.tokens_per_second](#gen_airesponsetokens_per_second)
2526
- [gen_ai.response.tool_calls](#gen_airesponsetool_calls)
2627
- [gen_ai.system](#gen_aisystem)
2728
- [gen_ai.system.message](#gen_aisystemmessage)
@@ -262,6 +263,17 @@ The model's response text messages. It has to be a stringified version of an arr
262263
| Exists in OpenTelemetry | No |
263264
| Example | `["The weather in Paris is rainy and overcast, with temperatures around 57°F", "The weather in London is sunny and warm, with temperatures around 65°F"]` |
264265

266+
### gen_ai.response.tokens_per_second
267+
268+
The total output tokens per seconds throughput
269+
270+
| Property | Value |
271+
| --- | --- |
272+
| Type | `double` |
273+
| Has PII | false |
274+
| Exists in OpenTelemetry | No |
275+
| Example | `12345.67` |
276+
265277
### gen_ai.response.tool_calls
266278

267279
The tool calls in the model's response. It has to be a stringified version of an array of objects.

javascript/sentry-conventions/src/attributes.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2253,6 +2253,26 @@ export const GEN_AI_RESPONSE_TEXT = 'gen_ai.response.text';
22532253
*/
22542254
export type GEN_AI_RESPONSE_TEXT_TYPE = string;
22552255

2256+
// Path: model/attributes/gen_ai/gen_ai__response__tokens_per_second.json
2257+
2258+
/**
2259+
* The total output tokens per seconds throughput `gen_ai.response.tokens_per_second`
2260+
*
2261+
* Attribute Value Type: `number` {@link GEN_AI_RESPONSE_TOKENS_PER_SECOND_TYPE}
2262+
*
2263+
* Contains PII: false
2264+
*
2265+
* Attribute defined in OTEL: No
2266+
*
2267+
* @example 12345.67
2268+
*/
2269+
export const GEN_AI_RESPONSE_TOKENS_PER_SECOND = 'gen_ai.response.tokens_per_second';
2270+
2271+
/**
2272+
* Type for {@link GEN_AI_RESPONSE_TOKENS_PER_SECOND} gen_ai.response.tokens_per_second
2273+
*/
2274+
export type GEN_AI_RESPONSE_TOKENS_PER_SECOND_TYPE = number;
2275+
22562276
// Path: model/attributes/gen_ai/gen_ai__response__tool_calls.json
22572277

22582278
/**
@@ -6070,6 +6090,7 @@ export type Attributes = {
60706090
[GEN_AI_RESPONSE_ID]?: GEN_AI_RESPONSE_ID_TYPE;
60716091
[GEN_AI_RESPONSE_MODEL]?: GEN_AI_RESPONSE_MODEL_TYPE;
60726092
[GEN_AI_RESPONSE_TEXT]?: GEN_AI_RESPONSE_TEXT_TYPE;
6093+
[GEN_AI_RESPONSE_TOKENS_PER_SECOND]?: GEN_AI_RESPONSE_TOKENS_PER_SECOND_TYPE;
60736094
[GEN_AI_RESPONSE_TOOL_CALLS]?: GEN_AI_RESPONSE_TOOL_CALLS_TYPE;
60746095
[GEN_AI_SYSTEM]?: GEN_AI_SYSTEM_TYPE;
60756096
[GEN_AI_SYSTEM_MESSAGE]?: GEN_AI_SYSTEM_MESSAGE_TYPE;
@@ -6322,6 +6343,7 @@ export type FullAttributes = {
63226343
[GEN_AI_RESPONSE_ID]?: GEN_AI_RESPONSE_ID_TYPE;
63236344
[GEN_AI_RESPONSE_MODEL]?: GEN_AI_RESPONSE_MODEL_TYPE;
63246345
[GEN_AI_RESPONSE_TEXT]?: GEN_AI_RESPONSE_TEXT_TYPE;
6346+
[GEN_AI_RESPONSE_TOKENS_PER_SECOND]?: GEN_AI_RESPONSE_TOKENS_PER_SECOND_TYPE;
63256347
[GEN_AI_RESPONSE_TOOL_CALLS]?: GEN_AI_RESPONSE_TOOL_CALLS_TYPE;
63266348
[GEN_AI_SYSTEM]?: GEN_AI_SYSTEM_TYPE;
63276349
[GEN_AI_SYSTEM_MESSAGE]?: GEN_AI_SYSTEM_MESSAGE_TYPE;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"key": "gen_ai.response.tokens_per_second",
3+
"brief": "The total output tokens per seconds throughput",
4+
"type": "double",
5+
"pii": {
6+
"key": "false"
7+
},
8+
"is_in_otel": false,
9+
"example": 12345.67
10+
}

0 commit comments

Comments
 (0)