-
Notifications
You must be signed in to change notification settings - Fork 56
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
Introducing Stream Direction to Optimize Metric Collection #224
Introducing Stream Direction to Optimize Metric Collection #224
Conversation
eb57a48
to
362902e
Compare
...e/engine/src/main/java/io/aklivity/zilla/runtime/engine/internal/registry/DispatchAgent.java
Outdated
Show resolved
Hide resolved
.../engine/src/main/java/io/aklivity/zilla/runtime/engine/internal/registry/MetricRegistry.java
Show resolved
Hide resolved
if (direction == RECEIVED || direction == BOTH) | ||
{ | ||
receivedOriginMetricHandler = receivedOriginMetricHandler.andThen(handler); | ||
} |
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 feel like there should be a simpler way to handle this than nested if-else
, but it works. 🙂
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.
Yeah, unfortunately it looks like this, but I don't exactly see a better way. We could introduce a map, but we have two keys so it should be something like Map<Direction, Map<MetricHandlerKind, MessageConsumer>>
so I am not sure it would be actually simpler. 🤔
runtime/engine/src/main/java/io/aklivity/zilla/runtime/engine/metrics/Metric.java
Outdated
Show resolved
Hide resolved
runtime/engine/src/main/java/io/aklivity/zilla/runtime/engine/metrics/MetricContext.java
Show resolved
Hide resolved
...rics-http/src/main/java/io/aklivity/zilla/runtime/metrics/http/internal/HttpSizeHandler.java
Outdated
Show resolved
Hide resolved
...nding-tcp/src/test/java/io/aklivity/zilla/runtime/binding/tcp/internal/streams/ClientIT.java
Outdated
Show resolved
Hide resolved
* Add stream metrics spec and impl projects * Add http metrics spec and impl projects * Add metrics modules to incubator docker image * Metrics schema, extensibility, storage and command line support (#173) * Create incubator projects for exporter-prometheus.spec and exporter-prometheus * Engine support to exporters (#202) * Fix metrics command, find layout files in the engine dir (#204) * Prometheus Exporter (#203) * Minimize performance overhead for metric collection (#217) * Remove zilla load command (#223) * Introducing Stream Direction to Optimize Metric Collection (#224) * Add http.active.requests and http.duration metrics (#227) --------- Co-authored-by: Attila Kreiner <[email protected]>
Description
This change reduces the performance overhead of the metric collection. All the metrics that we currently have operate exclusively either on received or on sent streams. It makes sense to add the stream direction as a property so that the engine should only call the necessary metrics when processing the received vs sent streams. We will soon have metrics that process both streams, so there is an option for that, too:
This also clears up some code duplication as the current received vs sent metric pairs have identical implementation when the stream direction check is removed, so the common logic is extracted to
*Context
and*Handler
classes.It depends on PR #223.