Skip to content

Commit

Permalink
Extended metrics bridge with new bucket boundaries APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasKunz committed Nov 29, 2023
1 parent c5a8373 commit 713adaf
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -52,4 +54,8 @@ public ProxyDoubleHistogramBuilder setDescription(String arg0) {
return this;
}

}
public ProxyDoubleHistogramBuilder setExplicitBucketBoundariesAdvice(List<Double> bucketBoundaries) {
delegate.setExplicitBucketBoundariesAdvice(bucketBoundaries);
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -47,4 +49,8 @@ public ProxyLongHistogramBuilder setDescription(String arg0) {
return this;
}

}
public ProxyLongHistogramBuilder setExplicitBucketBoundariesAdvice(List<Long> bucketBoundaries) {
delegate.setExplicitBucketBoundariesAdvice(bucketBoundaries);
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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<Double> bucketBoundaries) {
delegate.setExplicitBucketBoundariesAdvice(bucketBoundaries);
return this;
}
}
Original file line number Diff line number Diff line change
@@ -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<Long> bucketBoundaries) {
delegate.setExplicitBucketBoundariesAdvice(bucketBoundaries);
return this;
}
}
2 changes: 1 addition & 1 deletion apm-agent-plugins/apm-opentelemetry/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
-->
<version.opentelemetry>1.31.0</version.opentelemetry>
<version.opentelemetry>1.32.0</version.opentelemetry>
<version.opentelemetry-semconv>1.22.0-alpha</version.opentelemetry-semconv>

<maven.compiler.target>8</maven.compiler.target>
Expand Down

0 comments on commit 713adaf

Please sign in to comment.