1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-11-25 22:41:46 +02:00

Make the stdout exporter a package (#963)

* Make the stdout exporter its own package

Follow the pattern of the other exporters.

* Update dependabot with stdout exporter

* Add replace directives for stdout exporter

* Remove outdated example test from metric SDK

* go mod tidy

* Update othttp example test

Remove unused stdout exporter.

* Remove tests in API that depend on stdout exporter

The global package does not need to be validated with the SDK. A more
properly constructed end-to-end integration test should be built if this
is actually needed.

* Add replace clause for otel in stdout go.mod
This commit is contained in:
Tyler Yahn
2020-07-24 20:44:51 -07:00
committed by GitHub
parent c6611f4478
commit 3b01a854d1
10 changed files with 141 additions and 139 deletions

View File

@@ -1,55 +0,0 @@
// 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 metric_test
import (
"bytes"
"context"
"fmt"
"go.opentelemetry.io/otel/api/kv"
"go.opentelemetry.io/otel/api/metric"
"go.opentelemetry.io/otel/exporters/stdout"
)
func ExampleNew() {
buf := bytes.Buffer{}
_, pusher, err := stdout.NewExportPipeline([]stdout.Option{
// Defaults to STDOUT.
stdout.WithWriter(&buf),
stdout.WithPrettyPrint(),
stdout.WithoutTimestamps(), // This makes the output deterministic
}, nil)
if err != nil {
panic(fmt.Sprintln("Could not initialize stdout exporter:", err))
}
meter := metric.Must(pusher.Provider().Meter("example"))
counter := meter.NewInt64Counter("a.counter")
counter.Add(context.Background(), 100, kv.String("key", "value"))
// Flush everything
pusher.Stop()
fmt.Println(buf.String())
// Output:
// [
// {
// "Name": "a.counter{instrumentation.name=example,key=value}",
// "Sum": 100
// }
// ]
}