Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,16 @@ public double getValue(Statistics statistics, String query) {
.getExecutionTotalTime());
}
}
),
createGaugeForQuery("hibernate_per_query_execution_seconds_avg",
"Accumulated execution time of query in seconds (based on getExecutionAvgTime)",
new ValueProviderPerQuery() {
@Override
public double getValue(Statistics statistics, String query) {
return toSeconds(statistics.getQueryStatistics(query)
.getExecutionAvgTime());
}
}
)
));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public void shouldPublishPerQueryMetricsWhenEnabled() {
assertThat(getSampleForQuery("hibernate_per_query_execution_rows_total", "factory6", query), is(7.0));
assertThat(getSampleForQuery("hibernate_per_query_execution_total", "factory6", query), is(8.0));
assertThat(getSampleForQuery("hibernate_per_query_execution_seconds_total", "factory6", query), is(102.540d));

assertThat(getSampleForQuery("hibernate_per_query_execution_seconds_avg", "factory6", query), is(0.255d));
}

@Test
Expand All @@ -201,7 +201,8 @@ public void shouldNotPublishPerQueryMetricsByDefault() {
assertThat(getSampleForQuery("hibernate_per_query_execution_min_seconds", "factory7", query), nullValue());
assertThat(getSampleForQuery("hibernate_per_query_execution_rows_total", "factory7", query), nullValue());
assertThat(getSampleForQuery("hibernate_per_query_execution_total", "factory7", query), nullValue());
assertThat(getSampleForQuery("hibernate_per_query_execution_seconds", "factory7", query), nullValue());
assertThat(getSampleForQuery("hibernate_per_query_execution_seconds_total", "factory7", query), nullValue());
assertThat(getSampleForQuery("hibernate_per_query_execution_seconds_avg", "factory7", query), nullValue());

}

Expand All @@ -216,6 +217,7 @@ private void mockQueryStatistics(String query) {
when(queryStatistics.getExecutionRowCount()).thenReturn(7L);
when(queryStatistics.getExecutionCount()).thenReturn(8L);
when(queryStatistics.getExecutionTotalTime()).thenReturn(102540L);
when(queryStatistics.getExecutionAvgTime()).thenReturn(255L);
}

@Test
Expand Down