Skip to content

Commit b434f61

Browse files
authored
fix(sdk): used wrong completion attribute in manual instrumentations (#277)
1 parent 528c498 commit b434f61

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

packages/traceloop-sdk/src/lib/tracing/manual.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ export class LLMSpan {
126126
this.span.setAttributes({
127127
[`${SpanAttributes.LLM_COMPLETIONS}.${index}.finish_reason`]:
128128
completion.finish_reason,
129-
[`${SpanAttributes.LLM_COMPLETIONS}.${index}.message.role`]:
129+
[`${SpanAttributes.LLM_COMPLETIONS}.${index}.role`]:
130130
completion.message.role,
131-
[`${SpanAttributes.LLM_COMPLETIONS}.${index}.message.content`]:
131+
[`${SpanAttributes.LLM_COMPLETIONS}.${index}.content`]:
132132
completion.message.content || "",
133133
});
134134
});

packages/traceloop-sdk/test/decorators.test.ts

+4
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,10 @@ describe("Test SDK Decorators", () => {
435435
completionSpan.attributes[`${SpanAttributes.LLM_PROMPTS}.0.content`],
436436
"Tell me a joke about OpenTelemetry",
437437
);
438+
assert.strictEqual(
439+
completionSpan.attributes[`${SpanAttributes.LLM_COMPLETIONS}.0.content`],
440+
result.choices[0].message.content,
441+
);
438442
assert.ok(
439443
completionSpan.attributes[`${SpanAttributes.LLM_USAGE_TOTAL_TOKENS}`],
440444
);

0 commit comments

Comments
 (0)