| 1 |
// Copyright The OpenTelemetry Authors |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
package telemetrytest // import "go.opentelemetry.io/collector/internal/telemetry/telemetrytest" |
| 5 |
|
| 6 |
import ( |
| 7 |
"go.uber.org/zap" |
| 8 |
"go.uber.org/zap/zapcore" |
| 9 |
) |
| 10 |
|
| 11 |
type mockInjectorCore struct { |
| 12 |
zapcore.Core |
| 13 |
dropped *[]string |
| 14 |
} |
| 15 |
|
| 16 |
func (mic mockInjectorCore) DropInjectedAttributes(droppedAttrs ...string) zapcore.Core { |
| 17 |
*mic.dropped = append(*mic.dropped, droppedAttrs...) |
| 18 |
return mic |
| 19 |
} |
| 20 |
|
| 21 |
func MockInjectorLogger(logger *zap.Logger, dropped *[]string) *zap.Logger { |
| 22 |
return logger.WithOptions(zap.WrapCore(func(c zapcore.Core) zapcore.Core { |
| 23 |
return mockInjectorCore{ |
| 24 |
Core: c, |
| 25 |
dropped: dropped, |
| 26 |
} |
| 27 |
})) |
| 28 |
} |