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

[internal/comparetest] Add support for all metric types #17579

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .chloggen/comparetest-add-support-for-all-metric-types.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: internal/comparetest

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add support for all metric types

# One or more tracking issues related to the change
issues: [17538]
342 changes: 322 additions & 20 deletions internal/comparetest/metrics.go

Large diffs are not rendered by default.

119 changes: 117 additions & 2 deletions internal/comparetest/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func TestCompareMetrics(t *testing.T) {
err: multierr.Combine(
errors.New("datapoints for metric: `gauge.one`, do not match expected"),
errors.New("datapoint with attributes: map[], does not match expected"),
errors.New("metric datapoint types don't match: expected type: int, actual type: double"),
errors.New("metric datapoint types don't match: expected type: Int, actual type: Double"),
),
reason: "A data point with the wrong type of value should cause a failure.",
},
Expand All @@ -281,11 +281,126 @@ func TestCompareMetrics(t *testing.T) {
err: multierr.Combine(
errors.New("datapoints for metric: `gauge.one`, do not match expected"),
errors.New("datapoint with attributes: map[], does not match expected"),
errors.New("metric datapoint types don't match: expected type: double, actual type: int"),
errors.New("metric datapoint types don't match: expected type: Double, actual type: Int"),
),
reason: "A data point with the wrong type of value should cause a failure.",
},
},
{
name: "histogram-data-point-count-mismatch",
withoutOptions: expectation{
err: multierr.Combine(
errors.New("datapoints for metric: `histogram.one`, do not match expected"),
errors.New("datapoint with attributes: map[], does not match expected"),
errors.New("metric datapoint Count doesn't match expected: 123, actual: 654"),
),
reason: "A data point with the wrong bucket count should cause a failure.",
},
},
{
name: "histogram-data-point-sum-mismatch",
withoutOptions: expectation{
err: multierr.Combine(
errors.New("datapoints for metric: `histogram.one`, do not match expected"),
errors.New("datapoint with attributes: map[], does not match expected"),
errors.New("metric datapoint Sum doesn't match expected: 123.456000, actual: 654.321000"),
),
},
},
{
name: "histogram-data-point-buckets-mismatch",
withoutOptions: expectation{
err: multierr.Combine(
errors.New("datapoints for metric: `histogram.one`, do not match expected"),
errors.New("datapoint with attributes: map[], does not match expected"),
errors.New("metric datapoint BucketCounts doesn't match expected: [1 2 3], actual: [3 2 1]"),
),
},
},
{
name: "exp-histogram-data-point-count-mismatch",
withoutOptions: expectation{
err: multierr.Combine(
errors.New("datapoints for metric: `exponential_histogram.one`, do not match expected"),
errors.New("datapoint with attributes: map[], does not match expected"),
errors.New("metric datapoint Count doesn't match expected: 123, actual: 654"),
),
reason: "A data point with the wrong bucket count should cause a failure.",
},
},
{
name: "exp-histogram-data-point-sum-mismatch",
withoutOptions: expectation{
err: multierr.Combine(
errors.New("datapoints for metric: `exponential_histogram.one`, do not match expected"),
errors.New("datapoint with attributes: map[], does not match expected"),
errors.New("metric datapoint Sum doesn't match expected: 123.456000, actual: 654.321000"),
),
},
},
{
name: "exp-histogram-data-point-positive-buckets-mismatch",
withoutOptions: expectation{
err: multierr.Combine(
errors.New("datapoints for metric: `exponential_histogram.one`, do not match expected"),
errors.New("datapoint with attributes: map[], does not match expected"),
errors.New("metric datapoint Positive BucketCounts doesn't match expected: [1 2 3], "+
"actual: [3 2 1]"),
),
},
},
{
name: "exp-histogram-data-point-negative-offset-mismatch",
withoutOptions: expectation{
err: multierr.Combine(
errors.New("datapoints for metric: `exponential_histogram.one`, do not match expected"),
errors.New("datapoint with attributes: map[], does not match expected"),
errors.New("metric datapoint Negative Offset doesn't match expected: 10, actual: 1"),
),
},
},
{
name: "summary-data-point-count-mismatch",
withoutOptions: expectation{
err: multierr.Combine(
errors.New("datapoints for metric: `summary.one`, do not match expected"),
errors.New("datapoint with attributes: map[], does not match expected"),
errors.New("metric datapoint Count doesn't match expected: 123, actual: 654"),
),
reason: "A data point with the wrong bucket count should cause a failure.",
},
},
{
name: "summary-data-point-sum-mismatch",
withoutOptions: expectation{
err: multierr.Combine(
errors.New("datapoints for metric: `summary.one`, do not match expected"),
errors.New("datapoint with attributes: map[], does not match expected"),
errors.New("metric datapoint Sum doesn't match expected: 123.456000, actual: 654.321000"),
),
},
},
{
name: "summary-data-point-quantile-values-length-mismatch",
withoutOptions: expectation{
err: multierr.Combine(
errors.New("datapoints for metric: `summary.one`, do not match expected"),
errors.New("datapoint with attributes: map[], does not match expected"),
errors.New("metric datapoint QuantileValues length doesn't match expected: 3, actual: 2"),
),
},
},
{
name: "summary-data-point-quantile-values-mismatch",
withoutOptions: expectation{
err: multierr.Combine(
errors.New("datapoints for metric: `summary.one`, do not match expected"),
errors.New("datapoint with attributes: map[], does not match expected"),
errors.New("metric datapoint value at quantile 0.990000 doesn't match expected: 99.000000, "+
"actual: 110.000000"),
),
},
},
{
name: "ignore-timestamp",
withoutOptions: expectation{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"resourceMetrics": [
{
"scopeMetrics": [
{
"metrics": [
{
"name": "exponential_histogram.one",
"exponentialHistogram": {
"dataPoints": [
{
"count": 654
}
]
}
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"resourceMetrics": [
{
"scopeMetrics": [
{
"metrics": [
{
"name": "exponential_histogram.one",
"exponentialHistogram": {
"dataPoints": [
{
"count": 123
}
]
}
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"resourceMetrics": [
{
"scopeMetrics": [
{
"metrics": [
{
"name": "exponential_histogram.one",
"exponentialHistogram": {
"dataPoints": [
{
"negative": {
"offset": 1
}
}
]
}
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"resourceMetrics": [
{
"scopeMetrics": [
{
"metrics": [
{
"name": "exponential_histogram.one",
"exponentialHistogram": {
"dataPoints": [
{
"negative": {
"offset": 10
}
}
]
}
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"resourceMetrics": [
{
"scopeMetrics": [
{
"metrics": [
{
"name": "exponential_histogram.one",
"exponentialHistogram": {
"dataPoints": [
{
"positive": {
"bucketCounts": [3, 2, 1]
}
}
]
}
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"resourceMetrics": [
{
"scopeMetrics": [
{
"metrics": [
{
"name": "exponential_histogram.one",
"exponentialHistogram": {
"dataPoints": [
{
"positive": {
"bucketCounts": [1, 2, 3]
}
}
]
}
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"resourceMetrics": [
{
"scopeMetrics": [
{
"metrics": [
{
"name": "exponential_histogram.one",
"exponentialHistogram": {
"dataPoints": [
{
"sum": 654.321000
}
]
}
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"resourceMetrics": [
{
"scopeMetrics": [
{
"metrics": [
{
"name": "exponential_histogram.one",
"exponentialHistogram": {
"dataPoints": [
{
"sum": 123.456000
}
]
}
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"resourceMetrics": [
{
"scopeMetrics": [
{
"metrics": [
{
"name": "histogram.one",
"histogram": {
"dataPoints": [
{
"bucketCounts": [3, 2, 1]
}
]
}
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"resourceMetrics": [
{
"scopeMetrics": [
{
"metrics": [
{
"name": "histogram.one",
"histogram": {
"dataPoints": [
{
"bucketCounts": [1, 2, 3]
}
]
}
}
]
}
]
}
]
}
Loading