Skip to content

Commit

Permalink
feat(mockotlpserver): show some GenAI-related span details in trace s…
Browse files Browse the repository at this point in the history
…ummary view (#340)

E.g.:
  span 99bb32 "chat llama3.1:latest" (7475.4ms, SPAN_KIND_CLIENT, GenAI openai, finish_reasons=tool_calls, tokens 209in/22out)

The part from "GenAI" on are the added extra attributes included.
This shows a subset of semconv v1.27 gen_ai attrs.
  • Loading branch information
trentm authored Aug 23, 2024
1 parent 25a9200 commit ce15aa1
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/mockotlpserver/lib/waterfall.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,21 @@ function renderSpan(span, prefix = '') {
.join(' ')
);
}
// GenAI-related extras
// https://github.com/open-telemetry/semantic-conventions/blob/v1.27.0/model/registry/gen-ai.yaml
if ('gen_ai.system' in attrs) {
extras.push(`GenAI ${attrs['gen_ai.system']}`);
try {
extras.push(
`finish_reasons=${attrs['gen_ai.response.finish_reasons'].join(
','
)}`
);
extras.push(
`tokens ${attrs['gen_ai.usage.input_tokens']}in/${attrs['gen_ai.usage.output_tokens']}out`
);
} catch (_err) {}
}
if (extras.length) {
r += ` (${extras.join(', ')})`;
}
Expand Down

0 comments on commit ce15aa1

Please sign in to comment.