@@ -55,31 +55,29 @@ private static MeterSupplier createOtelMeterSupplier(Settings settings) {
5555 if (otelMetricsEnabled ) {
5656 return new OTelSdkMeterSupplier (settings );
5757 } else {
58- // CONFUSION ALERT: When we do `GlobalOpenTelemetry.get()`, we're actually getting an OpenTelemetry
59- // object that routes telemetry to the APM agent; that is, we're still using OTel to report telemetry
60- // from the code, but we're using the APM agent (instead of the OTel SDK) to export it.
61- // That's why this "else" branch, where otelMetricsEnabled is false, is still using OpenTelemetry.
62-
63- /*
64- * The agent offers no flush API, so this is only a best-effort pause that exceeds
65- * the agent reporting interval, making it extremely likely that all telemetry
66- * has been exported.
67- *
68- * Note that the first intake request to the APM server can still be delayed beyond this window:
69- * the APM agent checks for configuration changes only periodically,
70- * so the setting changes we made during initialization don't take effect immediately.
71- */
7258 long agentFlushWaitMs = 2 * agentMetricsInterval (settings ).millis ();
73-
7459 return new MeterSupplier () {
7560 @ Override
7661 public Meter get () {
62+ // CONFUSION ALERT: When we do `GlobalOpenTelemetry.get()`, we're actually getting an OpenTelemetry
63+ // object that routes telemetry to the APM agent; that is, we're still using OTel to report telemetry
64+ // from the code, but we're using the APM agent (instead of the OTel SDK) to export it.
65+ // That's why this "else" branch, where otelMetricsEnabled is false, is still using OpenTelemetry.
66+
7767 return GlobalOpenTelemetry .get ().getMeter ("elasticsearch" );
7868 }
7969
8070 @ Override
8171 public void attemptFlushMetrics () {
8272 try {
73+ // The agent offers no flush API, so we do a best-effort pause that exceeds
74+ // the agent reporting interval, making it extremely likely that all telemetry
75+ // has been exported.
76+ //
77+ // Note that the first intake request to the APM server can still be delayed beyond this window:
78+ // the APM agent checks for configuration changes only periodically,
79+ // so the setting changes we made during initialization don't take effect immediately.
80+
8381 LOGGER .info ("Waiting {} ms for APM agent to flush metrics" , agentFlushWaitMs );
8482 Thread .sleep (agentFlushWaitMs );
8583 } catch (InterruptedException e ) {
0 commit comments