[target-allocator] Add feature flag for labeled targets_remaining metric with OTel conventions - #4640
[target-allocator] Add feature flag for labeled targets_remaining metric with OTel conventions#4640hkf57 wants to merge 6 commits into
Conversation
|
I don't think what you've done is enough for the feature gate to propagate down. Right now, if you set it on the operator, it won't do anything. It is possible to set it on the allocator directly by passing it as an argument, but that's quite inconvenient. It'd be better if the operator did it if it's enabled. |
c163f8d to
dd71375
Compare
|
I'd prefer if we made this a feature flag in the target allocator as well.
Not only will this remove the need to set a new attribute on the structs in target allocator, you also won't need to add a new config option. Adding that option and then removing it later will be an unnecessary breaking change. |
df64187 to
057b77c
Compare
|
|
||
| a.targetsRemaining.Record(context.Background(), int64(len(targets))) | ||
| // Record remaining targets, with labels if feature flag is enabled | ||
| if a.useLabeledMetrics { |
There was a problem hiding this comment.
I think you can just use the feature gate directly here and avoid passing this option down from main.go.
E2E Test Results 32 files 251 suites 2h 6m 52s ⏱️ Results for commit c6b0456. ♻️ This comment has been updated with latest results. |
…ning metric
Add namespace and job_name labels to opentelemetry_allocator_targets_remaining
metric to allow distinguishing between intentionally filtered targets and
orphaned targets due to bugs.
Currently, the metric reports a scalar count making it impossible to alert
on orphaned targets without false positives from intentionally filtered
namespaces (e.g., istio-system excluded for cost control).
With this change, alerts can filter specific namespaces:
opentelemetry_allocator_targets_remaining{namespace!="istio-system"} > 10
Changes:
- Modified SetTargets() to group remaining targets by job_name and namespace
- Each unique job_name/namespace combination emits separate gauge value
- Targets without namespace use "unknown" label value
- All existing tests pass
Fixes open-telemetry#4637
Signed-off-by: Charles Lee <charles.lee@safetyculture.io>
…ric with OTel conventions - Add operator.targetallocator.labeledmetrics feature gate (alpha) - Change label names to OTel semantic conventions: job.name and k8s.namespace.name - Maintain backward compatibility when feature flag is disabled Signed-off-by: Charles Lee <charles.lee@safetyculture.io>
Move feature gate propagation to follow the existing pattern: operator checks the gate and writes config into the TA configmap, rather than passing CLI flags. The TA reads labeled_metrics from its config file. Signed-off-by: Charles Lee <charles.lee@safetyculture.io>
Signed-off-by: Charles Lee <charles.lee@safetyculture.io>
…nfig Add TA-local feature gate (target-allocator.labeled-metrics) and have the operator propagate it via --feature-gates on the container args. Avoids adding a config option that would be a breaking change to remove. Signed-off-by: Charles Lee <charles.lee@safetyculture.io>
…base Signed-off-by: Charles Lee <charles.lee@safetyculture.io>
057b77c to
c6b0456
Compare
|
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
|
Closed as inactive. Feel free to reopen if this PR is still being worked on. |
Description
Adds
k8s.namespace.nameandjob.namelabels to theopentelemetry_allocator_targets_remainingmetric (when enabled via feature gate) to enable distinguishing between intentionally filtered targets and orphaned targets due to bugs.Breaking Change Mitigation: This change is behind feature gates (alpha) to provide a migration path for existing users.
Motivation and Context
Currently,
opentelemetry_allocator_targets_remainingreports a scalar count, making it impossible to create meaningful alerts. In production environments with namespace filtering (e.g., excludingistio-systemto control costs), the baseline can be ~1600 targets. This masks genuine issues like orphaned targets from deleted collectors or version skew scenarios.Solution
Feature Gates (Alpha)
Operator gate:
operator.targetallocator.labeledmetricspkg/featuregate/featuregate.go--feature-gates=target-allocator.labeled-metricson the TA container argsTarget Allocator gate:
target-allocator.labeled-metricscmd/otel-allocator/internal/featuregate/featuregate.go--feature-gatesvia CLI flagsThis two-gate approach follows the reviewer's guidance: the operator gate propagates to the TA via
--feature-gates, avoiding any config struct changes that would be a breaking change to remove when the gate graduates.Label Names (OTel Semantic Conventions)
job.namek8s.namespace.nameImplementation
Modified
SetTargets()inallocator.goto:__meta_kubernetes_namespacelabelUsage
Enable via the operator's feature gates:
The operator propagates this to the target allocator container automatically.
After this change (when feature enabled)
Testing
Fixes #4637