File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
exporters/otlp/otlplog/otlploghttp Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright The OpenTelemetry Authors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ package otlploghttp_test
5
+
6
+ import (
7
+ "context"
8
+
9
+ "go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp"
10
+ "go.opentelemetry.io/otel/log/global"
11
+ "go.opentelemetry.io/otel/sdk/log"
12
+ )
13
+
14
+ func Example () {
15
+ ctx := context .Background ()
16
+ exp , err := otlploghttp .New (ctx )
17
+ if err != nil {
18
+ panic (err )
19
+ }
20
+
21
+ processor := log .NewBatchProcessor (exp )
22
+ provider := log .NewLoggerProvider (log .WithProcessor (processor ))
23
+ defer func () {
24
+ if err := provider .Shutdown (ctx ); err != nil {
25
+ panic (err )
26
+ }
27
+ }()
28
+
29
+ global .SetLoggerProvider (provider )
30
+
31
+ // From here, the provider can be used by instrumentation to collect
32
+ // telemetry.
33
+ }
You can’t perform that action at this time.
0 commit comments