Skip to content

Commit

Permalink
Merge pull request #2348 from atlanhq/PLT-1879
Browse files Browse the repository at this point in the history
PLT-1879: added options to enable method level observability metrics
  • Loading branch information
n5nk authored Sep 5, 2023
2 parents 02b6407 + 4132a73 commit e1579a8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public class MetricsRegistryServiceImpl implements MetricsRegistry {
private static final String NAME = "name";
private static final String METHOD_DIST_SUMMARY = "method_dist_summary";
private static final double[] PERCENTILES = {0.99};
private static final int SEC_MILLIS_SCALE = 1;
private static final String METHOD_LEVEL_METRICS_ENABLE = "atlas.metrics.method_level.enable";
private static final String ATLAS_METRICS_METHOD_PATTERNS = "atlas.metrics.method_patterns";
private final List<String> filteredMethods;
Expand All @@ -48,12 +47,14 @@ public void collect(String requestId, AtlasPerfMetrics metrics) {
}

for (String name : this.filteredMethods) {
AtlasPerfMetrics.Metric metric = metrics.getMetric(name);
Timer.builder(METHOD_DIST_SUMMARY).tags(Tags.of(NAME, metric.getName())).publishPercentiles(PERCENTILES)
.register(getMeterRegistry()).record(metric.getTotalTimeMSecs(), TimeUnit.MILLISECONDS);
if(metrics.hasMetric(name)) {
AtlasPerfMetrics.Metric metric = metrics.getMetric(name);
Timer.builder(METHOD_DIST_SUMMARY).tags(Tags.of(NAME, metric.getName())).publishPercentiles(PERCENTILES)
.register(getMeterRegistry()).record(metric.getTotalTimeMSecs(), TimeUnit.MILLISECONDS);
}
}
} catch (Exception e) {
LOG.error("Failed to read {} property from atlas config", METHOD_LEVEL_METRICS_ENABLE, e);
LOG.error("Failed to collect metrics", e);
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ public Metric getMetric(String name) {
return metrics.get(name);
}

public boolean hasMetric(String name) {
return metrics.containsKey(name);
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
Expand Down

0 comments on commit e1579a8

Please sign in to comment.