-
Notifications
You must be signed in to change notification settings - Fork 873
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable by default gauge-based histograms in the Micrometer bridge
- Loading branch information
Mateusz Rzeszutek
committed
Apr 25, 2023
1 parent
1a68f4d
commit 2e02a1e
Showing
17 changed files
with
636 additions
and
343 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# Settings for the Micrometer bridge instrumentation | ||
|
||
| System property | Type | Default | Description | | ||
|---|---|---|---| | ||
| `otel.instrumentation.micrometer.base-time-unit` | String | `ms` | Set the base time unit for the OpenTelemetry `MeterRegistry` implementation. <details><summary>Valid values</summary>`ns`, `nanoseconds`, `us`, `microseconds`, `ms`, `microseconds`, `s`, `seconds`, `min`, `minutes`, `h`, `hours`, `d`, `days`</details> | | ||
| `otel.instrumentation.micrometer.prometheus-mode.enabled` | boolean | false | Enable the "Prometheus mode" this will simulate the behavior of Micrometer's PrometheusMeterRegistry. The instruments will be renamed to match Micrometer instrument naming, and the base time unit will be set to seconds. | | ||
| System property | Type | Default | Description | | ||
|------------------------------------------------------------|---------|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| `otel.instrumentation.micrometer.base-time-unit` | String | `ms` | Set the base time unit for the OpenTelemetry `MeterRegistry` implementation. <details><summary>Valid values</summary>`ns`, `nanoseconds`, `us`, `microseconds`, `ms`, `microseconds`, `s`, `seconds`, `min`, `minutes`, `h`, `hours`, `d`, `days`</details> | | ||
| `otel.instrumentation.micrometer.prometheus-mode.enabled` | boolean | false | Enable the "Prometheus mode" this will simulate the behavior of Micrometer's PrometheusMeterRegistry. The instruments will be renamed to match Micrometer instrument naming, and the base time unit will be set to seconds. | | ||
| `otel.instrumentation.micrometer.histogram-gauges.enabled` | boolean | false | Enables the generation of gauge-based Micrometer histograms for `DistributionSummary` and `Timer` instruments. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...try/javaagent/instrumentation/micrometer/v1_5/DistributionSummaryHistogramGaugesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.micrometer.v1_5; | ||
|
||
import io.micrometer.core.instrument.Metrics; | ||
import io.opentelemetry.instrumentation.micrometer.v1_5.AbstractDistributionSummaryHistogramGaugesTest; | ||
import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; | ||
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
class DistributionSummaryHistogramGaugesTest | ||
extends AbstractDistributionSummaryHistogramGaugesTest { | ||
|
||
@RegisterExtension | ||
static final InstrumentationExtension testing = AgentInstrumentationExtension.create(); | ||
|
||
@AfterEach | ||
public void cleanup() { | ||
Metrics.globalRegistry.forEachMeter(Metrics.globalRegistry::remove); | ||
} | ||
|
||
@Override | ||
protected InstrumentationExtension testing() { | ||
return testing; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
.../io/opentelemetry/javaagent/instrumentation/micrometer/v1_5/TimerHistogramGaugesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.micrometer.v1_5; | ||
|
||
import io.micrometer.core.instrument.Metrics; | ||
import io.opentelemetry.instrumentation.micrometer.v1_5.AbstractTimerHistogramGaugesTest; | ||
import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; | ||
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
class TimerHistogramGaugesTest extends AbstractTimerHistogramGaugesTest { | ||
|
||
@RegisterExtension | ||
static final InstrumentationExtension testing = AgentInstrumentationExtension.create(); | ||
|
||
@AfterEach | ||
public void cleanup() { | ||
Metrics.globalRegistry.forEachMeter(Metrics.globalRegistry::remove); | ||
} | ||
|
||
@Override | ||
protected InstrumentationExtension testing() { | ||
return testing; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...io/opentelemetry/instrumentation/micrometer/v1_5/DistributionStatisticConfigModifier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.micrometer.v1_5; | ||
|
||
import io.micrometer.core.instrument.distribution.DistributionStatisticConfig; | ||
|
||
enum DistributionStatisticConfigModifier { | ||
DISABLE_HISTOGRAM_GAUGES { | ||
@Override | ||
DistributionStatisticConfig modify(DistributionStatisticConfig config) { | ||
return DistributionStatisticConfig.builder() | ||
// disable all percentile and slo related options | ||
.percentilesHistogram(null) | ||
.percentiles((double[]) null) | ||
.serviceLevelObjectives((double[]) null) | ||
.percentilePrecision(null) | ||
// and keep the rest | ||
.minimumExpectedValue(config.getMinimumExpectedValueAsDouble()) | ||
.maximumExpectedValue(config.getMaximumExpectedValueAsDouble()) | ||
.expiry(config.getExpiry()) | ||
.bufferLength(config.getBufferLength()) | ||
.build(); | ||
} | ||
}, | ||
IDENTITY { | ||
@Override | ||
DistributionStatisticConfig modify(DistributionStatisticConfig config) { | ||
return config; | ||
} | ||
}; | ||
|
||
abstract DistributionStatisticConfig modify(DistributionStatisticConfig config); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...opentelemetry/instrumentation/micrometer/v1_5/DistributionSummaryHistogramGaugesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.micrometer.v1_5; | ||
|
||
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; | ||
import io.opentelemetry.instrumentation.testing.junit.LibraryInstrumentationExtension; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
class DistributionSummaryHistogramGaugesTest | ||
extends AbstractDistributionSummaryHistogramGaugesTest { | ||
|
||
@RegisterExtension | ||
static final InstrumentationExtension testing = LibraryInstrumentationExtension.create(); | ||
|
||
@RegisterExtension | ||
static final MicrometerTestingExtension micrometerExtension = | ||
new MicrometerTestingExtension(testing) { | ||
@Override | ||
OpenTelemetryMeterRegistryBuilder configureOtelRegistry( | ||
OpenTelemetryMeterRegistryBuilder registry) { | ||
return registry.setMicrometerHistogramGaugesEnabled(true); | ||
} | ||
}; | ||
|
||
@Override | ||
protected InstrumentationExtension testing() { | ||
return testing; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
.../test/java/io/opentelemetry/instrumentation/micrometer/v1_5/TimerHistogramGaugesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.micrometer.v1_5; | ||
|
||
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; | ||
import io.opentelemetry.instrumentation.testing.junit.LibraryInstrumentationExtension; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
class TimerHistogramGaugesTest extends AbstractTimerHistogramGaugesTest { | ||
|
||
@RegisterExtension | ||
static final InstrumentationExtension testing = LibraryInstrumentationExtension.create(); | ||
|
||
@RegisterExtension | ||
static final MicrometerTestingExtension micrometerExtension = | ||
new MicrometerTestingExtension(testing) { | ||
@Override | ||
OpenTelemetryMeterRegistryBuilder configureOtelRegistry( | ||
OpenTelemetryMeterRegistryBuilder registry) { | ||
return registry.setMicrometerHistogramGaugesEnabled(true); | ||
} | ||
}; | ||
|
||
@Override | ||
protected InstrumentationExtension testing() { | ||
return testing; | ||
} | ||
} |
Oops, something went wrong.