Skip to content

Conversation

@piyush-zlai
Copy link
Contributor

@piyush-zlai piyush-zlai commented May 21, 2025

Summary

Currently our fetcher docker container assumes that folks wiring up their Otel metrics are using the Http reader. This doesn't work for some users as they want to use prom to scrape metrics. As Vert.x's micrometer uses prom using a set of interfaces and classes that differ a bit from the otel prom reader setup, we need to expose a PromHTTP server for scraping of Vert.x metrics. Thus for the complete set of metrics, we'll have them available across two ports (one for Vertx and one for fetcher / core chronon). In a future iteration we can try a bridge where we spin up just one server and have Vertx pipe to Fetcher's prom server (or vice versa). I did explore this and the work seemed a little involved so have punted on it for now.

Also added a couple of HTTP2 settings to bump concurrent streams from Vert.x's default as we noticed some errors due to them in a recent load test with a http2 client.

Checklist

  • Added Unit Tests
  • Covered by existing CI
  • Integration tested - Tested via running in docker containers + also on a user's install / traffic replay.
  • Documentation update

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Improved HTTP/2 server configuration with explicit settings for better performance and clarity.
    • Added support for multiple metrics readers, including HTTP OTLP and Prometheus, with configurable options.
  • Chores
    • Updated metrics initialization to disable metrics by default unless explicitly enabled.
    • Consolidated metrics configuration into a single option with enhanced environment variable handling.
    • Added new dependencies for Prometheus and Micrometer integration to support enhanced metrics capabilities.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 21, 2025

Walkthrough

The updates enhance metrics configuration by supporting multiple metrics readers (HTTP OTLP and Prometheus) in the fetcher startup script and service launcher. HTTP/2 server settings in FetcherVerticle are explicitly defined. Maven dependencies for Prometheus and Micrometer are added. Metrics defaults and reporter logic in Scala are adjusted to align with these changes.

Changes

File(s) Change Summary
docker/fetcher/start.sh Metrics enablement now depends on CHRONON_METRICS_READER; consolidated Java metrics options string replaces previous flags.
service/src/main/java/ai/chronon/service/FetcherVerticle.java Explicit HTTP/2 settings: max concurrent streams, initial window size, ALPN/SSL disabled, HTTP/2 cleartext enabled, updated comments.
service_commons/src/main/java/ai/chronon/service/ChrononServiceLauncher.java Added support for multiple metrics readers; separate methods to configure OTLP HTTP and Prometheus metrics; removed OTLP URL check.
online/src/main/scala/ai/chronon/online/metrics/Metrics.scala Default metrics enabled flag changed from true to false; simplified metric reader retrieval logic.
online/src/main/scala/ai/chronon/online/metrics/OtelMetricsReporter.scala Renamed constants; exporter URL default added; metric reader retrieval and building logic simplified to always return a MetricReader.
maven_install.json Added Micrometer Prometheus registry and Prometheus simpleclient artifacts with versions and SHA sums.
service_commons/BUILD.bazel Added io.micrometer:micrometer-registry-prometheus dependency.
tools/build_rules/dependencies/maven_repository.bzl Pinned micrometer-registry-prometheus to version 1.10.13 with explanatory comment about Vert.x compatibility.

Sequence Diagram(s)

sequenceDiagram
    participant StartScript as fetcher/start.sh
    participant JavaApp as Java Process
    participant Launcher as ChrononServiceLauncher
    participant Metrics as Metrics System

    StartScript->>JavaApp: Pass METRICS_OPTS with reader type and endpoints
    JavaApp->>Launcher: Start service with VertxOptions
    Launcher->>Metrics: Get metrics reader type
    alt Reader = "http"
        Launcher->>Metrics: configureOtlpHttpMetrics()
    else Reader = "prometheus"
        Launcher->>Metrics: configurePrometheusMetrics()
    else
        Launcher->>Launcher: Log warning, disable metrics
    end
Loading

Possibly related PRs

Suggested reviewers

  • nikhil-zlai
  • david-zlai

Poem

🐇 Metrics dance on streams anew,
Prometheus and OTLP too.
HTTP/2 waves its flag so bright,
Cleartext flows in the quiet night.
Dependencies added with care,
Fetcher runs with metrics fair!
🚀✨

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 30th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2f42eb2 and 6f88e0d.

📒 Files selected for processing (1)
  • service_commons/src/main/java/ai/chronon/service/ChrononServiceLauncher.java (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • service_commons/src/main/java/ai/chronon/service/ChrononServiceLauncher.java
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (5)
online/src/main/scala/ai/chronon/online/metrics/Metrics.scala (1)

131-140: Short-circuit on metricsEnabled to avoid needless reporter parsing

If metricsEnabled is false, we still parse metricsReporter and may throw for an unknown value even though metrics are off. Returning a noop client immediately is safer.

- val reporter: String = System.getProperty(MetricsReporter, "otel")
- reporter.toLowerCase match {
+ if (!metricsEnabled) return new OtelMetricsReporter(OpenTelemetry.noop())
+
+ val reporter: String = System.getProperty(MetricsReporter, "otel")
+ reporter.toLowerCase match {
service_commons/src/main/java/ai/chronon/service/ChrononServiceLauncher.java (2)

32-36: Follow Java constant naming conventions

VertxPrometheusPort / DefaultVertxPrometheusPort should be upper-snake (VERTX_PROMETHEUS_PORT) for consistency with the rest of the file.


92-110: Expose scrape path / customise host

PrometheusHttpServer defaults to /metrics on 0.0.0.0, while Vert.x embedded server uses localhost. Aligning host/port or making both configurable prevents head-scratching in prod.
Example:

- .setEmbeddedServerOptions(new HttpServerOptions().setPort(Integer.parseInt(prometheusPort)));
+ .setEmbeddedServerOptions(
+     new HttpServerOptions()
+         .setHost("0.0.0.0")
+         .setPort(Integer.parseInt(prometheusPort)));
online/src/main/scala/ai/chronon/online/metrics/OtelMetricsReporter.scala (2)

88-100: Consider renaming MetricsReaderHttpMetricsReaderOtlpHttp

The constant describes an OTLP/HTTP reader, not generic HTTP. Explicit naming avoids confusion with the Prometheus HTTP server introduced below.


102-120: Duplicate port property names may confuse operators

We now have:

  • ai.chronon.metrics.exporter.port (PrometheusHTTPServer)
  • ai.chronon.vertx.metrics.exporter.port (Vert.x Prometheus)

A comment or unified prefix would help users remember which one controls which endpoint.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 7acb887 and a5ba23c.

📒 Files selected for processing (7)
  • docker/fetcher/start.sh (2 hunks)
  • maven_install.json (13 hunks)
  • online/src/main/scala/ai/chronon/online/metrics/Metrics.scala (1 hunks)
  • online/src/main/scala/ai/chronon/online/metrics/OtelMetricsReporter.scala (1 hunks)
  • service_commons/BUILD.bazel (1 hunks)
  • service_commons/src/main/java/ai/chronon/service/ChrononServiceLauncher.java (3 hunks)
  • tools/build_rules/dependencies/maven_repository.bzl (1 hunks)
✅ Files skipped from review due to trivial changes (3)
  • service_commons/BUILD.bazel
  • tools/build_rules/dependencies/maven_repository.bzl
  • maven_install.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • docker/fetcher/start.sh
⏰ Context from checks skipped due to timeout of 90000ms (17)
  • GitHub Check: service_tests
  • GitHub Check: service_commons_tests
  • GitHub Check: api_tests
  • GitHub Check: cloud_gcp_tests
  • GitHub Check: service_tests
  • GitHub Check: cloud_aws_tests
  • GitHub Check: online_tests
  • GitHub Check: online_tests
  • GitHub Check: cloud_gcp_tests
  • GitHub Check: cloud_aws_tests
  • GitHub Check: flink_tests
  • GitHub Check: api_tests
  • GitHub Check: aggregator_tests
  • GitHub Check: aggregator_tests
  • GitHub Check: flink_tests
  • GitHub Check: scala_compile_fmt_fix
  • GitHub Check: enforce_triggered_workflows
🔇 Additional comments (1)
service_commons/src/main/java/ai/chronon/service/ChrononServiceLauncher.java (1)

50-59: Handle unknown reader more gracefully

When the reader value is unrecognised we log but silently disable Vert.x metrics, leaving enableMetrics=true. Consider either:

  1. Failing fast (invalid config), or
  2. Falling back to OTLP to avoid running without metrics unexpectedly.

@piyush-zlai piyush-zlai changed the title Plumb through prometheus otel reader in fetcher docker svc + some http2 settings Wire up Vert.x metrics in fetcher docker with Prometheus Otel reader May 22, 2025
@piyush-zlai piyush-zlai force-pushed the piyush/vertx_otel_prom branch from a5ba23c to 2f42eb2 Compare May 22, 2025 18:22
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
service_commons/src/main/java/ai/chronon/service/ChrononServiceLauncher.java (1)

92-110: Prometheus metrics configuration

Correctly implements Prometheus metrics with embedded server. Consider adding error handling for port parsing.

 private void configurePrometheusMetrics(VertxOptions options) {
     // Configure Prometheus using Micrometer's built-in registry
     String prometheusPort = System.getProperty(VertxPrometheusPort, DefaultVertxPrometheusPort);
+    int port;
+    try {
+        port = Integer.parseInt(prometheusPort);
+    } catch (NumberFormatException e) {
+        logger.warn("Invalid Prometheus port specified: {}. Using default: {}", prometheusPort, DefaultVertxPrometheusPort);
+        port = Integer.parseInt(DefaultVertxPrometheusPort);
+    }
     VertxPrometheusOptions promOptions =
             new VertxPrometheusOptions()
                     .setEnabled(true)
                     .setStartEmbeddedServer(true)
-                    .setEmbeddedServerOptions(new HttpServerOptions().setPort(Integer.parseInt(prometheusPort)));
+                    .setEmbeddedServerOptions(new HttpServerOptions().setPort(port));
+    logger.info("Configuring Prometheus metrics server on port {}", port);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a5ba23c and 2f42eb2.

📒 Files selected for processing (8)
  • docker/fetcher/start.sh (2 hunks)
  • maven_install.json (13 hunks)
  • online/src/main/scala/ai/chronon/online/metrics/Metrics.scala (1 hunks)
  • online/src/main/scala/ai/chronon/online/metrics/OtelMetricsReporter.scala (1 hunks)
  • service/src/main/java/ai/chronon/service/FetcherVerticle.java (2 hunks)
  • service_commons/BUILD.bazel (1 hunks)
  • service_commons/src/main/java/ai/chronon/service/ChrononServiceLauncher.java (3 hunks)
  • tools/build_rules/dependencies/maven_repository.bzl (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (7)
  • service_commons/BUILD.bazel
  • tools/build_rules/dependencies/maven_repository.bzl
  • service/src/main/java/ai/chronon/service/FetcherVerticle.java
  • docker/fetcher/start.sh
  • online/src/main/scala/ai/chronon/online/metrics/Metrics.scala
  • maven_install.json
  • online/src/main/scala/ai/chronon/online/metrics/OtelMetricsReporter.scala
🧰 Additional context used
🧬 Code Graph Analysis (1)
service_commons/src/main/java/ai/chronon/service/ChrononServiceLauncher.java (2)
online/src/main/scala/ai/chronon/online/metrics/Metrics.scala (1)
  • Metrics (26-237)
online/src/main/scala/ai/chronon/online/metrics/OtelMetricsReporter.scala (4)
  • OtelMetricsReporter (19-79)
  • OtelMetricsReporter (81-151)
  • getMetricsReader (98-100)
  • getExporterUrl (94-96)
⏰ Context from checks skipped due to timeout of 90000ms (17)
  • GitHub Check: service_tests
  • GitHub Check: service_commons_tests
  • GitHub Check: service_tests
  • GitHub Check: online_tests
  • GitHub Check: online_tests
  • GitHub Check: flink_tests
  • GitHub Check: cloud_gcp_tests
  • GitHub Check: cloud_gcp_tests
  • GitHub Check: cloud_aws_tests
  • GitHub Check: api_tests
  • GitHub Check: cloud_aws_tests
  • GitHub Check: flink_tests
  • GitHub Check: api_tests
  • GitHub Check: aggregator_tests
  • GitHub Check: scala_compile_fmt_fix
  • GitHub Check: aggregator_tests
  • GitHub Check: enforce_triggered_workflows
🔇 Additional comments (6)
service_commons/src/main/java/ai/chronon/service/ChrononServiceLauncher.java (6)

7-8: Appropriate imports added

Added necessary imports for Prometheus integration.


17-20: Logger imports and Prometheus options added

Required imports for new functionality.


32-34: Port configuration constants

Constants properly define the system property and default port for Prometheus metrics.


35-36: Logger initialization

Standard logger setup for the class.


43-60: Metrics initialization refactoring

Proper implementation of reader type selection logic that aligns with OtelMetricsReporter.


62-90: OTLP HTTP metrics configuration extracted

Clean extraction of existing logic into a dedicated method.

@piyush-zlai piyush-zlai merged commit c2b4cee into main May 22, 2025
21 checks passed
@piyush-zlai piyush-zlai deleted the piyush/vertx_otel_prom branch May 22, 2025 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants