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

Hermes frontend prometheus support #1692

Closed
wants to merge 7 commits into from

Conversation

moscicky
Copy link
Collaborator

@moscicky moscicky commented Jul 13, 2023

This PR adds support for prometheus metrics in

  • hermes-frontend

Prometheus support status

  • hermes-api (no metrics)
  • hermes-benchmark (no metrics)
  • hermes-client (already supported)
  • hermes-common
  • hermes-consumers
  • hermes-frontend (this PR)
  • hermes-management
  • hermers-metrics
  • hermes-mock (no metrics)
  • hermes-schema (no metrics)
  • hermes-test-helper (no metrics)
  • hermes-tracker
  • hermes-tracker-elasticsearch

The downside of defining all metrics in one module is visible in this PR. If we want to register a gauge in hermes-frontend it has to be defined in hermes-commons. If it is defined there then hermes-commons needs to have a knowledge about what is being metered (which state object).

In case of this PR hermes-commons now contains ProducerMetrics which needs to be kafka-producer aware - because it is responsible for creating metrics for it.

The other example is PersistentBufferMetrics which is responsible for measuring ChronicleMap size. It must have a knowledge of ChronicleMap (which is not it's dependency) or any of the interfaces which it implements (ConcurrentMap, Map):

 public void registerBackupStorageSizeGauge(Map<?, ?> map) {
        this.hermesMetrics.registerMessageRepositorySizeGauge(map::size);
        this.meterRegistry.gaugeMapSize("backup-storage.size", Tags.empty(), map);
    }

But this raises a question: should every map be accepted?

Perhaps the gauge should be defined flexibly as

public <T> void registerGauge(T obj, ToDoubleFunction<T> f) {
        this.hermesMetrics.registerMessageRepositorySizeGauge(() -> f.applyAsDouble(obj));
        Gauge.builder("backup-storage.size", obj, f)
                .register(meterRegistry);
    }

then hermes-commons does not need to have the knowledge about state objects and it is responsbility of the caller to supply correct arguments

@moscicky moscicky temporarily deployed to ci July 13, 2023 09:03 — with GitHub Actions Inactive
@moscicky moscicky temporarily deployed to ci July 13, 2023 13:07 — with GitHub Actions Inactive
@moscicky moscicky marked this pull request as ready for review July 13, 2023 14:16
@moscicky moscicky marked this pull request as draft July 13, 2023 14:29
@moscicky moscicky closed this Jul 17, 2023
@moscicky moscicky deleted the hermes-frontend-prometheus-support branch July 17, 2023 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant