mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-01-28 03:57:09 +02:00
Add example test to otlploghttp (#5235)
This commit is contained in:
parent
1ea4ee2717
commit
727395ad0e
33
exporters/otlp/otlplog/otlploghttp/example_test.go
Normal file
33
exporters/otlp/otlplog/otlploghttp/example_test.go
Normal file
@ -0,0 +1,33 @@
|
||||
// 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.
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user