Skip to content

Commit

Permalink
Fix: opentelemetry_allocator_targets_remaining should be a gauge inst…
Browse files Browse the repository at this point in the history
…ead of counter
  • Loading branch information
chenlujjj committed Jan 2, 2025
1 parent 5a270c9 commit 3e3ff40
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
16 changes: 16 additions & 0 deletions .chloggen/fix-allocator-metric.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: breaking

# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action)
component: target allocator

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "change metric `opentelemetry_allocator_targets_remaining` type from counter to gauge"

# One or more tracking issues related to the change
issues: [3578]

# (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:
4 changes: 2 additions & 2 deletions cmd/otel-allocator/allocation/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var (
Name: "opentelemetry_allocator_time_to_allocate",
Help: "The time it takes to allocate",
}, []string{"method", "strategy"})
targetsRemaining = promauto.NewCounter(prometheus.CounterOpts{
TargetsRemaining = promauto.NewGauge(prometheus.GaugeOpts{
Name: "opentelemetry_allocator_targets_remaining",
Help: "Number of targets kept after filtering.",
})
Expand Down Expand Up @@ -80,7 +80,7 @@ func WithFallbackStrategy(fallbackStrategy string) AllocationOption {
}

func RecordTargetsKept(targets map[string]*target.Item) {
targetsRemaining.Add(float64(len(targets)))
TargetsRemaining.Set(float64(len(targets)))
}

func New(name string, log logr.Logger, opts ...AllocationOption) (Allocator, error) {
Expand Down

0 comments on commit 3e3ff40

Please sign in to comment.