-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
52 lines (42 loc) · 973 Bytes
/
config.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
package amqptrace
import (
"github.com/streadway/amqp"
"go.opentelemetry.io/otel/api/global"
"go.opentelemetry.io/otel/api/propagation"
)
// Option is a function that allows configuration of the amqptrace Extract()
// and Inject() functions
type Option func(*config)
type config struct {
propagators propagation.Propagators
}
func newConfig(opts []Option) *config {
c := &config{propagators: global.Propagators()}
for _, o := range opts {
o(c)
}
return c
}
// WithPropagators sets the propagators to use for Extraction and Injection
func WithPropagators(props propagation.Propagators) Option {
return func(c *config) {
c.propagators = props
}
}
type headerSupplier struct {
headers amqp.Table
}
func (s *headerSupplier) Get(key string) string {
value, ok := s.headers[key]
if !ok {
return ""
}
str, ok := value.(string)
if !ok {
return ""
}
return str
}
func (s *headerSupplier) Set(key string, value string) {
s.headers[key] = value
}