-
Notifications
You must be signed in to change notification settings - Fork 831
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
Remove validations for noop instrument names and units #5146
Remove validations for noop instrument names and units #5146
Conversation
@MrAlias @tsloughter FYI |
FYI, here's where that was originally added. Essentially, we did the thing we deemed most correct given the ambiguity in the specification about how API level argument restrictions should actually be enforced.
I think the spec is contradictory on this point. It needs to resolve the "the SDK is not expected to validate the unit of measurement" phrasing with the "It can have a maximum length of 63 characters". Not sure how these can coexist. I brought up this contradiction in this issue. I'd want to hold off on merging this until the spec provides more clarity. It could end up being the case that noop API is supposed to do this validation. |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #5146 +/- ##
============================================
+ Coverage 91.05% 91.08% +0.02%
- Complexity 4880 4883 +3
============================================
Files 549 550 +1
Lines 14428 14420 -8
Branches 1374 1376 +2
============================================
- Hits 13138 13134 -4
+ Misses 893 890 -3
+ Partials 397 396 -1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
This seems reasonable 👍 |
Thanks, totally appreciate that perspective. I also commented on the issue to try and round up some momentum. |
Not sure if related, but with spring-security 6.0 we stumbled upon this issue. While the space in the name is unwanted, keeping the names under 63 characters long seems to be hard with the given example of |
@der-eismann it is unrelated. This is just about removing the check from the no-op API, but the constraint on length is still in the spec. |
Related specification PR: open-telemetry/opentelemetry-specification#3171 |
@jkwatson FYI spec PR #3171 seems likely to merge and explicitly requires that noop implementations do not do any instrument name / unit validation. This is fine with me, since it makes the noop a true noop, but means that you won't be able to see the same name / unit warnings when the noop is installed versus the sdk. |
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.
🚢
@@ -371,7 +359,6 @@ public LongGaugeBuilder setDescription(String description) { | |||
|
|||
@Override | |||
public LongGaugeBuilder setUnit(String unit) { | |||
ValidationUtil.checkValidInstrumentUnit(unit); |
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.
These validation utils can be moved to the SDK now. checkInstrumentName
probably makes most sense in SdkMeter
. checkValidInstrumentUnit
should be removed given that the spec has clarified that SDKs aren't supposed to do any validation on unit. You can do that removal in this PR if you want, or just move the method to AbstractInstrumentBuilder
.
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.
Bumping this @breedx-splk.
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.
Ok, I moved checkValidInstrumentName()
to a new internal utility class in the sdk, rather than SdkMeter
. This seemed a little more SRPy to me.
I did move the unit check over to the AbstractInstrumentBuilder
class, and I think removal of that should be tackled in a separate PR.
Once those were moved out of the validator, the only things that were left inValidationUtil
were the logging methods, so I renamed it to ApiUsageLogger
.
api/all/src/test/java/io/opentelemetry/api/metrics/DefaultMeterTest.java
Outdated
Show resolved
Hide resolved
@breedx-splk Hi. It will be really helpful if we can get the changes in this PR merged. |
…y to AbstractInstrumentBuilder.
ee3fb36
to
3d6a84a
Compare
We were chatting about API behavior and it was discovered that some metrics APIs do validation. We think that this is probably not what the spec intended, but also creates some log chatter and computational overhead in what should really be a true no-op implementation.
The instrument naming spec does, oddly enough, impose naming restrictions, but these are implemented in the sdk. The api does not seem like place for this behavior.
The metric api specification around units says that even the SDK isn't supposed to validate....so it makes little sense for the API to also be doing unit validations.
I think that it is unlikely that users are relying on this warning to be logged, so I believe that this change should be safe.