-
Notifications
You must be signed in to change notification settings - Fork 126
/
attributes.go
99 lines (85 loc) · 1.97 KB
/
attributes.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package servertel
import (
"github.com/hatchet-dev/hatchet/internal/repository/prisma/db"
"github.com/hatchet-dev/hatchet/internal/telemetry"
"go.opentelemetry.io/otel/trace"
)
func WithStepRunModel(span trace.Span, stepRun *db.StepRunModel) {
telemetry.WithAttributes(
span,
TenantId(stepRun.TenantID),
StepRunId(stepRun.ID),
Step(stepRun.StepID),
JobRunId(stepRun.JobRunID),
)
}
func WithJobRunModel(span trace.Span, jobRun *db.JobRunModel) {
telemetry.WithAttributes(
span,
TenantId(jobRun.TenantID),
JobRunId(jobRun.ID),
Job(jobRun.JobID),
)
}
func WithWorkflowRunModel(span trace.Span, workflowRun *db.WorkflowRunModel) {
telemetry.WithAttributes(
span,
TenantId(workflowRun.TenantID),
WorkflowRunId(workflowRun.ID),
WorkflowVersion(workflowRun.WorkflowVersionID),
)
}
func TenantId(tenantId string) telemetry.AttributeKV {
return telemetry.AttributeKV{
Key: "tenantId",
Value: tenantId,
}
}
func StepRunId(stepRunId string) telemetry.AttributeKV {
return telemetry.AttributeKV{
Key: "stepRunId",
Value: stepRunId,
}
}
func Step(step string) telemetry.AttributeKV {
return telemetry.AttributeKV{
Key: "stepId",
Value: step,
}
}
func JobRunId(jobRunId string) telemetry.AttributeKV {
return telemetry.AttributeKV{
Key: "jobRunId",
Value: jobRunId,
}
}
func Job(job string) telemetry.AttributeKV {
return telemetry.AttributeKV{
Key: "jobId",
Value: job,
}
}
func WorkflowRunId(workflowRunId string) telemetry.AttributeKV {
return telemetry.AttributeKV{
Key: "workflowRunId",
Value: workflowRunId,
}
}
func WorkflowVersion(workflowVersion string) telemetry.AttributeKV {
return telemetry.AttributeKV{
Key: "workflowVersionId",
Value: workflowVersion,
}
}
func WorkerId(workerId string) telemetry.AttributeKV {
return telemetry.AttributeKV{
Key: "workerId",
Value: workerId,
}
}
func EventId(eventId string) telemetry.AttributeKV {
return telemetry.AttributeKV{
Key: "eventId",
Value: eventId,
}
}