Skip to content

Commit

Permalink
Merge branch '1.13.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
shakuzen committed Aug 7, 2024
2 parents 73c5077 + d0c90b8 commit 9ffef08
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 15 deletions.
2 changes: 1 addition & 1 deletion concurrency-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies {
}

jcstress {
jcstressDependency 'org.openjdk.jcstress:jcstress-core:0.16'
libs.jcstressCore

verbose = true
}
2 changes: 1 addition & 1 deletion docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* xref:installing.adoc[Installing]
* xref:concepts.adoc[Concepts]
** xref:concepts/implementations.adoc[Supported Monitoring Systems]
** xref:concepts/registry.adoc[Registry]
** xref:concepts/meters.adoc[Meters]
** xref:concepts/registry.adoc[Registry]
** xref:concepts/naming.adoc[Naming Meters]
** xref:concepts/meter-filters.adoc[Meter Filters]
** xref:concepts/rate-aggregation.adoc[Rate Aggregation]
Expand Down
5 changes: 5 additions & 0 deletions docs/modules/ROOT/pages/concepts/meters.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
[[meters]]
= Meters

A `Meter` is the interface for collecting a set of measurements (which we individually call metrics) about your application.

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.

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.
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/concepts/registry.adoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[[registry]]
= Registry

A `Meter` is the interface for collecting a set of measurements (which we individually call metrics) about your application. Meters in Micrometer are created from and held in a `MeterRegistry`. Each supported monitoring system has an implementation of `MeterRegistry`. How a registry is created varies for each implementation.
Meters in Micrometer are created from and held in a `MeterRegistry`. Each supported monitoring system has an implementation of `MeterRegistry`. How a registry is created varies for each implementation.

Micrometer includes a `SimpleMeterRegistry` that holds the latest value of each meter in memory and does not export the data anywhere. If you do not yet have a preferred monitoring system, you can get started playing with metrics by using the simple registry:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ public abstract class MeterRegistry {

/**
* write/remove guarded by meterMapLock, read in
* {@link this#getOrCreateMeter(DistributionStatisticConfig, BiFunction, Id,
* Function)} is unguarded
* {@link #getOrCreateMeter(DistributionStatisticConfig, BiFunction, Id, Function)} is
* unguarded
*/
private final Map<Id, Meter> preFilterIdToMeterMap = new HashMap<>();

Expand Down Expand Up @@ -755,15 +755,16 @@ public Meter remove(Meter.Id mappedId) {
if (meterMap.containsKey(mappedId)) {
synchronized (meterMapLock) {
final Meter removedMeter = meterMap.remove(mappedId);
Iterator<Map.Entry<Id, Meter>> iterator = preFilterIdToMeterMap.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<Id, Meter> nextEntry = iterator.next();
if (nextEntry.getValue().equals(removedMeter)) {
stalePreFilterIds.remove(nextEntry.getKey());
iterator.remove();
}
}
if (removedMeter != null) {
Iterator<Map.Entry<Id, Meter>> iterator = preFilterIdToMeterMap.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<Id, Meter> nextEntry = iterator.next();
if (nextEntry.getValue().equals(removedMeter)) {
stalePreFilterIds.remove(nextEntry.getKey());
iterator.remove();
}
}

Set<Id> synthetics = syntheticAssociations.remove(mappedId);
if (synthetics != null) {
for (Id synthetic : synthetics) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ void differentPreFilterIdsMapToSameIdWithStaleId() {

assertThat(c1).isSameAs(c2);
assertThat(registry.remove(c1)).isSameAs(c2);
assertThat(registry.remove(c2)).isNull();
assertThat(registry.getMeters()).isEmpty();
}

Expand Down Expand Up @@ -314,6 +313,7 @@ void removingStaleMeterRemovesItFromAllInternalState() {
Counter c1 = registry.counter("counter");
// make c1 marked as stale
registry.config().commonTags("common", "tag");
assertThat(registry._getStalePreFilterIds()).hasSize(1);

registry.remove(c1.getId());
assertThat(registry.getMeters()).isEmpty();
Expand All @@ -338,6 +338,7 @@ void unchangedStaleMeterShouldBeUnmarked() {
Counter c1 = registry.counter("counter");
// make c1 stale
registry.config().meterFilter(MeterFilter.ignoreTags("abc"));
assertThat(registry._getStalePreFilterIds()).hasSize(1);
// this should cause c1 (== c2) to be unmarked as stale
Counter c2 = registry.counter("counter");

Expand All @@ -347,7 +348,7 @@ void unchangedStaleMeterShouldBeUnmarked() {
assertThat(registry._getPreFilterIdToMeterMap()).hasSize(1);
assertThat(registry._getStalePreFilterIds())
.describedAs("If the meter-filter doesn't alter the meter creation, meters are never unmarked "
+ "from staleness and we end-up paying the additional cost everytime")
+ "from staleness and we end up paying the additional cost every time")
.isEmpty();
}

Expand Down

0 comments on commit 9ffef08

Please sign in to comment.