mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-01-28 03:57:09 +02:00
34 lines
700 B
Go
34 lines
700 B
Go
|
// Copyright The OpenTelemetry Authors
|
||
|
// SPDX-License-Identifier: Apache-2.0
|
||
|
|
||
|
package otlploghttp_test
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp"
|
||
|
"go.opentelemetry.io/otel/log/global"
|
||
|
"go.opentelemetry.io/otel/sdk/log"
|
||
|
)
|
||
|
|
||
|
func Example() {
|
||
|
ctx := context.Background()
|
||
|
exp, err := otlploghttp.New(ctx)
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
|
||
|
processor := log.NewBatchProcessor(exp)
|
||
|
provider := log.NewLoggerProvider(log.WithProcessor(processor))
|
||
|
defer func() {
|
||
|
if err := provider.Shutdown(ctx); err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
}()
|
||
|
|
||
|
global.SetLoggerProvider(provider)
|
||
|
|
||
|
// From here, the provider can be used by instrumentation to collect
|
||
|
// telemetry.
|
||
|
}
|