forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[processor/metricsgeneration] Generate metrics even when the second m…
…etric's value is 0 (open-telemetry#35537) **Description:** Originally, this processor would not generate a new metric if the value of the metric configured as `metric2` was `0`. There are valid reasons why this calculation should still be done, and a new metric should be calculated. **Link to tracking Issue:** Resolves open-telemetry#35533 **Testing:** Added tests for each calculation type to show expected results when the second metric's value is 0.
- Loading branch information
Showing
29 changed files
with
388 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Use this changelog template to create an entry for release notes. | ||
|
||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: breaking | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) | ||
component: metricsgenerationprocessor | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Generate metrics even when the second metric's value is 0 | ||
|
||
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. | ||
issues: [35533] | ||
|
||
# (Optional) One or more lines of additional information to render under the primary note. | ||
# These lines will be padded with 2 spaces and then inserted directly into the document. | ||
# Use pipe (|) for multiline entries. | ||
subtext: | ||
|
||
# If your change doesn't affect end users or the exported elements of any package, | ||
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. | ||
# Optional: The change log or logs in which this entry should be included. | ||
# e.g. '[user]' or '[user, api]' | ||
# Include 'user' if the change is relevant to end users. | ||
# Include 'api' if there is a change to a library API. | ||
# Default: '[user]' | ||
change_logs: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
processor/metricsgenerationprocessor/testdata/input_metric_types/config.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
experimental_metricsgeneration/sum_gauge_metric: | ||
rules: | ||
- name: system.filesystem.capacity | ||
unit: bytes | ||
type: calculate | ||
metric1: system.filesystem.usage | ||
metric2: system.filesystem.utilization | ||
operation: divide |
File renamed without changes.
File renamed without changes.
30 changes: 30 additions & 0 deletions
30
processor/metricsgenerationprocessor/testdata/metric2_zero_value/config.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
experimental_metricsgeneration/metric2_zero_add: | ||
rules: | ||
- name: new_metric | ||
metric1: capacity.total | ||
metric2: capacity.used | ||
operation: add | ||
experimental_metricsgeneration/metric2_zero_subtract: | ||
rules: | ||
- name: new_metric | ||
metric1: capacity.total | ||
metric2: capacity.used | ||
operation: subtract | ||
experimental_metricsgeneration/metric2_zero_multiply: | ||
rules: | ||
- name: new_metric | ||
metric1: capacity.total | ||
metric2: capacity.used | ||
operation: multiply | ||
experimental_metricsgeneration/metric2_zero_divide: | ||
rules: | ||
- name: new_metric | ||
metric1: capacity.total | ||
metric2: capacity.used | ||
operation: divide | ||
experimental_metricsgeneration/metric2_zero_percent: | ||
rules: | ||
- name: new_metric | ||
metric1: capacity.total | ||
metric2: capacity.used | ||
operation: percent |
31 changes: 31 additions & 0 deletions
31
...sor/metricsgenerationprocessor/testdata/metric2_zero_value/metric2_zero_add_expected.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
resourceMetrics: | ||
- resource: {} | ||
schemaUrl: https://opentelemetry.io/schemas/1.9.0 | ||
scopeMetrics: | ||
- metrics: | ||
- description: total capacity | ||
name: capacity.total | ||
sum: | ||
aggregationTemporality: 2 | ||
dataPoints: | ||
- asInt: "50" | ||
startTimeUnixNano: "1000000" | ||
timeUnixNano: "2000000" | ||
unit: By | ||
- description: used capacity | ||
gauge: | ||
dataPoints: | ||
- asInt: "0" | ||
startTimeUnixNano: "1000000" | ||
timeUnixNano: "2000000" | ||
name: capacity.used | ||
unit: By | ||
- name: new_metric | ||
sum: | ||
dataPoints: | ||
- asDouble: 50 | ||
startTimeUnixNano: "1000000" | ||
timeUnixNano: "2000000" | ||
scope: | ||
name: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/filesystemscraper | ||
version: latest |
25 changes: 25 additions & 0 deletions
25
.../metricsgenerationprocessor/testdata/metric2_zero_value/metric2_zero_divide_expected.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
resourceMetrics: | ||
- resource: {} | ||
schemaUrl: https://opentelemetry.io/schemas/1.9.0 | ||
scopeMetrics: | ||
- metrics: | ||
- description: total capacity | ||
name: capacity.total | ||
sum: | ||
aggregationTemporality: 2 | ||
dataPoints: | ||
- asInt: "50" | ||
startTimeUnixNano: "1000000" | ||
timeUnixNano: "2000000" | ||
unit: By | ||
- description: used capacity | ||
gauge: | ||
dataPoints: | ||
- asInt: "0" | ||
startTimeUnixNano: "1000000" | ||
timeUnixNano: "2000000" | ||
name: capacity.used | ||
unit: By | ||
scope: | ||
name: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/filesystemscraper | ||
version: latest |
31 changes: 31 additions & 0 deletions
31
...etricsgenerationprocessor/testdata/metric2_zero_value/metric2_zero_multiply_expected.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
resourceMetrics: | ||
- resource: {} | ||
schemaUrl: https://opentelemetry.io/schemas/1.9.0 | ||
scopeMetrics: | ||
- metrics: | ||
- description: total capacity | ||
name: capacity.total | ||
sum: | ||
aggregationTemporality: 2 | ||
dataPoints: | ||
- asInt: "50" | ||
startTimeUnixNano: "1000000" | ||
timeUnixNano: "2000000" | ||
unit: By | ||
- description: used capacity | ||
gauge: | ||
dataPoints: | ||
- asInt: "0" | ||
startTimeUnixNano: "1000000" | ||
timeUnixNano: "2000000" | ||
name: capacity.used | ||
unit: By | ||
- name: new_metric | ||
sum: | ||
dataPoints: | ||
- asDouble: 0 | ||
startTimeUnixNano: "1000000" | ||
timeUnixNano: "2000000" | ||
scope: | ||
name: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/filesystemscraper | ||
version: latest |
25 changes: 25 additions & 0 deletions
25
...metricsgenerationprocessor/testdata/metric2_zero_value/metric2_zero_percent_expected.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
resourceMetrics: | ||
- resource: {} | ||
schemaUrl: https://opentelemetry.io/schemas/1.9.0 | ||
scopeMetrics: | ||
- metrics: | ||
- description: total capacity | ||
name: capacity.total | ||
sum: | ||
aggregationTemporality: 2 | ||
dataPoints: | ||
- asInt: "50" | ||
startTimeUnixNano: "1000000" | ||
timeUnixNano: "2000000" | ||
unit: By | ||
- description: used capacity | ||
gauge: | ||
dataPoints: | ||
- asInt: "0" | ||
startTimeUnixNano: "1000000" | ||
timeUnixNano: "2000000" | ||
name: capacity.used | ||
unit: By | ||
scope: | ||
name: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/filesystemscraper | ||
version: latest |
Oops, something went wrong.