-
Notifications
You must be signed in to change notification settings - Fork 296
x509 otel certificate refresh events in cert_refresher library. #3146
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
base: master
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @balamanova, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request introduces OpenTelemetry metrics for X.509 certificate refresh events by adding a new OpenTelemetryCertReloadEventEmitter class and integrating it into the KeyRefresher. The implementation is solid, adding valuable observability. My review includes several suggestions for the new OpenTelemetryCertReloadEventEmitter class to improve metric consistency, code clarity, and the utility of the emitted metrics. These changes will make the new telemetry data more robust and easier to consume.
libs/java/cert_refresher/src/main/java/com/oath/auth/OpenTelemetryCertReloadEventEmitter.java
Outdated
Show resolved
Hide resolved
libs/java/cert_refresher/src/main/java/com/oath/auth/OpenTelemetryCertReloadEventEmitter.java
Outdated
Show resolved
Hide resolved
libs/java/cert_refresher/src/main/java/com/oath/auth/OpenTelemetryCertReloadEventEmitter.java
Outdated
Show resolved
Hide resolved
libs/java/cert_refresher/src/main/java/com/oath/auth/OpenTelemetryCertReloadEventEmitter.java
Outdated
Show resolved
Hide resolved
libs/java/cert_refresher/src/main/java/com/oath/auth/OpenTelemetryCertReloadEventEmitter.java
Outdated
Show resolved
Hide resolved
libs/java/cert_refresher/src/main/java/com/oath/auth/OpenTelemetryCertReloadEventEmitter.java
Outdated
Show resolved
Hide resolved
bc60e29 to
c9e32ba
Compare
ATHENS-8722 adding cert refresh metrics Signed-off-by: abalamanova <[email protected]>
c9e32ba to
522931a
Compare
libs/java/cert_refresher/src/main/java/com/oath/auth/KeyRefresher.java
Outdated
Show resolved
Hide resolved
libs/java/cert_refresher/src/main/java/com/oath/auth/OpenTelemetryCertReloadEventEmitter.java
Outdated
Show resolved
Hide resolved
| .build(); | ||
|
|
||
| refreshResultCounter.add(1, attrs); | ||
| resultLastTimestampGauge.set(timestamp, attrs); |
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 we need to send timestamp explicity, won't that be automatically be available with refreshResultCounter?
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'm using OTel Metrics API (counter + gauge), not OTel Events/Logs API. Prometheus is a pull-based time-series database.
Prometheus only stores scrape timestamps, not event timestamps. I can detect that a refresh happened using increase(), but the timestamp is approximate (within scrape interval).
With this timestamp I save exact timestamp when the refresh occurred
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.
there is no need to generate a timestamp attribute. the metric already tells you that there is a failure in the given time period and the exact timestamp is not really needed and will not be used.
…tMetric Signed-off-by: abalamanova <[email protected]>
9b54ae6 to
8adce7d
Compare
| */ | ||
| private OpenTelemetryCertReloadEventEmitter initOtelMetrics() { | ||
| String otelDisabledProp = System.getProperty(PROP_OTEL_DISABLED); | ||
| boolean otelDisabled = "true".equalsIgnoreCase(otelDisabledProp); |
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 behavior here should be false. We can't introduce new functionality which could cause problems and generate more metrics if nobody is looking at them.
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.
Instead of using the "true" (or "false") , please specify a static string and use that. Alternatively you can convert to Boolean and use Boolean.TRUE/Boolean.FALSE
| //Signal key change event | ||
| if (keyRefresherListener != null) { | ||
| keyRefresherListener.onKeyChangeEvent(); | ||
| try { |
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.
why did we add a new try/catch block here? we already have one in place where we log any errors?
| .build(); | ||
|
|
||
| refreshResultCounter.add(1, attrs); | ||
| resultLastTimestampGauge.set(timestamp, attrs); |
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.
there is no need to generate a timestamp attribute. the metric already tells you that there is a failure in the given time period and the exact timestamp is not really needed and will not be used.
| <groupId>io.opentelemetry</groupId> | ||
| <artifactId>opentelemetry-api</artifactId> | ||
| <version>${opentelemetry.version}</version> | ||
| <optional>true</optional> |
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.
have we verified that if we enable otel metrics and the jars are not available, the code works as expected without throwing any errors?
Description
Added OpenTelemetry metrics for X.509 certificate refresh events in
cert_refresherlibrary.Implementation follows SIA OTel pattern
This implementation mirrors the existing SIA (Go) OTel metrics pattern from
libs/go/sia/otel/metricset.go:Metrics (aligned with SIA)
athenz_cert_refresher.refresh.result_total{function,result}sia.agent_command.result_total{function,result}athenz_cert_refresher.service_cert.validity.remaining_secs{name}sia.service_cert.validity.remaining_secs{cname}athenz_cert_refresher.refresh.result_last_timestamp{function,result}Attributes (same as SIA)
function- identifies the operation (e.g., "cert_refresh")result- "success" or "failure" (same values as SIA)name- certificate subject name (similar to SIA'scname)Configuration
-Dathenz.cert_refresher.otel_disabled=true-Dathenz.cert_refresher.otel_component_name=my-serviceContribution Checklist:
Attach Screenshots (Optional)