Skip to content

Commit

Permalink
Merge branch 'main' into sdk-release
Browse files Browse the repository at this point in the history
  • Loading branch information
pellared authored Apr 20, 2024
2 parents 592e38e + 727395a commit 149bf52
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions exporters/otlp/otlplog/otlploghttp/example_test.go
Original file line number Diff line number Diff line change
@@ -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.
}

0 comments on commit 149bf52

Please sign in to comment.