-
Notifications
You must be signed in to change notification settings - Fork 126
/
attributes.go
102 lines (87 loc) · 2.39 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
100
101
102
package servertel
import (
"github.com/jackc/pgx/v5/pgtype"
"github.com/hatchet-dev/hatchet/internal/repository/prisma/dbsqlc"
"github.com/hatchet-dev/hatchet/internal/repository/prisma/sqlchelpers"
"github.com/hatchet-dev/hatchet/internal/telemetry"
"go.opentelemetry.io/otel/trace"
)
func WithStepRunModel(span trace.Span, stepRun *dbsqlc.GetStepRunForEngineRow) {
telemetry.WithAttributes(
span,
TenantId(stepRun.StepRun.TenantId),
StepRunId(stepRun.StepRun.ID),
Step(stepRun.StepId),
JobRunId(stepRun.JobRunId),
)
}
func WithJobRunModel(span trace.Span, jobRun *dbsqlc.JobRun) {
telemetry.WithAttributes(
span,
TenantId(jobRun.TenantId),
JobRunId(jobRun.ID),
Job(jobRun.JobId),
)
}
func WithWorkflowRunModel(span trace.Span, workflowRun *dbsqlc.GetWorkflowRunRow) {
telemetry.WithAttributes(
span,
TenantId(workflowRun.WorkflowRun.TenantId),
WorkflowRunId(workflowRun.WorkflowRun.ID),
WorkflowVersion(workflowRun.WorkflowVersion.ID),
)
}
func TenantId(tenantId pgtype.UUID) telemetry.AttributeKV {
return telemetry.AttributeKV{
Key: "tenantId",
Value: sqlchelpers.UUIDToStr(tenantId),
}
}
func StepRunId(stepRunId pgtype.UUID) telemetry.AttributeKV {
return telemetry.AttributeKV{
Key: "stepRunId",
Value: sqlchelpers.UUIDToStr(stepRunId),
}
}
func Step(step pgtype.UUID) telemetry.AttributeKV {
return telemetry.AttributeKV{
Key: "stepId",
Value: sqlchelpers.UUIDToStr(step),
}
}
func JobRunId(jobRunId pgtype.UUID) telemetry.AttributeKV {
return telemetry.AttributeKV{
Key: "jobRunId",
Value: sqlchelpers.UUIDToStr(jobRunId),
}
}
func Job(job pgtype.UUID) telemetry.AttributeKV {
return telemetry.AttributeKV{
Key: "jobId",
Value: sqlchelpers.UUIDToStr(job),
}
}
func WorkflowRunId(workflowRunId pgtype.UUID) telemetry.AttributeKV {
return telemetry.AttributeKV{
Key: "workflowRunId",
Value: sqlchelpers.UUIDToStr(workflowRunId),
}
}
func WorkflowVersion(workflowVersion pgtype.UUID) telemetry.AttributeKV {
return telemetry.AttributeKV{
Key: "workflowVersionId",
Value: sqlchelpers.UUIDToStr(workflowVersion),
}
}
func WorkerId(workerId pgtype.UUID) telemetry.AttributeKV {
return telemetry.AttributeKV{
Key: "workerId",
Value: sqlchelpers.UUIDToStr(workerId),
}
}
func EventId(eventId pgtype.UUID) telemetry.AttributeKV {
return telemetry.AttributeKV{
Key: "eventId",
Value: sqlchelpers.UUIDToStr(eventId),
}
}