Skip to content
Open
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
27 changes: 27 additions & 0 deletions .chloggen/spanmetrics-skip-reset-iteration.yaml
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: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. receiver/filelog)
component: connector/span_metrics

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Skip the per-flush resource iteration in cumulative mode when no exemplar clearing or expiration is configured.

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [50925]

# (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: [user]
2 changes: 1 addition & 1 deletion connector/spanmetricsconnector/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ func (p *connectorImp) resetState() {

// If none of these features are enabled then we can skip the remaining operations.
// Enabling either of these features requires to go over resource metrics and do operation on each.
if p.config.Histogram.Disable && p.config.MetricsExpiration == 0 && p.config.SeriesExpiration == 0 && !p.config.Exemplars.Enabled {
if p.config.MetricsExpiration == 0 && p.config.SeriesExpiration == 0 && !p.config.Exemplars.Enabled {
return
}

Expand Down
12 changes: 12 additions & 0 deletions connector/spanmetricsconnector/connector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1432,6 +1432,18 @@ func TestSeriesExpiration(t *testing.T) {
assert.True(t, hasDataPointWithStringAttrValue(exported, "B"))
}

func TestResetStateSkipsIterationWhenNothingToReset(t *testing.T) {
p, err := newConnectorImp(new("defaultNullValue"), explicitHistogramsConfig, disabledExemplarsConfig, disabledEventsConfig, cumulative, 0, []string{}, 1000, clockwork.NewFakeClock(), false)
require.NoError(t, err)
require.NoError(t, p.ConsumeTraces(metadata.NewIncomingContext(t.Context(), nil), buildSampleTrace()))

// With cumulative temporality and no exemplars or expiration configured, resetState has
// nothing to do per resource, so it must not iterate over (and allocate a key slice for) the cache.
allocs := testing.AllocsPerRun(10, p.resetState)
assert.Zero(t, allocs)
assert.Equal(t, 2, p.resourceMetrics.Len())
}

func TestResourceMetricsKeyAttributes(t *testing.T) {
resourceMetricsKeyAttributes := []string{
"service.name",
Expand Down
Loading