-
Notifications
You must be signed in to change notification settings - Fork 658
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
Implement ExplicitBucketBoundaries advisory for Histograms #4361
base: main
Are you sure you want to change the base?
Conversation
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.
Thanks. Any clue on the docs CI error? I would say to add to nitpick_ignore.
Nope, it's really hard for me to understand where this is coming from. Tried using |
Appear to work fine with the flask implementation after updating the create_histogram calls for HTTP_SERVER_REQUEST_DURATION:
|
We can probably use a TypedDict or just add
|
Moved to TypedDict, thanks for the hint! |
3c8b98e
to
181596b
Compare
opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/__init__.py
Outdated
Show resolved
Hide resolved
7500.0, | ||
10000.0, | ||
), | ||
boundaries: Optional[Sequence[float]] = None, |
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.
Any reason to not leave the default as _DEFAULT_EXPLICIT_BUCKET_HISTOGRAM_AGGREGATION_BOUNDARIES
? I'm wondering because this allows explicitly passing None
now
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.
@aabmass Yeah, now you can pass None boundaries but then the defaults boundaries are used. Also this is more pythonic I guess?
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.
What's the reason user would pass None instead of allowing the default?
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.
There's no reason the user would pass None, I expected to just call it without passing the parameter as currently doing. But no big deal in keeping thing as is.
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.
Well, it looks like we have someone passing None:
def __init__(self, boundaries: Sequence[float], **kwargs) -> None:
> super().__init__(len(boundaries) + 1, **kwargs)
E TypeError: object of type 'NoneType' has no len()
opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/exemplar/exemplar_reservoir.py:296: TypeError
and
> self._boundaries = tuple(boundaries)
E TypeError: 'NoneType' object is not iterable
opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/aggregation.py:488: TypeError
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'm fine with whatever you want to do here
opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/instrument.py
Outdated
Show resolved
Hide resolved
opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/instrument.py
Outdated
Show resolved
Hide resolved
opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/aggregation.py
Show resolved
Hide resolved
22b40b0
to
c148618
Compare
opentelemetry-api/src/opentelemetry/metrics/_internal/__init__.py
Outdated
Show resolved
Hide resolved
opentelemetry-api/src/opentelemetry/metrics/_internal/__init__.py
Outdated
Show resolved
Hide resolved
opentelemetry-api/src/opentelemetry/metrics/_internal/__init__.py
Outdated
Show resolved
Hide resolved
|
||
@abstractmethod | ||
def create_counter( | ||
self, | ||
name: str, | ||
unit: str = "", | ||
description: str = "", | ||
advisory: None = None, |
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.
Wdyt of adding doing this?
advisory: None = None, | |
*, | |
advisory: None = None, |
to force any new arguments to be passed by name explicitly
- getting to having a lot of arguments here and IMO it is less error prone for users
- that would allow us to reorder the argument list if needed in the future
if we also added a trailing **kwargs
, we could even remove parameters in the future if they get deprecated. Maybe lets discuss in the SIG but wanted to get your thoughts.
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'm fine with that
# pylint: disable=super-init-not-called | ||
def __init__( |
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 it because of multiple inheritance?
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 think this is because I haven't updated _ProxyInstrument and all the other instrument classes to get the advisory parameter.
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.
Adding them broke mypy ofc 😓
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.
Fixed in 0b6fc1f
opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/__init__.py
Outdated
Show resolved
Hide resolved
opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/__init__.py
Outdated
Show resolved
Hide resolved
opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/aggregation.py
Show resolved
Hide resolved
7500.0, | ||
10000.0, | ||
), | ||
boundaries: Optional[Sequence[float]] = None, |
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'm fine with whatever you want to do here
e8c6a4d
to
d3a345f
Compare
First to take into account advisory and then to avoid printing warnings if there's not duplicate for already registered instrument.
d3a345f
to
005295a
Compare
1372540
to
5cd650a
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.
💯
@@ -394,6 +451,7 @@ def create_gauge( # type: ignore # pylint: disable=no-self-use | |||
name: str, | |||
unit: str = "", | |||
description: str = "", | |||
advisory: Optional[MetricsCommonAdvisory] = None, |
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.
What if the spec adds specification adds a new advisory type for another instrument, say MetricsGaugeAdvisory
? I think if we changed the type here, that would be a breaking 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.
So are you suggesting to add preemptively a custom type for each instrumenting or having the specific dataclass inherit from the common be enough? In other words, is the issue about the name of the type or its structure?
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.
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 guess the flat approach is for this very same reason of avoiding breaking compatibility by changing the layout of the advisory
Description
This adds basic support for the advisory attribute of Instruments and implements ExplicitBucketBoundaries advisory for Histograms.
Fixes #4140
Fixes #3042
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Does This PR Require a Contrib Repo Change?
Checklist: