otelzap

package module
v0.0.0-...-b368fc0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package otelzap provides a bridge between the go.uber.org/zap and OpenTelemetry logging.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Core

type Core struct {
	// contains filtered or unexported fields
}

Core is a zapcore.Core that sends logging records to OpenTelemetry.

func NewCore

func NewCore(name string, opts ...Option) *Core

NewCore creates a new zapcore.Core that can be used with go.uber.org/zap.New.

func (*Core) Check

Check determines whether the supplied Entry should be logged using core.Enabled method. If the entry should be logged, the Core adds itself to the CheckedEntry and returns the result.

func (*Core) Enabled

func (o *Core) Enabled(level zapcore.Level) bool

Enabled decides whether a given logging level is enabled when logging a message.

func (*Core) Sync

func (o *Core) Sync() error

TODO Sync flushes buffered logs (if any).

func (*Core) With

func (o *Core) With(fields []zapcore.Field) zapcore.Core

With adds structured context to the Core.

func (*Core) Write

func (o *Core) Write(ent zapcore.Entry, fields []zapcore.Field) error

Write method encodes zap fields to OTel logs and emits them.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option configures a Core.

func WithLoggerProvider

func WithLoggerProvider(provider log.LoggerProvider) Option

WithLoggerProvider returns an Option that configures log.LoggerProvider used by a Core to create its log.Logger.

By default if this Option is not provided, the Handler will use the global LoggerProvider.

func WithSchemaURL

func WithSchemaURL(schemaURL string) Option

WithSchemaURL returns an Option that configures the semantic convention schema URL of the log.Logger used by a Core. The schemaURL should be the schema URL for the semantic conventions used in log records.

func WithVersion

func WithVersion(version string) Option

WithVersion returns an Option that configures the version of the log.Logger used by a Core. The version should be the version of the package that is being logged.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL