Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update exporters/otlp Readme.md #1441

Merged
merged 1 commit into from
Jan 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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