Skip to content

Commit

Permalink
Update exporters/otlp Readme.md (#1441)
Browse files Browse the repository at this point in the history
  • Loading branch information
eundoosong authored Jan 7, 2021
1 parent bc9cb5e commit 5ed96e9
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions exporters/otlp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,25 @@ A new exporter can be created using the `NewExporter` function.
package main

import (
"context"
"log"

"go.opentelemetry.io/otel/exporters/otlp"
"go.opentelemetry.io/otel/sdk/metric/controller/push"
"go.opentelemetry.io/otel/exporters/otlp"
processor "go.opentelemetry.io/otel/sdk/metric/processor/basic"
"go.opentelemetry.io/otel/sdk/metric/selector/simple"
metricsdk "go.opentelemetry.io/otel/sdk/export/metric"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
)

func main() {
exporter, err := otlp.NewExporter() // Configure as needed.
ctx := context.Background()
exporter, err := otlp.NewExporter(ctx) // Configure as needed.
if err != nil {
log.Fatalf("failed to create exporter: %v", err)
}
defer func() {
err := exporter.Stop()
err := exporter.Shutdown(ctx)
if err != nil {
log.Fatalf("failed to stop exporter: %v", err)
}
Expand All @@ -47,7 +51,8 @@ func main() {
// ),
// )
tracerProvider := sdktrace.NewTracerProvider(sdktrace.WithBatcher(exporter))
pusher := push.New(simple.NewWithInexpensiveDistribution(), exporter)
processor := processor.New(simple.NewWithInexpensiveDistribution(), metricsdk.StatelessExportKindSelector())
pusher := push.New(processor, exporter)
pusher.Start()
metricProvider := pusher.MeterProvider()

Expand Down

0 comments on commit 5ed96e9

Please sign in to comment.