Search in sources :

Example 1 with CounterSet

use of org.apache.jena.fuseki.server.CounterSet in project jena by apache.

the class ActionService method executeLifecycle.

/**
 * Add counters to the validate-execute lifecycle.
 */
@Override
protected void executeLifecycle(HttpAction action) {
    // And also HTTP counter
    CounterSet csService = (action.getDataService() == null) ? null : action.getDataService().getCounters();
    CounterSet csOperation = null;
    if (action.getEndpoint() != null)
        // Direct naming GSP does not have an "endpoint".
        csOperation = action.getEndpoint().getCounters();
    incCounter(csService, Requests);
    incCounter(csOperation, Requests);
    // or in execution in perform.
    try {
        validate(action);
    } catch (ActionErrorException ex) {
        incCounter(csOperation, RequestsBad);
        incCounter(csService, RequestsBad);
        throw ex;
    }
    try {
        execute(action);
        // Success
        incCounter(csOperation, RequestsGood);
        incCounter(csService, RequestsGood);
    } catch (ActionErrorException | QueryCancelledException | RuntimeIOException ex) {
        incCounter(csOperation, RequestsBad);
        incCounter(csService, RequestsBad);
        throw ex;
    }
}
Also used : RuntimeIOException(org.apache.jena.atlas.RuntimeIOException) CounterSet(org.apache.jena.fuseki.server.CounterSet) QueryCancelledException(org.apache.jena.query.QueryCancelledException)

Example 2 with CounterSet

use of org.apache.jena.fuseki.server.CounterSet in project jena by apache.

the class FusekiRequestsMetrics method bindTo.

@Override
public void bindTo(MeterRegistry registry) {
    DataService dataService = dataAccessPoint.getDataService();
    for (Operation operation : dataService.getOperations()) {
        List<Endpoint> endpoints = dataService.getEndpoints(operation);
        for (Endpoint endpoint : endpoints) {
            CounterSet counters = endpoint.getCounters();
            for (CounterName counterName : counters.counters()) {
                Counter counter = counters.get(counterName);
                Gauge.builder("fuseki_" + counterName.getFullName(), counter, Counter::value).tags(new String[] { "dataset", dataAccessPoint.getName(), "endpoint", endpoint.getName(), "operation", operation.getName(), "description", operation.getDescription() }).register(registry);
            }
        }
    }
}
Also used : Counter(org.apache.jena.fuseki.server.Counter) Endpoint(org.apache.jena.fuseki.server.Endpoint) CounterSet(org.apache.jena.fuseki.server.CounterSet) CounterName(org.apache.jena.fuseki.server.CounterName) Operation(org.apache.jena.fuseki.server.Operation) DataService(org.apache.jena.fuseki.server.DataService)

Aggregations

CounterSet (org.apache.jena.fuseki.server.CounterSet)2 RuntimeIOException (org.apache.jena.atlas.RuntimeIOException)1 Counter (org.apache.jena.fuseki.server.Counter)1 CounterName (org.apache.jena.fuseki.server.CounterName)1 DataService (org.apache.jena.fuseki.server.DataService)1 Endpoint (org.apache.jena.fuseki.server.Endpoint)1 Operation (org.apache.jena.fuseki.server.Operation)1 QueryCancelledException (org.apache.jena.query.QueryCancelledException)1