Skip to content

Commit 2e9a52c

Browse files
committed
comm
1 parent e32cc3f commit 2e9a52c

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

traceloop-sdk/agent.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ func (agent *Agent) NewTool(name string, toolType string, toolFunction ToolFunct
5252
semconvai.TraceloopEntityName.String(name),
5353
}
5454

55+
if agent.workflow != nil {
56+
attrs = append(attrs, semconvai.TraceloopWorkflowName.String(agent.workflow.Attributes.Name))
57+
}
58+
5559
for key, value := range agent.Attributes.AssociationProperties {
5660
attrs = append(attrs, attribute.String("traceloop.association.properties."+key, value))
5761
}

traceloop-sdk/sdk.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ func (instance *Traceloop) NewAgent(ctx context.Context, name string, agentAttrs
151151
}
152152

153153
if agentAttrs.ABTest != nil {
154+
if agentAttrs.AssociationProperties == nil {
155+
agentAttrs.AssociationProperties = make(map[string]string)
156+
}
154157
for key, activeVariant := range agentAttrs.ABTest.VariantKeys {
155158
if activeVariant {
156159
agentAttrs.AssociationProperties["ab_testing_variant"] = key

traceloop-sdk/workflow.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package traceloop
33
import (
44
"context"
55
"fmt"
6+
"maps"
67

78
semconvai "github.com/traceloop/go-openllmetry/semconv-ai"
89
"github.com/traceloop/go-openllmetry/traceloop-sdk/model"
@@ -78,15 +79,17 @@ func (workflow *Workflow) NewAgent(name string, associationProperties map[string
7879
semconvai.TraceloopEntityName.String(name),
7980
}
8081

82+
agentAssociationProps := make(map[string]string, len(associationProperties)+1)
83+
maps.Copy(agentAssociationProps, associationProperties)
84+
8185
if workflow.Attributes.ABTest != nil {
8286
for key, activeVariant := range workflow.Attributes.ABTest.VariantKeys {
8387
if activeVariant {
84-
associationProperties["ab_testing_variant"] = key
88+
agentAssociationProps["ab_testing_variant"] = key
8589
}
8690
}
8791
}
88-
// Add agent-specific association properties to the span
89-
for key, value := range associationProperties {
92+
for key, value := range agentAssociationProps {
9093
attrs = append(attrs, attribute.String("traceloop.association.properties."+key, value))
9194
}
9295

@@ -98,7 +101,7 @@ func (workflow *Workflow) NewAgent(name string, associationProperties map[string
98101
ctx: aCtx,
99102
Attributes: AgentAttributes{
100103
Name: name,
101-
AssociationProperties: associationProperties,
104+
AssociationProperties: agentAssociationProps,
102105
},
103106
}
104107
}

0 commit comments

Comments
 (0)