From d8faeb9ee3beeacecdfb04887e75080e7e427147 Mon Sep 17 00:00:00 2001 From: Anthony J Mirabella Date: Mon, 14 Jun 2021 17:57:54 -0400 Subject: [PATCH] Split stdout exporter into stdouttrace and stdoutmetric Signed-off-by: Anthony J Mirabella --- .github/dependabot.yml | 12 +- CHANGELOG.md | 7 +- Makefile | 2 +- bridge/opencensus/go.mod | 6 +- bridge/opentracing/go.mod | 6 +- example/jaeger/go.mod | 6 +- example/namedtracer/go.mod | 7 +- example/namedtracer/go.sum | 2 - example/namedtracer/main.go | 6 +- example/opencensus/go.mod | 8 +- example/opencensus/main.go | 26 ++-- example/otel-collector/go.mod | 6 +- example/passthrough/go.mod | 7 +- example/passthrough/go.sum | 2 - example/passthrough/main.go | 6 +- example/prometheus/go.mod | 6 +- example/zipkin/go.mod | 6 +- exporters/jaeger/go.mod | 6 +- exporters/metric/prometheus/go.mod | 6 +- exporters/otlp/otlpmetric/go.mod | 6 +- .../otlp/otlpmetric/otlpmetricgrpc/go.mod | 6 +- exporters/otlp/otlptrace/go.mod | 6 +- exporters/otlp/otlptrace/otlptracegrpc/go.mod | 6 +- exporters/otlp/otlptrace/otlptracehttp/go.mod | 6 +- exporters/prometheus/go.mod | 6 +- exporters/stdout/go.mod | 77 --------- exporters/stdout/stdoutmetric/config.go | 146 ++++++++++++++++++ exporters/stdout/stdoutmetric/doc.go | 21 +++ .../stdout/{ => stdoutmetric}/example_test.go | 47 +----- .../stdout/{ => stdoutmetric}/exporter.go | 8 +- exporters/stdout/stdoutmetric/go.mod | 77 +++++++++ exporters/stdout/{ => stdoutmetric}/go.sum | 0 exporters/stdout/{ => stdoutmetric}/metric.go | 4 +- .../stdout/{ => stdoutmetric}/metric_test.go | 21 +-- exporters/stdout/{ => stdouttrace}/config.go | 4 +- exporters/stdout/{ => stdouttrace}/doc.go | 2 +- exporters/stdout/stdouttrace/example_test.go | 93 +++++++++++ exporters/stdout/stdouttrace/exporter.go | 38 +++++ exporters/stdout/stdouttrace/go.mod | 76 +++++++++ exporters/stdout/stdouttrace/go.sum | 15 ++ exporters/stdout/{ => stdouttrace}/trace.go | 2 +- .../stdout/{ => stdouttrace}/trace_test.go | 12 +- exporters/trace/jaeger/go.mod | 6 +- exporters/trace/zipkin/go.mod | 6 +- exporters/zipkin/go.mod | 6 +- go.mod | 6 +- internal/metric/go.mod | 6 +- internal/tools/go.mod | 6 +- metric/go.mod | 6 +- oteltest/go.mod | 6 +- sdk/export/metric/go.mod | 6 +- sdk/go.mod | 6 +- sdk/metric/go.mod | 6 +- trace/go.mod | 6 +- 54 files changed, 656 insertions(+), 228 deletions(-) delete mode 100644 exporters/stdout/go.mod create mode 100644 exporters/stdout/stdoutmetric/config.go create mode 100644 exporters/stdout/stdoutmetric/doc.go rename exporters/stdout/{ => stdoutmetric}/example_test.go (66%) rename exporters/stdout/{ => stdoutmetric}/exporter.go (78%) create mode 100644 exporters/stdout/stdoutmetric/go.mod rename exporters/stdout/{ => stdoutmetric}/go.sum (100%) rename exporters/stdout/{ => stdoutmetric}/metric.go (97%) rename exporters/stdout/{ => stdoutmetric}/metric_test.go (95%) rename exporters/stdout/{ => stdouttrace}/config.go (96%) rename exporters/stdout/{ => stdouttrace}/doc.go (92%) create mode 100644 exporters/stdout/stdouttrace/example_test.go create mode 100644 exporters/stdout/stdouttrace/exporter.go create mode 100644 exporters/stdout/stdouttrace/go.mod create mode 100644 exporters/stdout/stdouttrace/go.sum rename exporters/stdout/{ => stdouttrace}/trace.go (95%) rename exporters/stdout/{ => stdouttrace}/trace_test.go (95%) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index f669211cdf1..d68bbd3ff27 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -148,7 +148,17 @@ updates: interval: weekly - package-ecosystem: gomod - directory: /exporters/stdout + directory: /exporters/stdout/stdouttrace + labels: + - dependencies + - go + - "Skip Changelog" + schedule: + day: sunday + interval: weekly + - + package-ecosystem: gomod + directory: /exporters/stdout/stdoutmetric labels: - dependencies - go diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bef76628f6..b717cbcc4ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,7 +41,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Changes `go.opentelemetry.io/otel/sdk/resource.NewWithAttributes` to require a schema URL. The old function is still available as `resource.NewSchemaless`. This is a breaking change. (#1938) - Several builtin resource detectors now correctly populate the schema URL. (#1938) - Creates package `go.opentelemetry.io/otel/exporters/otlp/otlpmetric` that defines a metrics exporter that uses a `otlpmetric.Client` to send data. - Creates package `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc` implementing a gRPC `otlpmetric.Client` and offers convenience functions, `New` and `NewUnstarted`, to create an `otlpmetric.Exporter`.(#1991) +- Creates package `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc` implementing a gRPC `otlpmetric.Client` and offers convenience functions, `New` and `NewUnstarted`, to create an `otlpmetric.Exporter`.(#1991) +- Added `go.opentelemetry.io/otel/exporters/stdout/stdouttrace` exporter. (#2005) +- Added `go.opentelemetry.io/otel/exporters/stdout/stdoutmetric` exporter. (#2005) ### Changed @@ -109,10 +111,11 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - The `http.url` attribute generated by `HTTPClientAttributesFromHTTPRequest` will no longer include username or password information. (#1919) - The `IsEmpty` method of the `TraceState` type in the `go.opentelemetry.io/otel/trace` package is removed in favor of using the added `TraceState.Len` method. (#1931) - The `Set`, `Value`, `ContextWithValue`, `ContextWithoutValue`, and `ContextWithEmpty` functions in the `go.opentelemetry.io/otel/baggage` package are removed. - Handling of baggage is now done using the added `Baggage` type and related context functions (`ContextWithBaggage`, `ContextWithoutBaggage`, and `FromContext`) in that package. (TBD) + Handling of baggage is now done using the added `Baggage` type and related context functions (`ContextWithBaggage`, `ContextWithoutBaggage`, and `FromContext`) in that package. (#1967) - The `InstallNewPipeline` and `NewExportPipeline` creation functions in all the exporters (prometheus, otlp, stdout, jaeger, and zipkin) have been removed. These functions were deemed premature attempts to provide convenience that did not achieve this aim. (#1985) - The `go.opentelemetry.io/otel/exporters/otlp` exporter has been removed. Use `go.opentelemetry.io/otel/exporters/otlp/otlptrace` instead. (#1990) +- The `go.opentelemetry.io/otel/exporters/stdout` exporter has been removed. Use `go.opentelemetry.io/otel/exporters/stdout/stdouttrace` or `go.opentelemetry.io/otel/exporters/stdout/stdoutmetric` instead. (#2005) ### Fixed diff --git a/Makefile b/Makefile index 8d0452e4e49..7df5424e256 100644 --- a/Makefile +++ b/Makefile @@ -161,7 +161,7 @@ license-check: .PHONY: dependabot-check dependabot-check: @result=$$( \ - for f in $$( find . -type f -name go.mod -exec dirname {} \; | sed 's/^.\/\?/\//' ); \ + for f in $$( find . -type f -name go.mod -exec dirname {} \; | sed 's/^.//' ); \ do grep -q "directory: \+$$f" .github/dependabot.yml \ || echo "$$f"; \ done; \ diff --git a/bridge/opencensus/go.mod b/bridge/opencensus/go.mod index 531f3600fc5..66c57dcf73c 100644 --- a/bridge/opencensus/go.mod +++ b/bridge/opencensus/go.mod @@ -34,8 +34,6 @@ replace go.opentelemetry.io/otel/example/zipkin => ../../example/zipkin replace go.opentelemetry.io/otel/exporters/prometheus => ../../exporters/prometheus -replace go.opentelemetry.io/otel/exporters/stdout => ../../exporters/stdout - replace go.opentelemetry.io/otel/exporters/jaeger => ../../exporters/jaeger replace go.opentelemetry.io/otel/exporters/zipkin => ../../exporters/zipkin @@ -73,3 +71,7 @@ replace go.opentelemetry.io/otel/exporters/trace/zipkin => ../../exporters/trace replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric => ../../exporters/otlp/otlpmetric replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc => ../../exporters/otlp/otlpmetric/otlpmetricgrpc + +replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ../../exporters/stdout/stdoutmetric + +replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../../exporters/stdout/stdouttrace diff --git a/bridge/opentracing/go.mod b/bridge/opentracing/go.mod index 6cd04f079bc..329a5f03f80 100644 --- a/bridge/opentracing/go.mod +++ b/bridge/opentracing/go.mod @@ -30,8 +30,6 @@ replace go.opentelemetry.io/otel/example/zipkin => ../../example/zipkin replace go.opentelemetry.io/otel/exporters/prometheus => ../../exporters/prometheus -replace go.opentelemetry.io/otel/exporters/stdout => ../../exporters/stdout - replace go.opentelemetry.io/otel/exporters/jaeger => ../../exporters/jaeger replace go.opentelemetry.io/otel/exporters/zipkin => ../../exporters/zipkin @@ -69,3 +67,7 @@ replace go.opentelemetry.io/otel/exporters/trace/zipkin => ../../exporters/trace replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric => ../../exporters/otlp/otlpmetric replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc => ../../exporters/otlp/otlpmetric/otlpmetricgrpc + +replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ../../exporters/stdout/stdoutmetric + +replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../../exporters/stdout/stdouttrace diff --git a/example/jaeger/go.mod b/example/jaeger/go.mod index 84a2caae708..558aac074a6 100644 --- a/example/jaeger/go.mod +++ b/example/jaeger/go.mod @@ -34,8 +34,6 @@ replace go.opentelemetry.io/otel/example/zipkin => ../zipkin replace go.opentelemetry.io/otel/exporters/prometheus => ../../exporters/prometheus -replace go.opentelemetry.io/otel/exporters/stdout => ../../exporters/stdout - replace go.opentelemetry.io/otel/exporters/zipkin => ../../exporters/zipkin replace go.opentelemetry.io/otel/internal/tools => ../../internal/tools @@ -69,3 +67,7 @@ replace go.opentelemetry.io/otel/exporters/trace/zipkin => ../../exporters/trace replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric => ../../exporters/otlp/otlpmetric replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc => ../../exporters/otlp/otlpmetric/otlpmetricgrpc + +replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ../../exporters/stdout/stdoutmetric + +replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../../exporters/stdout/stdouttrace diff --git a/example/namedtracer/go.mod b/example/namedtracer/go.mod index 2fa0a080d6d..9e3de00bc5b 100644 --- a/example/namedtracer/go.mod +++ b/example/namedtracer/go.mod @@ -4,13 +4,12 @@ go 1.15 replace ( go.opentelemetry.io/otel => ../.. - go.opentelemetry.io/otel/exporters/stdout => ../../exporters/stdout go.opentelemetry.io/otel/sdk => ../../sdk ) require ( go.opentelemetry.io/otel v0.20.0 - go.opentelemetry.io/otel/exporters/stdout v0.20.0 + go.opentelemetry.io/otel/exporters/stdout/stdouttrace v0.20.0 go.opentelemetry.io/otel/sdk v0.20.0 go.opentelemetry.io/otel/trace v0.20.0 ) @@ -70,3 +69,7 @@ replace go.opentelemetry.io/otel/exporters/trace/zipkin => ../../exporters/trace replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric => ../../exporters/otlp/otlpmetric replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc => ../../exporters/otlp/otlpmetric/otlpmetricgrpc + +replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ../../exporters/stdout/stdoutmetric + +replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../../exporters/stdout/stdouttrace diff --git a/example/namedtracer/go.sum b/example/namedtracer/go.sum index bbe08ebba0e..f212493d586 100644 --- a/example/namedtracer/go.sum +++ b/example/namedtracer/go.sum @@ -1,5 +1,3 @@ -github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= -github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= diff --git a/example/namedtracer/main.go b/example/namedtracer/main.go index 830835904d9..ac96316c673 100644 --- a/example/namedtracer/main.go +++ b/example/namedtracer/main.go @@ -22,7 +22,7 @@ import ( "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/baggage" "go.opentelemetry.io/otel/example/namedtracer/foo" - "go.opentelemetry.io/otel/exporters/stdout" + "go.opentelemetry.io/otel/exporters/stdout/stdouttrace" sdktrace "go.opentelemetry.io/otel/sdk/trace" "go.opentelemetry.io/otel/trace" ) @@ -38,9 +38,9 @@ var tp *sdktrace.TracerProvider // initTracer creates and registers trace provider instance. func initTracer() { var err error - exp, err := stdout.New(stdout.WithPrettyPrint()) + exp, err := stdouttrace.New(stdouttrace.WithPrettyPrint()) if err != nil { - log.Panicf("failed to initialize stdout exporter %v\n", err) + log.Panicf("failed to initialize stdouttrace exporter %v\n", err) return } bsp := sdktrace.NewBatchSpanProcessor(exp) diff --git a/example/opencensus/go.mod b/example/opencensus/go.mod index 2c2311844f9..60de8857c49 100644 --- a/example/opencensus/go.mod +++ b/example/opencensus/go.mod @@ -5,7 +5,6 @@ go 1.15 replace ( go.opentelemetry.io/otel => ../.. go.opentelemetry.io/otel/bridge/opencensus => ../../bridge/opencensus - go.opentelemetry.io/otel/exporters/stdout => ../../exporters/stdout go.opentelemetry.io/otel/sdk => ../../sdk ) @@ -13,7 +12,8 @@ require ( go.opencensus.io v0.22.6-0.20201102222123-380f4078db9f go.opentelemetry.io/otel v0.20.0 go.opentelemetry.io/otel/bridge/opencensus v0.20.0 - go.opentelemetry.io/otel/exporters/stdout v0.20.0 + go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.20.0 + go.opentelemetry.io/otel/exporters/stdout/stdouttrace v0.20.0 go.opentelemetry.io/otel/sdk v0.20.0 go.opentelemetry.io/otel/sdk/export/metric v0.20.0 ) @@ -71,3 +71,7 @@ replace go.opentelemetry.io/otel/exporters/trace/zipkin => ../../exporters/trace replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric => ../../exporters/otlp/otlpmetric replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc => ../../exporters/otlp/otlpmetric/otlpmetricgrpc + +replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ../../exporters/stdout/stdoutmetric + +replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../../exporters/stdout/stdouttrace diff --git a/example/opencensus/main.go b/example/opencensus/main.go index 4ea5c68ef76..a99891ff0be 100644 --- a/example/opencensus/main.go +++ b/example/opencensus/main.go @@ -16,6 +16,7 @@ package main import ( "context" + "fmt" "log" "time" @@ -31,7 +32,8 @@ import ( "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/bridge/opencensus" - "go.opentelemetry.io/otel/exporters/stdout" + "go.opentelemetry.io/otel/exporters/stdout/stdoutmetric" + "go.opentelemetry.io/otel/exporters/stdout/stdouttrace" otmetricexport "go.opentelemetry.io/otel/sdk/export/metric" sdktrace "go.opentelemetry.io/otel/sdk/trace" ) @@ -51,13 +53,17 @@ var ( ) func main() { - log.Println("Using OpenTelemetry stdout exporter.") - otExporter, err := stdout.New(stdout.WithPrettyPrint()) + log.Println("Using OpenTelemetry stdout exporters.") + traceExporter, err := stdouttrace.New(stdouttrace.WithPrettyPrint()) if err != nil { - log.Fatal(err) + log.Fatal(fmt.Errorf("error creating trace exporter: %w", err)) } - tracing(otExporter) - monitoring(otExporter) + metricsExporter, err := stdoutmetric.New(stdoutmetric.WithPrettyPrint()) + if err != nil { + log.Fatal(fmt.Errorf("error creating metric exporter: %w", err)) + } + tracing(traceExporter) + monitoring(metricsExporter) } // tracing demonstrates overriding the OpenCensus DefaultTracer to send spans @@ -75,7 +81,7 @@ func tracing(otExporter sdktrace.SpanExporter) { tracer := tp.Tracer("simple") octrace.DefaultTracer = opencensus.NewTracer(tracer) - log.Println("Creating OpenCensus span, which should be printed out using the OpenTelemetry stdout exporter.\n-- It should have no parent, since it is the first span.") + log.Println("Creating OpenCensus span, which should be printed out using the OpenTelemetry stdouttrace exporter.\n-- It should have no parent, since it is the first span.") ctx, outerOCSpan := octrace.StartSpan(ctx, "OpenCensusOuterSpan") outerOCSpan.End() @@ -83,7 +89,7 @@ func tracing(otExporter sdktrace.SpanExporter) { ctx, otspan := tracer.Start(ctx, "OpenTelemetrySpan") otspan.End() - log.Println("Creating OpenCensus span, which should be printed out using the OpenTelemetry stdout exporter.\n-- It should have the OpenTelemetry span as a parent, since it was written using OpenTelemetry APIs") + log.Println("Creating OpenCensus span, which should be printed out using the OpenTelemetry stdouttrace exporter.\n-- It should have the OpenTelemetry span as a parent, since it was written using OpenTelemetry APIs") _, innerOCSpan := octrace.StartSpan(ctx, "OpenCensusInnerSpan") innerOCSpan.End() } @@ -92,14 +98,14 @@ func tracing(otExporter sdktrace.SpanExporter) { // exporter to send metrics to the exporter by using either an OpenCensus // registry or an OpenCensus view. func monitoring(otExporter otmetricexport.Exporter) { - log.Println("Using the OpenTelemetry stdout exporter to export OpenCensus metrics. This allows routing telemetry from both OpenTelemetry and OpenCensus to a single exporter.") + log.Println("Using the OpenTelemetry stdoutmetric exporter to export OpenCensus metrics. This allows routing telemetry from both OpenTelemetry and OpenCensus to a single exporter.") ocExporter := opencensus.NewMetricExporter(otExporter) intervalReader, err := metricexport.NewIntervalReader(&metricexport.Reader{}, ocExporter) if err != nil { log.Fatalf("Failed to create interval reader: %v\n", err) } intervalReader.ReportingInterval = 10 * time.Second - log.Println("Emitting metrics using OpenCensus APIs. These should be printed out using the OpenTelemetry stdout exporter.") + log.Println("Emitting metrics using OpenCensus APIs. These should be printed out using the OpenTelemetry stdoutmetric exporter.") err = intervalReader.Start() if err != nil { log.Fatalf("Failed to start interval reader: %v\n", err) diff --git a/example/otel-collector/go.mod b/example/otel-collector/go.mod index 9c290ee23bd..4dd9b0cc74d 100644 --- a/example/otel-collector/go.mod +++ b/example/otel-collector/go.mod @@ -35,8 +35,6 @@ replace go.opentelemetry.io/otel/example/zipkin => ../zipkin replace go.opentelemetry.io/otel/exporters/prometheus => ../../exporters/prometheus -replace go.opentelemetry.io/otel/exporters/stdout => ../../exporters/stdout - replace go.opentelemetry.io/otel/exporters/jaeger => ../../exporters/jaeger replace go.opentelemetry.io/otel/exporters/zipkin => ../../exporters/zipkin @@ -72,3 +70,7 @@ replace go.opentelemetry.io/otel/exporters/trace/zipkin => ../../exporters/trace replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric => ../../exporters/otlp/otlpmetric replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc => ../../exporters/otlp/otlpmetric/otlpmetricgrpc + +replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ../../exporters/stdout/stdoutmetric + +replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../../exporters/stdout/stdouttrace diff --git a/example/passthrough/go.mod b/example/passthrough/go.mod index 2610e394aff..831dd00b15c 100644 --- a/example/passthrough/go.mod +++ b/example/passthrough/go.mod @@ -4,14 +4,13 @@ go 1.15 require ( go.opentelemetry.io/otel v0.20.0 - go.opentelemetry.io/otel/exporters/stdout v0.20.0 + go.opentelemetry.io/otel/exporters/stdout/stdouttrace v0.20.0 go.opentelemetry.io/otel/sdk v0.20.0 go.opentelemetry.io/otel/trace v0.20.0 ) replace ( go.opentelemetry.io/otel => ../.. - go.opentelemetry.io/otel/exporters/stdout => ../../exporters/stdout go.opentelemetry.io/otel/sdk => ../../sdk go.opentelemetry.io/otel/trace => ../../trace ) @@ -71,3 +70,7 @@ replace go.opentelemetry.io/otel/exporters/trace/zipkin => ../../exporters/trace replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric => ../../exporters/otlp/otlpmetric replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc => ../../exporters/otlp/otlpmetric/otlpmetricgrpc + +replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ../../exporters/stdout/stdoutmetric + +replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../../exporters/stdout/stdouttrace diff --git a/example/passthrough/go.sum b/example/passthrough/go.sum index bbe08ebba0e..f212493d586 100644 --- a/example/passthrough/go.sum +++ b/example/passthrough/go.sum @@ -1,5 +1,3 @@ -github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= -github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= diff --git a/example/passthrough/main.go b/example/passthrough/main.go index 69a6cae2526..0d5a2d98322 100644 --- a/example/passthrough/main.go +++ b/example/passthrough/main.go @@ -22,7 +22,7 @@ import ( "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/example/passthrough/handler" - "go.opentelemetry.io/otel/exporters/stdout" + "go.opentelemetry.io/otel/exporters/stdout/stdouttrace" "go.opentelemetry.io/otel/propagation" sdktrace "go.opentelemetry.io/otel/sdk/trace" "go.opentelemetry.io/otel/trace" @@ -76,9 +76,9 @@ func initPassthroughGlobals() { // set it as the global tracer provider func nonGlobalTracer() *sdktrace.TracerProvider { var err error - exp, err := stdout.New(stdout.WithPrettyPrint()) + exp, err := stdouttrace.New(stdouttrace.WithPrettyPrint()) if err != nil { - log.Panicf("failed to initialize stdout exporter %v\n", err) + log.Panicf("failed to initialize stdouttrace exporter %v\n", err) } bsp := sdktrace.NewBatchSpanProcessor(exp) tp := sdktrace.NewTracerProvider( diff --git a/example/prometheus/go.mod b/example/prometheus/go.mod index d463bbb8070..f950de8c9e1 100644 --- a/example/prometheus/go.mod +++ b/example/prometheus/go.mod @@ -34,8 +34,6 @@ replace go.opentelemetry.io/otel/example/prometheus => ./ replace go.opentelemetry.io/otel/example/zipkin => ../zipkin -replace go.opentelemetry.io/otel/exporters/stdout => ../../exporters/stdout - replace go.opentelemetry.io/otel/exporters/jaeger => ../../exporters/jaeger replace go.opentelemetry.io/otel/exporters/zipkin => ../../exporters/zipkin @@ -71,3 +69,7 @@ replace go.opentelemetry.io/otel/exporters/trace/zipkin => ../../exporters/trace replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric => ../../exporters/otlp/otlpmetric replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc => ../../exporters/otlp/otlpmetric/otlpmetricgrpc + +replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ../../exporters/stdout/stdoutmetric + +replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../../exporters/stdout/stdouttrace diff --git a/example/zipkin/go.mod b/example/zipkin/go.mod index 9908a81d2f4..8c855c46a69 100644 --- a/example/zipkin/go.mod +++ b/example/zipkin/go.mod @@ -35,8 +35,6 @@ replace go.opentelemetry.io/otel/example/zipkin => ./ replace go.opentelemetry.io/otel/exporters/prometheus => ../../exporters/prometheus -replace go.opentelemetry.io/otel/exporters/stdout => ../../exporters/stdout - replace go.opentelemetry.io/otel/exporters/jaeger => ../../exporters/jaeger replace go.opentelemetry.io/otel/internal/tools => ../../internal/tools @@ -70,3 +68,7 @@ replace go.opentelemetry.io/otel/exporters/trace/zipkin => ../../exporters/trace replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric => ../../exporters/otlp/otlpmetric replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc => ../../exporters/otlp/otlpmetric/otlpmetricgrpc + +replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ../../exporters/stdout/stdoutmetric + +replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../../exporters/stdout/stdouttrace diff --git a/exporters/jaeger/go.mod b/exporters/jaeger/go.mod index 37d3da62047..1acc86dc572 100644 --- a/exporters/jaeger/go.mod +++ b/exporters/jaeger/go.mod @@ -32,8 +32,6 @@ replace go.opentelemetry.io/otel/exporters/prometheus => ../prometheus replace go.opentelemetry.io/otel/exporters/otlp => ../otlp -replace go.opentelemetry.io/otel/exporters/stdout => ../stdout - replace go.opentelemetry.io/otel/exporters/jaeger => ./ replace go.opentelemetry.io/otel/internal/tools => ../../internal/tools @@ -73,3 +71,7 @@ replace go.opentelemetry.io/otel/exporters/trace/zipkin => ../trace/zipkin replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric => ../otlp/otlpmetric replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc => ../otlp/otlpmetric/otlpmetricgrpc + +replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ../stdout/stdoutmetric + +replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../stdout/stdouttrace diff --git a/exporters/metric/prometheus/go.mod b/exporters/metric/prometheus/go.mod index b8d7a9ba60b..2cb5bec4400 100644 --- a/exporters/metric/prometheus/go.mod +++ b/exporters/metric/prometheus/go.mod @@ -37,8 +37,6 @@ replace go.opentelemetry.io/otel/example/zipkin => ../../../example/zipkin replace go.opentelemetry.io/otel/exporters/metric/prometheus => ./ -replace go.opentelemetry.io/otel/exporters/stdout => ../../stdout - replace go.opentelemetry.io/otel/exporters/trace/jaeger => ../../trace/jaeger replace go.opentelemetry.io/otel/exporters/trace/zipkin => ../../trace/zipkin @@ -74,3 +72,7 @@ replace go.opentelemetry.io/otel/exporters/zipkin => ../../zipkin replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric => ../../otlp/otlpmetric replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc => ../../otlp/otlpmetric/otlpmetricgrpc + +replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ../../stdout/stdoutmetric + +replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../../stdout/stdouttrace diff --git a/exporters/otlp/otlpmetric/go.mod b/exporters/otlp/otlpmetric/go.mod index 6a7a17076b0..27f15d0246e 100644 --- a/exporters/otlp/otlpmetric/go.mod +++ b/exporters/otlp/otlpmetric/go.mod @@ -64,8 +64,6 @@ replace go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc => ../ot replace go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp => ../otlptrace/otlptracehttp -replace go.opentelemetry.io/otel/exporters/stdout => ../../stdout - replace go.opentelemetry.io/otel/exporters/trace/jaeger => ../../trace/jaeger replace go.opentelemetry.io/otel/exporters/trace/zipkin => ../../trace/zipkin @@ -79,3 +77,7 @@ replace go.opentelemetry.io/otel/exporters/jaeger => ../../jaeger replace go.opentelemetry.io/otel/exporters/prometheus => ../../prometheus replace go.opentelemetry.io/otel/exporters/zipkin => ../../zipkin + +replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ../../stdout/stdoutmetric + +replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../../stdout/stdouttrace diff --git a/exporters/otlp/otlpmetric/otlpmetricgrpc/go.mod b/exporters/otlp/otlpmetric/otlpmetricgrpc/go.mod index 160ea4f4006..10dd0a12d8e 100644 --- a/exporters/otlp/otlpmetric/otlpmetricgrpc/go.mod +++ b/exporters/otlp/otlpmetric/otlpmetricgrpc/go.mod @@ -60,8 +60,6 @@ replace go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc => ../.. replace go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp => ../../otlptrace/otlptracehttp -replace go.opentelemetry.io/otel/exporters/stdout => ../../../stdout - replace go.opentelemetry.io/otel/exporters/trace/jaeger => ../../../trace/jaeger replace go.opentelemetry.io/otel/exporters/trace/zipkin => ../../../trace/zipkin @@ -77,3 +75,7 @@ replace go.opentelemetry.io/otel/exporters/jaeger => ../../../jaeger replace go.opentelemetry.io/otel/exporters/prometheus => ../../../prometheus replace go.opentelemetry.io/otel/exporters/zipkin => ../../../zipkin + +replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ../../../stdout/stdoutmetric + +replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../../../stdout/stdouttrace diff --git a/exporters/otlp/otlptrace/go.mod b/exporters/otlp/otlptrace/go.mod index da66f4480e1..0a6f59339c1 100644 --- a/exporters/otlp/otlptrace/go.mod +++ b/exporters/otlp/otlptrace/go.mod @@ -50,8 +50,6 @@ replace go.opentelemetry.io/otel/exporters/otlp/otlptrace => ./ replace go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc => ./otlptracegrpc -replace go.opentelemetry.io/otel/exporters/stdout => ../../stdout - replace go.opentelemetry.io/otel/exporters/jaeger => ../../jaeger replace go.opentelemetry.io/otel/exporters/zipkin => ../../zipkin @@ -77,3 +75,7 @@ replace go.opentelemetry.io/otel/exporters/trace/zipkin => ../../trace/zipkin replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric => ../otlpmetric replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc => ../otlpmetric/otlpmetricgrpc + +replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ../../stdout/stdoutmetric + +replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../../stdout/stdouttrace diff --git a/exporters/otlp/otlptrace/otlptracegrpc/go.mod b/exporters/otlp/otlptrace/otlptracegrpc/go.mod index f459c086c46..453a30d9ed4 100644 --- a/exporters/otlp/otlptrace/otlptracegrpc/go.mod +++ b/exporters/otlp/otlptrace/otlptracegrpc/go.mod @@ -47,8 +47,6 @@ replace go.opentelemetry.io/otel/exporters/prometheus => ../../../prometheus replace go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc => ./ -replace go.opentelemetry.io/otel/exporters/stdout => ../../../stdout - replace go.opentelemetry.io/otel/exporters/jaeger => ../../../jaeger replace go.opentelemetry.io/otel/exporters/zipkin => ../../../zipkin @@ -74,3 +72,7 @@ replace go.opentelemetry.io/otel/exporters/trace/zipkin => ../../../trace/zipkin replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric => ../../otlpmetric replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc => ../../otlpmetric/otlpmetricgrpc + +replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ../../../stdout/stdoutmetric + +replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../../../stdout/stdouttrace diff --git a/exporters/otlp/otlptrace/otlptracehttp/go.mod b/exporters/otlp/otlptrace/otlptracehttp/go.mod index 7fa389ca726..872d39f11ed 100644 --- a/exporters/otlp/otlptrace/otlptracehttp/go.mod +++ b/exporters/otlp/otlptrace/otlptracehttp/go.mod @@ -40,8 +40,6 @@ replace go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc => ../ot replace go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp => ./ -replace go.opentelemetry.io/otel/exporters/stdout => ../../../stdout - replace go.opentelemetry.io/otel/exporters/jaeger => ../../../jaeger replace go.opentelemetry.io/otel/exporters/zipkin => ../../../zipkin @@ -71,3 +69,7 @@ replace go.opentelemetry.io/otel/exporters/trace/zipkin => ../../../trace/zipkin replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric => ../../otlpmetric replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc => ../../otlpmetric/otlpmetricgrpc + +replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ../../../stdout/stdoutmetric + +replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../../../stdout/stdouttrace diff --git a/exporters/prometheus/go.mod b/exporters/prometheus/go.mod index 318ad952d4c..70b9f1b170b 100644 --- a/exporters/prometheus/go.mod +++ b/exporters/prometheus/go.mod @@ -44,8 +44,6 @@ replace go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp => ../ot replace go.opentelemetry.io/otel/exporters/prometheus => ./ -replace go.opentelemetry.io/otel/exporters/stdout => ../stdout - replace go.opentelemetry.io/otel/exporters/jaeger => ../jaeger replace go.opentelemetry.io/otel/exporters/zipkin => ../zipkin @@ -75,3 +73,7 @@ replace go.opentelemetry.io/otel/exporters/trace/zipkin => ../trace/zipkin replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric => ../otlp/otlpmetric replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc => ../otlp/otlpmetric/otlpmetricgrpc + +replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ../stdout/stdoutmetric + +replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../stdout/stdouttrace diff --git a/exporters/stdout/go.mod b/exporters/stdout/go.mod deleted file mode 100644 index 90202e86ba1..00000000000 --- a/exporters/stdout/go.mod +++ /dev/null @@ -1,77 +0,0 @@ -module go.opentelemetry.io/otel/exporters/stdout - -go 1.15 - -replace ( - go.opentelemetry.io/otel => ../.. - go.opentelemetry.io/otel/sdk => ../../sdk -) - -require ( - github.com/stretchr/testify v1.7.0 - go.opentelemetry.io/otel v0.20.0 - go.opentelemetry.io/otel/metric v0.20.0 - go.opentelemetry.io/otel/oteltest v0.20.0 - go.opentelemetry.io/otel/sdk v0.20.0 - go.opentelemetry.io/otel/sdk/export/metric v0.20.0 - go.opentelemetry.io/otel/sdk/metric v0.20.0 - go.opentelemetry.io/otel/trace v0.20.0 -) - -replace go.opentelemetry.io/otel/bridge/opencensus => ../../bridge/opencensus - -replace go.opentelemetry.io/otel/bridge/opentracing => ../../bridge/opentracing - -replace go.opentelemetry.io/otel/example/jaeger => ../../example/jaeger - -replace go.opentelemetry.io/otel/example/namedtracer => ../../example/namedtracer - -replace go.opentelemetry.io/otel/example/opencensus => ../../example/opencensus - -replace go.opentelemetry.io/otel/example/otel-collector => ../../example/otel-collector - -replace go.opentelemetry.io/otel/example/prom-collector => ../../example/prom-collector - -replace go.opentelemetry.io/otel/example/prometheus => ../../example/prometheus - -replace go.opentelemetry.io/otel/example/zipkin => ../../example/zipkin - -replace go.opentelemetry.io/otel/exporters/prometheus => ../prometheus - -replace go.opentelemetry.io/otel/exporters/stdout => ./ - -replace go.opentelemetry.io/otel/exporters/jaeger => ../jaeger - -replace go.opentelemetry.io/otel/exporters/zipkin => ../zipkin - -replace go.opentelemetry.io/otel/internal/tools => ../../internal/tools - -replace go.opentelemetry.io/otel/metric => ../../metric - -replace go.opentelemetry.io/otel/oteltest => ../../oteltest - -replace go.opentelemetry.io/otel/sdk/export/metric => ../../sdk/export/metric - -replace go.opentelemetry.io/otel/sdk/metric => ../../sdk/metric - -replace go.opentelemetry.io/otel/trace => ../../trace - -replace go.opentelemetry.io/otel/example/passthrough => ../../example/passthrough - -replace go.opentelemetry.io/otel/exporters/otlp/otlptrace => ../otlp/otlptrace - -replace go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc => ../otlp/otlptrace/otlptracegrpc - -replace go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp => ../otlp/otlptrace/otlptracehttp - -replace go.opentelemetry.io/otel/internal/metric => ../../internal/metric - -replace go.opentelemetry.io/otel/exporters/metric/prometheus => ../metric/prometheus - -replace go.opentelemetry.io/otel/exporters/trace/jaeger => ../trace/jaeger - -replace go.opentelemetry.io/otel/exporters/trace/zipkin => ../trace/zipkin - -replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric => ../otlp/otlpmetric - -replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc => ../otlp/otlpmetric/otlpmetricgrpc diff --git a/exporters/stdout/stdoutmetric/config.go b/exporters/stdout/stdoutmetric/config.go new file mode 100644 index 00000000000..d0f8917cc78 --- /dev/null +++ b/exporters/stdout/stdoutmetric/config.go @@ -0,0 +1,146 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package stdoutmetric // import "go.opentelemetry.io/otel/exporters/stdoutmetric" + +import ( + "io" + "os" + + "go.opentelemetry.io/otel/attribute" +) + +var ( + defaultWriter = os.Stdout + defaultPrettyPrint = false + defaultTimestamps = true + defaultLabelEncoder = attribute.DefaultEncoder() + defaultDisableTraceExport = false + defaultDisableMetricExport = false +) + +// config contains options for the STDOUT exporter. +type config struct { + // Writer is the destination. If not set, os.Stdout is used. + Writer io.Writer + + // PrettyPrint will encode the output into readable JSON. Default is + // false. + PrettyPrint bool + + // Timestamps specifies if timestamps should be printed. Default is + // true. + Timestamps bool + + // LabelEncoder encodes the labels. + LabelEncoder attribute.Encoder + + // DisableTraceExport prevents any export of trace telemetry. + DisableTraceExport bool + + // DisableMetricExport prevents any export of metric telemetry. + DisableMetricExport bool +} + +// newConfig creates a validated Config configured with options. +func newConfig(options ...Option) (config, error) { + cfg := config{ + Writer: defaultWriter, + PrettyPrint: defaultPrettyPrint, + Timestamps: defaultTimestamps, + LabelEncoder: defaultLabelEncoder, + DisableTraceExport: defaultDisableTraceExport, + DisableMetricExport: defaultDisableMetricExport, + } + for _, opt := range options { + opt.apply(&cfg) + + } + return cfg, nil +} + +// Option sets the value of an option for a Config. +type Option interface { + apply(*config) +} + +// WithWriter sets the export stream destination. +func WithWriter(w io.Writer) Option { + return writerOption{w} +} + +type writerOption struct { + W io.Writer +} + +func (o writerOption) apply(cfg *config) { + cfg.Writer = o.W +} + +// WithPrettyPrint sets the export stream format to use JSON. +func WithPrettyPrint() Option { + return prettyPrintOption(true) +} + +type prettyPrintOption bool + +func (o prettyPrintOption) apply(cfg *config) { + cfg.PrettyPrint = bool(o) +} + +// WithoutTimestamps sets the export stream to not include timestamps. +func WithoutTimestamps() Option { + return timestampsOption(false) +} + +type timestampsOption bool + +func (o timestampsOption) apply(cfg *config) { + cfg.Timestamps = bool(o) +} + +// WithLabelEncoder sets the label encoder used in export. +func WithLabelEncoder(enc attribute.Encoder) Option { + return labelEncoderOption{enc} +} + +type labelEncoderOption struct { + LabelEncoder attribute.Encoder +} + +func (o labelEncoderOption) apply(cfg *config) { + cfg.LabelEncoder = o.LabelEncoder +} + +// WithoutTraceExport disables all trace exporting. +func WithoutTraceExport() Option { + return disableTraceExportOption(true) +} + +type disableTraceExportOption bool + +func (o disableTraceExportOption) apply(cfg *config) { + cfg.DisableTraceExport = bool(o) +} + +// WithoutMetricExport disables all metric exporting. +func WithoutMetricExport() Option { + return disableMetricExportOption(true) +} + +type disableMetricExportOption bool + +func (o disableMetricExportOption) apply(cfg *config) { + cfg.DisableMetricExport = bool(o) +} diff --git a/exporters/stdout/stdoutmetric/doc.go b/exporters/stdout/stdoutmetric/doc.go new file mode 100644 index 00000000000..d78573c2cd5 --- /dev/null +++ b/exporters/stdout/stdoutmetric/doc.go @@ -0,0 +1,21 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package stdout contains an OpenTelemetry exporter for both tracing and +// metric telemetry to be written to an output destination as JSON. +// +// This package is currently in a pre-GA phase. Backwards incompatible changes +// may be introduced in subsequent minor version releases as we work to track +// the evolving OpenTelemetry specification and user feedback. +package stdoutmetric // import "go.opentelemetry.io/otel/exporters/stdoutmetric" diff --git a/exporters/stdout/example_test.go b/exporters/stdout/stdoutmetric/example_test.go similarity index 66% rename from exporters/stdout/example_test.go rename to exporters/stdout/stdoutmetric/example_test.go index d9a7c59de56..7107b9fce66 100644 --- a/exporters/stdout/example_test.go +++ b/exporters/stdout/stdoutmetric/example_test.go @@ -12,24 +12,20 @@ // See the License for the specific language governing permissions and // limitations under the License. -package stdout_test +package stdoutmetric_test import ( "context" "log" - "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/exporters/stdout/stdoutmetric" + "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/exporters/stdout" "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/metric/global" controller "go.opentelemetry.io/otel/sdk/metric/controller/basic" processor "go.opentelemetry.io/otel/sdk/metric/processor/basic" "go.opentelemetry.io/otel/sdk/metric/selector/simple" - "go.opentelemetry.io/otel/sdk/resource" - sdktrace "go.opentelemetry.io/otel/sdk/trace" - semconv "go.opentelemetry.io/otel/semconv/v1.4.0" - "go.opentelemetry.io/otel/trace" ) const ( @@ -38,12 +34,6 @@ const ( ) var ( - tracer = otel.GetTracerProvider().Tracer( - instrumentationName, - trace.WithInstrumentationVersion(instrumentationVersion), - trace.WithSchemaURL("https://opentelemetry.io/schemas/1.2.0"), - ) - meter = global.GetMeterProvider().Meter( instrumentationName, metric.WithInstrumentationVersion(instrumentationVersion), @@ -58,10 +48,6 @@ var ( func add(ctx context.Context, x, y int64) int64 { nameKV := nameKey.String("add") - var span trace.Span - ctx, span = tracer.Start(ctx, "Addition") - defer span.End() - loopCounter.Add(ctx, 1, nameKV) paramValue.Record(ctx, x, nameKV) paramValue.Record(ctx, y, nameKV) @@ -72,10 +58,6 @@ func add(ctx context.Context, x, y int64) int64 { func multiply(ctx context.Context, x, y int64) int64 { nameKV := nameKey.String("multiply") - var span trace.Span - ctx, span = tracer.Start(ctx, "Multiplication") - defer span.End() - loopCounter.Add(ctx, 1, nameKV) paramValue.Record(ctx, x, nameKV) paramValue.Record(ctx, y, nameKV) @@ -83,26 +65,12 @@ func multiply(ctx context.Context, x, y int64) int64 { return x * y } -func Resource() *resource.Resource { - return resource.NewWithAttributes( - semconv.SchemaURL, - semconv.ServiceNameKey.String("stdout-example"), - semconv.ServiceVersionKey.String("0.0.1"), - ) -} - func InstallExportPipeline(ctx context.Context) func() { - exporter, err := stdout.New(stdout.WithPrettyPrint()) + exporter, err := stdoutmetric.New(stdoutmetric.WithPrettyPrint()) if err != nil { - log.Fatalf("creating stdout exporter: %v", err) + log.Fatalf("creating stdoutmetric exporter: %v", err) } - tracerProvider := sdktrace.NewTracerProvider( - sdktrace.WithBatcher(exporter), - sdktrace.WithResource(Resource()), - ) - otel.SetTracerProvider(tracerProvider) - pusher := controller.New( processor.New( simple.NewWithInexpensiveDistribution(), @@ -119,16 +87,13 @@ func InstallExportPipeline(ctx context.Context) func() { if err := pusher.Stop(ctx); err != nil { log.Fatalf("stopping push controller: %v", err) } - if err := tracerProvider.Shutdown(ctx); err != nil { - log.Fatalf("stopping tracer provider: %v", err) - } } } func Example() { ctx := context.Background() - // Registers both a tracer and meter Provider globally. + // Registers a meter Provider globally. cleanup := InstallExportPipeline(ctx) defer cleanup() diff --git a/exporters/stdout/exporter.go b/exporters/stdout/stdoutmetric/exporter.go similarity index 78% rename from exporters/stdout/exporter.go rename to exporters/stdout/stdoutmetric/exporter.go index b47106d86db..2c8fbd17e80 100644 --- a/exporters/stdout/exporter.go +++ b/exporters/stdout/stdoutmetric/exporter.go @@ -12,21 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. -package stdout // import "go.opentelemetry.io/otel/exporters/stdout" +package stdoutmetric // import "go.opentelemetry.io/otel/exporters/stdoutmetric" import ( "go.opentelemetry.io/otel/sdk/export/metric" - sdktrace "go.opentelemetry.io/otel/sdk/trace" ) type Exporter struct { - traceExporter metricExporter } var ( - _ metric.Exporter = &Exporter{} - _ sdktrace.SpanExporter = &Exporter{} + _ metric.Exporter = &Exporter{} ) // New creates an Exporter with the passed options. @@ -36,7 +33,6 @@ func New(options ...Option) (*Exporter, error) { return nil, err } return &Exporter{ - traceExporter: traceExporter{config: cfg}, metricExporter: metricExporter{cfg}, }, nil } diff --git a/exporters/stdout/stdoutmetric/go.mod b/exporters/stdout/stdoutmetric/go.mod new file mode 100644 index 00000000000..547f746642c --- /dev/null +++ b/exporters/stdout/stdoutmetric/go.mod @@ -0,0 +1,77 @@ +module go.opentelemetry.io/otel/exporters/stdout/stdoutmetric + +go 1.15 + +replace ( + go.opentelemetry.io/otel => ../../.. + go.opentelemetry.io/otel/sdk => ../../../sdk +) + +require ( + github.com/stretchr/testify v1.7.0 + go.opentelemetry.io/otel v0.20.0 + go.opentelemetry.io/otel/metric v0.20.0 + go.opentelemetry.io/otel/sdk v0.20.0 + go.opentelemetry.io/otel/sdk/export/metric v0.20.0 + go.opentelemetry.io/otel/sdk/metric v0.20.0 +) + +replace go.opentelemetry.io/otel/bridge/opencensus => ../../../bridge/opencensus + +replace go.opentelemetry.io/otel/bridge/opentracing => ../../../bridge/opentracing + +replace go.opentelemetry.io/otel/example/jaeger => ../../../example/jaeger + +replace go.opentelemetry.io/otel/example/namedtracer => ../../../example/namedtracer + +replace go.opentelemetry.io/otel/example/opencensus => ../../../example/opencensus + +replace go.opentelemetry.io/otel/example/otel-collector => ../../../example/otel-collector + +replace go.opentelemetry.io/otel/example/prom-collector => ../../example/prom-collector + +replace go.opentelemetry.io/otel/example/prometheus => ../../../example/prometheus + +replace go.opentelemetry.io/otel/example/zipkin => ../../../example/zipkin + +replace go.opentelemetry.io/otel/exporters/prometheus => ../../prometheus + +replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ./ + +replace go.opentelemetry.io/otel/exporters/jaeger => ../../jaeger + +replace go.opentelemetry.io/otel/exporters/zipkin => ../../zipkin + +replace go.opentelemetry.io/otel/internal/tools => ../../../internal/tools + +replace go.opentelemetry.io/otel/metric => ../../../metric + +replace go.opentelemetry.io/otel/oteltest => ../../../oteltest + +replace go.opentelemetry.io/otel/sdk/export/metric => ../../../sdk/export/metric + +replace go.opentelemetry.io/otel/sdk/metric => ../../../sdk/metric + +replace go.opentelemetry.io/otel/trace => ../../../trace + +replace go.opentelemetry.io/otel/example/passthrough => ../../../example/passthrough + +replace go.opentelemetry.io/otel/exporters/otlp/otlptrace => ../../otlp/otlptrace + +replace go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc => ../../otlp/otlptrace/otlptracegrpc + +replace go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp => ../../otlp/otlptrace/otlptracehttp + +replace go.opentelemetry.io/otel/internal/metric => ../../../internal/metric + +replace go.opentelemetry.io/otel/exporters/metric/prometheus => ../../metric/prometheus + +replace go.opentelemetry.io/otel/exporters/trace/jaeger => ../../trace/jaeger + +replace go.opentelemetry.io/otel/exporters/trace/zipkin => ../../trace/zipkin + +replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric => ../../otlp/otlpmetric + +replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc => ../../otlp/otlpmetric/otlpmetricgrpc + +replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../stdouttrace diff --git a/exporters/stdout/go.sum b/exporters/stdout/stdoutmetric/go.sum similarity index 100% rename from exporters/stdout/go.sum rename to exporters/stdout/stdoutmetric/go.sum diff --git a/exporters/stdout/metric.go b/exporters/stdout/stdoutmetric/metric.go similarity index 97% rename from exporters/stdout/metric.go rename to exporters/stdout/stdoutmetric/metric.go index ae20f1d61db..290120a6787 100644 --- a/exporters/stdout/metric.go +++ b/exporters/stdout/stdoutmetric/metric.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package stdout // import "go.opentelemetry.io/otel/exporters/stdout" +package stdoutmetric // import "go.opentelemetry.io/otel/exporters/stdoutmetric" import ( "context" @@ -153,7 +153,7 @@ func (e *metricExporter) Export(_ context.Context, checkpointSet exportmetric.Ch return aggError } -// marshal v with approriate indentation. +// marshal v with appropriate indentation. func (e *metricExporter) marshal(v interface{}) ([]byte, error) { if e.config.PrettyPrint { return json.MarshalIndent(v, "", "\t") diff --git a/exporters/stdout/metric_test.go b/exporters/stdout/stdoutmetric/metric_test.go similarity index 95% rename from exporters/stdout/metric_test.go rename to exporters/stdout/stdoutmetric/metric_test.go index c385f4f27fc..a2200f149ac 100644 --- a/exporters/stdout/metric_test.go +++ b/exporters/stdout/stdoutmetric/metric_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package stdout_test +package stdoutmetric_test import ( "bytes" @@ -23,11 +23,12 @@ import ( "testing" "time" + "go.opentelemetry.io/otel/exporters/stdout/stdoutmetric" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/exporters/stdout" "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/metric/number" export "go.opentelemetry.io/otel/sdk/export/metric" @@ -42,17 +43,17 @@ import ( type testFixture struct { t *testing.T ctx context.Context - exporter *stdout.Exporter + exporter *stdoutmetric.Exporter output *bytes.Buffer } var testResource = resource.NewSchemaless(attribute.String("R", "V")) -func newFixture(t *testing.T, opts ...stdout.Option) testFixture { +func newFixture(t *testing.T, opts ...stdoutmetric.Option) testFixture { buf := &bytes.Buffer{} - opts = append(opts, stdout.WithWriter(buf)) - opts = append(opts, stdout.WithoutTimestamps()) - exp, err := stdout.New(opts...) + opts = append(opts, stdoutmetric.WithWriter(buf)) + opts = append(opts, stdoutmetric.WithoutTimestamps()) + exp, err := stdoutmetric.New(opts...) if err != nil { t.Fatal("Error building fixture: ", err) } @@ -77,8 +78,8 @@ func (fix testFixture) Export(checkpointSet export.CheckpointSet) { func TestStdoutTimestamp(t *testing.T) { var buf bytes.Buffer - exporter, err := stdout.New( - stdout.WithWriter(&buf), + exporter, err := stdoutmetric.New( + stdoutmetric.WithWriter(&buf), ) if err != nil { t.Fatal("Invalid config: ", err) @@ -185,7 +186,7 @@ func TestStdoutMinMaxSumCount(t *testing.T) { } func TestStdoutValueRecorderFormat(t *testing.T) { - fix := newFixture(t, stdout.WithPrettyPrint()) + fix := newFixture(t, stdoutmetric.WithPrettyPrint()) checkpointSet := metrictest.NewCheckpointSet(testResource) diff --git a/exporters/stdout/config.go b/exporters/stdout/stdouttrace/config.go similarity index 96% rename from exporters/stdout/config.go rename to exporters/stdout/stdouttrace/config.go index f434f47cf51..a830fe5483c 100644 --- a/exporters/stdout/config.go +++ b/exporters/stdout/stdouttrace/config.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package stdout // import "go.opentelemetry.io/otel/exporters/stdout" +package stdouttrace // import "go.opentelemetry.io/otel/exporters/stdouttrace" import ( "io" @@ -39,7 +39,7 @@ type config struct { // false. PrettyPrint bool - // Timestamps specifies if timestamps should be pritted. Default is + // Timestamps specifies if timestamps should be printed. Default is // true. Timestamps bool diff --git a/exporters/stdout/doc.go b/exporters/stdout/stdouttrace/doc.go similarity index 92% rename from exporters/stdout/doc.go rename to exporters/stdout/stdouttrace/doc.go index 0f6c96c5f57..a46cf968ae8 100644 --- a/exporters/stdout/doc.go +++ b/exporters/stdout/stdouttrace/doc.go @@ -18,4 +18,4 @@ // This package is currently in a pre-GA phase. Backwards incompatible changes // may be introduced in subsequent minor version releases as we work to track // the evolving OpenTelemetry specification and user feedback. -package stdout // import "go.opentelemetry.io/otel/exporters/stdout" +package stdouttrace // import "go.opentelemetry.io/otel/exporters/stdouttrace" diff --git a/exporters/stdout/stdouttrace/example_test.go b/exporters/stdout/stdouttrace/example_test.go new file mode 100644 index 00000000000..64bcab28d8c --- /dev/null +++ b/exporters/stdout/stdouttrace/example_test.go @@ -0,0 +1,93 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package stdouttrace_test + +import ( + "context" + "log" + + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/exporters/stdout/stdouttrace" + "go.opentelemetry.io/otel/sdk/resource" + sdktrace "go.opentelemetry.io/otel/sdk/trace" + semconv "go.opentelemetry.io/otel/semconv/v1.4.0" + "go.opentelemetry.io/otel/trace" +) + +const ( + instrumentationName = "github.com/instrumentron" + instrumentationVersion = "v0.1.0" +) + +var ( + tracer = otel.GetTracerProvider().Tracer( + instrumentationName, + trace.WithInstrumentationVersion(instrumentationVersion), + trace.WithSchemaURL("https://opentelemetry.io/schemas/1.2.0"), + ) +) + +func add(ctx context.Context, x, y int64) int64 { + var span trace.Span + _, span = tracer.Start(ctx, "Addition") + defer span.End() + + return x + y +} + +func multiply(ctx context.Context, x, y int64) int64 { + var span trace.Span + _, span = tracer.Start(ctx, "Multiplication") + defer span.End() + + return x * y +} + +func Resource() *resource.Resource { + return resource.NewWithAttributes( + semconv.SchemaURL, + semconv.ServiceNameKey.String("stdout-example"), + semconv.ServiceVersionKey.String("0.0.1"), + ) +} + +func InstallExportPipeline(ctx context.Context) func() { + exporter, err := stdouttrace.New(stdouttrace.WithPrettyPrint()) + if err != nil { + log.Fatalf("creating stdout exporter: %v", err) + } + + tracerProvider := sdktrace.NewTracerProvider( + sdktrace.WithBatcher(exporter), + sdktrace.WithResource(Resource()), + ) + otel.SetTracerProvider(tracerProvider) + + return func() { + if err := tracerProvider.Shutdown(ctx); err != nil { + log.Fatalf("stopping tracer provider: %v", err) + } + } +} + +func Example() { + ctx := context.Background() + + // Registers a tracer Provider globally. + cleanup := InstallExportPipeline(ctx) + defer cleanup() + + log.Println("the answer is", add(ctx, multiply(ctx, multiply(ctx, 2, 2), 10), 2)) +} diff --git a/exporters/stdout/stdouttrace/exporter.go b/exporters/stdout/stdouttrace/exporter.go new file mode 100644 index 00000000000..81ce7f48cc2 --- /dev/null +++ b/exporters/stdout/stdouttrace/exporter.go @@ -0,0 +1,38 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package stdouttrace // import "go.opentelemetry.io/otel/exporters/stdouttrace" + +import ( + sdktrace "go.opentelemetry.io/otel/sdk/trace" +) + +type Exporter struct { + traceExporter +} + +var ( + _ sdktrace.SpanExporter = &Exporter{} +) + +// New creates an Exporter with the passed options. +func New(options ...Option) (*Exporter, error) { + cfg, err := newConfig(options...) + if err != nil { + return nil, err + } + return &Exporter{ + traceExporter: traceExporter{config: cfg}, + }, nil +} diff --git a/exporters/stdout/stdouttrace/go.mod b/exporters/stdout/stdouttrace/go.mod new file mode 100644 index 00000000000..b65af221c9f --- /dev/null +++ b/exporters/stdout/stdouttrace/go.mod @@ -0,0 +1,76 @@ +module go.opentelemetry.io/otel/exporters/stdout/stdouttrace + +go 1.15 + +replace ( + go.opentelemetry.io/otel => ../../.. + go.opentelemetry.io/otel/sdk => ../../../sdk +) + +require ( + github.com/stretchr/testify v1.7.0 + go.opentelemetry.io/otel v0.20.0 + go.opentelemetry.io/otel/oteltest v0.20.0 + go.opentelemetry.io/otel/sdk v0.20.0 + go.opentelemetry.io/otel/trace v0.20.0 +) + +replace go.opentelemetry.io/otel/bridge/opencensus => ../../../bridge/opencensus + +replace go.opentelemetry.io/otel/bridge/opentracing => ../../../bridge/opentracing + +replace go.opentelemetry.io/otel/example/jaeger => ../../../example/jaeger + +replace go.opentelemetry.io/otel/example/namedtracer => ../../../example/namedtracer + +replace go.opentelemetry.io/otel/example/opencensus => ../../../example/opencensus + +replace go.opentelemetry.io/otel/example/otel-collector => ../../../example/otel-collector + +replace go.opentelemetry.io/otel/example/prom-collector => ../../example/prom-collector + +replace go.opentelemetry.io/otel/example/prometheus => ../../../example/prometheus + +replace go.opentelemetry.io/otel/example/zipkin => ../../../example/zipkin + +replace go.opentelemetry.io/otel/exporters/prometheus => ../../prometheus + +replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ./ + +replace go.opentelemetry.io/otel/exporters/jaeger => ../../jaeger + +replace go.opentelemetry.io/otel/exporters/zipkin => ../../zipkin + +replace go.opentelemetry.io/otel/internal/tools => ../../../internal/tools + +replace go.opentelemetry.io/otel/metric => ../../../metric + +replace go.opentelemetry.io/otel/oteltest => ../../../oteltest + +replace go.opentelemetry.io/otel/sdk/export/metric => ../../../sdk/export/metric + +replace go.opentelemetry.io/otel/sdk/metric => ../../../sdk/metric + +replace go.opentelemetry.io/otel/trace => ../../../trace + +replace go.opentelemetry.io/otel/example/passthrough => ../../../example/passthrough + +replace go.opentelemetry.io/otel/exporters/otlp/otlptrace => ../../otlp/otlptrace + +replace go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc => ../../otlp/otlptrace/otlptracegrpc + +replace go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp => ../../otlp/otlptrace/otlptracehttp + +replace go.opentelemetry.io/otel/internal/metric => ../../../internal/metric + +replace go.opentelemetry.io/otel/exporters/metric/prometheus => ../../metric/prometheus + +replace go.opentelemetry.io/otel/exporters/trace/jaeger => ../../trace/jaeger + +replace go.opentelemetry.io/otel/exporters/trace/zipkin => ../../trace/zipkin + +replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric => ../../otlp/otlpmetric + +replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc => ../../otlp/otlpmetric/otlpmetricgrpc + +replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ../stdoutmetric diff --git a/exporters/stdout/stdouttrace/go.sum b/exporters/stdout/stdouttrace/go.sum new file mode 100644 index 00000000000..f212493d586 --- /dev/null +++ b/exporters/stdout/stdouttrace/go.sum @@ -0,0 +1,15 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/exporters/stdout/trace.go b/exporters/stdout/stdouttrace/trace.go similarity index 95% rename from exporters/stdout/trace.go rename to exporters/stdout/stdouttrace/trace.go index 1022b13b548..d49c57af14a 100644 --- a/exporters/stdout/trace.go +++ b/exporters/stdout/stdouttrace/trace.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package stdout // import "go.opentelemetry.io/otel/exporters/stdout" +package stdouttrace // import "go.opentelemetry.io/otel/exporters/stdouttrace" import ( "context" diff --git a/exporters/stdout/trace_test.go b/exporters/stdout/stdouttrace/trace_test.go similarity index 95% rename from exporters/stdout/trace_test.go rename to exporters/stdout/stdouttrace/trace_test.go index 4c3579e7daf..e54571b0e73 100644 --- a/exporters/stdout/trace_test.go +++ b/exporters/stdout/stdouttrace/trace_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package stdout_test +package stdouttrace_test import ( "bytes" @@ -26,7 +26,7 @@ import ( "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/codes" - "go.opentelemetry.io/otel/exporters/stdout" + "go.opentelemetry.io/otel/exporters/stdout/stdouttrace" "go.opentelemetry.io/otel/oteltest" "go.opentelemetry.io/otel/sdk/resource" tracesdk "go.opentelemetry.io/otel/sdk/trace" @@ -37,7 +37,7 @@ import ( func TestExporter_ExportSpan(t *testing.T) { // write to buffer for testing var b bytes.Buffer - ex, err := stdout.New(stdout.WithWriter(&b), stdout.WithPrettyPrint()) + ex, err := stdouttrace.New(stdouttrace.WithWriter(&b), stdouttrace.WithPrettyPrint()) if err != nil { t.Errorf("Error constructing stdout exporter %s", err) } @@ -183,7 +183,7 @@ func TestExporterShutdownHonorsTimeout(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute) defer cancel() - e, err := stdout.New() + e, err := stdouttrace.New() if err != nil { t.Fatalf("failed to create exporter: %v", err) } @@ -202,7 +202,7 @@ func TestExporterShutdownHonorsCancel(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute) defer cancel() - e, err := stdout.New() + e, err := stdouttrace.New() if err != nil { t.Fatalf("failed to create exporter: %v", err) } @@ -217,7 +217,7 @@ func TestExporterShutdownHonorsCancel(t *testing.T) { } func TestExporterShutdownNoError(t *testing.T) { - e, err := stdout.New() + e, err := stdouttrace.New() if err != nil { t.Fatalf("failed to create exporter: %v", err) } diff --git a/exporters/trace/jaeger/go.mod b/exporters/trace/jaeger/go.mod index ef71e39a64a..7649c234457 100644 --- a/exporters/trace/jaeger/go.mod +++ b/exporters/trace/jaeger/go.mod @@ -35,8 +35,6 @@ replace go.opentelemetry.io/otel/example/zipkin => ../../../example/zipkin replace go.opentelemetry.io/otel/exporters/metric/prometheus => ../../metric/prometheus -replace go.opentelemetry.io/otel/exporters/stdout => ../../stdout - replace go.opentelemetry.io/otel/exporters/trace/jaeger => ./ replace go.opentelemetry.io/otel/exporters/trace/zipkin => ../zipkin @@ -72,3 +70,7 @@ replace go.opentelemetry.io/otel/exporters/zipkin => ../../zipkin replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric => ../../otlp/otlpmetric replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc => ../../otlp/otlpmetric/otlpmetricgrpc + +replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ../../stdout/stdoutmetric + +replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../../stdout/stdouttrace diff --git a/exporters/trace/zipkin/go.mod b/exporters/trace/zipkin/go.mod index a4e5878025f..5ca66d329f2 100644 --- a/exporters/trace/zipkin/go.mod +++ b/exporters/trace/zipkin/go.mod @@ -36,8 +36,6 @@ replace go.opentelemetry.io/otel/example/zipkin => ../../../example/zipkin replace go.opentelemetry.io/otel/exporters/metric/prometheus => ../../metric/prometheus -replace go.opentelemetry.io/otel/exporters/stdout => ../../stdout - replace go.opentelemetry.io/otel/exporters/trace/jaeger => ../jaeger replace go.opentelemetry.io/otel/exporters/trace/zipkin => ./ @@ -73,3 +71,7 @@ replace go.opentelemetry.io/otel/exporters/zipkin => ../../zipkin replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric => ../../otlp/otlpmetric replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc => ../../otlp/otlpmetric/otlpmetricgrpc + +replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ../../stdout/stdoutmetric + +replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../../stdout/stdouttrace diff --git a/exporters/zipkin/go.mod b/exporters/zipkin/go.mod index e99e9119c62..22260e0ad91 100644 --- a/exporters/zipkin/go.mod +++ b/exporters/zipkin/go.mod @@ -33,8 +33,6 @@ replace go.opentelemetry.io/otel/exporters/prometheus => ../prometheus replace go.opentelemetry.io/otel/exporters/otlp => ../otlp -replace go.opentelemetry.io/otel/exporters/stdout => ../stdout - replace go.opentelemetry.io/otel/exporters/jaeger => ../jaeger replace go.opentelemetry.io/otel/exporters/zipkin => ./ @@ -74,3 +72,7 @@ replace go.opentelemetry.io/otel/exporters/trace/zipkin => ../trace/zipkin replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric => ../otlp/otlpmetric replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc => ../otlp/otlpmetric/otlpmetricgrpc + +replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ../stdout/stdoutmetric + +replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../stdout/stdouttrace diff --git a/go.mod b/go.mod index 6b16d557852..d2497df1489 100644 --- a/go.mod +++ b/go.mod @@ -31,8 +31,6 @@ replace go.opentelemetry.io/otel/example/zipkin => ./example/zipkin replace go.opentelemetry.io/otel/exporters/prometheus => ./exporters/prometheus -replace go.opentelemetry.io/otel/exporters/stdout => ./exporters/stdout - replace go.opentelemetry.io/otel/exporters/jaeger => ./exporters/jaeger replace go.opentelemetry.io/otel/exporters/zipkin => ./exporters/zipkin @@ -70,3 +68,7 @@ replace go.opentelemetry.io/otel/exporters/trace/zipkin => ./exporters/trace/zip replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric => ./exporters/otlp/otlpmetric replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc => ./exporters/otlp/otlpmetric/otlpmetricgrpc + +replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ./exporters/stdout/stdoutmetric + +replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ./exporters/stdout/stdouttrace diff --git a/internal/metric/go.mod b/internal/metric/go.mod index aafcfac89eb..c90658c2bae 100644 --- a/internal/metric/go.mod +++ b/internal/metric/go.mod @@ -42,8 +42,6 @@ replace go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc => ../.. replace go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp => ../../exporters/otlp/otlptrace/otlptracehttp -replace go.opentelemetry.io/otel/exporters/stdout => ../../exporters/stdout - replace go.opentelemetry.io/otel/exporters/jaeger => ../../exporters/jaeger replace go.opentelemetry.io/otel/exporters/zipkin => ../../exporters/zipkin @@ -69,3 +67,7 @@ replace go.opentelemetry.io/otel/exporters/trace/zipkin => ../../exporters/trace replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric => ../../exporters/otlp/otlpmetric replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc => ../../exporters/otlp/otlpmetric/otlpmetricgrpc + +replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ../../exporters/stdout/stdoutmetric + +replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../../exporters/stdout/stdouttrace diff --git a/internal/tools/go.mod b/internal/tools/go.mod index b70f47eb12e..734b0aac81c 100644 --- a/internal/tools/go.mod +++ b/internal/tools/go.mod @@ -34,8 +34,6 @@ replace go.opentelemetry.io/otel/example/zipkin => ../../example/zipkin replace go.opentelemetry.io/otel/exporters/prometheus => ../../exporters/prometheus -replace go.opentelemetry.io/otel/exporters/stdout => ../../exporters/stdout - replace go.opentelemetry.io/otel/exporters/jaeger => ../../exporters/jaeger replace go.opentelemetry.io/otel/exporters/zipkin => ../../exporters/zipkin @@ -73,3 +71,7 @@ replace go.opentelemetry.io/otel/exporters/trace/zipkin => ../../exporters/trace replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric => ../../exporters/otlp/otlpmetric replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc => ../../exporters/otlp/otlpmetric/otlpmetricgrpc + +replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ../../exporters/stdout/stdoutmetric + +replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../../exporters/stdout/stdouttrace diff --git a/metric/go.mod b/metric/go.mod index deb5119d23e..08174635760 100644 --- a/metric/go.mod +++ b/metric/go.mod @@ -24,8 +24,6 @@ replace go.opentelemetry.io/otel/example/zipkin => ../example/zipkin replace go.opentelemetry.io/otel/exporters/prometheus => ../exporters/prometheus -replace go.opentelemetry.io/otel/exporters/stdout => ../exporters/stdout - replace go.opentelemetry.io/otel/exporters/jaeger => ../exporters/jaeger replace go.opentelemetry.io/otel/exporters/zipkin => ../exporters/zipkin @@ -70,3 +68,7 @@ replace go.opentelemetry.io/otel/exporters/trace/zipkin => ../exporters/trace/zi replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric => ../exporters/otlp/otlpmetric replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc => ../exporters/otlp/otlpmetric/otlpmetricgrpc + +replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ../exporters/stdout/stdoutmetric + +replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../exporters/stdout/stdouttrace diff --git a/oteltest/go.mod b/oteltest/go.mod index ca82fb70774..c0081ddee62 100644 --- a/oteltest/go.mod +++ b/oteltest/go.mod @@ -24,8 +24,6 @@ replace go.opentelemetry.io/otel/example/zipkin => ../example/zipkin replace go.opentelemetry.io/otel/exporters/prometheus => ../exporters/prometheus -replace go.opentelemetry.io/otel/exporters/stdout => ../exporters/stdout - replace go.opentelemetry.io/otel/exporters/jaeger => ../exporters/jaeger replace go.opentelemetry.io/otel/exporters/zipkin => ../exporters/zipkin @@ -69,3 +67,7 @@ replace go.opentelemetry.io/otel/exporters/trace/zipkin => ../exporters/trace/zi replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric => ../exporters/otlp/otlpmetric replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc => ../exporters/otlp/otlpmetric/otlpmetricgrpc + +replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ../exporters/stdout/stdoutmetric + +replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../exporters/stdout/stdouttrace diff --git a/sdk/export/metric/go.mod b/sdk/export/metric/go.mod index 24075f6514b..a49d4fe738c 100644 --- a/sdk/export/metric/go.mod +++ b/sdk/export/metric/go.mod @@ -24,8 +24,6 @@ replace go.opentelemetry.io/otel/example/zipkin => ../../../example/zipkin replace go.opentelemetry.io/otel/exporters/prometheus => ../../../exporters/prometheus -replace go.opentelemetry.io/otel/exporters/stdout => ../../../exporters/stdout - replace go.opentelemetry.io/otel/exporters/jaeger => ../../../exporters/jaeger replace go.opentelemetry.io/otel/exporters/zipkin => ../../../exporters/zipkin @@ -70,3 +68,7 @@ replace go.opentelemetry.io/otel/exporters/trace/zipkin => ../../../exporters/tr replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric => ../../../exporters/otlp/otlpmetric replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc => ../../../exporters/otlp/otlpmetric/otlpmetricgrpc + +replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ../../../exporters/stdout/stdoutmetric + +replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../../../exporters/stdout/stdouttrace diff --git a/sdk/go.mod b/sdk/go.mod index f051a45f905..eb3980bdecf 100644 --- a/sdk/go.mod +++ b/sdk/go.mod @@ -32,8 +32,6 @@ replace go.opentelemetry.io/otel/example/zipkin => ../example/zipkin replace go.opentelemetry.io/otel/exporters/prometheus => ../exporters/prometheus -replace go.opentelemetry.io/otel/exporters/stdout => ../exporters/stdout - replace go.opentelemetry.io/otel/exporters/jaeger => ../exporters/jaeger replace go.opentelemetry.io/otel/exporters/zipkin => ../exporters/zipkin @@ -71,3 +69,7 @@ replace go.opentelemetry.io/otel/exporters/trace/zipkin => ../exporters/trace/zi replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric => ../exporters/otlp/otlpmetric replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc => ../exporters/otlp/otlpmetric/otlpmetricgrpc + +replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ../exporters/stdout/stdoutmetric + +replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../exporters/stdout/stdouttrace diff --git a/sdk/metric/go.mod b/sdk/metric/go.mod index 8bf4ad7b121..e57aa9c23ab 100644 --- a/sdk/metric/go.mod +++ b/sdk/metric/go.mod @@ -24,8 +24,6 @@ replace go.opentelemetry.io/otel/example/zipkin => ../../example/zipkin replace go.opentelemetry.io/otel/exporters/prometheus => ../../exporters/prometheus -replace go.opentelemetry.io/otel/exporters/stdout => ../../exporters/stdout - replace go.opentelemetry.io/otel/exporters/jaeger => ../../exporters/jaeger replace go.opentelemetry.io/otel/exporters/zipkin => ../../exporters/zipkin @@ -73,3 +71,7 @@ replace go.opentelemetry.io/otel/exporters/trace/zipkin => ../../exporters/trace replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric => ../../exporters/otlp/otlpmetric replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc => ../../exporters/otlp/otlpmetric/otlpmetricgrpc + +replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ../../exporters/stdout/stdoutmetric + +replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../../exporters/stdout/stdouttrace diff --git a/trace/go.mod b/trace/go.mod index deb9c249144..44a977ef2f4 100644 --- a/trace/go.mod +++ b/trace/go.mod @@ -24,8 +24,6 @@ replace go.opentelemetry.io/otel/example/zipkin => ../example/zipkin replace go.opentelemetry.io/otel/exporters/prometheus => ../exporters/prometheus -replace go.opentelemetry.io/otel/exporters/stdout => ../exporters/stdout - replace go.opentelemetry.io/otel/exporters/jaeger => ../exporters/jaeger replace go.opentelemetry.io/otel/exporters/zipkin => ../exporters/zipkin @@ -69,3 +67,7 @@ replace go.opentelemetry.io/otel/exporters/trace/zipkin => ../exporters/trace/zi replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric => ../exporters/otlp/otlpmetric replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc => ../exporters/otlp/otlpmetric/otlpmetricgrpc + +replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ../exporters/stdout/stdoutmetric + +replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../exporters/stdout/stdouttrace