Skip to content
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

Change prometheus to not aggregate metrics and only export them. #385

Merged
merged 22 commits into from
Dec 23, 2019
Merged

Change prometheus to not aggregate metrics and only export them. #385

merged 22 commits into from
Dec 23, 2019

Conversation

paivagustavo
Copy link
Member

Closes #370

What does this changes?

  • This removes usage of the prometheus client to aggregate metrics, instead use the already aggregated data from the Otel SDK;
  • Removes the ability of a histogram metrics (until Implement Histogram aggregator #317 is addressed);
  • Simplify prometheus exporter;

There is an obvious improvement to be done here in the error handling part.

With this changes, The Export(_ context.Context, checkpointSet export.CheckpointSet) only stores the last checkpointSet and defer the exporting to when the prometheus http handler is called.

Initially I thought about a bigger change, using a pull controller that would aggregate data when this handler is activated, but that could make the export operation slower.

The decision here was between two types of exporters:

  • one that could be a somewhat expensive since we would need to aggregate, batch and export the metrics but would have consistent and fresh data;
  • or a lighter export that could have a somewhat stale data (this would be at most the time between Controller.Ticks)

I've chosen the later to have a more consistent and ligther operation when exporting data. After further analyses of the OpenCensus they also do it this way.

I've also changed the test.CheckpointSet to accept Add several metrics with the same name and label set, this would batch them just like a defaultkeys.Batcher to proper tests summaries/histogram since Prometheus doesn't aggregate them anymore.

Copy link
Contributor

@jmacd jmacd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe there's a synchronization issue here--I think it can be addressed by simply copying the checkpoint set.

I also am still pushing for a new kind of "pull" controller (which may be dedicated to Prometheus only) that would call Collect() on demand as I think it will make the synchronization more natural and address the need to reset some state, discussed below.

That said, I would be happy to approve this and work on the remaining issues in a future PR.

example/prometheus/main.go Show resolved Hide resolved
exporter/metric/prometheus/prometheus.go Show resolved Hide resolved
@jmacd jmacd marked this pull request as ready for review December 17, 2019 19:02
@lizthegrey
Copy link
Member

remove WIP from title if ready for review.

@paivagustavo paivagustavo changed the title WIP: Change prometheus to not aggregate metrics and only export them. Change prometheus to not aggregate metrics and only export them. Dec 17, 2019
Copy link
Contributor

@rghetia rghetia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple of minor comments. LGTM otherwise.

exporter/metric/prometheus/prometheus.go Outdated Show resolved Hide resolved
exporter/metric/prometheus/prometheus.go Outdated Show resolved Hide resolved
example/prometheus/main.go Show resolved Hide resolved
exporter/metric/prometheus/prometheus.go Outdated Show resolved Hide resolved
exporter/metric/prometheus/prometheus.go Outdated Show resolved Hide resolved
example/prometheus/main.go Show resolved Hide resolved
exporter/metric/prometheus/prometheus.go Outdated Show resolved Hide resolved
_ = gagg.Update(ctx, createNumber(desc, v), desc)
gagg.Checkpoint(ctx, desc)
p.Add(desc, gagg, labels...)
if agg != gagg {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment about this new test support?

Copy link
Member Author

@paivagustavo paivagustavo Dec 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, this was a little bit enigmatic. I've refactored it a bit and added some docs.

@rghetia
Copy link
Contributor

rghetia commented Dec 20, 2019

@lizthegrey are you satisfied with the changes?

@jmacd yesterday you had mentioned that you were going to look at this PR one more time. Do you have additional comments?

@jmacd
Copy link
Contributor

jmacd commented Dec 20, 2019

I just wanted to make sure I understood the test changes (and I do). Thanks @paivagustavo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prometheus client should not be used to aggregate metrics points
5 participants