-
Notifications
You must be signed in to change notification settings - Fork 825
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
feat(sdk-metrics-base): meter registration #2666
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5e8d522
feat(sdk-metrics-base): meter identity
legendecas a57a183
Merge remote-tracking branch 'upstream/main' into metrics-ff/meter
legendecas d50eaa7
fixup! create new meters for every MeterProvider.getMeter
legendecas 92a0112
fixup!
legendecas d502dd3
fixup! remove outdated todo
legendecas 6419453
fixup!
legendecas f5220ac
Merge branch 'main' into metrics-ff/meter
legendecas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 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
50 changes: 50 additions & 0 deletions
50
experimental/packages/opentelemetry-sdk-metrics-base/test/MeterProvider.test.ts
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,50 @@ | ||
/* | ||
* 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 | ||
* | ||
* https://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. | ||
*/ | ||
|
||
import * as assert from 'assert'; | ||
import { NOOP_METER } from '@opentelemetry/api-metrics-wip'; | ||
import { Meter } from '../src/Meter'; | ||
import { MeterProvider } from '../src/MeterProvider'; | ||
import { defaultResource } from './util'; | ||
|
||
describe('MeterProvider', () => { | ||
describe('constructor', () => { | ||
it('should construct without exceptions', () => { | ||
const meterProvider = new MeterProvider(); | ||
assert(meterProvider instanceof MeterProvider); | ||
}); | ||
|
||
it('construct with resource', () => { | ||
const meterProvider = new MeterProvider({ resource: defaultResource }); | ||
assert(meterProvider instanceof MeterProvider); | ||
}); | ||
}); | ||
|
||
describe('getMeter', () => { | ||
it('should get a meter', () => { | ||
const meterProvider = new MeterProvider(); | ||
const meter = meterProvider.getMeter('meter1', '1.0.0'); | ||
assert(meter instanceof Meter); | ||
}); | ||
|
||
it('get a noop meter on shutdown', () => { | ||
const meterProvider = new MeterProvider(); | ||
meterProvider.shutdown(); | ||
const meter = meterProvider.getMeter('meter1', '1.0.0'); | ||
assert.strictEqual(meter, NOOP_METER); | ||
}); | ||
}); | ||
}); |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the schema URL is part of the identity, shouldn't it be a top-level property and not buried in options?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, there is only one requirement for meter creation:
It also suggests that:
So, as long as we propagate the configurations to all meters created without another
getMeter
call, it should be spec-compliant.As we are using the
MeterProviderSharedState
pattern to share the meter provider configurations, I'd believe we've already met the bar that the created meters can automatically get configuration updates without the need to callgetMeter
again. So it seems that we actually don't have to return an identical meter for eachgetMeter
call.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another problem is that the spec is said instrument names are unique in a meter:
So, if we are going to return a new meter instance for every
getMeter
, how do we define "same Meter instance" in the above context?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Submitted a spec issue for this: open-telemetry/opentelemetry-specification#2226