Skip to content

Commit 036edab

Browse files
fix: send min and max histogram data (#1766)
1 parent 89ca91d commit 036edab

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/Contrib/Otlp/MetricConverter.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ private function convertHistogramDataPoint(SDK\Metrics\Data\HistogramDataPoint $
204204
$pHistogramDataPoint->setTimeUnixNano($dataPoint->timestamp);
205205
$pHistogramDataPoint->setCount($dataPoint->count);
206206
$pHistogramDataPoint->setSum($dataPoint->sum);
207+
$pHistogramDataPoint->setMin($dataPoint->min);
208+
$pHistogramDataPoint->setMax($dataPoint->max);
207209
$pHistogramDataPoint->setBucketCounts($dataPoint->bucketCounts);
208210
$pHistogramDataPoint->setExplicitBounds($dataPoint->explicitBounds);
209211
foreach ($dataPoint->exemplars as $exemplar) {

tests/Unit/Contrib/Otlp/MetricConverterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function test_metrics_are_converted_to_metrics_request(): void
4343
{"attributes":[{"key":"foo","value":{"stringValue":"bar"}}],"startTimeUnixNano":"17","timeUnixNano":"42","asInt":"5"}
4444
],"aggregationTemporality":"AGGREGATION_TEMPORALITY_CUMULATIVE"}},
4545
{"name":"test-2","histogram":{"dataPoints":[
46-
{"startTimeUnixNano":"17","timeUnixNano":"42","count":"2","sum":7,"bucketCounts":["2", "0"],"explicitBounds":[5]}
46+
{"startTimeUnixNano":"17","timeUnixNano":"42","count":"2","sum":7,"bucketCounts":["2", "0"],"explicitBounds":[5],"min":3,"max":4}
4747
],"aggregationTemporality":"AGGREGATION_TEMPORALITY_DELTA"}},
4848
{"name":"test-3","gauge":{"dataPoints":[
4949
{"startTimeUnixNano":"17","timeUnixNano":"42","asDouble":9.5}
@@ -122,7 +122,7 @@ public function test_histogram_exemplars_are_converted(): void
122122
<<<JSON
123123
{"resourceMetrics":[{"resource":{},"scopeMetrics":[{"scope":{"name":"test"},"metrics":[
124124
{"name":"test-1","histogram":{"dataPoints":[
125-
{"attributes":[{"key":"foo","value":{"stringValue":"bar"}}],"startTimeUnixNano":"17","timeUnixNano":"42","count":"5","sum":9,"bucketCounts":["5"],"exemplars":[
125+
{"attributes":[{"key":"foo","value":{"stringValue":"bar"}}],"startTimeUnixNano":"17","timeUnixNano":"42","count":"5","sum":9,"bucketCounts":["5"],"min":-2,"max":8,"exemplars":[
126126
{"filteredAttributes":[{"key":"key","value":{"stringValue":"value"}}],"timeUnixNano":"19","asDouble":0.5},
127127
{"filteredAttributes":[{"key":"key","value":{"stringValue":"other"}}],"timeUnixNano":"37","asInt":"-3","spanId":"APBnqgupArc=","traceId":"S/kvNXezTaajzpKdDg5HNg=="}
128128
]}

0 commit comments

Comments
 (0)