-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample_gen.go
More file actions
106 lines (103 loc) · 3.16 KB
/
Copy pathexample_gen.go
File metadata and controls
106 lines (103 loc) · 3.16 KB
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
103
104
105
106
// Code generated by tracegen. DO NOT EDIT.
// Source: example.go
package tracegen
import (
context "context"
"encoding/json"
"fmt"
foobar "github.com/KazanExpress/tracegen/examples/bar"
foo "github.com/KazanExpress/tracegen/examples/foo"
attribute "go.opentelemetry.io/otel/attribute"
codes "go.opentelemetry.io/otel/codes"
trace "go.opentelemetry.io/otel/trace"
)
type TracedExample struct {
base Example
tracer trace.Tracer
}
func NewTracedExample(_base Example, _tracer trace.Tracer) *TracedExample {
return &TracedExample{
base: _base,
tracer: _tracer,
}
}
func (_d *TracedExample) A(ctx context.Context, id int64, text string) (bool, error) {
var _span trace.Span
ctx, _span = _d.tracer.Start(ctx, "Example.A()")
defer _span.End()
_span.SetAttributes(attribute.Int64("id", id))
_span.SetAttributes(attribute.String("text", text))
_var0, _var1 := _d.base.A(ctx, id, text)
if _var1 != nil {
_span.RecordError(_var1)
_span.SetStatus(codes.Error, _var1.Error())
}
return _var0, _var1
}
func (_d *TracedExample) B(ctx context.Context, foo *foo.Foo) foobar.Bar {
var _span trace.Span
ctx, _span = _d.tracer.Start(ctx, "Example.B()")
defer _span.End()
if data, err := json.Marshal(foo); err == nil {
_span.SetAttributes(attribute.String("foo", string(data)))
} else {
_span.SetAttributes(attribute.String("foo", fmt.Sprint(foo)))
}
_span.SetAttributes(attribute.String("foo.Name", foo.Name))
_var0 := _d.base.B(ctx, foo)
return _var0
}
func (_d *TracedExample) C(ctx context.Context, foo *foo.Foo) error {
var _span trace.Span
ctx, _span = _d.tracer.Start(ctx, "Example.C()")
defer _span.End()
_span.SetAttributes(attribute.String("foo.Name", foo.Name))
_var0 := _d.base.C(ctx, foo)
if _var0 != nil {
_span.RecordError(_var0)
_span.SetStatus(codes.Error, _var0.Error())
}
return _var0
}
func (_d *TracedExample) D(ctx context.Context) {
var _span trace.Span
ctx, _span = _d.tracer.Start(ctx, "Example.D()")
defer _span.End()
_d.base.D(ctx)
}
func (_d *TracedExample) E(ctx context.Context, bar []foobar.Bar) []foobar.Bar {
var _span trace.Span
ctx, _span = _d.tracer.Start(ctx, "Example.E()")
defer _span.End()
if data, err := json.Marshal(bar); err == nil {
_span.SetAttributes(attribute.String("bar", string(data)))
} else {
_span.SetAttributes(attribute.String("bar", fmt.Sprint(bar)))
}
_var0 := _d.base.E(ctx, bar)
return _var0
}
func (_d *TracedExample) F(ctx context.Context, bars []*foobar.Bar) []*foobar.Bar {
var _span trace.Span
ctx, _span = _d.tracer.Start(ctx, "Example.F()")
defer _span.End()
if data, err := json.Marshal(bars); err == nil {
_span.SetAttributes(attribute.String("bars", string(data)))
} else {
_span.SetAttributes(attribute.String("bars", fmt.Sprint(bars)))
}
_var0 := _d.base.F(ctx, bars)
return _var0
}
func (_d *TracedExample) G(ctx context.Context, bars *[]*foobar.Bar) *[]*foobar.Bar {
var _span trace.Span
ctx, _span = _d.tracer.Start(ctx, "Example.G()")
defer _span.End()
if data, err := json.Marshal(bars); err == nil {
_span.SetAttributes(attribute.String("bars", string(data)))
} else {
_span.SetAttributes(attribute.String("bars", fmt.Sprint(bars)))
}
_var0 := _d.base.G(ctx, bars)
return _var0
}