forked from elastic/apm-agent-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug.go
45 lines (40 loc) · 840 Bytes
/
debug.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
package apmdebug
import (
"log"
"os"
"strings"
)
var (
// TraceTransport reports whether or not the transport methods
// should be traced. If true, messages will be sent to stderr
// for each SendTransactions and SendErrors call, proceeded by
// the results.
TraceTransport bool
)
func init() {
v := os.Getenv("ELASTIC_APM_DEBUG")
if v == "" {
return
}
for _, field := range strings.Split(v, ",") {
pos := strings.IndexRune(field, '=')
if pos == -1 {
invalidField(field)
continue
}
k, _ := field[:pos], field[pos+1:]
switch k {
case "tracetransport":
TraceTransport = true
default:
unknownKey(k)
continue
}
}
}
func unknownKey(key string) {
log.Println("unknown ELASTIC_APM_DEBUG field:", key)
}
func invalidField(field string) {
log.Println("invalid ELASTIC_APM_DEBUG field:", field)
}