-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pkg/golden]: Add option to skip normalizing timestamps when writing …
…metrics (#31161) **Description:** <Describe what has changed.> * Adds a new WriteMetricsOption type, which can be specified when calling WriteMetrics * Adds a WriteMetricsOption for skipping the timestamp normalization step. **Link to tracking Issue:** Closes #30919 **Testing:** <Describe what testing was performed and which tests were added.> * Unit test added for new functionality
- Loading branch information
1 parent
debaf05
commit 7320350
Showing
5 changed files
with
137 additions
and
4 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
.chloggen/feat_optional-metric-timestamp-normalization.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,15 @@ | ||
# Use this changelog template to create an entry for release notes. | ||
|
||
# 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: pkg/golden | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Added an option to skip the metric timestamp normalization for WriteMetrics. | ||
|
||
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. | ||
issues: [30919] | ||
|
||
change_logs: ["api"] |
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
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,18 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package golden // import "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden" | ||
|
||
// WriteMetricsOption is an option for the WriteMetrics function | ||
type WriteMetricsOption func(*writeMetricsOptions) | ||
|
||
type writeMetricsOptions struct { | ||
normalizeTimestamps bool | ||
} | ||
|
||
// SkipMetricTimestampNormalization is an option that skips normalizing timestamps before writing metrics to disk. | ||
func SkipMetricTimestampNormalization() WriteMetricsOption { | ||
return func(wmo *writeMetricsOptions) { | ||
wmo.normalizeTimestamps = false | ||
} | ||
} |
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,66 @@ | ||
resourceMetrics: | ||
- resource: {} | ||
scopeMetrics: | ||
- metrics: | ||
- description: multi gauge | ||
gauge: | ||
dataPoints: | ||
- asDouble: 2 | ||
attributes: | ||
- key: testKey1 | ||
value: | ||
stringValue: teststringvalue1 | ||
- key: testKey2 | ||
value: | ||
stringValue: testvalue1 | ||
timeUnixNano: "11651379494838206464" | ||
- asDouble: 2 | ||
attributes: | ||
- key: testKey1 | ||
value: | ||
stringValue: teststringvalue2 | ||
- key: testKey2 | ||
value: | ||
stringValue: testvalue2 | ||
timeUnixNano: "11651379494838206464" | ||
name: test gauge multi | ||
unit: "1" | ||
- description: single gauge | ||
gauge: | ||
dataPoints: | ||
- asInt: "2" | ||
attributes: | ||
- key: testKey2 | ||
value: | ||
stringValue: teststringvalue2 | ||
timeUnixNano: "11651379494838206464" | ||
name: test gauge single | ||
unit: By | ||
- description: multi sum | ||
name: test delta sum multi | ||
sum: | ||
aggregationTemporality: 1 | ||
dataPoints: | ||
- asInt: "2" | ||
attributes: | ||
- key: testKey2 | ||
value: | ||
stringValue: teststringvalue2 | ||
timeUnixNano: "11651379494838206464" | ||
- asInt: "2" | ||
attributes: | ||
- key: testKey2 | ||
value: | ||
stringValue: teststringvalue2 | ||
timeUnixNano: "11651379494838206464" | ||
unit: s | ||
- description: single sum | ||
name: test cumulative sum single | ||
sum: | ||
aggregationTemporality: 2 | ||
dataPoints: | ||
- asDouble: 2 | ||
timeUnixNano: "869965261000000001" | ||
isMonotonic: true | ||
unit: 1/s | ||
scope: {} |