Skip to content

Commit

Permalink
report slow queries nunogit#35
Browse files Browse the repository at this point in the history
  • Loading branch information
nunogit committed Jul 14, 2020
1 parent c217a5d commit bbc91b8
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 280,13 @@ public String getPageTypeId() {
public void setPageTypeId(String pageTypeId) {
this.pageTypeId = pageTypeId;
}

public void addTestResult(boolean successfulResult, String tag, String widgetIdentifier, String comment, int testDuration) {
addTestResult( successfulResult, tag, widgetIdentifier, comment, testDuration, "");
}


public void addTestResult(boolean successfulResult, String tag, String widgetIdentifier, String comment, int testDuration, String extraDescription) {
HashMap<String, ArrayList<TestResult>> resultList;

resultList = successfulResult ? successList : failureList;
Expand All @@ -295,7 300,7 @@ public void addTestResult(boolean successfulResult, String tag, String widgetId
//dirty solutionm, by manually adding the tab, to showcase; make a proper structure to host the description and comment


list.add( new TestResult(widgetIdentifier "\t" comment, testDuration) );
list.add( new TestResult(widgetIdentifier, comment, testDuration, extraDescription) );

}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/opendata/scholia/Tests/SPARQLWidgetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 61,7 @@ void testPage(ScholiaContentPage scPage, String sURL, int iframeSeqId) {
int iframeRuntime = scPage.checkIframeWidgetRuntime(sURL, iframeSeqId);

//TODO add load times registration
scPage.addTestResult(iframeRuntime > 0, ScholiaContentPage.SPARQL_IFRAME_WIDGET, "iframe #" iframeSeqId, iframeHeader, iframeRuntime * 1000);
scPage.addTestResult(iframeRuntime > 0, ScholiaContentPage.SPARQL_IFRAME_WIDGET, "iframe #" iframeSeqId, iframeHeader, iframeRuntime * 1000, sURL);
assertTrue("WikiData iframe SPARQL based widget fully rendered. iframe #" iframeSeqId " Header: " iframeHeader, iframeRuntime > 0);

System.out.println("Took " iframeRuntime " seconds");
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/opendata/scholia/cachepreloader/CachePreLoader.java
Original file line number Diff line number Diff line change
@@ -0,0 1,14 @@
package opendata.scholia.cachepreloader;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;

public class CachePreLoader {

public static void main(String [] args) {

//URLListLoader listLoader = URLListLoader();
//List<string> URLStringList = listLoader.load();

}
}
27 changes: 27 additions & 0 deletions src/main/java/opendata/scholia/cachepreloader/URLListLoader.java
Original file line number Diff line number Diff line change
@@ -0,0 1,27 @@
package opendata.scholia.cachepreloader;

import java.util.List;

import opendata.scholia.util.GitReader;

public class URLListLoader {

String sUrl;

public URLListLoader() {

}

public void setUrl(String sUrl) {
this.sUrl = sUrl;
}


public List<String> getList(){
GitReader gitReader = new GitReader();
gitReader.setURL(this.sUrl);
gitReader.getList();
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 48,15 @@ public class HttpExporter {
static final Gauge totalTimeRunning = Gauge.build().name("scholia_seleniumtest_runtime_seconds").help("total datatables tested").register();
static final Gauge memoryProcess = Gauge.build().name("scholia_seleniumtest_memory_processusage_bytes").help("memory spent by the exporter").register();

// static final Gauge backendperformance = Gauge.build().name("scholia_backendperformance_seconds").help("backendperformance").register();
// static final Gauge frontendperformance = Gauge.build().name("scholia_frontendperformance_seconds").help("backendperformance").register();
// static final Gauge backendperformance = Gauge.build().name("scholia_backendperformance_seconds").help("backendperformance").register();
// static final Gauge frontendperformance = Gauge.build().name("scholia_frontendperformance_seconds").help("backendperformance").register();

static final Histogram backendperformance = Histogram.build().name("scholia_backendperformance_seconds").help("backendperformance").labelNames("page_family").register();
static final Histogram frontendperformance = Histogram.build().name("scholia_frontendperformance_seconds").help("backendperformance").labelNames("page_family").register();

//not being used yet
static final Histogram iframeSparqlPerformance = Histogram.build().name("scholia_widgets_sparqliframeperformance_seconds").help("sparqlwidget").labelNames("page_family").register();

static final Gauge nodeInfo = Gauge.build().name("scholia_node_info").labelNames("sysname","nodename","release","version","machine","domainname","scholiaid").help("node information").register();


Expand Down Expand Up @@ -169,21 172,21 @@ public static void main(String[] args) throws Exception {
System.out.println("Adding front end performance (" scp.getPageTypeId() "):" scp.getFrontendPerformance());
System.out.println("Adding back end performance (" scp.getPageTypeId() "):" scp.getBackendPerformance());

backendperformance.labels(scp.getPageTypeId()).observe(scp.getBackendPerformance()/1000);
frontendperformance.labels(scp.getPageTypeId()).observe(scp.getFrontendPerformance()/1000);
backendperformance.labels(scp.getPageTypeId()).observe(scp.getBackendPerformance()/1000); //convert to seconds
frontendperformance.labels(scp.getPageTypeId()).observe(scp.getFrontendPerformance()/1000); //covert to seconds

for(TestResult failure : scp.getFailureTestResultList()) {
failureLog4Git = scp.getURL() "\t" scp.getPageTypeId() "\t" failure.getMessage() "\n";
performanceReportWidget = scp.getURL() "\t" scp.getPageTypeId() "\t" failure.getMessage() "\t" failure.getTestDuration() "\tfailure\n";
failureLog4Git = scp.getURL() "\t" scp.getPageTypeId() "\t" failure.getIdentifier() "\t" failure.getDescription() "\t" failure.getExtendedDescription() "\n";
performanceReportWidget = scp.getURL() "\t" scp.getPageTypeId() "\t" failure.getIdentifier() "\t" failure.getDescription() "\t" failure.getTestDuration() "\tfailure\t" failure.getExtendedDescription() "\n";

}
for(TestResult success : scp.getSuccessTestResultList()) {
successLog4Git = scp.getURL() "\t" scp.getPageTypeId() "\t" success.getMessage() "\n";
performanceReportWidget = scp.getURL() "\t" scp.getPageTypeId() "\t" success.getMessage() "\t" success.getTestDuration() "\tsuccess\n";
successLog4Git = scp.getURL() "\t" scp.getPageTypeId() "\t" success.getIdentifier() "\t" success.getDescription() "\t" success.getExtendedDescription() "\n";
performanceReportWidget = scp.getURL() "\t" scp.getPageTypeId() "\t" success.getIdentifier() "\t" success.getDescription() "\t" success.getTestDuration() "\tsuccess\t" success.getExtendedDescription() "\n";
}

for(TestResult diffFailure: scp.getFailureTestResultDiffList()) {
failureLogDiff4Git = scp.getURL() "\t" scp.getPageTypeId() "\t" diffFailure.getMessage() "\n";
failureLogDiff4Git = scp.getURL() "\t" scp.getPageTypeId() "\t" diffFailure.getIdentifier() "\t" diffFailure.getDescription() "\t" diffFailure.getExtendedDescription() "\n";
}


Expand Down Expand Up @@ -233,7 236,7 @@ public static void main(String[] args) throws Exception {
logger.info("Run time Delta: " deltaTime " seconds");

int timeBetweenTests = ConfigManager.instance().getConfig().getInt("timeBetweenTests", 0);
Thread.sleep(1000 * 60* timeBetweenTests); //interval between tests
Thread.sleep(1000 * 60 * timeBetweenTests); //interval between tests in seconds


} catch (InterruptedException e) {
Expand Down
42 changes: 34 additions & 8 deletions src/main/java/opendata/scholia/util/model/TestResult.java
Original file line number Diff line number Diff line change
@@ -1,23 1,49 @@
package opendata.scholia.util.model;

public class TestResult {
String message = "";
int testDuration = -1; // miliseconds
String identifier;
String description;
int testDuration = -1000; // miliseconds
String extendedDescription = "";



public TestResult(String identifier, String description, int testDuration) {
super();
this.identifier = identifier;
this.description = description;
this.testDuration = testDuration;
}

public TestResult(String message, int testDuration) {
public TestResult(String identifier, String description, int testDuration, String extendedDescription) {
super();
this.message = message;
this.identifier = identifier;
this.description = description;
this.testDuration = testDuration;
this.extendedDescription = extendedDescription;
}

public void setExtendedMessage(String extendedDescription) {
this.extendedDescription = extendedDescription;
}

public String getExtendedDescription() {
return extendedDescription;
}

public String getDescription() {
return this.description;
}

public void setDescription(String description) {
this.description = description;
}

public String getMessage() {
return message;
public String getIdentifier() {
return identifier;
}
public void setMessage(String message) {
this.message = message;
public void setIdentifier(String identifier) {
this.identifier = identifier;
}
public int getTestDuration() {
return testDuration;
Expand Down

0 comments on commit bbc91b8

Please sign in to comment.