File tree 2 files changed +21
-4
lines changed
2 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ type otlpCore struct {
34
34
logger otel.Logger
35
35
36
36
fields []zapcore.Field
37
+ level zapcore.Level
37
38
}
38
39
39
40
var instrumentationScope = instrumentation.Scope {
@@ -42,8 +43,8 @@ var instrumentationScope = instrumentation.Scope{
42
43
SchemaURL : semconv .SchemaURL ,
43
44
}
44
45
45
- func (otlpCore ) Enabled (zapcore.Level ) bool {
46
- return true
46
+ func (c * otlpCore ) Enabled (level zapcore.Level ) bool {
47
+ return c . level . Enabled ( level )
47
48
}
48
49
49
50
func (c * otlpCore ) With (f []zapcore.Field ) zapcore.Core {
Original file line number Diff line number Diff line change @@ -22,13 +22,29 @@ import (
22
22
)
23
23
24
24
// NewOtelCore creates new OpenTelemetry Core to export logs in OTLP format
25
- func NewOtelCore (loggerProvider otel.LoggerProvider ) zapcore.Core {
25
+ func NewOtelCore (loggerProvider otel.LoggerProvider , opts ... Option ) zapcore.Core {
26
26
logger := loggerProvider .Logger (
27
27
instrumentationScope .Name ,
28
28
otel .WithInstrumentationVersion (instrumentationScope .Version ),
29
29
)
30
30
31
- return & otlpCore {
31
+ c := & otlpCore {
32
32
logger : logger ,
33
+ level : zapcore .InfoLevel ,
33
34
}
35
+ for _ , apply := range opts {
36
+ apply (c )
37
+ }
38
+
39
+ return c
40
+ }
41
+
42
+ // Option is a function that applies an option to an OpenTelemetry Core
43
+ type Option func (c * otlpCore )
44
+
45
+ // WithLevel sets the minimum level for the OpenTelemetry Core log to be exported
46
+ func WithLevel (level zapcore.Level ) Option {
47
+ return Option (func (c * otlpCore ) {
48
+ c .level = level
49
+ })
34
50
}
You can’t perform that action at this time.
0 commit comments