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

feat: validate metric names #468

Merged

Conversation

dyladan
Copy link
Member

@dyladan dyladan commented Oct 30, 2019

Which problem is this PR solving?

Short description of the changes

  • Ensure metric names are valid according to the spec
  • Invalid metric names return noop implementations (per SIG meeting)

@codecov-io
Copy link

codecov-io commented Oct 30, 2019

Codecov Report

Merging #468 into master will increase coverage by 0.36%.
The diff coverage is 95.16%.

@@            Coverage Diff            @@
##           master    #468      +/-   ##
=========================================
+ Coverage   94.83%   95.2%   +0.36%     
=========================================
  Files         130     125       -5     
  Lines        6524    6295     -229     
  Branches      556     519      -37     
=========================================
- Hits         6187    5993     -194     
+ Misses        337     302      -35
Impacted Files Coverage Δ
packages/opentelemetry-metrics/test/Meter.test.ts 100% <100%> (ø) ⬆️
packages/opentelemetry-metrics/src/Meter.ts 80% <76.92%> (-5.72%) ⬇️
...ges/opentelemetry-exporter-zipkin/src/transform.ts 100% <0%> (ø) ⬆️
...telemetry-plugin-grpc/test/utils/assertionUtils.ts 100% <0%> (ø) ⬆️
.../opentelemetry-exporter-zipkin/test/zipkin.test.ts 100% <0%> (ø) ⬆️
...telemetry-scope-base/test/NoopScopeManager.test.ts 100% <0%> (ø) ⬆️
...entelemetry-exporter-zipkin/test/transform.test.ts 100% <0%> (ø) ⬆️
...es/opentelemetry-plugin-postgres/test/testUtils.ts
...entelemetry-plugin-postgres/test/assertionUtils.ts
... and 5 more

@@ -48,7 +48,7 @@ describe('Meter', () => {

describe('.getHandle()', () => {
it('should create a counter handle', () => {
const counter = meter.createCounter('name');
const counter = meter.createCounter('name') as CounterMetric;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, why do you need to use as - Type assertion here? Earlier it used to work, Is it because we are returning noop implementation?

Copy link
Member Author

@dyladan dyladan Oct 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the function createCounter now returns types.Metric<types.CounterHandle> where it used to return just CounterMetric. The return type needed to be changed in order to allow returning the noop implementation which satisfies the type types.Metric<types.CounterHandle> but is not a CounterMetric

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got you. As a user, I have to use/do the same assertion? This looks little inconvenient. WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No you don't, because users will only use the public interface. This is only done because the tests access private fields

@mayurkale22 mayurkale22 merged commit 2953a29 into open-telemetry:master Oct 31, 2019
@Flarna Flarna deleted the validate-metric-names branch December 13, 2019 20:58
pichlermarc pushed a commit to dynatrace-oss-contrib/opentelemetry-js that referenced this pull request Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validate Metric names
5 participants