File tree Expand file tree Collapse file tree 3 files changed +12
-1
lines changed
ai-semantic-conventions/src Expand file tree Collapse file tree 3 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ export const SpanAttributes = {
5151 TRACELOOP_SPAN_KIND : "traceloop.span.kind" ,
5252 TRACELOOP_WORKFLOW_NAME : "traceloop.workflow.name" ,
5353 TRACELOOP_ENTITY_NAME : "traceloop.entity.name" ,
54+ TRACELOOP_ENTITY_VERSION : "traceloop.entity.version" ,
5455 TRACELOOP_ASSOCIATION_PROPERTIES : "traceloop.association.properties" ,
5556 TRACELOOP_ENTITY_INPUT : "traceloop.entity.input" ,
5657 TRACELOOP_ENTITY_OUTPUT : "traceloop.entity.output" ,
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import { Telemetry } from "../telemetry/telemetry";
1414
1515export type DecoratorConfig = {
1616 name : string ;
17+ version ?: number ;
1718 associationProperties ?: { [ name : string ] : string } ;
1819 traceContent ?: boolean ;
1920 inputParameters ?: unknown [ ] ;
@@ -26,6 +27,7 @@ function withEntity<
2627 type : TraceloopSpanKindValues ,
2728 {
2829 name,
30+ version,
2931 associationProperties,
3032 traceContent : overrideTraceContent ,
3133 inputParameters,
@@ -69,6 +71,10 @@ function withEntity<
6971 span . setAttribute ( SpanAttributes . TRACELOOP_SPAN_KIND , type ) ;
7072 span . setAttribute ( SpanAttributes . TRACELOOP_ENTITY_NAME , name ) ;
7173
74+ if ( version ) {
75+ span . setAttribute ( SpanAttributes . TRACELOOP_ENTITY_VERSION , version ) ;
76+ }
77+
7278 if ( shouldSendTraces ( ) ) {
7379 try {
7480 const input = inputParameters ?? args ;
Original file line number Diff line number Diff line change @@ -147,7 +147,7 @@ describe("Test SDK Decorators", () => {
147147
148148 it ( "should create spans for workflows using decoration syntax" , async ( ) => {
149149 class TestOpenAI {
150- @traceloop . workflow ( { name : "sample_chat" } )
150+ @traceloop . workflow ( { name : "sample_chat" , version : 2 } )
151151 async chat ( things : Map < string , string > ) {
152152 const generations : Map < string , string > = new Map ( ) ;
153153 for await ( const [ key , value ] of things ) {
@@ -195,6 +195,10 @@ describe("Test SDK Decorators", () => {
195195 workflowSpan . attributes [ `${ SpanAttributes . TRACELOOP_ENTITY_NAME } ` ] ,
196196 "sample_chat" ,
197197 ) ;
198+ assert . strictEqual (
199+ workflowSpan . attributes [ `${ SpanAttributes . TRACELOOP_ENTITY_VERSION } ` ] ,
200+ 2 ,
201+ ) ;
198202 assert . strictEqual (
199203 workflowSpan . attributes [ `${ SpanAttributes . TRACELOOP_ENTITY_INPUT } ` ] ,
200204 JSON . stringify ( {
You can’t perform that action at this time.
0 commit comments