Skip to content

Commit 43b4eab

Browse files
jsonlsyMovieStoreGuy
authored andcommitted
[connector/spanmetrics] Fix delta span metrics (open-telemetry#40148)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Fixes bug causing calls count to always be 0 when using delta aggregation temporality (see linked issue). This PR adds a check for the temporality used so that we only overwrite the first value for cumulative metrics only. <!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes open-telemetry#40139 <!--Please delete paragraphs that you did not use before submitting.--> --------- Co-authored-by: Sean Marciniak <[email protected]>
1 parent 10c9863 commit 43b4eab

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: 'bug_fix'
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: 'spanmetricsconnector'
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: 'Fix bug causing span metrics calls count to be always 0 when using delta temporality'
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [40139]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: [user]

connector/spanmetricsconnector/connector_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ func verifyConsumeMetricsInput(tb testing.TB, input pmetric.Metrics, expectedTem
190190
dp := callsDps.At(dpi)
191191
expectIntValue := numCumulativeConsumptions
192192
// this calls init value is 0 for the first Consumption.
193-
if numCumulativeConsumptions == 1 {
193+
if expectedTemporality == pmetric.AggregationTemporalityCumulative && numCumulativeConsumptions == 1 {
194194
expectIntValue = 0
195195
}
196196
assert.Equal(tb,

connector/spanmetricsconnector/internal/metrics/metrics.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ func (m *SumMetrics) BuildMetrics(
391391
startTimeStamp := startTimeStampGenerator(k, s.startTimestamp)
392392
dp.SetStartTimestamp(startTimeStamp)
393393
dp.SetTimestamp(timestamp)
394-
if s.isFirst {
394+
if temporality == pmetric.AggregationTemporalityCumulative && s.isFirst {
395395
dp.SetIntValue(0)
396396
s.isFirst = false
397397
} else {

0 commit comments

Comments
 (0)