-
Notifications
You must be signed in to change notification settings - Fork 10
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
Prometheus fix metrics #23
Conversation
) Bumps [express](https://github.com/expressjs/express) from 4.18.2 to 4.19.2. - [Release notes](https://github.com/expressjs/express/releases) - [Changelog](https://github.com/expressjs/express/blob/master/History.md) - [Commits](expressjs/express@4.18.2...4.19.2) --- updated-dependencies: - dependency-name: express dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
{ | ||
return this.ExecuteAsync(0, function, cancellationToken); | ||
return this.ExecuteAsync(Priority.Normal, function, method, cancellationToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question for maintainers: Regarding the first commit, should the default priority be Normal or should we keep it as a Critical(0) priority?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default priority should be normal.
public void Increment(string method, string priority) | ||
{ | ||
this.Metric? | ||
.WithLabels(method, priority) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question for maintainers, I didn't see any use of the method in this framework or even in the Grafana dashboard.
What are the plans for this type of custom labels?
My implementation proposal may be slightly misaligned depending on the vision for these labels.
On the one hand, requiring the method in a base interface can compromise the coupling. On the other hand, leaving Prometheus to resolve the method closes the to a HtppClient implementation, leaving out other clients and background tasks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I would say that the http method is useless for now and maybe we can remove that instead of creating a coupling.
Benchmark results
|
/// </summary> | ||
/// <param name="method">The method.</param> | ||
/// <param name="priority">The priority.</param> | ||
/// <param name="value">The value.</param> | ||
public void Set(string method, string priority, double value) | ||
public void Decrement(string method, string priority) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change introduces a breaking change, if, for some reason, someone calls the Set method, right?
The same applies to other changes from a Set method to an Increment and Decrement methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @brmagadutra , The class and method are public, so I would say, Yes, it's a breaking change. However, I think everyone should call the extension IAdaptativeLimiterOptionsExtensions.AddMetrics
to configure the LoadSheddingOptions
. It will have no impact on who uses this extension method that configures the gauges metrics.
For example, internally we, Farfetch, use always the Options extension.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand, and this would be the best way. Still, we have this scenario to consider, so if the rest of the team is ok I won't oppose going forward. @joelfoliveira and @ailtonguitar what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, It is a breaking change but I think that the impact is very low.
But what is the rational of this change?
/// <param name="cancellationToken">A cancellation token is used to signal that the running operation should be stopped.</param> | ||
/// <returns></returns> | ||
Task ExecuteAsync(Priority priority, Func<Task> function, CancellationToken cancellationToken = default); | ||
Task ExecuteAsync(Priority priority, Func<Task> function, string method = null, CancellationToken cancellationToken = default); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method should not be passed here, it is the base lib and it can be used in other context (it is not exclusive for web requests)
{ | ||
public interface ITaskItem | ||
{ | ||
string Method { get; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The base lib should not be coupled to web implementation
@@ -65,18 +61,17 @@ public static class IAdaptativeLimiterOptionsExtensions | |||
|
|||
events.ItemDequeued.Subscribe(args => | |||
{ | |||
var method = accessor.GetMethod(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the rational of removing the method resolver from the accessor?
* feat: grafana dashboard V2 * fix: decrease queue once on reject * fix: queue gauge metric * chore: remove xUnit traits from Benchmark and Performance projects
This reverts commit 8b4b690.
Description
First Commit - feat: normal priority as default task execution
Changed the default Execute TaskItem default priority from Critical(0) to Normal.
Second Commit - fix: prometeus Inc/Dec gauge metrics
In this pull #19, I tried to remove the counter copies to use the counter reference and then set the Prometheus gauge value with the counter instant value. I tested in production and the issue persists.
The Prometheus documentation suggests using the Inc and Dec method for a queue problem as we have here.
As I mentioned in #22, it is possible to replicate using only unit tests.
This commit changes the use of
gauge.Set
togauge.Inc
andgauge.Dec
in the queue and concurrency events.Thrid Commit - fix: prometheus resolves UNKNOWN method
After the second commit, I improved the integration tests to add more tests with more than one priority task and added a second HTTP Method (Delete).
In this test, is possible to watch the IAdaptativeLimiterOptionsExtensions.GetMethod losing the HttpContext and resolving the UNKNOWN method.
I propose to send the method on
ITaskManager.AcquireAsync
used by Middleware and then we never need to resolve the method anymore during the task execution. Additionally allows users to define the method they want outside of the use of AdaptiveConcurrencyLimiterMiddleware.Fixes #22
How Has This Been Tested?
Run the integration tests
Checklist
Disclaimer
By sending us your contributions, you are agreeing that your contribution is made subject to the terms of our Contributor Ownership Statement