From 23856c75d21668403e4b33b040fc9775faca0868 Mon Sep 17 00:00:00 2001 From: Bing Han Date: Fri, 23 Sep 2022 10:50:34 +0800 Subject: [PATCH] Fix code review and add CHANGELOG --- CHANGELOG.md | 4 ++++ example/view/doc.go | 2 +- example/view/go.mod | 2 +- example/view/main.go | 8 ++------ 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 434aeae8397..79cec1cd069 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [Unreleased] +### Added + +- Added an example of using metric views to customize instruments. (#3177) + ## [0.32.0] Revised Metric SDK (Alpha) - 2022-09-18 ### Changed diff --git a/example/view/doc.go b/example/view/doc.go index 5aa678b1372..6307e5f20e3 100644 --- a/example/view/doc.go +++ b/example/view/doc.go @@ -12,5 +12,5 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Package main provides a code sample of using view to custom instruments. +// Package main provides a code sample of using metric views to customize instruments. package main diff --git a/example/view/go.mod b/example/view/go.mod index 2ac1ea916f4..4e73ec0d679 100644 --- a/example/view/go.mod +++ b/example/view/go.mod @@ -1,4 +1,4 @@ -module go.opentelemetry.io/otel/example/prometheus +module go.opentelemetry.io/otel/example/view go 1.18 diff --git a/example/view/main.go b/example/view/main.go index 3bc657975ad..872e12dde1f 100644 --- a/example/view/main.go +++ b/example/view/main.go @@ -12,9 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build go1.18 -// +build go1.18 - package main import ( @@ -42,14 +39,13 @@ const meterName = "github.com/open-telemetry/opentelemetry-go/example/view" func main() { ctx := context.Background() - // The exporter embeds a default OpenTelemetry Reader, allowing it to be used in WithReader + // The exporter embeds a default OpenTelemetry Reader, allowing it to be used in WithReader. exporter := otelprom.New() - // View to customize histogram + // View to customize histogram buckets and rename a single histogram instrument. customBucketsView, err := view.New( // Match* to match instruments view.MatchInstrumentName("custom_histogram"), - view.MatchInstrumentKind(view.SyncHistogram), view.MatchInstrumentationScope(instrumentation.Scope{Name: meterName}), // With* to modify instruments