-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_helper.go
68 lines (61 loc) · 2.35 KB
/
test_helper.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
//go:build linux && traceable_filter
// +build linux,traceable_filter
package traceable // import "github.com/Traceableai/goagent/filter/traceable"
// "-Wl,-rpath=\$ORIGIN" ensures we don't need to pass LD_LIBRARY_PATH when running the application.
// See https://stackoverflow.com/a/44214486
/*
#cgo CFLAGS: -I./
#cgo LDFLAGS: -Wl,-rpath=\$ORIGIN -ldl
#include "libtraceable.h"
*/
import "C"
import (
traceableconfig "github.com/Traceableai/agent-config/gen/go/v1"
_ "github.com/Traceableai/goagent/filter/traceable/libs/linux_amd64"
_ "github.com/Traceableai/goagent/filter/traceable/libs/linux_amd64-alpine"
_ "github.com/Traceableai/goagent/filter/traceable/libs/linux_arm64"
)
func getLibTraceableConfig(serviceName string, config *traceableconfig.AgentConfig) C.traceable_libtraceable_config {
libtraceableConfig := C.traceable_libtraceable_config{}
populateLibtraceableConfig(&libtraceableConfig, serviceName, config)
return libtraceableConfig
}
func getGoLogMode(mode C.TRACEABLE_LOG_MODE) traceableconfig.LogMode {
switch mode {
case C.TRACEABLE_LOG_NONE:
return traceableconfig.LogMode_LOG_MODE_NONE
case C.TRACEABLE_LOG_STDOUT:
return traceableconfig.LogMode_LOG_MODE_STDOUT
case C.TRACEABLE_LOG_FILE:
return traceableconfig.LogMode_LOG_MODE_FILE
}
return traceableconfig.LogMode_LOG_MODE_UNSPECIFIED
}
func getGoLogLevel(level C.TRACEABLE_LOG_LEVEL) traceableconfig.LogLevel {
switch level {
case C.TRACEABLE_LOG_LEVEL_TRACE:
return traceableconfig.LogLevel_LOG_LEVEL_TRACE
case C.TRACEABLE_LOG_LEVEL_DEBUG:
return traceableconfig.LogLevel_LOG_LEVEL_DEBUG
case C.TRACEABLE_LOG_LEVEL_INFO:
return traceableconfig.LogLevel_LOG_LEVEL_INFO
case C.TRACEABLE_LOG_LEVEL_WARN:
return traceableconfig.LogLevel_LOG_LEVEL_WARN
case C.TRACEABLE_LOG_LEVEL_ERROR:
return traceableconfig.LogLevel_LOG_LEVEL_ERROR
case C.TRACEABLE_LOG_LEVEL_CRITICAL:
return traceableconfig.LogLevel_LOG_LEVEL_CRITICAL
}
return traceableconfig.LogLevel_LOG_LEVEL_UNSPECIFIED
}
func getGoSpanType(spanType C.TRACEABLE_SPAN_TYPE) traceableconfig.SpanType {
switch spanType {
case C.TRACEABLE_NO_SPAN:
return traceableconfig.SpanType_SPAN_TYPE_NO_SPAN
case C.TRACEABLE_BARE_SPAN:
return traceableconfig.SpanType_SPAN_TYPE_BARE_SPAN
case C.TRACEABLE_FULL_SPAN:
return traceableconfig.SpanType_SPAN_TYPE_FULL_SPAN
}
return traceableconfig.SpanType_SPAN_TYPE_UNSPECIFIED
}