Skip to content

Commit

Permalink
Backport: Ensure no warnings are printed when using default settings (#…
Browse files Browse the repository at this point in the history
…3155)

See original commit: 24dcfa6 and PR gh-3155
  • Loading branch information
pirgeo authored and jonatan-ivanov committed May 9, 2022
1 parent de70a01 commit 41ec8f2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ private void registerMinPercentile() {
*/
@Override
public DistributionStatisticConfig configure(Meter.Id id, DistributionStatisticConfig config) {
if (useDynatraceSummaryInstruments && dynatraceInstrumentTypeExists(id)) {
// do not add artificial 0 percentile when using Dynatrace instruments
return config;
}

double[] percentiles;

double[] configPercentiles = config.getPercentiles();
Expand Down Expand Up @@ -179,6 +184,16 @@ private boolean hasArtificialZerothPercentile(Meter.Id id) {
});
}

private boolean dynatraceInstrumentTypeExists(Meter.Id id) {
switch (id.getType()) {
case DISTRIBUTION_SUMMARY:
case TIMER:
return true;
default:
return false;
}
}

public static class Builder {

private final DynatraceConfig config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,20 @@ public final class DynatraceDistributionSummary extends AbstractDistributionSumm
// Configuration that will set the Histogram in AbstractDistributionSummary to a
// NoopHistogram.
private static final DistributionStatisticConfig NOOP_HISTOGRAM_CONFIG = DistributionStatisticConfig.builder()
.percentilesHistogram(false).percentiles().build();
.percentilesHistogram(false).percentiles().serviceLevelObjectives().build();

private final DynatraceSummary summary = new DynatraceSummary();

public DynatraceDistributionSummary(Id id, Clock clock, DistributionStatisticConfig distributionStatisticConfig,
double scale) {
super(id, clock, NOOP_HISTOGRAM_CONFIG, scale, false);

if (distributionStatisticConfig != DistributionStatisticConfig.NONE) {
LOGGER.warn("Distribution statistic config is currently ignored.");
// make sure the Histogram in AbstractDistributionSummary is always a
// NoopHistogram by disabling the respective config options
super(id, clock, distributionStatisticConfig.merge(NOOP_HISTOGRAM_CONFIG), scale, false);

if (distributionStatisticConfig.isPublishingPercentiles()
|| distributionStatisticConfig.isPublishingHistogram()) {
LOGGER.warn(
"Histogram config on DistributionStatisticConfig is currently ignored. Collecting summary statistics.");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,20 @@ public final class DynatraceTimer extends AbstractTimer implements DynatraceSumm

// Configuration that will set the Histogram in AbstractTimer to a NoopHistogram.
private static final DistributionStatisticConfig NOOP_HISTOGRAM_CONFIG = DistributionStatisticConfig.builder()
.percentilesHistogram(false).percentiles().build();
.percentilesHistogram(false).percentiles().serviceLevelObjectives().build();

private final DynatraceSummary summary = new DynatraceSummary();

public DynatraceTimer(Id id, Clock clock, DistributionStatisticConfig distributionStatisticConfig,
PauseDetector pauseDetector, TimeUnit baseTimeUnit) {
// make sure the Histogram in AbstractTimer is always a NoopHistogram by disabling
// the respective config options
super(id, clock, NOOP_HISTOGRAM_CONFIG, pauseDetector, baseTimeUnit, false);
super(id, clock, distributionStatisticConfig.merge(NOOP_HISTOGRAM_CONFIG), pauseDetector, baseTimeUnit, false);

if (distributionStatisticConfig != DistributionStatisticConfig.NONE) {
LOGGER.warn("Distribution statistic config is currently ignored.");
if (distributionStatisticConfig.isPublishingPercentiles()
|| distributionStatisticConfig.isPublishingHistogram()) {
LOGGER.warn(
"Histogram config on DistributionStatisticConfig is currently ignored. Collecting summary statistics.");
}
}

Expand Down

0 comments on commit 41ec8f2

Please sign in to comment.