Search in sources :

Example 1 with StatisticCollector

use of com.predic8.membrane.core.rules.StatisticCollector in project service-proxy by membrane.

the class ElasticSearchExchangeStore method getStatistics.

@Override
public StatisticCollector getStatistics(RuleKey ruleKey) {
    StatisticCollector statistics = new StatisticCollector(false);
    List<AbstractExchange> exchangesList = Arrays.asList(getExchanges(ruleKey));
    if (exchangesList == null || exchangesList.isEmpty())
        return statistics;
    for (int i = 0; i < exchangesList.size(); i++) statistics.collectFrom(exchangesList.get(i));
    return statistics;
}
Also used : AbstractExchange(com.predic8.membrane.core.exchange.AbstractExchange) StatisticCollector(com.predic8.membrane.core.rules.StatisticCollector)

Example 2 with StatisticCollector

use of com.predic8.membrane.core.rules.StatisticCollector in project service-proxy by membrane.

the class LimitedMemoryExchangeStore method getStatistics.

public synchronized StatisticCollector getStatistics(RuleKey key) {
    StatisticCollector statistics = new StatisticCollector(false);
    List<AbstractExchange> exchangesList = getExchangeList(key);
    if (exchangesList == null || exchangesList.isEmpty())
        return statistics;
    for (int i = 0; i < exchangesList.size(); i++) statistics.collectFrom(exchangesList.get(i));
    return statistics;
}
Also used : AbstractExchange(com.predic8.membrane.core.exchange.AbstractExchange) StatisticCollector(com.predic8.membrane.core.rules.StatisticCollector)

Example 3 with StatisticCollector

use of com.predic8.membrane.core.rules.StatisticCollector in project service-proxy by membrane.

the class MemoryExchangeStore method getStatistics.

public StatisticCollector getStatistics(RuleKey key) {
    StatisticCollector statistics = new StatisticCollector(false);
    List<AbstractExchange> exchangesList = exchangesMap.get(key);
    if (exchangesList == null || exchangesList.isEmpty())
        return statistics;
    for (int i = 0; i < exchangesList.size(); i++) statistics.collectFrom(exchangesList.get(i));
    return statistics;
}
Also used : AbstractExchange(com.predic8.membrane.core.exchange.AbstractExchange) StatisticCollector(com.predic8.membrane.core.rules.StatisticCollector)

Example 4 with StatisticCollector

use of com.predic8.membrane.core.rules.StatisticCollector in project service-proxy by membrane.

the class AMStatisticsCollector method collectStatisticFrom.

private String collectStatisticFrom(Exchange exc, String apiKey) throws IOException {
    StatisticCollector statistics = new StatisticCollector(false);
    statistics.collectFrom(exc);
    JsonGenerator gen = getAndResetJsonGenerator();
    try {
        gen.writeStartObject();
        gen.writeObjectField("excId", exc.getId());
        gen.writeObjectField("excTime", exc.getTime().toInstant().toString());
        gen.writeObjectField("excApiKey", apiKey);
        gen.writeObjectField("service", exc.getRule().getName());
        gen.writeObjectField("uri", exc.getOriginalRequestUri());
        gen.writeObjectField("method", exc.getRequest().getMethod());
        gen.writeObjectField("excStatus", exc.getStatus().toString());
        gen.writeObjectField("code", exc.getResponse().getStatusCode());
        gen.writeObjectField("time", getInflightTime(exc));
        gen.writeEndObject();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return getStringFromJsonGenerator();
}
Also used : JsonGenerator(com.fasterxml.jackson.core.JsonGenerator) IOException(java.io.IOException) StatisticCollector(com.predic8.membrane.core.rules.StatisticCollector)

Example 5 with StatisticCollector

use of com.predic8.membrane.core.rules.StatisticCollector in project service-proxy by membrane.

the class Node method getStatisticCollectorByStatusCode.

private StatisticCollector getStatisticCollectorByStatusCode(int code) {
    StatisticCollector sc = statusCodes.get(code);
    if (sc == null) {
        sc = new StatisticCollector(true);
        StatisticCollector sc2 = statusCodes.putIfAbsent(code, sc);
        if (sc2 != null)
            sc = sc2;
    }
    return sc;
}
Also used : StatisticCollector(com.predic8.membrane.core.rules.StatisticCollector)

Aggregations

StatisticCollector (com.predic8.membrane.core.rules.StatisticCollector)5 AbstractExchange (com.predic8.membrane.core.exchange.AbstractExchange)3 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)1 IOException (java.io.IOException)1