Skip to content
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
29 changes: 29 additions & 0 deletions .chloggen/gaurab_tagging.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 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: processor/adaptivetelemetry

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Add `process.atp.enabled` attribute to resources actively processed by the Adaptive Telemetry Processor"

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

# (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: |
Resources that are included due to ATP filter evaluation (thresholds, anomaly detection, multi-metric, retention, include list, or zombie process detection) will now have the `process.atp.enabled=true` attribute set.
Resources included by default (those not targeted by ATP configuration) will not have this attribute.

# 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]
7 changes: 7 additions & 0 deletions processor/adaptivetelemetryprocessor/process_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,13 @@ func (p *processorImp) handleIncludedResource(rm pmetric.ResourceMetrics, resour

dest := filtered.ResourceMetrics().AppendEmpty()
rm.CopyTo(dest)

// Add process.atp.enabled=true for resources processed by ATP
// Exclude stageDefaultInclusion as those weren't evaluated by ATP
if includeReason != stageDefaultInclusion && includeReason != "" {
dest.Resource().Attributes().PutBool("process.atp.enabled", true)
}

// Remove the internal filter stage attribute from the output, unless debugging is enabled
if !p.config.DebugShowAllFilterStages {
dest.Resource().Attributes().Remove(internalFilterStageAttributeKey)
Expand Down
31 changes: 31 additions & 0 deletions processor/adaptivetelemetryprocessor/process_metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,37 @@ func TestProcessMetricsExtended(t *testing.T) {
assert.Equal(t, 0, countNonSummaryResources(result),
"All resources should be filtered out")
})

t.Run("ATP enabled attribute is set for processed resources", func(t *testing.T) {
// Test 1: Above threshold - should be included by ATP, not default inclusion
metrics := createExtendedTestMetrics(
map[string]string{"service.name": "atp-enabled-service"},
map[string]float64{"system.cpu.utilization": 90.0}, // Above threshold
)
result, err := processor.processMetrics(t.Context(), metrics)
assert.NoError(t, err)
assert.Positive(t, countNonSummaryResources(result), "Should have at least one resource")

rm := result.ResourceMetrics().At(0)
atpEnabled, exists := rm.Resource().Attributes().Get("process.atp.enabled")
assert.True(t, exists, "process.atp.enabled should be set for ATP-processed resource")
if exists {
assert.True(t, atpEnabled.Bool(), "process.atp.enabled should be true")
}

// Test 2: Below threshold with no matching metric - should be included by default, not ATP
metricsDefault := createExtendedTestMetrics(
map[string]string{"service.name": "default-inclusion-service"},
map[string]float64{"some.other.metric": 10.0}, // Not in MetricThresholds config
)
resultDefault, err := processor.processMetrics(t.Context(), metricsDefault)
assert.NoError(t, err)
assert.Positive(t, countNonSummaryResources(resultDefault), "Should have at least one resource")

rmDefault := resultDefault.ResourceMetrics().At(0)
_, existsDefault := rmDefault.Resource().Attributes().Get("process.atp.enabled")
assert.False(t, existsDefault, "process.atp.enabled should NOT be set for default-included resource")
})
}

// Helper function to count metrics in a batch, excluding summary metrics
Expand Down
Loading