Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds metrics Global #2660

Merged
merged 27 commits into from Mar 22, 2022
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3245245
WIP: add global API
MadVikingGod Mar 2, 2022
2594638
WIP
MadVikingGod Mar 2, 2022
cac40eb
Add a global meter.
MadVikingGod Mar 4, 2022
888f67f
moved global access out of metric because of loop imports
MadVikingGod Mar 4, 2022
2c125e4
fix linting issues
MadVikingGod Mar 4, 2022
dec12e6
remove changes from other lint failures.
MadVikingGod Mar 7, 2022
00ae60f
Merge remote-tracking branch 'upstream/main' into mvg/metrics-global
MadVikingGod Mar 7, 2022
17598c5
Add changelog
MadVikingGod Mar 7, 2022
6944af3
Fixes for comments.
MadVikingGod Mar 9, 2022
3541823
Merge remote-tracking branch 'upstream/main' into mvg/metrics-global
MadVikingGod Mar 9, 2022
8a360dd
Apply suggestions from code review
MadVikingGod Mar 11, 2022
3bcc00a
Consolidated instrument tests
MadVikingGod Mar 11, 2022
a6b9238
Merge remote-tracking branch 'upstream/main' into mvg/metrics-global
MadVikingGod Mar 11, 2022
f075b20
fixed lint, and removed unneeded type checking
MadVikingGod Mar 11, 2022
3f66669
change require's to asserts.
MadVikingGod Mar 11, 2022
503228a
Update misspelling
MadVikingGod Mar 11, 2022
d63de58
Fix meter race test.
MadVikingGod Mar 14, 2022
3c7df6f
Merge remote-tracking branch 'upstream/main' into mvg/metrics-global
MadVikingGod Mar 18, 2022
c90fb7e
Copy SetTracerProvider logic.
MadVikingGod Mar 18, 2022
713a5b1
Fix global test for panic.
MadVikingGod Mar 21, 2022
7825492
Merge branch 'main' into mvg/metrics-global
MadVikingGod Mar 21, 2022
560b92b
Fix linting error
MadVikingGod Mar 21, 2022
0e17c69
Merge remote-tracking branch 'upstream/main' into mvg/metrics-global
MadVikingGod Mar 21, 2022
8690ed8
Merge remote-tracking branch 'upstream/main' into mvg/metrics-global
MadVikingGod Mar 21, 2022
a6f16ef
bump testify version
MadVikingGod Mar 21, 2022
dd15b7c
moved changelog into unreleased
MadVikingGod Mar 22, 2022
16341b8
Merge remote-tracking branch 'upstream/main' into mvg/metrics-global
MadVikingGod Mar 22, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -35,6 +35,7 @@ This update is a breaking change of the unstable Metrics API. Code instrumented
Zero or negative values will not be changed to the default value like `WithSpanLimits` does.
Setting a limit to zero will effectively disable the related resource it limits and setting to a negative value will mean that resource is unlimited.
Consequentially, limits should be constructed using `NewSpanLimits` and updated accordingly. (#2637)
- Add the `metric/global` for obtaining and setting the global `MeterProvider` (#2660)
XSAM marked this conversation as resolved.
Show resolved Hide resolved

### Changed

Expand Down
31 changes: 31 additions & 0 deletions metric/global/global.go
@@ -0,0 +1,31 @@
// 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 global // import "go.opentelemetry.io/otel/metric/global"

import (
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/internal/global"
)

// MeterProvider returns the registered global trace provider.
// If none is registered then a No-op MeterProvider is returned.
func MeterProvider() metric.MeterProvider {
return global.MeterProvider()
}

// SetMeterProvider registers `mp` as the global meter provider.
func SetMeterProvider(mp metric.MeterProvider) {
global.SetMeterProvider(mp)
}
5 changes: 4 additions & 1 deletion metric/go.mod
Expand Up @@ -2,7 +2,10 @@ module go.opentelemetry.io/otel/metric

go 1.16

require go.opentelemetry.io/otel v1.4.1
require (
github.com/stretchr/testify v1.7.0
go.opentelemetry.io/otel v1.4.1
)

replace go.opentelemetry.io/otel => ../

Expand Down
3 changes: 3 additions & 0 deletions metric/go.sum
@@ -1,6 +1,8 @@
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/go-logr/logr v1.2.2 h1:ahHml/yUpnlb96Rp8HCvtYVPY8ZYpxq3g7UYchIYwbs=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o=
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
Expand All @@ -10,6 +12,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
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/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=