forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
With this commit we add a new API to the Universal Profiling plugin that allows to gather a list of functions with the most observed samples (TopN functions).
- Loading branch information
1 parent
2a624e5
commit 35c2bcb
Showing
22 changed files
with
865 additions
and
516 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
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
84 changes: 84 additions & 0 deletions
84
.../internalClusterTest/java/org/elasticsearch/xpack/profiling/GetTopNFunctionsActionIT.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,84 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.profiling; | ||
|
||
import org.elasticsearch.index.query.BoolQueryBuilder; | ||
import org.elasticsearch.index.query.QueryBuilders; | ||
|
||
public class GetTopNFunctionsActionIT extends ProfilingTestCase { | ||
public void testGetTopNFunctionsUnfiltered() throws Exception { | ||
GetStackTracesRequest request = new GetStackTracesRequest( | ||
1000, | ||
600.0d, | ||
1.0d, | ||
1.0d, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null | ||
); | ||
request.setAdjustSampleCount(true); | ||
GetTopNFunctionsResponse response = client().execute(GetTopNFunctionsAction.INSTANCE, request).get(); | ||
assertEquals(46, response.getTotalSamples()); | ||
assertEquals(747, response.getTopN().size()); | ||
} | ||
|
||
public void testGetTopNFunctionsGroupedByServiceName() throws Exception { | ||
GetStackTracesRequest request = new GetStackTracesRequest( | ||
1000, | ||
600.0d, | ||
1.0d, | ||
1.0d, | ||
null, | ||
null, | ||
null, | ||
"service.name", | ||
null, | ||
null, | ||
null, | ||
null, | ||
null | ||
); | ||
request.setAdjustSampleCount(true); | ||
request.setLimit(50); | ||
GetTopNFunctionsResponse response = client().execute(GetTopNFunctionsAction.INSTANCE, request).get(); | ||
assertEquals(46, response.getTotalSamples()); | ||
assertEquals(50, response.getTopN().size()); | ||
} | ||
|
||
public void testGetTopNFunctionsFromAPM() throws Exception { | ||
BoolQueryBuilder query = QueryBuilders.boolQuery(); | ||
query.must().add(QueryBuilders.termQuery("transaction.name", "encodeSha1")); | ||
query.must().add(QueryBuilders.rangeQuery("@timestamp").lte("1698624000")); | ||
|
||
GetStackTracesRequest request = new GetStackTracesRequest( | ||
null, | ||
1.0d, | ||
1.0d, | ||
1.0d, | ||
query, | ||
// also match an index that does not contain stacktrace ids to ensure it is ignored | ||
new String[] { "apm-test-*", "apm-legacy-test-*" }, | ||
"transaction.profiler_stack_trace_ids", | ||
"transaction.name", | ||
null, | ||
null, | ||
null, | ||
null, | ||
null | ||
); | ||
GetTopNFunctionsResponse response = client().execute(GetTopNFunctionsAction.INSTANCE, request).get(); | ||
assertEquals(5, response.getTotalSamples()); | ||
assertEquals(45, response.getTopN().size()); | ||
} | ||
} |
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
Oops, something went wrong.