-
Notifications
You must be signed in to change notification settings - Fork 576
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move examples and tests to runtime directory
- Loading branch information
Showing
10 changed files
with
188 additions
and
340 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package runtime_test | ||
|
||
import ( | ||
"context" | ||
"log" | ||
"time" | ||
|
||
"go.opentelemetry.io/contrib/instrumentation/runtime" | ||
"go.opentelemetry.io/otel" | ||
"go.opentelemetry.io/otel/sdk/metric" | ||
) | ||
|
||
func Example() { | ||
// This reader is used as a stand-in for a reader that will actually export | ||
// data. See https://pkg.go.dev/go.opentelemetry.io/otel/exporters for | ||
// exporters that can be used as or with readers. | ||
reader := metric.NewManualReader( | ||
// Add the runtime producer to get histograms from the Go runtime. | ||
metric.WithProducer(runtime.NewProducer()), | ||
) | ||
provider := metric.NewMeterProvider(metric.WithReader(reader)) | ||
defer func() { | ||
err := provider.Shutdown(context.Background()) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
}() | ||
otel.SetMeterProvider(provider) | ||
|
||
// Start go runtime metric collection. | ||
err := runtime.Start(runtime.WithMinimumReadMemStatsInterval(time.Second)) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.