Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ endif::[]
//===== Bug fixes


=== Unreleased

// Unreleased changes go here
// When the next release happens, nest these changes under the "Python Agent version 6.x" heading
//[float]
//===== Features
//
//
[float]
===== Bug fixes
* ensure that Prometheus histograms are encoded correctly for APM Server {pull}1354[#1354]

[[release-notes-6.x]]
=== Python Agent version 6.x

Expand Down
2 changes: 1 addition & 1 deletion elasticapm/metrics/sets/prometheus.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def _prom_histogram_handler(self, name, samples, unit):
sample = samples[sample_pos]
if "le" in sample.labels:
values.append(float(sample.labels["le"]))
counts.append(sample.value - prev_val)
counts.append(int(sample.value - prev_val))
prev_val = sample.value
sample_pos += 1

Expand Down
3 changes: 3 additions & 0 deletions tests/metrics/prometheus_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,14 @@ def test_histogram(elasticapm_client, prometheus):
data = list(metricset.collect())
assert data[0]["samples"]["prometheus.metrics.histo"]["values"] == [0.5, 5.5, 55.0, 100.0]
assert data[0]["samples"]["prometheus.metrics.histo"]["counts"] == [2, 1, 3, 1]
assert all(isinstance(v, int) for v in data[0]["samples"]["prometheus.metrics.histo"]["counts"])

assert data[1]["samples"]["prometheus.metrics.histowithlabel"]["values"] == [0.5, 5.5, 55.0, 100.0]
assert data[1]["samples"]["prometheus.metrics.histowithlabel"]["counts"] == [1, 1, 1, 0]
assert all(isinstance(v, int) for v in data[1]["samples"]["prometheus.metrics.histowithlabel"]["counts"])
assert data[1]["tags"] == {"alabel": "foo", "anotherlabel": "baz"}

assert data[2]["samples"]["prometheus.metrics.histowithlabel"]["values"] == [0.5, 5.5, 55.0, 100.0]
assert data[2]["samples"]["prometheus.metrics.histowithlabel"]["counts"] == [0, 0, 0, 1]
assert all(isinstance(v, int) for v in data[2]["samples"]["prometheus.metrics.histowithlabel"]["counts"])
assert data[2]["tags"] == {"alabel": "foo", "anotherlabel": "bazzinga"}