diff --git a/packages/traceloop-sdk/src/lib/tracing/manual.ts b/packages/traceloop-sdk/src/lib/tracing/manual.ts index 7c123e75..55c001fe 100644 --- a/packages/traceloop-sdk/src/lib/tracing/manual.ts +++ b/packages/traceloop-sdk/src/lib/tracing/manual.ts @@ -163,6 +163,7 @@ export function withLLMCall< F extends ({ span }: { span: LLMSpan }) => ReturnType, >({ vendor, type }: LLMCallConfig, fn: F, thisArg?: ThisParameterType) { const span = getTracer().startSpan(`${vendor}.${type}`, {}, context.active()); + span.setAttribute(SpanAttributes.LLM_REQUEST_TYPE, type); trace.setSpan(context.active(), span); const res = fn.apply(thisArg, [{ span: new LLMSpan(span) }]); diff --git a/packages/traceloop-sdk/test/decorators.test.ts b/packages/traceloop-sdk/test/decorators.test.ts index 5a3658f4..029c7be4 100644 --- a/packages/traceloop-sdk/test/decorators.test.ts +++ b/packages/traceloop-sdk/test/decorators.test.ts @@ -415,6 +415,10 @@ describe("Test SDK Decorators", () => { workflowSpan.spanContext().spanId, ); + assert.strictEqual( + completionSpan.attributes[`${SpanAttributes.LLM_REQUEST_TYPE}`], + "chat", + ); assert.strictEqual( completionSpan.attributes[`${SpanAttributes.LLM_REQUEST_MODEL}`], "gpt-3.5-turbo",