Merge pull request #1741 from jamesagnew/elastic-apm-integration-for-search
Create custom span for Search Threads for Elastic APM
This commit is contained in:
commit
4d7f39cfdc
|
@ -48,6 +48,11 @@
|
|||
<artifactId>commons-csv</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>co.elastic.apm</groupId>
|
||||
<artifactId>apm-agent-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-base</artifactId>
|
||||
|
|
|
@ -56,6 +56,9 @@ import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
|||
import ca.uhn.fhir.rest.server.util.ICachedSearchDetails;
|
||||
import ca.uhn.fhir.util.AsyncUtil;
|
||||
import ca.uhn.fhir.util.StopWatch;
|
||||
import co.elastic.apm.api.ElasticApm;
|
||||
import co.elastic.apm.api.Span;
|
||||
import co.elastic.apm.api.Transaction;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
|
@ -601,7 +604,7 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc {
|
|||
private List<ResourcePersistentId> myPreviouslyAddedResourcePids;
|
||||
private Integer myMaxResultsToFetch;
|
||||
private SearchRuntimeDetails mySearchRuntimeDetails;
|
||||
|
||||
private Transaction myParentTransaction;
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
|
@ -614,6 +617,7 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc {
|
|||
mySearchRuntimeDetails = new SearchRuntimeDetails(theRequest, mySearch.getUuid());
|
||||
mySearchRuntimeDetails.setQueryString(theParams.toNormalizedQueryString(theCallingDao.getContext()));
|
||||
myRequest = theRequest;
|
||||
myParentTransaction = ElasticApm.currentTransaction();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -841,7 +845,8 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc {
|
|||
@Override
|
||||
public Void call() {
|
||||
StopWatch sw = new StopWatch();
|
||||
|
||||
Span span = myParentTransaction.startSpan("db", "query", "search");
|
||||
span.setName("FHIR Database Search");
|
||||
try {
|
||||
// Create an initial search in the DB and give it an ID
|
||||
saveSearch();
|
||||
|
@ -897,7 +902,6 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc {
|
|||
ourLog.error("Failed during search loading after {}ms", sw.getMillis(), t);
|
||||
}
|
||||
myUnsyncedPids.clear();
|
||||
|
||||
Throwable rootCause = ExceptionUtils.getRootCause(t);
|
||||
rootCause = defaultIfNull(rootCause, t);
|
||||
|
||||
|
@ -924,12 +928,13 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc {
|
|||
JpaInterceptorBroadcaster.doCallHooks(myInterceptorBroadcaster, myRequest, Pointcut.JPA_PERFTRACE_SEARCH_FAILED, params);
|
||||
|
||||
saveSearch();
|
||||
|
||||
span.captureException(t);
|
||||
} finally {
|
||||
|
||||
myIdToSearchTask.remove(mySearch.getUuid());
|
||||
myInitialCollectionLatch.countDown();
|
||||
markComplete();
|
||||
span.end();
|
||||
|
||||
}
|
||||
return null;
|
||||
|
|
6
pom.xml
6
pom.xml
|
@ -679,6 +679,7 @@
|
|||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<ebay_cors_filter_version>1.0.1</ebay_cors_filter_version>
|
||||
|
||||
<elastic_apm_version>1.13.0</elastic_apm_version>
|
||||
<!-- Site properties -->
|
||||
<fontawesomeVersion>5.4.1</fontawesomeVersion>
|
||||
</properties>
|
||||
|
@ -1036,6 +1037,11 @@
|
|||
<artifactId>httpcore</artifactId>
|
||||
<version>${httpcore_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>co.elastic.apm</groupId>
|
||||
<artifactId>apm-agent-api</artifactId>
|
||||
<version>${elastic_apm_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.jena</groupId>
|
||||
<artifactId>apache-jena-libs</artifactId>
|
||||
|
|
Loading…
Reference in New Issue