-
Notifications
You must be signed in to change notification settings - Fork 651
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
Renaming Meter to Accumulator in Metrics SDK context #1372
Renaming Meter to Accumulator in Metrics SDK context #1372
Conversation
@@ -42,24 +42,24 @@ | |||
|
|||
# The Meter is responsible for creating and recording metrics. Each meter has a | |||
# unique name, which we set as the module's name here. | |||
meter = metrics.get_meter(__name__) | |||
accumulator = metrics.get_meter(__name__) |
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.
Getting an accumulator from get_meter
seems so weird. As a user, I wouldn't want to be bombarded by more terms. I'm wondering why we the specs needs to introduce a new word to represent the instrumentation. We don't have this for Tracer
.
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.
As a user, I wouldn't want to be bombarded by more terms.
yup, you do raise a good point. But IMO if we're renaming the Meter class to Accumulator to comply with the spec, I think we also need to update its usages as well. Otherwise it'll be even more confusing because meter
is an interface and meter = metrics.get_meter()
gives the impression that you're directly instantiating an object of the interface.
Getting an accumulator from
get_meter
seems so weird
lol you're right, I wonder if we can fix this incongruity between method name and return type 🤔
This kind of makes sense to me because meter
is the super type of accumulator
so you're still getting a meter from the method. That said, I can also see how get_meter()
makes it sound like you're explicity expecting a meter
object.
The Go repo actually renamed get_meter()
to meter()
CHANGELOG. Do you think it would help add clarity to make the same change here? This way, with metrics.meter()
, you're just accessing whichever meter-type object the meterprovider
is exposing (which could be anything since meter is just an interface)
Do you have another approach in mind?
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.
The Go repo actually renamed get_meter() to meter()
I don't believe we should be following the Go implementation as the source of truth, rather the api specs say GetMeter
. I don't know if this is outdated but we can change it if it changes in the future.
I think we also need to update its usages as well.
With that being said, I don't think the usage documents should be renamed. Accumulator is an implemenation in the sdk of the meter interface defined in the api, so it is purely an sdk concept. The usage documents don't guarantee the usage of the sdk (even though we are instantiating the MeterProvider from the SDK`). Looking at these examples, if I were a user coming in with my own sdk implementation of the meter, I don't know what the accumulator is. Also take a look at some of the instrumentations that use the meter but only depend on the api. It doesn't make sense for them to refer it as accumulators, so why should we even introduce that term to users? Meter is the only word that all users would be familiar with, whether or not they are using the sdk.
I think this whole naming thing is weird in the specs itself, but it's fine right now to adhere to it. Just don't be surprised if there are changes in the future :D
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.
Alright makes sense, i'll revert the usage change
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.
My understanding is that Accumulator doesn't have to be the SDK meter, but that is an implementation detail of the Python and Go SDKs (see this comment thread open-telemetry/opentelemetry-specification#880 (comment))
I think it's even still a bit confusing if type(metrics.get_meter())
is Accumulator
instead of Meter
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.
A best of both worlds approach (and this may require spec changes) may be to add a new Meter object, whose only job is to create instruments that bind to the accumulator.
IMO this is actually a fairly clean break: Meter owns the logic required create new instruments, and accumulation can be the first part of the processing pipeline.
2edb265
to
baa6b10
Compare
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.
I understand the valid concerns raised in the conversation. Nevertheless, I think the confusion related to the names Meter
or Accumulator
should be resolved in the specification if they are not solved there yet. We do the right thing by following the specification as best as possible and by trying to also be similar to other implementations where possible. I think this is a step in that direction, approving.
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.
I agree with the whole discussion above, but also with @ocelotl: this is what the spec says for now, so adhering to it and raising discussions is the best choice.
@@ -26,18 +26,18 @@ class PushController(threading.Thread): | |||
exports them and performs some post-processing. | |||
|
|||
Args: | |||
meter: The meter used to collect metrics. | |||
accumulator: The meter used to collect metrics. |
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.
please update the description. I believe it's incorrect that any meter from any SDK will work in this architecture.
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.
Is this more accurate?
accumulator: The meter from the Metrics API used to collect metrics.
15f90d5
to
335e81e
Compare
335e81e
to
86038f4
Compare
rebased now that #1373 got merged |
@AzfaarQureshi @lzchen It looks like this PR broke the Contrib Tests 😞 . This was caught in the PR to add Contrib Tests to Core repos but it hasn't been merged yet #1357 We'll have to make an equivalent PR in the Contrib Repo to fix these references: And bump the Contrib Repo |
@NathanielRN o rip mb, i'll put up an equivalent PR in contrib tonight! 😄 |
Description
This PR addresses Issue #1342 and issue #1307 by renaming the
Meter
class in the metrics sdk toAccumulator
Summary of changes
Meter
class toAccumulator
rename allmeter = meter_provider.get_meter()
toaccumulator = meter_provider.get_meter()
for consistencyRationale behind changes
Meter
class does all of what is defined for theAccumulator
in the specMeter
interfacerename allmeter = meter_provider.get_meter()
toaccumulator = meter_provider.get_meter()
for consistencyfeels awkward to have an instance of ameter
since a meter is an interfacenow that the metrics sdk meter_provider returns an accumulator, the usage in various tests and examples should reflect what is actually being returnedType of change
Please delete options that are not relevant.
Bug fix (non-breaking change which fixes an issue)New feature (non-breaking change which adds functionality)How Has This Been Tested?
Just made sure all the tests are passing post name changes.
Checklist:
Unit tests have been addedcc - @ocelotl