Documentation ¶
Overview ¶
Package otelog provides global function to register an Open Telemetry Collector endpoint to export log records to.
This package is meant to be a temporarly replacement while waiting a more thoroughly implemented and tested package provided by https://pkg.go.dev/go.opentelemetry.io/ . Please use it in production only if you really needs it.
Basics ¶
You will need to SetLogExporter() with a NewLogExporter() indicating the Open Telemetry Collector Endpoint.
Then you can use hooks in `github.com/atuleu/otelog/pkg/hooks` to integrate your logging library. Currently only `github.com/sirupsen/logrus` integration is provided.
Index ¶
- func SetLogExporter(exporter LogExporter)
- type BatchLogProcessorOption
- type LogExporter
- type LogExporterOption
- func WithBatchLogProcessor(options ...BatchLogProcessorOption) LogExporterOption
- func WithEndpoint(endpoint string) LogExporterOption
- func WithGRPCConn(conn *grpc.ClientConn) LogExporterOption
- func WithInsecure() LogExporterOption
- func WithResource(r *resource.Resource) LogExporterOption
- func WithScope(s instrumentation.Scope) LogExporterOption
- func WithSyncer() LogExporterOption
- func WithTLSCredentials(c credentials.TransportCredentials) LogExporterOption
- type LogProcessor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetLogExporter ¶
func SetLogExporter(exporter LogExporter)
SetLogExporter sets the global LogExporter to exporter. This method is not concurrently safe.
Types ¶
type BatchLogProcessorOption ¶
type BatchLogProcessorOption interface {
// contains filtered or unexported methods
}
BatchLogProcessorOption is an Option for WithBatchLogProcessor()
func WithBatchTimeout ¶
func WithBatchTimeout(timeout time.Duration) BatchLogProcessorOption
WithBatchTimeout sets the timeout after which a batch will be exported regardless of the number of queued LogRecord.
func WithMaxQueueSize ¶
func WithMaxQueueSize(size int) BatchLogProcessorOption
WithMaxQueueSize sets the max queue size before a batch will be emitted.
type LogExporter ¶
A LogExporter is used to export log for example, to an Open Telemetry collector.
func GetLogExporter ¶
func GetLogExporter() LogExporter
GetLogExporter gets the global LogExporter registered with SetLogExporter. If none was registered a NoopLogExporter will be returned. It is concurrently safe to call GetLogExporter from multiple go routines.
func NewLogExporter ¶
func NewLogExporter(options ...LogExporterOption) (LogExporter, error)
Creates a new LogExporter that will export LogRecord to the specified endpoint. The endpoint address must be specified with WithEndpoint(). Credential must be specified with either WithInsecure() or WithTLSCredential().
func NoopLogExporter ¶
func NoopLogExporter() LogExporter
Creates a Log exporter that exports nothing.
type LogExporterOption ¶
type LogExporterOption interface {
// contains filtered or unexported methods
}
LogExporterOption is an option to use with NewLogExporter().
func WithBatchLogProcessor ¶
func WithBatchLogProcessor(options ...BatchLogProcessorOption) LogExporterOption
Sets a LogProcessor that batches logs before exporting them.
func WithEndpoint ¶
func WithEndpoint(endpoint string) LogExporterOption
Sets the Open Telemetry collector endpoint to export logs to.
func WithGRPCConn ¶ added in v0.1.3
func WithGRPCConn(conn *grpc.ClientConn) LogExporterOption
func WithInsecure ¶
func WithInsecure() LogExporterOption
Sets no credential for the OpenTelemetry endpoint.
func WithResource ¶
func WithResource(r *resource.Resource) LogExporterOption
Sets the resource associated with the LogExporter
func WithScope ¶
func WithScope(s instrumentation.Scope) LogExporterOption
Sets the scope associated with the LogExporter
func WithSyncer ¶
func WithSyncer() LogExporterOption
Sets a LogProcessor that sends every event immediatly. It should be avoided in production.
func WithTLSCredentials ¶
func WithTLSCredentials(c credentials.TransportCredentials) LogExporterOption
Sets the gRPC TLS credential to use for the OpenTelemetry endpoint.
type LogProcessor ¶
type LogProcessor interface {
// contains filtered or unexported methods
}
LogProcessor process incoming LogRecord and batches them if needed.