From 713adafede0072ec37551bdbad714b66d64a6331 Mon Sep 17 00:00:00 2001 From: Jonas Kunz Date: Tue, 28 Nov 2023 11:39:24 +0100 Subject: [PATCH] Extended metrics bridge with new bucket boundaries APIs --- .../proxy/ProxyDoubleHistogramBuilder.java | 8 +++- .../proxy/ProxyLongHistogramBuilder.java | 8 +++- .../metrics/bridge/BridgeFactoryLatest.java | 16 +++++++ .../latest/BridgeDoubleHistogramBuilder.java | 40 ++++++++++++++++++ .../latest/BridgeLongHistogramBuilder.java | 42 +++++++++++++++++++ apm-agent-plugins/apm-opentelemetry/pom.xml | 2 +- 6 files changed, 113 insertions(+), 3 deletions(-) create mode 100644 apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metrics-bridge-parent/apm-opentelemetry-metrics-bridge-latest/src/main/java/co/elastic/apm/agent/opentelemetry/metrics/bridge/latest/BridgeDoubleHistogramBuilder.java create mode 100644 apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metrics-bridge-parent/apm-opentelemetry-metrics-bridge-latest/src/main/java/co/elastic/apm/agent/opentelemetry/metrics/bridge/latest/BridgeLongHistogramBuilder.java diff --git a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-embedded-metrics-sdk/src/main/java/co/elastic/apm/agent/embeddedotel/proxy/ProxyDoubleHistogramBuilder.java b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-embedded-metrics-sdk/src/main/java/co/elastic/apm/agent/embeddedotel/proxy/ProxyDoubleHistogramBuilder.java index 1e3ee4087b..91127d6736 100644 --- a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-embedded-metrics-sdk/src/main/java/co/elastic/apm/agent/embeddedotel/proxy/ProxyDoubleHistogramBuilder.java +++ b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-embedded-metrics-sdk/src/main/java/co/elastic/apm/agent/embeddedotel/proxy/ProxyDoubleHistogramBuilder.java @@ -22,6 +22,8 @@ import io.opentelemetry.api.metrics.DoubleHistogramBuilder; import io.opentelemetry.api.metrics.LongHistogramBuilder; +import java.util.List; + public class ProxyDoubleHistogramBuilder { private final DoubleHistogramBuilder delegate; @@ -52,4 +54,8 @@ public ProxyDoubleHistogramBuilder setDescription(String arg0) { return this; } -} \ No newline at end of file + public ProxyDoubleHistogramBuilder setExplicitBucketBoundariesAdvice(List bucketBoundaries) { + delegate.setExplicitBucketBoundariesAdvice(bucketBoundaries); + return this; + } +} diff --git a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-embedded-metrics-sdk/src/main/java/co/elastic/apm/agent/embeddedotel/proxy/ProxyLongHistogramBuilder.java b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-embedded-metrics-sdk/src/main/java/co/elastic/apm/agent/embeddedotel/proxy/ProxyLongHistogramBuilder.java index 4f3fb3e76e..210ea31b60 100644 --- a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-embedded-metrics-sdk/src/main/java/co/elastic/apm/agent/embeddedotel/proxy/ProxyLongHistogramBuilder.java +++ b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-embedded-metrics-sdk/src/main/java/co/elastic/apm/agent/embeddedotel/proxy/ProxyLongHistogramBuilder.java @@ -21,6 +21,8 @@ import io.opentelemetry.api.metrics.LongHistogram; import io.opentelemetry.api.metrics.LongHistogramBuilder; +import java.util.List; + public class ProxyLongHistogramBuilder { private final LongHistogramBuilder delegate; @@ -47,4 +49,8 @@ public ProxyLongHistogramBuilder setDescription(String arg0) { return this; } -} \ No newline at end of file + public ProxyLongHistogramBuilder setExplicitBucketBoundariesAdvice(List bucketBoundaries) { + delegate.setExplicitBucketBoundariesAdvice(bucketBoundaries); + return this; + } +} diff --git a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metrics-bridge-parent/apm-opentelemetry-metrics-bridge-latest/src/main/java/co/elastic/apm/agent/opentelemetry/metrics/bridge/BridgeFactoryLatest.java b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metrics-bridge-parent/apm-opentelemetry-metrics-bridge-latest/src/main/java/co/elastic/apm/agent/opentelemetry/metrics/bridge/BridgeFactoryLatest.java index c873de6e01..dfe5e4d746 100644 --- a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metrics-bridge-parent/apm-opentelemetry-metrics-bridge-latest/src/main/java/co/elastic/apm/agent/opentelemetry/metrics/bridge/BridgeFactoryLatest.java +++ b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metrics-bridge-parent/apm-opentelemetry-metrics-bridge-latest/src/main/java/co/elastic/apm/agent/opentelemetry/metrics/bridge/BridgeFactoryLatest.java @@ -21,25 +21,31 @@ import co.elastic.apm.agent.embeddedotel.proxy.ProxyBatchCallback; import co.elastic.apm.agent.embeddedotel.proxy.ProxyDoubleCounterBuilder; import co.elastic.apm.agent.embeddedotel.proxy.ProxyDoubleGaugeBuilder; +import co.elastic.apm.agent.embeddedotel.proxy.ProxyDoubleHistogramBuilder; import co.elastic.apm.agent.embeddedotel.proxy.ProxyDoubleUpDownCounterBuilder; import co.elastic.apm.agent.embeddedotel.proxy.ProxyLongCounterBuilder; import co.elastic.apm.agent.embeddedotel.proxy.ProxyLongGaugeBuilder; +import co.elastic.apm.agent.embeddedotel.proxy.ProxyLongHistogramBuilder; import co.elastic.apm.agent.embeddedotel.proxy.ProxyLongUpDownCounterBuilder; import co.elastic.apm.agent.embeddedotel.proxy.ProxyMeter; import co.elastic.apm.agent.opentelemetry.metrics.bridge.latest.BridgeBatchCallback; import co.elastic.apm.agent.opentelemetry.metrics.bridge.latest.BridgeDoubleCounterBuilder; import co.elastic.apm.agent.opentelemetry.metrics.bridge.latest.BridgeDoubleGaugeBuilder; +import co.elastic.apm.agent.opentelemetry.metrics.bridge.latest.BridgeDoubleHistogramBuilder; import co.elastic.apm.agent.opentelemetry.metrics.bridge.latest.BridgeDoubleUpDownCounterBuilder; import co.elastic.apm.agent.opentelemetry.metrics.bridge.latest.BridgeLongCounterBuilder; import co.elastic.apm.agent.opentelemetry.metrics.bridge.latest.BridgeLongGaugeBuilder; +import co.elastic.apm.agent.opentelemetry.metrics.bridge.latest.BridgeLongHistogramBuilder; import co.elastic.apm.agent.opentelemetry.metrics.bridge.latest.BridgeLongUpDownCounterBuilder; import co.elastic.apm.agent.opentelemetry.metrics.bridge.latest.BridgeMeter; import io.opentelemetry.api.metrics.BatchCallback; import io.opentelemetry.api.metrics.DoubleCounterBuilder; import io.opentelemetry.api.metrics.DoubleGaugeBuilder; +import io.opentelemetry.api.metrics.DoubleHistogramBuilder; import io.opentelemetry.api.metrics.DoubleUpDownCounterBuilder; import io.opentelemetry.api.metrics.LongCounterBuilder; import io.opentelemetry.api.metrics.LongGaugeBuilder; +import io.opentelemetry.api.metrics.LongHistogramBuilder; import io.opentelemetry.api.metrics.LongUpDownCounterBuilder; import io.opentelemetry.api.metrics.Meter; @@ -99,4 +105,14 @@ public DoubleGaugeBuilder bridgeDoubleGaugeBuilder(ProxyDoubleGaugeBuilder deleg public BatchCallback bridgeBatchCallback(ProxyBatchCallback delegate) { return new BridgeBatchCallback(delegate); } + + @Override + public DoubleHistogramBuilder bridgeDoubleHistogramBuilder(ProxyDoubleHistogramBuilder delegate) { + return new BridgeDoubleHistogramBuilder(delegate); + } + + @Override + public LongHistogramBuilder bridgeLongHistogramBuilder(ProxyLongHistogramBuilder delegate) { + return new BridgeLongHistogramBuilder(delegate); + } } diff --git a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metrics-bridge-parent/apm-opentelemetry-metrics-bridge-latest/src/main/java/co/elastic/apm/agent/opentelemetry/metrics/bridge/latest/BridgeDoubleHistogramBuilder.java b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metrics-bridge-parent/apm-opentelemetry-metrics-bridge-latest/src/main/java/co/elastic/apm/agent/opentelemetry/metrics/bridge/latest/BridgeDoubleHistogramBuilder.java new file mode 100644 index 0000000000..fed2abdcea --- /dev/null +++ b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metrics-bridge-parent/apm-opentelemetry-metrics-bridge-latest/src/main/java/co/elastic/apm/agent/opentelemetry/metrics/bridge/latest/BridgeDoubleHistogramBuilder.java @@ -0,0 +1,40 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package co.elastic.apm.agent.opentelemetry.metrics.bridge.latest; + +import co.elastic.apm.agent.embeddedotel.proxy.ProxyDoubleHistogramBuilder; +import io.opentelemetry.api.metrics.DoubleHistogramBuilder; + +import java.util.List; + +public class BridgeDoubleHistogramBuilder extends co.elastic.apm.agent.opentelemetry.metrics.bridge.v1_14.BridgeDoubleHistogramBuilder { + public BridgeDoubleHistogramBuilder(ProxyDoubleHistogramBuilder delegate) { + super(delegate); + } + + /** + * This method was added in 1.32.0, but is safe to have even if the provided API is older. + * This is safe because it doesn't reference any newly added API types. + */ + @Override + public DoubleHistogramBuilder setExplicitBucketBoundariesAdvice(List bucketBoundaries) { + delegate.setExplicitBucketBoundariesAdvice(bucketBoundaries); + return this; + } +} diff --git a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metrics-bridge-parent/apm-opentelemetry-metrics-bridge-latest/src/main/java/co/elastic/apm/agent/opentelemetry/metrics/bridge/latest/BridgeLongHistogramBuilder.java b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metrics-bridge-parent/apm-opentelemetry-metrics-bridge-latest/src/main/java/co/elastic/apm/agent/opentelemetry/metrics/bridge/latest/BridgeLongHistogramBuilder.java new file mode 100644 index 0000000000..7dbd44ef9b --- /dev/null +++ b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metrics-bridge-parent/apm-opentelemetry-metrics-bridge-latest/src/main/java/co/elastic/apm/agent/opentelemetry/metrics/bridge/latest/BridgeLongHistogramBuilder.java @@ -0,0 +1,42 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package co.elastic.apm.agent.opentelemetry.metrics.bridge.latest; + +import co.elastic.apm.agent.embeddedotel.proxy.ProxyDoubleHistogramBuilder; +import co.elastic.apm.agent.embeddedotel.proxy.ProxyLongHistogramBuilder; +import io.opentelemetry.api.metrics.DoubleHistogramBuilder; +import io.opentelemetry.api.metrics.LongHistogramBuilder; + +import java.util.List; + +public class BridgeLongHistogramBuilder extends co.elastic.apm.agent.opentelemetry.metrics.bridge.v1_14.BridgeLongHistogramBuilder { + public BridgeLongHistogramBuilder(ProxyLongHistogramBuilder delegate) { + super(delegate); + } + + /** + * This method was added in 1.32.0, but is safe to have even if the provided API is older. + * This is safe because it doesn't reference any newly added API types. + */ + @Override + public LongHistogramBuilder setExplicitBucketBoundariesAdvice(List bucketBoundaries) { + delegate.setExplicitBucketBoundariesAdvice(bucketBoundaries); + return this; + } +} diff --git a/apm-agent-plugins/apm-opentelemetry/pom.xml b/apm-agent-plugins/apm-opentelemetry/pom.xml index da814ccac4..a9e2917f56 100644 --- a/apm-agent-plugins/apm-opentelemetry/pom.xml +++ b/apm-agent-plugins/apm-opentelemetry/pom.xml @@ -19,7 +19,7 @@ When updating the version, add the old version to OpenTelemetryVersionIT to make sure that in the future we stay compatible with the previous version. --> - 1.31.0 + 1.32.0 1.22.0-alpha 8