Search in sources :

Example 1 with RequestTracingExecutionOptions

use of fish.payara.nucleus.requesttracing.domain.execoptions.RequestTracingExecutionOptions in project Payara by payara.

the class ListRequestTraces method execute.

@Override
public void execute(AdminCommandContext context) {
    final ActionReport actionReport = context.getActionReport();
    RequestTracingExecutionOptions executionOptions = service.getExecutionOptions();
    if ((historicTraces == null || historicTraces) && !executionOptions.isHistoricTraceStoreEnabled()) {
        actionReport.setMessage("Historic Request Trace Store is not enabled!");
        actionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
    } else {
        if (server.isDas()) {
            if (targetUtil.getConfig(target).isDas()) {
                generateReport(actionReport);
            }
        } else {
            // apply as not the DAS so implicitly it is for us
            generateReport(actionReport);
        }
    }
}
Also used : ActionReport(org.glassfish.api.ActionReport) RequestTracingExecutionOptions(fish.payara.nucleus.requesttracing.domain.execoptions.RequestTracingExecutionOptions)

Example 2 with RequestTracingExecutionOptions

use of fish.payara.nucleus.requesttracing.domain.execoptions.RequestTracingExecutionOptions in project Payara by payara.

the class ListRequestTraces method generateReport.

private void generateReport(ActionReport actionReport) {
    RequestTracingExecutionOptions executionOptions = service.getExecutionOptions();
    if (first == null) {
        first = executionOptions.getTraceStoreSize();
    }
    RequestTraceStoreInterface eventStore;
    if (historicTraces == null || historicTraces) {
        eventStore = service.getHistoricRequestTraceStore();
    } else {
        eventStore = service.getRequestTraceStore();
    }
    ColumnFormatter columnFormatter = new ColumnFormatter(headers);
    Properties extrasProps = new Properties();
    List<Map<String, String>> tracesList = new ArrayList<>();
    Collection<RequestTrace> traces = eventStore.getTraces(first);
    for (RequestTrace requestTrace : traces) {
        Map<String, String> messages = new LinkedHashMap<>();
        Object[] values = new Object[3];
        values[0] = requestTrace.getStartTime();
        values[1] = requestTrace.getElapsedTime();
        values[2] = requestTrace.toString();
        messages.put("occuringTime", values[0].toString());
        messages.put("elapsedTime", values[1].toString());
        messages.put("message", (String) values[2]);
        tracesList.add(messages);
        columnFormatter.addRow(values);
    }
    actionReport.setMessage(columnFormatter.toString());
    extrasProps.put("traces", tracesList);
    actionReport.setExtraProperties(extrasProps);
    actionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
Also used : RequestTrace(fish.payara.notification.requesttracing.RequestTrace) RequestTraceStoreInterface(fish.payara.nucleus.requesttracing.store.RequestTraceStoreInterface) ColumnFormatter(com.sun.enterprise.util.ColumnFormatter) RequestTracingExecutionOptions(fish.payara.nucleus.requesttracing.domain.execoptions.RequestTracingExecutionOptions)

Aggregations

RequestTracingExecutionOptions (fish.payara.nucleus.requesttracing.domain.execoptions.RequestTracingExecutionOptions)2 ColumnFormatter (com.sun.enterprise.util.ColumnFormatter)1 RequestTrace (fish.payara.notification.requesttracing.RequestTrace)1 RequestTraceStoreInterface (fish.payara.nucleus.requesttracing.store.RequestTraceStoreInterface)1 ActionReport (org.glassfish.api.ActionReport)1