Skip to content

Commit

Permalink
Merge pull request #2840 from atlanhq/metric-hist-idxsrch
Browse files Browse the repository at this point in the history
feat: publishing histogram to get better view of indexsearch
  • Loading branch information
sumandas0 authored Feb 8, 2024
2 parents 9ce03ca + 8ad756e commit cae72e9
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public interface MetricsRegistry {

void collect(String requestId, String requestUri, AtlasPerfMetrics metrics);

void collect(String requestId, String requestUri, List<AtlasPerfMetrics.Metric> applicationMetrics);
void collectIndexsearch(String requestId, String requestUri, List<AtlasPerfMetrics.Metric> applicationMetrics);

void scrape(PrintWriter writer) throws IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import javax.inject.Inject;
import java.io.IOException;
import java.io.PrintWriter;
import java.time.Duration;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -62,10 +63,27 @@ public void collect(String requestId, String requestUri, AtlasPerfMetrics metric
return;
}
}
public void collect(String requestId, String requestUri, List<AtlasPerfMetrics.Metric> applicationMetrics){
//Use this if you want to publish Histograms
public void collectIndexsearch(String requestId, String requestUri, List<AtlasPerfMetrics.Metric> applicationMetrics){
try {
for(AtlasPerfMetrics.Metric metric : applicationMetrics){
Timer.builder(APPLICATION_LEVEL_METRICS_SUMMARY).tags(convertToMicrometerTags(metric.getTags())).publishPercentiles(PERCENTILES)
Timer.builder(APPLICATION_LEVEL_METRICS_SUMMARY)
.serviceLevelObjectives(
Duration.ofMillis(500),
Duration.ofMillis(750),
Duration.ofMillis(1000),
Duration.ofMillis(1200),
Duration.ofMillis(1500),
Duration.ofSeconds(2),
Duration.ofSeconds(3),
Duration.ofSeconds(4),
Duration.ofSeconds(5),
Duration.ofSeconds(7),
Duration.ofSeconds(10),
Duration.ofSeconds(15)
)
.publishPercentiles(PERCENTILES)
.tags(convertToMicrometerTags(metric.getTags()))
.register(getMeterRegistry()).record(metric.getTotalTimeMSecs(), TimeUnit.MILLISECONDS);
}
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public String toString() {
", persona='" + persona + '\'' +
", queryString='" + queryString + '\'' +
", allowDeletedRelations=" + allowDeletedRelations +
", utmTags="+ getUtmTags() +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public void clearCache() {
}
if (CollectionUtils.isNotEmpty(applicationMetrics)) {
if (Objects.nonNull(this.metricsRegistry)){
this.metricsRegistry.collect(traceId, this.requestUri, applicationMetrics);
this.metricsRegistry.collectIndexsearch(traceId, this.requestUri, applicationMetrics);
}
applicationMetrics.clear();
}
Expand Down
13 changes: 10 additions & 3 deletions webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.Arrays;
import static org.apache.atlas.repository.Constants.QUALIFIED_NAME;
import static org.apache.atlas.repository.Constants.REQUEST_HEADER_HOST;
import static org.apache.atlas.repository.Constants.REQUEST_HEADER_USER_AGENT;
Expand All @@ -92,6 +93,7 @@ public class DiscoveryREST {
private final SearchLoggingManagement loggerManagement;

private static final String INDEXSEARCH_TAG_NAME = "indexsearch";
private static final Set<String> TRACKING_UTM_TAGS = new HashSet<>(Arrays.asList("ui_main_list", "ui_popup_searchbar"));

@Inject
public DiscoveryREST(AtlasTypeRegistry typeRegistry, AtlasDiscoveryService discoveryService,
Expand Down Expand Up @@ -427,11 +429,16 @@ public AtlasSearchResult indexSearch(@Context HttpServletRequest servletRequest,
}
throw abe;
} finally {
if(parameters.getUtmTags() != null) {
if(CollectionUtils.isNotEmpty(parameters.getUtmTags())) {
AtlasPerfMetrics.Metric indexsearchMetric = new AtlasPerfMetrics.Metric(INDEXSEARCH_TAG_NAME);
indexsearchMetric.addTag("utmTags", String.join(",", parameters.getUtmTags()));
indexsearchMetric.addTag("utmTag", "other");
for (String utmTag : parameters.getUtmTags()) {
if (TRACKING_UTM_TAGS.contains(utmTag)) {
indexsearchMetric.addTag("utmTag", utmTag);
break;
}
}
indexsearchMetric.addTag("name", INDEXSEARCH_TAG_NAME);
indexsearchMetric.addTag("querySize",parameters.getDsl().getOrDefault("size", 20).toString());
indexsearchMetric.setTotalTimeMSecs(System.currentTimeMillis() - startTime);
RequestContext.get().addApplicationMetrics(indexsearchMetric);
}
Expand Down

0 comments on commit cae72e9

Please sign in to comment.