-
Notifications
You must be signed in to change notification settings - Fork 218
PR for Micrometer Integration - #64 #486
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
PR for Micrometer Integration - #64 #486
Conversation
@laxmikantbpandhare will this tie into the How will we ensure the increment occurs for the metrics we plan to support? Or is that for another follow on PR? |
I think that we should create a metrics package in the
So I think we should have a ReconcileTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
Name: "controller_runtime_reconcile_total",
Help: "Total number of reconciliations per controller",
}, []string{"controller", "result"}) As you see in controller-runtime, there are a series of default structures that represent the default metrics they want to expose. I could see us having 5 classes representing the metrics we want. Then in the |
|
||
public class CounterDetails { | ||
|
||
int counter; |
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.
do these fields need to be package-private instead of private?
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.
checking on this, we can make those field as a private.
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 don't currently see what's the point of this class since it doesn't appear to be used but I would assume that it should be immutable: all fields should be private and final and there shouldn't be any setters (i.e. it shouldn't be possible to modify an instance, after it's been created)
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 counter details class will be used when we call/use these utility methods. You can refer to sample memcached-quarkus-operator where I used this - https://github.com/laxmikantbpandhare/memcached-quarkus-operator/blob/main/src/main/java/com/example/MemcachedController.java
@jmrodri - I am still looking into the code of |
@jmrodri - We will not decrement any counter as operator-sdk does not decrement anything as such. After delete event, the reconciliation process happens thats why need to increment controller execution counter. The operator-sdk has two counters, succeeded and failed. If reconciliation process fails then failed counter increases. We will follow the same logic for our metrics part in java-operator-sdk. |
You are correct we only increment. Thanks. |
@laxmikantbpandhare also, this code should live in a |
@jmrodri - Sure, I will create |
Also remember that PRs should follow the conventional commit: https://github.com/java-operator-sdk/java-operator-sdk/blob/master/CONTRIBUTING.md#pull-request-process |
Modified commit as a conventional commit. |
I've converted this PR to draft since it seems quite far from being finished. I cannot really review it in its current state because I need to see:
|
@metacosm - I showed demo of metrics during our weekly meeting. Attached screen print for your reference. The current changes are just utility methods and I am planning to call/use those methods from reconciliation process. This will calculate the successful execution of reconciliation process. You can see in above image, I marked that data in red box. |
On a design note: I'd like to see something similar to what is seen in https://github.com/ebullient/monster-combat/blob/main/core/src/main/java/dev/ebullient/dnd/combat/client/CombatMetrics.java. All metrics-related code is confined to a single class so that it doesn't "infect" the code and we can tweak what gets recorded and how in a single spot. The SDK code would call method of this class with application-specific results (e.g. |
Yes, agree on this. I will update the code accordingly. |
@metacosm - I completely removed CounterDetails class and added entire logic in only one class. Please review the PR. About the second suggestion, Links - |
We're not going to provide a registry implementation in the SDK: this will be up to users to decide which one to use. |
Ah! sorry it was my confusion. I updated dependency as said by you in |
I already tick marked |
@metacosm @adam-sandor @csviri - I created similar method for |
operator-framework-core/src/main/java/io/javaoperatorsdk/operator/Metrics.java
Outdated
Show resolved
Hide resolved
...tor-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/EventDispatcher.java
Outdated
Show resolved
Hide resolved
...tor-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/EventDispatcher.java
Outdated
Show resolved
Hide resolved
...framework-core/src/test/java/io/javaoperatorsdk/operator/processing/EventDispatcherTest.java
Outdated
Show resolved
Hide resolved
On a strictly process-oriented basis: please do not request reviews for each commit. Finish the PR as you think it should be done and then we will be able to review it. Also, please leave the PR in draft mode until it's ready for review and merging, which isn't the case as this stage. |
@metacosm - Sure |
import java.util.function.ToDoubleFunction; | ||
import java.util.function.ToLongFunction; | ||
|
||
public class Metrics { |
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.
For me this whole construct while wrapping the logic in a Metrics class is little bit smelly, not sure if there is a better way. But will take a look soon.
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.
Initially, I wrote a separate class without wrapping it. @metacosm - Chris asked to have it like above wrapping the logic.
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's wrong with wrapping the logic, @csviri? More than wrapping, it's about measuring things that make sense from the operator's perspective as opposed to calling more metrics-oriented methods. Another aspect is that all metrics code is in a single spot which makes it easier to figure out what's measured and change it if needed.
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.
That the metrics code is in one place that is good. That we are mixing the application logic with metrics is not that nice. Those should be as loosely coupled as possible IMHO. And also seamlessly if possible.
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 don't say I have a better answer for this now, just mentioning that design principle. So something to think about.
operator-framework-core/src/main/java/io/javaoperatorsdk/operator/Metrics.java
Outdated
Show resolved
Hide resolved
feature: micrometer integration for genering metrics feature: modified variables and made it private feature: added changes for customize increment method feature: removed ConterDetails class and modified IncrementCounter accordingly feature: modified pom depedency feature: modified pom depedency feature: added changes and wrapped counter and timer with createAndUpdate method feature: modified and added inceremenmt() method feature: modified for enabling google formatter removed spaces removed spaces feature: added counter and timer for delete resource feature: added counter and timer for delete resource feature: added changes for delete resource feature: added changes for delete resource feature: update control modified feature: delete control modified feature: delete control modified test delete resource feature: modiofied to retest feature: modified according to PR review comments feature: added count for each and event (create, update, and delete) feature: added count for each and event (create, update, and delete) feature: added Histogram changes for Time feature: added histogram changes for delete as well feature: modified name field in tags feature: retry counter added
This sounds odd to me. I've never done that for any of my other contributions to other projects. |
Update on the PR -
|
@metacosm - I added changes in DefaultEventHandler. I created object of Metrics and not added it into the Constructor Parameter as it is causing changes in Multiple files. I used NoopMeterRegistry due to which it asked me to make it Public. These are the changes I did as part of retry related metrics. |
...framework-core/src/main/java/io/javaoperatorsdk/operator/processing/DefaultEventHandler.java
Outdated
Show resolved
Hide resolved
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.
Let's get this merged and do subsequent changes on different PRs.
Working on Timer and other remaining part. @metacosm and @csviri - Could you please verify the code for Counter and its implemented methods.