Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unregisters #3122

Merged
merged 2 commits into from
Jan 4, 2024
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
2 changes: 1 addition & 1 deletion pkg/otelcollector/metricsprocessor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func (p *metricsProcessor) updateMetricsForWorkload(limiterID iface.LimiterID, l
Str(metrics.PolicyNameLabel, limiterID.PolicyName).
Str(metrics.PolicyHashLabel, limiterID.PolicyHash).
Str(metrics.ComponentIDLabel, limiterID.ComponentID).
Msg("LoadScheduler not found")
Msg("Scheduler not found")
return
}
// Observe latency only if the request was allowed by Aperture and response was received from the server (I.E. latency is found)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,8 @@ func (cl *concurrencyLimiter) setup(lifecycle fx.Lifecycle) error {
},
OnStop: func(context.Context) error {
var merr, err error
deleted := cl.clFactory.counterVector.DeletePartialMatch(metricLabels)
if deleted == 0 {
logger.Warn().Msg("Could not delete concurrency limiter counter from its metric vector. No traffic to generate metrics?")
}
// remove from data engine
err = cl.clFactory.engineAPI.UnregisterRateLimiter(cl)
err = cl.clFactory.engineAPI.UnregisterConcurrencyLimiter(cl)
if err != nil {
logger.Error().Err(err).Msg("Failed to unregister concurrency limiter")
merr = multierr.Append(merr, err)
Expand All @@ -273,6 +269,10 @@ func (cl *concurrencyLimiter) setup(lifecycle fx.Lifecycle) error {
merr = multierr.Append(merr, err)
}
cl.limiter.Close()
deleted := cl.clFactory.counterVector.DeletePartialMatch(metricLabels)
if deleted == 0 {
logger.Warn().Msg("Could not delete concurrency limiter counter from its metric vector. No traffic to generate metrics?")
}
cl.registry.SetStatus(status.NewStatus(nil, merr))

return merr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ func (cs *concurrencyScheduler) setup(lifecycle fx.Lifecycle) error {
var merr, err error

// remove from data engine
err = cs.csFactory.engineAPI.UnregisterScheduler(cs)
err = cs.csFactory.engineAPI.UnregisterConcurrencyScheduler(cs)
if err != nil {
logger.Error().Err(err).Msg("Failed to unregister rate limiter")
merr = multierr.Append(merr, err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,6 @@ func (rl *rateLimiter) setup(lifecycle fx.Lifecycle) error {
},
OnStop: func(context.Context) error {
var merr, err error
deleted := rl.rlFactory.counterVector.DeletePartialMatch(metricLabels)
if deleted == 0 {
logger.Warn().Msg("Could not delete rate limiter counter from its metric vector. No traffic to generate metrics?")
}
// remove from data engine
err = rl.rlFactory.engineAPI.UnregisterRateLimiter(rl)
if err != nil {
Expand All @@ -307,6 +303,10 @@ func (rl *rateLimiter) setup(lifecycle fx.Lifecycle) error {
merr = multierr.Append(merr, err)
}
rl.limiter.Close()
deleted := rl.rlFactory.counterVector.DeletePartialMatch(metricLabels)
if deleted == 0 {
logger.Warn().Msg("Could not delete rate limiter counter from its metric vector. No traffic to generate metrics?")
}
rl.registry.SetStatus(status.NewStatus(nil, merr))

return merr
Expand Down
10 changes: 5 additions & 5 deletions pkg/policies/flowcontrol/actuators/sampler/sampler.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,10 @@ func (fr *sampler) setup(lifecycle fx.Lifecycle) error {
},
OnStop: func(context.Context) error {
var merr, err error
deleted := counterVec.DeletePartialMatch(metricLabels)
if deleted == 0 {
logger.Warn().Msg("Could not delete sampler counter from its metric vector. No traffic to generate metrics?")
}
// remove from data engine
err = fr.factory.engineAPI.UnregisterSampler(fr)
if err != nil {
tanveergill marked this conversation as resolved.
Show resolved Hide resolved
logger.Error().Err(err).Msg("Failed to unregister rate limiter")
logger.Error().Err(err).Msg("Failed to unregister sampler")
merr = multierr.Append(merr, err)
}
// remove decisions notifier
Expand All @@ -269,6 +265,10 @@ func (fr *sampler) setup(lifecycle fx.Lifecycle) error {
logger.Error().Err(err).Msg("Failed to remove decision notifier")
merr = multierr.Append(merr, err)
}
deleted := counterVec.DeletePartialMatch(metricLabels)
if deleted == 0 {
logger.Warn().Msg("Could not delete sampler counter from its metric vector. No traffic to generate metrics?")
}
fr.registry.SetStatus(status.NewStatus(nil, merr))

return merr
Expand Down
Loading