|
6 | 6 | package org.opensearch.dataprepper.plugins.sink.otlp.metrics; |
7 | 7 |
|
8 | 8 | import io.micrometer.core.instrument.DistributionSummary; |
9 | | -import io.micrometer.core.instrument.Metrics; |
10 | 9 | import io.micrometer.core.instrument.Timer; |
11 | 10 | import org.opensearch.dataprepper.metrics.PluginMetrics; |
12 | 11 | import org.opensearch.dataprepper.model.configuration.PluginSetting; |
@@ -38,48 +37,10 @@ public class OtlpSinkMetrics { |
38 | 37 | public OtlpSinkMetrics(@Nonnull final PluginMetrics pluginMetrics, @Nonnull final PluginSetting pluginSetting) { |
39 | 38 | this.pluginMetrics = pluginMetrics; |
40 | 39 |
|
41 | | - final String pipelineName = pluginSetting.getPipelineName(); |
42 | | - final String pluginName = pluginSetting.getName(); |
| 40 | + httpLatency = pluginMetrics.timer("httpLatency"); |
43 | 41 |
|
44 | | - httpLatency = buildLatencyTimer(pipelineName, pluginName, "httpLatency"); |
45 | | - |
46 | | - payloadSize = buildDistributionSummary(pipelineName, pluginName, "payloadSize"); |
47 | | - payloadGzipSize = buildDistributionSummary(pipelineName, pluginName, "payloadGzipSize"); |
48 | | - } |
49 | | - |
50 | | - /** |
51 | | - * Builds a timer for latency metrics with percentiles |
52 | | - * |
53 | | - * @param pipelineName The pipeline name |
54 | | - * @param pluginName The plugin name |
55 | | - * @param metricName The metric name |
56 | | - * @return The timer |
57 | | - */ |
58 | | - private static Timer buildLatencyTimer(@Nonnull final String pipelineName, @Nonnull final String pluginName, @Nonnull final String metricName) { |
59 | | - return Timer.builder(String.format("%s_%s_%s", pipelineName, pluginName, metricName)) |
60 | | - .publishPercentiles(0.5, 0.9, 0.95, 0.99, 1.0) |
61 | | - .publishPercentileHistogram(true) |
62 | | - .distributionStatisticBufferLength(1024) |
63 | | - .distributionStatisticExpiry(Duration.ofMinutes(10)) |
64 | | - .register(Metrics.globalRegistry); |
65 | | - } |
66 | | - |
67 | | - /** |
68 | | - * Builds a distribution summary for payload size metrics with percentiles |
69 | | - * |
70 | | - * @param pipelineName The pipeline name |
71 | | - * @param pluginName The plugin name |
72 | | - * @param metricName The metric name |
73 | | - * @return The distribution summary |
74 | | - */ |
75 | | - private static DistributionSummary buildDistributionSummary(@Nonnull final String pipelineName, @Nonnull final String pluginName, @Nonnull final String metricName) { |
76 | | - return DistributionSummary.builder(String.format("%s_%s_%s", pipelineName, pluginName, metricName)) |
77 | | - .baseUnit("bytes") |
78 | | - .publishPercentiles(0.5, 0.9, 0.95, 0.99, 1.0) |
79 | | - .publishPercentileHistogram(true) |
80 | | - .distributionStatisticBufferLength(1024) |
81 | | - .distributionStatisticExpiry(Duration.ofMinutes(10)) |
82 | | - .register(Metrics.globalRegistry); |
| 42 | + payloadSize = pluginMetrics.summary("payloadSize"); |
| 43 | + payloadGzipSize = pluginMetrics.summary("payloadGzipSize"); |
83 | 44 | } |
84 | 45 |
|
85 | 46 | public void incrementRecordsOut(final long count) { |
@@ -133,6 +94,6 @@ public void incrementFailedSpansCount(final long count) { |
133 | 94 | */ |
134 | 95 | public void recordResponseCode(final int statusCode) { |
135 | 96 | final String codeCategory = (statusCode / 100) + "xx"; |
136 | | - pluginMetrics.counter("http_" + codeCategory + "_responses").increment(); |
| 97 | + pluginMetrics.counter("http" + codeCategory + "Responses").increment(); |
137 | 98 | } |
138 | 99 | } |
0 commit comments