1
0
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:
Tyler Yahn 2024-04-20 02:51:04 -07:00 committed by GitHub
parent 1ea4ee2717
commit 727395ad0e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View 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.
}