@@ -14,6 +14,7 @@ import (
1414 "google.golang.org/protobuf/types/known/wrapperspb"
1515
1616 "github.com/dapr/durabletask-go/api/protos"
17+ "github.com/dapr/durabletask-go/api/semconv"
1718)
1819
1920var tracer = otel .Tracer ("durabletask" )
@@ -22,9 +23,9 @@ func StartNewCreateOrchestrationSpan(
2223 ctx context.Context , name string , version string , instanceID string ,
2324) (context.Context , trace.Span ) {
2425 attributes := []attribute.KeyValue {
25- { Key : "durabletask.type" , Value : attribute . StringValue ("orchestration" )} ,
26- { Key : "durabletask.task.name" , Value : attribute . StringValue (name )} ,
27- { Key : "durabletask.task.instance_id" , Value : attribute . StringValue (instanceID )} ,
26+ semconv . DaprWorkflowTypeKey . String ("orchestration" ),
27+ semconv . DaprWorkflowNameKey . String (name ),
28+ semconv . DaprWorkflowInstanceIdKey . String (instanceID ),
2829 }
2930 return startNewSpan (ctx , "create_orchestration" , name , version , attributes , trace .SpanKindClient , time .Now ().UTC ())
3031}
@@ -36,9 +37,9 @@ func StartNewRunOrchestrationSpan(
3637 instanceID := es .OrchestrationInstance .InstanceId
3738 version := es .Version .GetValue ()
3839 attributes := []attribute.KeyValue {
39- { Key : "durabletask.type" , Value : attribute . StringValue ("orchestration" )} ,
40- { Key : "durabletask.task.name" , Value : attribute . StringValue (name )} ,
41- { Key : "durabletask.task.instance_id" , Value : attribute . StringValue (instanceID )} ,
40+ semconv . DaprWorkflowTypeKey . String ("orchestration" ),
41+ semconv . DaprWorkflowNameKey . String (name ),
42+ semconv . DaprWorkflowInstanceIdKey . String (instanceID ),
4243 }
4344 return startNewSpan (ctx , "orchestration" , name , version , attributes , trace .SpanKindServer , startedTime )
4445}
@@ -47,20 +48,20 @@ func StartNewActivitySpan(
4748 ctx context.Context , name string , version string , instanceID string , taskID int32 ,
4849) (context.Context , trace.Span ) {
4950 attributes := []attribute.KeyValue {
50- { Key : "durabletask.type" , Value : attribute . StringValue ("activity" )} ,
51- { Key : "durabletask.task.name" , Value : attribute . StringValue (name )} ,
52- { Key : "durabletask.task.task_id" , Value : attribute . Int64Value (int64 (taskID ))} ,
53- { Key : "durabletask.task.instance_id" , Value : attribute . StringValue (instanceID )} ,
51+ semconv . DaprWorkflowTypeKey . String ("activity" ),
52+ semconv . DaprWorkflowNameKey . String (name ),
53+ semconv . DaprWorkflowTaskIdKey . Int64 (int64 (taskID )),
54+ semconv . DaprWorkflowInstanceIdKey . String (instanceID ),
5455 }
5556 return startNewSpan (ctx , "activity" , name , version , attributes , trace .SpanKindServer , time .Now ().UTC ())
5657}
5758
5859func StartAndEndNewTimerSpan (ctx context.Context , tf * protos.TimerFiredEvent , createdTime time.Time , instanceID string ) error {
5960 attributes := []attribute.KeyValue {
60- { Key : "durabletask.type" , Value : attribute . StringValue ("timer" )} ,
61- { Key : "durabletask.fire_at" , Value : attribute . StringValue (tf .FireAt .AsTime ().Format (time .RFC3339 ))} , // time.RFC3339 most closely maps to ISO 8601
62- { Key : "durabletask.task.task_id" , Value : attribute . Int64Value (int64 (tf .TimerId ))} ,
63- { Key : "durabletask.task.instance_id" , Value : attribute . StringValue (instanceID )} ,
61+ semconv . DaprWorkflowTypeKey . String ("timer" ),
62+ semconv . DaprWorkflowTimerFireAtKey . String (tf .FireAt .AsTime ().Format (time .RFC3339 )), // time.RFC3339 most closely maps to ISO 8601
63+ semconv . DaprWorkflowTimerIdKey . Int64 (int64 (tf .TimerId )),
64+ semconv . DaprWorkflowInstanceIdKey . String (instanceID ),
6465 }
6566
6667 _ , span := startNewSpan (ctx , "timer" , "" , "" , attributes , trace .SpanKindInternal , createdTime )
@@ -80,10 +81,7 @@ func startNewSpan(
8081 var spanName string
8182 if taskVersion != "" {
8283 spanName = taskType + "||" + taskName + "||" + taskVersion
83- attributes = append (attributes , attribute.KeyValue {
84- Key : "durabletask.task.version" ,
85- Value : attribute .StringValue (taskVersion ),
86- })
84+ attributes = append (attributes , semconv .DaprWorkflowVersionKey .String (taskVersion ))
8785 } else if taskName != "" {
8886 spanName = taskType + "||" + taskName
8987 } else {
0 commit comments