forked from instana/go-sensor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
collector_noop.go
89 lines (69 loc) · 1.97 KB
/
collector_noop.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
// (c) Copyright IBM Corp. 2023
package instana
import (
"context"
"errors"
ot "github.com/opentracing/opentracing-go"
)
var (
_ TracerLogger = (*noopCollector)(nil)
noopCollectorErrMsg string = "collector not initialized. make sure to initialize the Collector. eg: instana.InitCollector"
noopCollectorErr error = errors.New(noopCollectorErrMsg)
)
type noopCollector struct {
l LeveledLogger
}
func newNoopCollector() TracerLogger {
c := &noopCollector{
l: defaultLogger,
}
return c
}
func (c *noopCollector) Extract(format interface{}, carrier interface{}) (ot.SpanContext, error) {
c.l.Error(noopCollectorErrMsg)
return nil, noopCollectorErr
}
func (c *noopCollector) Inject(sm ot.SpanContext, format interface{}, carrier interface{}) error {
c.l.Error(noopCollectorErrMsg)
return noopCollectorErr
}
func (c *noopCollector) StartSpan(operationName string, opts ...ot.StartSpanOption) ot.Span {
c.l.Error(noopCollectorErrMsg)
return nil
}
func (c *noopCollector) StartSpanWithOptions(operationName string, opts ot.StartSpanOptions) ot.Span {
c.l.Error(noopCollectorErrMsg)
return nil
}
func (c *noopCollector) Options() TracerOptions {
return TracerOptions{}
}
func (c *noopCollector) Flush(ctx context.Context) error {
return noopCollectorErr
}
func (c *noopCollector) Debug(v ...interface{}) {
c.l.Error(noopCollectorErrMsg)
}
func (c *noopCollector) Info(v ...interface{}) {
c.l.Error(noopCollectorErrMsg)
}
func (c *noopCollector) Warn(v ...interface{}) {
c.l.Error(noopCollectorErrMsg)
}
func (c *noopCollector) Error(v ...interface{}) {
c.l.Error(noopCollectorErrMsg)
}
func (c *noopCollector) LegacySensor() *Sensor {
c.l.Error(noopCollectorErrMsg)
return nil
}
func (c *noopCollector) Tracer() ot.Tracer {
c.l.Error(noopCollectorErrMsg)
return nil
}
func (c *noopCollector) Logger() LeveledLogger {
c.l.Error(noopCollectorErrMsg)
return nil
}
// SetLogger sets the logger
func (c *noopCollector) SetLogger(l LeveledLogger) {}