From 5ed96e92446d2d58d131e0672da613a84c16af7a Mon Sep 17 00:00:00 2001 From: Eundoo Song Date: Fri, 8 Jan 2021 04:45:35 +0900 Subject: [PATCH] Update exporters/otlp Readme.md (#1441) --- exporters/otlp/README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/exporters/otlp/README.md b/exporters/otlp/README.md index 79dbd769b28..87b1d931965 100644 --- a/exporters/otlp/README.md +++ b/exporters/otlp/README.md @@ -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) } @@ -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()