-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[Multi-Tenancy Test]WireConnectionSharingInBenchmark #48131
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
Merged
xinlian12
merged 31 commits into
Azure:main
from
xinlian12:wireConnectionSharingInBenchmark
Mar 2, 2026
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
9935b28
Add support for multi-tenancy benchmark test + client telemetry close
39819b1
update
65485db
Wire connectionSharingAcrossClientsEnabled through benchmark harness
a4027e9
Update BENCHMARK_RESULTS.md with deep investigation findings
dc53947
Enable Reactor Netty connection pool metrics via SimpleMeterRegistry
fae26c3
Fix: register SimpleMeterRegistry on globalRegistry before client cre…
2068219
Add per-endpoint pool names for connection pool metrics
3ac4e4e
Add pool id tag and full tag dump to pool metrics logging
06eb58c
Wire App Insights MeterRegistry into Metrics.globalRegistry for pool …
26da910
Add NettyHttpMetricsReporter for clean pool metrics CSV export
d0ed2a6
Make Netty HTTP client metrics opt-in via system property
c8c251b
Wire http2Enabled through benchmark harness (field, getter, setter, a…
928ede4
Fix: wire NettyHttpMetricsReporter into BenchmarkOrchestrator lifecycle
585dddf
Clear COSMOS.NETTY_HTTP_CLIENT_METRICS_ENABLED system property on shu…
908bd0a
Fix: add SimpleMeterRegistry as backing store for Reactor Netty pool …
f50cc59
Fix: pre-population concurrency uses configured value instead of hard…
0c7605f
merge from main and resolve conflicts
b08565c
merge and resolve conflicts
c11f7bf
delete unrelated files
1b0cc05
refactor
989f6fc
gitignore: exclude benchmark docs/scripts and copilot agents/skills
e81e6f9
remove local md files
db641b5
remove local md files
5cb41e8
Merge branch 'wireConnectionSharingInBenchmark' of https://github.com…
9f7c73d
Simplify benchmark .gitignore: use docs/ instead of individual file e…
af967bf
Merge branch 'wireConnectionSharingInBenchmark' of https://github.com…
1345869
delete
922835a
Fix: per-tenant Dropwizard meter names to avoid HdrHistogram contention
903a5a4
Revert "Fix: per-tenant Dropwizard meter names to avoid HdrHistogram …
76e389e
Address PR review comments
705b84b
Add enableNettyHttpMetrics to EXCLUDED_FIELDS allowlist
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
153 changes: 153 additions & 0 deletions
153
...e-cosmos-benchmark/src/main/java/com/azure/cosmos/benchmark/NettyHttpMetricsReporter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,153 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| package com.azure.cosmos.benchmark; | ||
|
|
||
| import io.micrometer.core.instrument.Gauge; | ||
| import io.micrometer.core.instrument.Meter; | ||
| import io.micrometer.core.instrument.MeterRegistry; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| import java.io.BufferedWriter; | ||
| import java.io.IOException; | ||
| import java.nio.file.Files; | ||
| import java.nio.file.Path; | ||
| import java.nio.file.StandardOpenOption; | ||
| import java.time.Instant; | ||
| import java.util.concurrent.Executors; | ||
| import java.util.concurrent.ScheduledExecutorService; | ||
| import java.util.concurrent.TimeUnit; | ||
|
|
||
| /** | ||
| * Periodically samples Reactor Netty connection pool metrics from a Micrometer | ||
| * {@link MeterRegistry} and writes them to a CSV file. | ||
| * | ||
| * <p>Metrics captured (when {@code ConnectionProvider.metrics(true)} is enabled):</p> | ||
| * <ul> | ||
| * <li>{@code reactor.netty.connection.provider.total.connections}</li> | ||
| * <li>{@code reactor.netty.connection.provider.active.connections}</li> | ||
| * <li>{@code reactor.netty.connection.provider.idle.connections}</li> | ||
| * <li>{@code reactor.netty.connection.provider.pending.connections}</li> | ||
| * <li>{@code reactor.netty.connection.provider.max.connections}</li> | ||
| * <li>{@code reactor.netty.connection.provider.max.pending.connections}</li> | ||
| * </ul> | ||
| * | ||
| * <p>CSV columns: timestamp, metric, pool_id, pool_name, remote_address, value</p> | ||
| */ | ||
| public class NettyHttpMetricsReporter { | ||
|
xinlian12 marked this conversation as resolved.
|
||
|
|
||
| private static final Logger logger = LoggerFactory.getLogger(NettyHttpMetricsReporter.class); | ||
| private static final String METRIC_PREFIX = "reactor.netty.connection.provider"; | ||
| private static final String CSV_HEADER = "timestamp,metric,pool_id,pool_name,remote_address,value"; | ||
|
|
||
| private final MeterRegistry registry; | ||
| private final Path outputFile; | ||
| private final ScheduledExecutorService scheduler; | ||
| private BufferedWriter writer; | ||
|
|
||
| /** | ||
| * @param registry the Micrometer registry to query (typically {@code Metrics.globalRegistry}) | ||
| * @param outputDir directory to write the CSV file into | ||
| */ | ||
| public NettyHttpMetricsReporter(MeterRegistry registry, Path outputDir) { | ||
| this.registry = registry; | ||
| this.outputFile = outputDir.resolve("netty-pool-metrics.csv"); | ||
| this.scheduler = Executors.newSingleThreadScheduledExecutor(r -> { | ||
| Thread t = new Thread(r, "netty-metrics-reporter"); | ||
| t.setDaemon(true); | ||
| return t; | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Start periodic reporting. | ||
| * | ||
| * @param interval reporting interval | ||
| * @param unit time unit | ||
| */ | ||
| public void start(long interval, TimeUnit unit) { | ||
| try { | ||
| Files.createDirectories(outputFile.getParent()); | ||
| writer = Files.newBufferedWriter(outputFile, | ||
| StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); | ||
| writer.write(CSV_HEADER); | ||
| writer.newLine(); | ||
| writer.flush(); | ||
| } catch (IOException e) { | ||
| logger.error("Failed to create netty pool metrics CSV: {}", outputFile, e); | ||
| return; | ||
| } | ||
|
|
||
| scheduler.scheduleAtFixedRate(this::report, interval, interval, unit); | ||
| logger.info("NettyHttpMetricsReporter started -> {} (every {}s)", outputFile, unit.toSeconds(interval)); | ||
| } | ||
|
|
||
| /** | ||
| * Write a single snapshot of all pool metrics to CSV. | ||
| */ | ||
| public void report() { | ||
| if (writer == null) return; | ||
|
|
||
| String timestamp = Instant.now().toString(); | ||
| int count = 0; | ||
|
|
||
| try { | ||
| for (Meter meter : registry.getMeters()) { | ||
| String name = meter.getId().getName(); | ||
| if (!name.startsWith(METRIC_PREFIX)) continue; | ||
|
|
||
| // Only report gauge-type metrics (connections counts) | ||
| if (!(meter instanceof Gauge)) continue; | ||
|
|
||
| double value = ((Gauge) meter).value(); | ||
| String poolId = meter.getId().getTag("id"); | ||
| String poolName = meter.getId().getTag("name"); | ||
| String remoteAddr = meter.getId().getTag("remote.address"); | ||
|
|
||
| // Strip the common prefix for shorter metric names in CSV | ||
| String shortName = name.substring(METRIC_PREFIX.length() + 1); | ||
|
|
||
| writer.write(String.format("%s,%s,%s,%s,%s,%.0f", | ||
| timestamp, shortName, | ||
| poolId != null ? poolId : "", | ||
| poolName != null ? poolName : "", | ||
| remoteAddr != null ? remoteAddr : "", | ||
| value)); | ||
| writer.newLine(); | ||
| count++; | ||
| } | ||
| writer.flush(); | ||
| } catch (IOException e) { | ||
| logger.warn("Failed to write netty pool metrics", e); | ||
| } | ||
|
|
||
| if (count > 0) { | ||
| logger.debug("NettyHttpMetricsReporter: wrote {} pool metrics", count); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Stop the reporter and close the CSV file. | ||
| */ | ||
| public void stop() { | ||
| scheduler.shutdown(); | ||
| try { | ||
| scheduler.awaitTermination(5, TimeUnit.SECONDS); | ||
| } catch (InterruptedException e) { | ||
| Thread.currentThread().interrupt(); | ||
| } | ||
|
|
||
| // Final snapshot | ||
| report(); | ||
|
|
||
| if (writer != null) { | ||
| try { | ||
| writer.close(); | ||
| logger.info("NettyHttpMetricsReporter stopped. Output: {}", outputFile); | ||
| } catch (IOException e) { | ||
| logger.warn("Failed to close netty pool metrics CSV", e); | ||
| } | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.