Documentation
¶
Overview ¶
Package stdoutlog provides an exporter for OpenTelemetry log telemetry.
The exporter is intended to be used for testing and debugging, it is not meant for production use. Additionally, it does not provide an interchange format for OpenTelemetry that is supported with any stability or compatibility guarantees. If these are needed features, please use the OTLP exporter instead.
Example ¶
package main import ( "context" "go.opentelemetry.io/otel/exporters/stdout/stdoutlog" "go.opentelemetry.io/otel/log/global" "go.opentelemetry.io/otel/sdk/log" ) func main() { exp, err := stdoutlog.New() if err != nil { panic(err) } processor := log.NewSimpleProcessor(exp) provider := log.NewLoggerProvider(log.WithProcessor(processor)) defer func() { if err := provider.Shutdown(context.Background()); err != nil { panic(err) } }() global.SetLoggerProvider(provider) // From here, the provider can be used by instrumentation to collect // telemetry. }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Exporter ¶
type Exporter struct {
// contains filtered or unexported fields
}
Exporter writes JSON-encoded log records to an io.Writer (os.Stdout by default). Exporter must be created with New.
func (*Exporter) ForceFlush ¶
ForceFlush performs no action.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option sets the configuration value for an Exporter.
func WithWriter ¶
WithWriter sets the export stream destination.
func WithoutTimestamps ¶
func WithoutTimestamps() Option
WithoutTimestamps sets the export stream to not include timestamps.