-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Duplicate instrument registration generates an error instead of a valid instrument #3229
Comments
I think returning an error here is potentially appropriate according to:
I could also see this being a time when logging an info message with the global logger makes more sense. That said, the returned counter is currently empty. That is definitely invalid behavior. Whether a non-nil error is returned or not, the returned counter needs to be valid. @alanwest in your use of this. Do you just halt when this fails? Or do you handle the error in a different way. |
Yes, in the code I shared I just halt, but I totally could have just logged out the error myself and continued. But, as you point out a non-nil error should still result in a valid counter. I'm no Go engineer, so I can't say what would be idiomatic for y'all to meet the requirement: "the implementation SHOULD emit a warning to the user". I guess the question is whether a non-nil error in Go is the way a user would expect this to be handled. In .NET we do not log anything when a duplicate instrument is "identical". We only log a warning when a duplicate instrument registration would result in a "distinct" instrument. So something like: var meter = new Meter("my-meter")
meter.CreateCounter("my-instrument")
// Duplicate registration differs by instrument kind
meter.CreateHistogram("my-instrument") |
Ah, makes sense 👍 |
I did make a patch to change this behavior to closer match what java and .NET do: #3181 |
I was able to verify #3181 resolves this based on the example provided. |
I have validated that #3238 resolves this issue based on the example example provided. |
Sorry for the chatter and false starts, but I have validated that #3251 resolves this issue based on the example example provided. |
Description
Spec says:
The loop in the following code creates a duplicate instrument. An error is generated and the instrument is not valid.
Steps To Reproduce
The text was updated successfully, but these errors were encountered: