Skip to content

Commit

Permalink
Merge branch 'main' into micrometer-metricsgh-1149
Browse files Browse the repository at this point in the history
  • Loading branch information
shakuzen authored Aug 27, 2024
2 parents 03b4aa8 + d0e40ac commit 0c765a8
Show file tree
Hide file tree
Showing 21 changed files with 38 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies {

testImplementation project(':micrometer-test')
testImplementation project(':micrometer-observation-test')
testImplementation 'org.aspectj:aspectjweaver'
testImplementation libs.aspectjweaver
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'org.assertj:assertj-core'
testImplementation 'org.springframework:spring-context'
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/concepts/meters.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ A `Meter` is the interface for collecting a set of measurements (which we indivi
Micrometer supports a set of `Meter` primitives, including `Timer`, `Counter`, `Gauge`, `DistributionSummary`, `LongTaskTimer`, `FunctionCounter`, `FunctionTimer`, and `TimeGauge`. Different meter types result in a different number of time series metrics. For example, while there is a single metric that represents a `Gauge`, a `Timer` measures both the count of timed events and the total time of all timed events.

TIP: Recording a measurement for a `Meter` is expected to be a relatively cheap operation and should not throw any exception.
If the xref:./registry.adoc[registry] supports publishing metrics to a monitoring system, this is done in a separate thread snd should not affect recording metrics.
If the xref:./registry.adoc[registry] supports publishing metrics to a monitoring system, this is done in a separate thread and should not affect recording metrics.

A meter is uniquely identified by its name and dimensions. We use the terms, "`dimensions`" and "`tags,`" interchangeably, and the Micrometer interface is `Tag` simply because it is shorter. As a general rule, it should be possible to use the name as a pivot. Dimensions let a particular named metric be sliced to drill down and reason about the data. This means that, if only the name is selected, you can drill down by using other dimensions and reason about the value being shown.
1 change: 1 addition & 0 deletions micrometer-bom/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dependencies {
!it.name.contains('concurrency-tests') &&
!it.name.contains('micrometer-bom') &&
!it.name.contains('micrometer-osgi-test') &&
!it.name.contains('-test-aspectj') &&
it.name != 'docs'
}.each {
api(group: it.group,
Expand Down
2 changes: 1 addition & 1 deletion micrometer-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ dependencies {
testImplementation 'io.grpc:grpc-testing-proto'
testImplementation 'com.squareup.retrofit2:retrofit'

testImplementation 'org.aspectj:aspectjweaver'
testImplementation libs.aspectjweaver
}

task shenandoahTest(type: Test) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package io.micrometer.observation.tck;

import io.micrometer.common.lang.Nullable;
import io.micrometer.observation.NullObservation.NullContext;
import io.micrometer.observation.Observation.Context;
import io.micrometer.observation.Observation.Event;
import io.micrometer.observation.ObservationHandler;
Expand Down Expand Up @@ -47,7 +48,7 @@ class ObservationValidator implements ObservationHandler<Context> {
}

ObservationValidator(Consumer<ValidationResult> consumer) {
this(consumer, context -> true);
this(consumer, context -> !(context instanceof NullContext));
}

ObservationValidator(Consumer<ValidationResult> consumer, Predicate<Context> supportsContextPredicate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package io.micrometer.observation.tck;

import io.micrometer.observation.NullObservation;
import io.micrometer.observation.Observation;
import io.micrometer.observation.Observation.Event;
import io.micrometer.observation.Observation.Scope;
Expand Down Expand Up @@ -253,4 +254,9 @@ void startErrorErrorStopShouldBeValid() {
Observation.start("test", registry).error(new RuntimeException()).error(new RuntimeException()).stop();
}

@Test
void nullObservationShouldBeIgnored() {
new NullObservation(registry).openScope();
}

}
2 changes: 1 addition & 1 deletion micrometer-observation/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ dependencies {

testImplementation 'org.assertj:assertj-core'
testImplementation 'org.awaitility:awaitility'
testImplementation 'org.aspectj:aspectjweaver'
testImplementation libs.aspectjweaver
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
public class NullObservation extends SimpleObservation {

public NullObservation(ObservationRegistry registry) {
super("null", registry, new Context());
super("null", registry, new NullContext());
}

@Override
Expand Down Expand Up @@ -66,4 +66,16 @@ public Observation start() {
return this;
}

/**
* A special {@link Observation.Context} that should be used only in
* {@link NullObservation} in special cases where clearing of scopes is important. Its
* only purpose is to make scenarios through {@link NullObservation} distinguishable
* from "normal" {@link Observation Observations}.
*
* @since 1.14.0
*/
public static class NullContext extends Context {

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public final class Observations {
initialRegistry);

private Observations() {
throw new UnsupportedOperationException("You can't instantiate a utility class");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,13 @@ public class ObservedAspect {

private final Predicate<ProceedingJoinPoint> shouldSkip;

// For Compile Time Weaving
/**
* Create an {@code ObservedAspect} with {@link Observations#getGlobalRegistry()}.
*
* This is for compile-time weaving.
*
* @since 1.14.0
*/
public ObservedAspect() {
this(Observations.getGlobalRegistry(), null, DONT_SKIP_ANYTHING);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ plugins {
description 'AspectJ compile-time weaving test for Micrometer aspects'

dependencies {
implementation project(':micrometer-core')
aspect project(':micrometer-core')
aspect project(':micrometer-observation')
implementation libs.aspectjrt

testImplementation libs.junitJupiter
testImplementation libs.assertj
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledForJreRange;
import org.junit.jupiter.api.condition.JRE;

import java.util.Collection;

import static org.assertj.core.api.BDDAssertions.then;

@DisabledForJreRange(min = JRE.JAVA_17,
disabledReason = "See https://github.com/micrometer-metrics/micrometer/pull/5401#issuecomment-2308440259")
class MeasuredClassTest {

MeterRegistry registry = new SimpleMeterRegistry();
Expand Down

0 comments on commit 0c765a8

Please sign in to comment.