use of org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect in project tracecompass by tracecompass.
the class LttngKernelTrace method initTrace.
@Override
public void initTrace(IResource resource, String path, Class<? extends ITmfEvent> eventType) throws TmfTraceException {
super.initTrace(resource, path, eventType);
/*
* Add aspects
*/
fOriginTracer = getTracerFromEnv();
ImmutableList.Builder<ITmfEventAspect<?>> builder = new Builder<>();
builder.addAll(LTTNG_KERNEL_ASPECTS);
builder.addAll(createCounterAspects(this));
ContextPidAspect pidAspect = ContextPidAspect.getAspect(this);
if (pidAspect != null) {
builder.add(pidAspect);
}
ContextTidAspect tidAspect = ContextTidAspect.getAspect(this);
if (tidAspect != null) {
builder.add(tidAspect);
}
fAspects = builder.build();
}
use of org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect in project tracecompass by tracecompass.
the class TmfFilterHelperTest method testInputRegexNoField.
/**
* Test a regex with no parameter
*/
@Test
public void testInputRegexNoField() {
String regex = "afield";
ITmfFilter filter = getFilter(regex);
assertTrue(filter instanceof TmfFilterRootNode);
TmfFilterRootNode node = (TmfFilterRootNode) filter;
assertEquals(1, node.getChildrenCount());
ITmfFilterTreeNode child = node.getChild(0);
assertTrue(child instanceof TmfFilterOrNode);
// Verify the orNode
TmfFilterOrNode orNode = (TmfFilterOrNode) child;
ITmfTrace trace = STUB_TRACE;
assertNotNull(trace);
Iterable<@NonNull ITmfEventAspect<?>> eventAspects = trace.getEventAspects();
// Verify that each child is a matches node and there's one per aspect
assertEquals(Iterables.size(eventAspects), orNode.getChildrenCount());
for (int i = 0; i < orNode.getChildrenCount(); i++) {
assertTrue(orNode.getChild(i) instanceof TmfFilterMatchesNode);
}
for (ITmfEventAspect<?> aspect : eventAspects) {
// Find a contains condition for each aspect
ITmfFilterTreeNode[] children = orNode.getChildren();
TmfFilterMatchesNode found = null;
for (int i = 0; i < children.length; i++) {
TmfFilterMatchesNode childFilter = (TmfFilterMatchesNode) children[i];
if (aspect.equals(childFilter.getEventAspect())) {
found = childFilter;
break;
}
}
assertNotNull("found aspect " + aspect.getName(), found);
assertEquals(regex, found.getRegex());
}
// Test expected behavior on events
assertTrue(filter.matches(fEvent1));
assertFalse(filter.matches(fEvent2));
assertTrue(filter.matches(fEvent3));
}
use of org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect in project tracecompass by tracecompass.
the class TmfEventTableDataProvider method getExperimentAspects.
/**
* Get the events table for an experiment. If all traces in the experiment are
* of the same type, use the same behavior as if it was one trace of that type.
*
* @param experiment
* the experiment
* @param parent
* the parent Composite
* @param cacheSize
* the event table cache size
* @return An event table of the appropriate type
*/
private static Iterable<ITmfEventAspect<?>> getExperimentAspects(TmfExperiment experiment) {
List<ITmfTrace> traces = experiment.getTraces();
ImmutableSet.Builder<ITmfEventAspect<?>> builder = new ImmutableSet.Builder<>();
/* For experiments, we'll add a "trace name" aspect/column */
builder.add(TmfBaseAspects.getTraceNameAspect());
if (hasCommonTraceType(experiment)) {
/*
* All the traces in this experiment are of the same type, let's just use the
* normal table for that type.
*/
builder.addAll(traces.get(0).getEventAspects());
} else {
/*
* There are different trace types in the experiment, so we are definitely using
* a TmfEventsTable. Aggregate the columns from all trace types.
*/
for (ITmfTrace trace : traces) {
builder.addAll(trace.getEventAspects());
}
}
return builder.build();
}
use of org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect in project tracecompass by tracecompass.
the class TmfEventsEditor method createEventsTable.
/**
* Create the event table
*
* @param parent
* The parent composite
* @param cacheSize
* The cache size
* @return The event table instance
*/
@NonNull
protected TmfEventsTable createEventsTable(final Composite parent, final int cacheSize) {
ITmfTrace trace = fTrace;
/*
* Check if the trace (or experiment type) defines a specific event
* table in its extension point.
*/
TmfEventsTable table = TmfTraceTypeUIUtils.getEventTable(trace, parent, cacheSize);
if (table != null) {
return table;
}
/*
* Use the aspects defined by the trace type (or each trace type in an
* experiment) to build a table consisting of these.
*/
Iterable<ITmfEventAspect<?>> aspects = getTraceAspects(trace);
if (Iterables.isEmpty(aspects)) {
/* Couldn't find any event aspects, use a default table */
return new TmfEventsTable(parent, cacheSize);
}
return new TmfEventsTable(parent, cacheSize, aspects);
}
use of org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect in project tracecompass by tracecompass.
the class CustomEventAspects method generateAspects.
/**
* Build a set of event aspects for a given trace definition
*
* @param definition
* The {@link CustomTraceDefinition} of the trace for which you
* want the aspects
* @return The set of event aspects for the given trace
*/
@NonNull
public static Iterable<ITmfEventAspect<?>> generateAspects(CustomTraceDefinition definition) {
List<String> fieldNames = new ArrayList<>();
ImmutableList.Builder<ITmfEventAspect<?>> builder = new ImmutableList.Builder<>();
for (OutputColumn output : definition.outputs) {
if (output.tag.equals(Tag.TIMESTAMP) && (definition.timeStampOutputFormat == null || definition.timeStampOutputFormat.isEmpty())) {
builder.add(TmfBaseAspects.getTimestampAspect());
fieldNames.add(output.name);
} else if (output.tag.equals(Tag.EVENT_TYPE)) {
builder.add(TmfBaseAspects.getEventTypeAspect());
fieldNames.add(output.name);
} else if (output.tag.equals(Tag.EXTRA_FIELD_NAME) || output.tag.equals(Tag.EXTRA_FIELD_VALUE)) {
// These tags should have been substituted with Tag.EXTRA_FIELDS
continue;
} else if (output.tag.equals(Tag.EXTRA_FIELDS)) {
builder.add(new CustomExtraFieldsAspect());
} else {
builder.add(new TmfContentFieldAspect(output.name, output.name));
fieldNames.add(output.name);
}
}
return builder.build();
}
Aggregations