Skip to content

Commit

Permalink
Merge branch '1.14.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
shakuzen committed Dec 23, 2024
2 parents bbc3003 + 7f5071f commit 9d650ca
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,34 +35,29 @@ public class GaugeBenchmark {

private MeterRegistry registry;

private AtomicInteger stateObject;

@Setup
public void setup() {
registry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
stateObject = registry.gauge("test.gauge", new AtomicInteger());
registry.gauge("test.gauge", new AtomicInteger());
// emits warn because of double registration
stateObject = registry.gauge("test.gauge", new AtomicInteger());
registry.gauge("test.gauge", new AtomicInteger());
// emits debug because of double registration and keeps emitting debug from now on
stateObject = registry.gauge("test.gauge", new AtomicInteger());
registry.gauge("test.gauge", new AtomicInteger());
}

@Benchmark
public AtomicInteger baseline() {
stateObject = new AtomicInteger();
return stateObject;
return new AtomicInteger();
}

@Benchmark
public AtomicInteger gaugeReRegistrationWithoutBuilder() {
stateObject = registry.gauge("test.gauge", new AtomicInteger());
return stateObject;
return registry.gauge("test.gauge", new AtomicInteger());
}

@Benchmark
public Gauge gaugeReRegistrationWithBuilder() {
stateObject = new AtomicInteger();
return Gauge.builder("test.gauge", stateObject, AtomicInteger::doubleValue).register(registry);
return Gauge.builder("test.gauge", new AtomicInteger(), AtomicInteger::doubleValue).register(registry);
}

public static void main(String[] args) throws RunnerException {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ nexusPublishing {
}

wrapper {
gradleVersion = '8.11.1'
gradleVersion = '8.12'
}

defaultTasks 'build'
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
3 changes: 1 addition & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class OtlpMetricConverter {

private final long deltaTimeUnixNano;

@SuppressWarnings("deprecation")
OtlpMetricConverter(Clock clock, Duration step, TimeUnit baseTimeUnit,
AggregationTemporality aggregationTemporality, NamingConvention namingConvention) {
this.clock = clock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ void distributionWithPercentileHistogramShouldWriteHistogramOrExponentialHistogr
.isEqualTo(Metric.DataCase.EXPONENTIAL_HISTOGRAM.getNumber());
}

@SuppressWarnings("deprecation")
@Test
void multipleMetricsWithSameMetaDataShouldBeSingleMetric() {
Tags firstTag = Tags.of("key", "first");
Expand Down Expand Up @@ -427,6 +428,7 @@ protected void stepOverNStep(int numStepsToSkip) {
clock.addSeconds(otlpConfig().step().getSeconds() * numStepsToSkip);
}

@SuppressWarnings("deprecation")
protected void assertHistogram(Metric metric, long startTime, long endTime, String unit, long count, double sum,
double max) {
assertThat(metric.getHistogram().getAggregationTemporality())
Expand All @@ -452,6 +454,7 @@ protected void assertHistogram(Metric metric, long startTime, long endTime, Stri
}
}

@SuppressWarnings("deprecation")
protected void assertSum(Metric metric, long startTime, long endTime, double expectedValue) {
NumberDataPoint sumDataPoint = metric.getSum().getDataPoints(0);
assertMetricMetadata(metric, Optional.empty());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package io.micrometer.core.instrument.binder.grpc;

import io.micrometer.common.KeyValue;
import io.micrometer.common.KeyValues;
import io.micrometer.core.instrument.binder.grpc.GrpcObservationDocumentation.LowCardinalityKeyNames;

Expand All @@ -27,6 +28,10 @@
*/
public class DefaultGrpcClientObservationConvention implements GrpcClientObservationConvention {

private static final KeyValue STATUS_CODE_UNKNOWN = LowCardinalityKeyNames.STATUS_CODE.withValue(UNKNOWN);

private static final KeyValue PEER_PORT_UNKNOWN = LowCardinalityKeyNames.PEER_PORT.withValue(UNKNOWN);

@Override
public String getName() {
return "grpc.client";
Expand All @@ -39,12 +44,12 @@ public String getContextualName(GrpcClientObservationContext context) {

@Override
public KeyValues getLowCardinalityKeyValues(GrpcClientObservationContext context) {
String statusCode = context.getStatusCode() != null ? context.getStatusCode().name() : UNKNOWN;
String peerPort = context.getPeerPort() != null ? context.getPeerPort().toString() : UNKNOWN;
return KeyValues.of(LowCardinalityKeyNames.STATUS_CODE.withValue(statusCode),
LowCardinalityKeyNames.PEER_NAME.withValue(context.getPeerName()),
LowCardinalityKeyNames.PEER_PORT.withValue(peerPort),
LowCardinalityKeyNames.METHOD.withValue(context.getMethodName()),
KeyValue statusCodeKeyValue = context.getStatusCode() != null
? LowCardinalityKeyNames.STATUS_CODE.withValue(context.getStatusCode().name()) : STATUS_CODE_UNKNOWN;
KeyValue peerPortKeyValue = context.getPeerPort() != null
? LowCardinalityKeyNames.PEER_PORT.withValue(context.getPeerPort().toString()) : PEER_PORT_UNKNOWN;
return KeyValues.of(statusCodeKeyValue, LowCardinalityKeyNames.PEER_NAME.withValue(context.getPeerName()),
peerPortKeyValue, LowCardinalityKeyNames.METHOD.withValue(context.getMethodName()),
LowCardinalityKeyNames.SERVICE.withValue(context.getServiceName()),
LowCardinalityKeyNames.METHOD_TYPE.withValue(context.getMethodType().name()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package io.micrometer.core.instrument.binder.grpc;

import io.micrometer.common.KeyValue;
import io.micrometer.common.KeyValues;
import io.micrometer.core.instrument.binder.grpc.GrpcObservationDocumentation.LowCardinalityKeyNames;

Expand All @@ -27,6 +28,12 @@
*/
public class DefaultGrpcServerObservationConvention implements GrpcServerObservationConvention {

private static final KeyValue STATUS_CODE_UNKNOWN = LowCardinalityKeyNames.STATUS_CODE.withValue(UNKNOWN);

private static final KeyValue PEER_NAME_UNKNOWN = LowCardinalityKeyNames.PEER_NAME.withValue(UNKNOWN);

private static final KeyValue PEER_PORT_UNKNOWN = LowCardinalityKeyNames.PEER_PORT.withValue(UNKNOWN);

@Override
public String getName() {
return "grpc.server";
Expand All @@ -39,12 +46,13 @@ public String getContextualName(GrpcServerObservationContext context) {

@Override
public KeyValues getLowCardinalityKeyValues(GrpcServerObservationContext context) {
String statusCode = context.getStatusCode() != null ? context.getStatusCode().name() : UNKNOWN;
String peerName = context.getPeerName() != null ? context.getPeerName() : UNKNOWN;
String peerPort = context.getPeerPort() != null ? context.getPeerPort().toString() : UNKNOWN;
return KeyValues.of(LowCardinalityKeyNames.STATUS_CODE.withValue(statusCode),
LowCardinalityKeyNames.PEER_NAME.withValue(peerName),
LowCardinalityKeyNames.PEER_PORT.withValue(peerPort),
KeyValue statusCodeKeyValue = context.getStatusCode() != null
? LowCardinalityKeyNames.STATUS_CODE.withValue(context.getStatusCode().name()) : STATUS_CODE_UNKNOWN;
KeyValue peerNameKeyValue = context.getPeerName() != null
? LowCardinalityKeyNames.PEER_NAME.withValue(context.getPeerName()) : PEER_NAME_UNKNOWN;
KeyValue peerPortKeyValue = context.getPeerPort() != null
? LowCardinalityKeyNames.PEER_PORT.withValue(context.getPeerPort().toString()) : PEER_PORT_UNKNOWN;
return KeyValues.of(statusCodeKeyValue, peerNameKeyValue, peerPortKeyValue,
LowCardinalityKeyNames.METHOD.withValue(context.getMethodName()),
LowCardinalityKeyNames.SERVICE.withValue(context.getServiceName()),
LowCardinalityKeyNames.METHOD_TYPE.withValue(context.getMethodType().name()));
Expand Down

0 comments on commit 9d650ca

Please sign in to comment.