Skip to content

Allow multiple gauge values within the same MetricAggregator instance. #2700

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

brandondahler
Copy link

Adds the provided timestamp to the metric instance's context.
Use of multiple gauge values for a single metric requires the timestamps to be passed explicitly.

Problem:
Currently calling self.gauge() with the same metric name, hostname, and tags but different timestamp only retains the last call's value.

Use case:
Upstream API that provides data has a variable delay before values are available. When data is available, it provides multiple values for different timestamps all at once.

Proposed solution:
Includes the provided timestamp as part of the metric instance's context to allow multiple instances that differ only by timestamp.

Notes about solution:
This technically affects all metrics, potentially changing the way the previous metric instance is selected. The updated code only affects previous implementations if and only if the timestamp parameter is specified. The timestamp parameter is currently only used by the gauge metric.

Adds the provided timestamp to the metric instance's context.
Use of multiple gauge values for a single metric requires the timestamps to be passed explicitly.
@brandondahler
Copy link
Author

brandondahler commented Jul 25, 2016

Checks failing due to change in how MetricAggregator handles multiple calls to self.gauge when timestamp parameter is different (as intended for this request).

@degemer degemer added this to the Triage milestone Aug 19, 2016
@degemer
Copy link
Member

degemer commented Aug 19, 2016

Hey @brandondahler, thanks for the PR!

This could be a pretty big change, could you elaborate on your use case ? I.e. how far in the past are the timestamps you are adding ? What's the resolution (one metric every second, 10 seconds, ...) ?

Let me know if you have any question!

@degemer degemer self-assigned this Aug 19, 2016
@brandondahler
Copy link
Author

This PR is a product of what I had to do in implementation of AzureServiceBusCheck.py:40-53 (which I plan on submitting as a community check eventually).

Specifically the management_service.get_metrics_data_queue(...) function calls an Azure web service. That web service returns aggregated metrics data (such as messages outgoing and incoming) over a configurable time period, I'm using the smallest at 5 minutes.

The problem is that the metrics aren't immediately available every 5 minutes, instead they seem to slowly come in based on load of their system, usually within 15 minutes (or never if the value is 0). The service is structured so that you can query time ranges and it will return all non-zero results within that time range.

Ideally I'd be able to query this service every 5 minutes and get only the new metric values, even if there are multiple available since the last time I tried, and submit all of them at once. However, since the metrics only differ by value and timestamp, I can only submit a single value for that run.

I do understand that there are other ways for me to solve this particular problem, I'm submitting this PR because the functionality seems confusing.

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.

2 participants