/
service_trace_gen.go
81 lines (70 loc) · 2.4 KB
/
service_trace_gen.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
// Code generated by gowrap. DO NOT EDIT.
// template: https://raw.githubusercontent.com/hexdigest/gowrap/6c8f05695fec23df85903a8da0af66ac414e2a63/templates/opentelemetry
// gowrap: http://github.com/hexdigest/gowrap
package service
import (
"context"
"github.com/Semior001/glmrl/pkg/git"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
)
// tracingServiceWithTracing implements tracingService interface instrumented with opentracing spans
type tracingServiceWithTracing struct {
tracingService
_instance string
_spanDecorator func(span trace.Span, params, results map[string]interface{})
}
// NewtracingServiceWithTracing returns tracingServiceWithTracing
func NewtracingServiceWithTracing(base tracingService, instance string, spanDecorator ...func(span trace.Span, params, results map[string]interface{})) tracingServiceWithTracing {
d := tracingServiceWithTracing{
tracingService: base,
_instance: instance,
}
if len(spanDecorator) > 0 && spanDecorator[0] != nil {
d._spanDecorator = spanDecorator[0]
}
return d
}
// Approve implements tracingService
func (_d tracingServiceWithTracing) Approve(ctx context.Context, pID string, prNum int) (err error) {
ctx, _span := otel.Tracer(_d._instance).Start(ctx, "tracingService.Approve")
defer func() {
if _d._spanDecorator != nil {
_d._spanDecorator(_span, map[string]interface{}{
"ctx": ctx,
"pID": pID,
"prNum": prNum}, map[string]interface{}{
"err": err})
} else if err != nil {
_span.RecordError(err)
_span.SetAttributes(
attribute.String("event", "error"),
attribute.String("message", err.Error()),
)
}
_span.End()
}()
return _d.tracingService.Approve(ctx, pID, prNum)
}
// ListPullRequests implements tracingService
func (_d tracingServiceWithTracing) ListPullRequests(ctx context.Context, req ListPRsRequest) (pa1 []git.PullRequest, err error) {
ctx, _span := otel.Tracer(_d._instance).Start(ctx, "tracingService.ListPullRequests")
defer func() {
if _d._spanDecorator != nil {
_d._spanDecorator(_span, map[string]interface{}{
"ctx": ctx,
"req": req}, map[string]interface{}{
"pa1": pa1,
"err": err})
} else if err != nil {
_span.RecordError(err)
_span.SetAttributes(
attribute.String("event", "error"),
attribute.String("message", err.Error()),
)
}
_span.End()
}()
return _d.tracingService.ListPullRequests(ctx, req)
}