Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKatherine Nadeau2018-06-05 14:04:36 -0400
committerMatthew Khouzam2018-07-11 11:24:40 -0400
commitb408e6d4334374dd76311ab2a5c70b833b6d2294 (patch)
treeae4e86e361ea9087e7dcb50664d4cfcee5b55f25
parent95327d9c961e6a4bd0c65840b2cf38f617bc524d (diff)
downloadorg.eclipse.tracecompass.incubator-b408e6d4334374dd76311ab2a5c70b833b6d2294.tar.gz
org.eclipse.tracecompass.incubator-b408e6d4334374dd76311ab2a5c70b833b6d2294.tar.xz
org.eclipse.tracecompass.incubator-b408e6d4334374dd76311ab2a5c70b833b6d2294.zip
opentracing: Span life view
Change-Id: I490424041ed4ab083fc9ac0aa14acfe143540c06 Signed-off-by: Katherine Nadeau <katherine.nadeau@ericsson.com> Reviewed-on: https://git.eclipse.org/r/124913 Tested-by: CI Bot Reviewed-by: Simon Delisle <simon.delisle@ericsson.com> Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com> Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
-rw-r--r--tracetypes/org.eclipse.tracecompass.incubator.opentracing.core.tests/META-INF/MANIFEST.MF1
-rw-r--r--tracetypes/org.eclipse.tracecompass.incubator.opentracing.core.tests/src/org/eclipse/tracecompass/incubator/opentracing/core/tests/OpenTracingTraceTest.java4
-rw-r--r--tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/META-INF/MANIFEST.MF2
-rw-r--r--tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/build.properties3
-rw-r--r--tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/icons/spanslife.pngbin0 -> 4084 bytes
-rw-r--r--tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/icons/spanslife@2x.pngbin0 -> 4249 bytes
-rw-r--r--tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/icons/spanslife@4x.pngbin0 -> 3530 bytes
-rw-r--r--tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/plugin.xml21
-rw-r--r--tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/src/org/eclipse/tracecompass/incubator/internal/opentracing/core/analysis/spanlife/SpanLifeAnalysis.java46
-rw-r--r--tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/src/org/eclipse/tracecompass/incubator/internal/opentracing/core/analysis/spanlife/SpanLifeDataProvider.java156
-rw-r--r--tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/src/org/eclipse/tracecompass/incubator/internal/opentracing/core/analysis/spanlife/SpanLifeDataProviderFactory.java39
-rw-r--r--tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/src/org/eclipse/tracecompass/incubator/internal/opentracing/core/analysis/spanlife/SpanLifeStateProvider.java86
-rw-r--r--tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/src/org/eclipse/tracecompass/incubator/internal/opentracing/core/trace/OpenTracingTrace.java29
-rw-r--r--tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui.swtbot.tests/META-INF/MANIFEST.MF1
-rw-r--r--tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui/META-INF/MANIFEST.MF9
-rw-r--r--tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui/icons/spanslife.pngbin0 -> 4084 bytes
-rw-r--r--tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui/icons/spanslife@2x.pngbin0 -> 4249 bytes
-rw-r--r--tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui/icons/spanslife@4x.pngbin0 -> 3530 bytes
-rw-r--r--tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui/plugin.xml21
-rw-r--r--tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui/src/org/eclipse/tracecompass/incubator/internal/opentracing/ui/view/spanlife/SpanLifePresentationProvider.java46
-rw-r--r--tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui/src/org/eclipse/tracecompass/incubator/internal/opentracing/ui/view/spanlife/SpanLifeView.java47
21 files changed, 506 insertions, 5 deletions
diff --git a/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core.tests/META-INF/MANIFEST.MF b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core.tests/META-INF/MANIFEST.MF
index ce7a5adc..7f274a79 100644
--- a/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core.tests/META-INF/MANIFEST.MF
+++ b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core.tests/META-INF/MANIFEST.MF
@@ -16,3 +16,4 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.jdt.annotation
Export-Package: org.eclipse.tracecompass.incubator.opentracing.core.tests
Import-Package: com.google.common.collect
+Automatic-Module-Name: org.eclipse.tracecompass.incubator.opentracing.core.tests
diff --git a/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core.tests/src/org/eclipse/tracecompass/incubator/opentracing/core/tests/OpenTracingTraceTest.java b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core.tests/src/org/eclipse/tracecompass/incubator/opentracing/core/tests/OpenTracingTraceTest.java
index b1dbe6b1..06314c9f 100644
--- a/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core.tests/src/org/eclipse/tracecompass/incubator/opentracing/core/tests/OpenTracingTraceTest.java
+++ b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core.tests/src/org/eclipse/tracecompass/incubator/opentracing/core/tests/OpenTracingTraceTest.java
@@ -84,7 +84,7 @@ public class OpenTracingTraceTest {
String path = "traces/simple.json";
int nbEvents = 3;
Double start = 1526674498419000.0;
- Double end = 1526674498435000.0;
+ Double end = 1526674498436163.0;
ITmfTimestamp startTime = TmfTimestamp.fromMicros(start.longValue());
ITmfTimestamp endTime = TmfTimestamp.fromMicros(end.longValue());
testTrace(path, nbEvents, startTime, endTime);
@@ -101,7 +101,7 @@ public class OpenTracingTraceTest {
String path = "traces/multiple_services.json";
int nbEvents = 5;
Double start = 1527684461617000.0;
- Double end = 1527684462096000.0;
+ Double end = 1527684462133362.0;
ITmfTimestamp startTime = TmfTimestamp.fromMicros(start.longValue());
ITmfTimestamp endTime = TmfTimestamp.fromMicros(end.longValue());
testTrace(path, nbEvents, startTime, endTime);
diff --git a/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/META-INF/MANIFEST.MF b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/META-INF/MANIFEST.MF
index 43d469ee..d5ca80e6 100644
--- a/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/META-INF/MANIFEST.MF
+++ b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/META-INF/MANIFEST.MF
@@ -18,5 +18,7 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.jdt.annotation,
org.eclipse.tracecompass.incubator.jsontrace.core
Export-Package: org.eclipse.tracecompass.incubator.internal.opentracing.core;x-friends:="org.eclipse.tracecompass.incubator.opentracing.core.tests",
+ org.eclipse.tracecompass.incubator.internal.opentracing.core.analysis.spanlife;x-friends:="org.eclipse.tracecompass.incubator.opentracing.core.tests,org.eclipse.tracecompass.incubator.opentracing.ui",
org.eclipse.tracecompass.incubator.internal.opentracing.core.event,
org.eclipse.tracecompass.incubator.internal.opentracing.core.trace
+Automatic-Module-Name: org.eclipse.tracecompass.incubator.opentracing.core
diff --git a/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/build.properties b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/build.properties
index bb6fb0d4..dc884e97 100644
--- a/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/build.properties
+++ b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/build.properties
@@ -13,6 +13,7 @@ bin.includes = META-INF/,\
about.html,\
plugin.properties,\
.,\
- plugin.xml
+ plugin.xml,\
+ icons/
additional.bundles = org.eclipse.jdt.annotation
jars.extra.classpath = platform:/plugin/org.eclipse.jdt.annotation
diff --git a/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/icons/spanslife.png b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/icons/spanslife.png
new file mode 100644
index 00000000..0465eb8a
--- /dev/null
+++ b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/icons/spanslife.png
Binary files differ
diff --git a/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/icons/spanslife@2x.png b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/icons/spanslife@2x.png
new file mode 100644
index 00000000..ca0bef41
--- /dev/null
+++ b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/icons/spanslife@2x.png
Binary files differ
diff --git a/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/icons/spanslife@4x.png b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/icons/spanslife@4x.png
new file mode 100644
index 00000000..9e77e97b
--- /dev/null
+++ b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/icons/spanslife@4x.png
Binary files differ
diff --git a/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/plugin.xml b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/plugin.xml
index 4fd82f86..1a404c67 100644
--- a/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/plugin.xml
+++ b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/plugin.xml
@@ -17,4 +17,25 @@
trace_type="org.eclipse.tracecompass.incubator.internal.opentracing.core.trace.OpenTracingTrace">
</type>
</extension>
+ <extension
+ point="org.eclipse.linuxtools.tmf.core.analysis">
+ <module
+ analysis_module="org.eclipse.tracecompass.incubator.internal.opentracing.core.analysis.spanlife.SpanLifeAnalysis"
+ automatic="true"
+ icon="icons/spanslife.png"
+ id="org.eclipse.tracecompass.incubator.opentracing.analysis.spanlife"
+ name="Spans Life">
+ <tracetype
+ applies="true"
+ class="org.eclipse.tracecompass.incubator.internal.opentracing.core.trace.OpenTracingTrace">
+ </tracetype>
+ </module>
+ </extension>
+ <extension
+ point="org.eclipse.tracecompass.tmf.core.dataprovider">
+ <dataProviderFactory
+ class="org.eclipse.tracecompass.incubator.internal.opentracing.core.analysis.spanlife.SpanLifeDataProviderFactory"
+ id="org.eclipse.tracecompass.incubator.opentracing.analysis.spanlife.dataprovider">
+ </dataProviderFactory>
+ </extension>
</plugin>
diff --git a/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/src/org/eclipse/tracecompass/incubator/internal/opentracing/core/analysis/spanlife/SpanLifeAnalysis.java b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/src/org/eclipse/tracecompass/incubator/internal/opentracing/core/analysis/spanlife/SpanLifeAnalysis.java
new file mode 100644
index 00000000..832e805d
--- /dev/null
+++ b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/src/org/eclipse/tracecompass/incubator/internal/opentracing/core/analysis/spanlife/SpanLifeAnalysis.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.incubator.internal.opentracing.core.analysis.spanlife;
+
+import java.util.Objects;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider;
+import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule;
+import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
+
+/**
+ * Spans life tracker
+ *
+ * @author Katherine Nadeau
+ */
+@NonNullByDefault
+public class SpanLifeAnalysis extends TmfStateSystemAnalysisModule {
+
+ /**
+ * ID
+ */
+ public static final String ID = "org.eclipse.tracecompass.incubator.opentracing.analysis.spanlife"; //$NON-NLS-1$
+
+ /**
+ * Constructor
+ */
+ public SpanLifeAnalysis() {
+ setId(ID);
+ }
+
+ @Override
+ protected @NonNull ITmfStateProvider createStateProvider() {
+ ITmfTrace trace = getTrace();
+ return new SpanLifeStateProvider(Objects.requireNonNull(trace));
+ }
+
+}
diff --git a/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/src/org/eclipse/tracecompass/incubator/internal/opentracing/core/analysis/spanlife/SpanLifeDataProvider.java b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/src/org/eclipse/tracecompass/incubator/internal/opentracing/core/analysis/spanlife/SpanLifeDataProvider.java
new file mode 100644
index 00000000..1bea3c29
--- /dev/null
+++ b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/src/org/eclipse/tracecompass/incubator/internal/opentracing/core/analysis/spanlife/SpanLifeDataProvider.java
@@ -0,0 +1,156 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.incubator.internal.opentracing.core.analysis.spanlife;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Predicate;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.tracecompass.internal.tmf.core.model.filters.TimeGraphStateQueryFilter;
+import org.eclipse.tracecompass.internal.tmf.core.model.timegraph.AbstractTimeGraphDataProvider;
+import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
+import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException;
+import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval;
+import org.eclipse.tracecompass.tmf.core.model.CommonStatusMessage;
+import org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter;
+import org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter;
+import org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphArrow;
+import org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphRowModel;
+import org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphState;
+import org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel;
+import org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphRowModel;
+import org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphState;
+import org.eclipse.tracecompass.tmf.core.response.ITmfResponse;
+import org.eclipse.tracecompass.tmf.core.response.TmfModelResponse;
+import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
+
+import com.google.common.collect.ImmutableList.Builder;
+import com.google.common.collect.TreeMultimap;
+
+/**
+ * Data provider that will show the object lifespans.
+ *
+ * @author Katherine Nadeau
+ *
+ */
+@SuppressWarnings("restriction")
+public class SpanLifeDataProvider extends AbstractTimeGraphDataProvider<@NonNull SpanLifeAnalysis, @NonNull TimeGraphEntryModel> {
+
+ /**
+ * Suffix for dataprovider ID
+ */
+ public static final String SUFFIX = ".dataprovider"; //$NON-NLS-1$
+
+ /**
+ * Constructor
+ *
+ * @param trace
+ * the trace this provider represents
+ * @param analysisModule
+ * the analysis encapsulated by this provider
+ */
+ public SpanLifeDataProvider(@NonNull ITmfTrace trace, @NonNull SpanLifeAnalysis analysisModule) {
+ super(trace, analysisModule);
+ }
+
+ @Override
+ public @NonNull TmfModelResponse<@NonNull List<@NonNull ITimeGraphArrow>> fetchArrows(@NonNull TimeQueryFilter filter, @Nullable IProgressMonitor monitor) {
+ return new TmfModelResponse<>(null, ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
+ }
+
+ @Override
+ public @NonNull TmfModelResponse<@NonNull Map<@NonNull String, @NonNull String>> fetchTooltip(@NonNull SelectionTimeQueryFilter filter, @Nullable IProgressMonitor monitor) {
+ return new TmfModelResponse<>(null, ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
+ }
+
+ @Override
+ public @NonNull String getId() {
+ return getAnalysisModule().getId() + SUFFIX;
+ }
+
+ @Override
+ protected @Nullable List<@NonNull ITimeGraphRowModel> getRowModel(@NonNull ITmfStateSystem ss, @NonNull SelectionTimeQueryFilter filter, @Nullable IProgressMonitor monitor) throws StateSystemDisposedException {
+ TreeMultimap<Integer, ITmfStateInterval> intervals = TreeMultimap.create(Comparator.naturalOrder(),
+ Comparator.comparing(ITmfStateInterval::getStartTime));
+ Map<@NonNull Long, @NonNull Integer> entries = getSelectedEntries(filter);
+ Collection<Long> times = getTimes(filter, ss.getStartTime(), ss.getCurrentEndTime());
+ /* Do the actual query */
+ for (ITmfStateInterval interval : ss.query2D(entries.values(), times)) {
+ if (monitor != null && monitor.isCanceled()) {
+ return Collections.emptyList();
+ }
+ intervals.put(interval.getAttribute(), interval);
+ }
+ Map<@NonNull Integer, @NonNull Predicate<@NonNull Map<@NonNull String, @NonNull String>>> predicates = new HashMap<>();
+ if (filter instanceof TimeGraphStateQueryFilter) {
+ TimeGraphStateQueryFilter timeEventFilter = (TimeGraphStateQueryFilter) filter;
+ predicates.putAll(computeRegexPredicate(timeEventFilter));
+ }
+ List<@NonNull ITimeGraphRowModel> rows = new ArrayList<>();
+ for (Map.Entry<@NonNull Long, @NonNull Integer> entry : entries.entrySet()) {
+ if (monitor != null && monitor.isCanceled()) {
+ return Collections.emptyList();
+ }
+
+ List<ITimeGraphState> eventList = new ArrayList<>();
+ for (ITmfStateInterval interval : intervals.get(entry.getValue())) {
+ long startTime = interval.getStartTime();
+ long duration = interval.getEndTime() - startTime + 1;
+ Object state = interval.getValue();
+ TimeGraphState value = new TimeGraphState(startTime, duration, state == null ? Integer.MIN_VALUE : 0);
+ addToStateList(eventList, value, entry.getKey(), predicates, monitor);
+ }
+ rows.add(new TimeGraphRowModel(entry.getKey(), eventList));
+
+ }
+ return rows;
+ }
+
+ @Override
+ protected boolean isCacheable() {
+ return true;
+ }
+
+ @Override
+ protected @NonNull List<@NonNull TimeGraphEntryModel> getTree(@NonNull ITmfStateSystem ss, @NonNull TimeQueryFilter filter, @Nullable IProgressMonitor monitor) throws StateSystemDisposedException {
+ Builder<@NonNull TimeGraphEntryModel> builder = new Builder<>();
+ long parentId = getId(ITmfStateSystem.ROOT_ATTRIBUTE);
+ builder.add(new TimeGraphEntryModel(parentId, -1, String.valueOf(getTrace().getName()), ss.getStartTime(), ss.getCurrentEndTime()));
+ addChildren(ss, builder, ITmfStateSystem.ROOT_ATTRIBUTE, parentId);
+ return builder.build();
+ }
+
+ private void addChildren(ITmfStateSystem ss, Builder<@NonNull TimeGraphEntryModel> builder, int quark, long parentId) {
+ for (Integer child : ss.getSubAttributes(quark, false)) {
+ long childId = getId(child);
+ builder.add(new TimeGraphEntryModel(childId, parentId, getSpanName(ss.getAttributeName(child)), ss.getStartTime(), ss.getCurrentEndTime()));
+ addChildren(ss, builder, child, childId);
+ }
+ }
+
+ /**
+ * Get the span name without the span id
+ *
+ * @param attributeName
+ * the attribute name and id
+ * @return only the span name
+ */
+ private static @NonNull String getSpanName(String attributeName) {
+ return attributeName.substring(0, attributeName.lastIndexOf('/'));
+ }
+}
diff --git a/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/src/org/eclipse/tracecompass/incubator/internal/opentracing/core/analysis/spanlife/SpanLifeDataProviderFactory.java b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/src/org/eclipse/tracecompass/incubator/internal/opentracing/core/analysis/spanlife/SpanLifeDataProviderFactory.java
new file mode 100644
index 00000000..188d56a9
--- /dev/null
+++ b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/src/org/eclipse/tracecompass/incubator/internal/opentracing/core/analysis/spanlife/SpanLifeDataProviderFactory.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.incubator.internal.opentracing.core.analysis.spanlife;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.tracecompass.tmf.core.dataprovider.IDataProviderFactory;
+import org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel;
+import org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataProvider;
+import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
+import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
+
+/**
+ * {@link SpanLifeDataProviderFactory} factory, uses the data provider extension
+ * point.
+ *
+ * @author Katherine Nadeau
+ */
+public class SpanLifeDataProviderFactory implements IDataProviderFactory {
+
+ @Override
+ public @Nullable ITmfTreeDataProvider<? extends ITmfTreeDataModel> createProvider(@NonNull ITmfTrace trace) {
+ SpanLifeAnalysis module = TmfTraceUtils.getAnalysisModuleOfClass(trace, SpanLifeAnalysis.class, SpanLifeAnalysis.ID);
+ if (module != null) {
+ module.schedule();
+ return new SpanLifeDataProvider(trace, module);
+ }
+
+ return null;
+ }
+
+}
diff --git a/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/src/org/eclipse/tracecompass/incubator/internal/opentracing/core/analysis/spanlife/SpanLifeStateProvider.java b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/src/org/eclipse/tracecompass/incubator/internal/opentracing/core/analysis/spanlife/SpanLifeStateProvider.java
new file mode 100644
index 00000000..86494b1b
--- /dev/null
+++ b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/src/org/eclipse/tracecompass/incubator/internal/opentracing/core/analysis/spanlife/SpanLifeStateProvider.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.incubator.internal.opentracing.core.analysis.spanlife;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.incubator.internal.opentracing.core.event.IOpenTracingConstants;
+import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
+import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
+import org.eclipse.tracecompass.tmf.core.statesystem.AbstractTmfStateProvider;
+import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider;
+import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
+import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
+
+/**
+ * Span life state provider
+ *
+ * @author Katherine Nadeau
+ *
+ */
+public class SpanLifeStateProvider extends AbstractTmfStateProvider {
+
+ private final Map<String, Integer> spanMap;
+
+ /**
+ * Constructor
+ *
+ * @param trace
+ * the trace to follow
+ */
+ public SpanLifeStateProvider(@NonNull ITmfTrace trace) {
+ super(trace, SpanLifeAnalysis.ID);
+ spanMap = new HashMap<>();
+ }
+
+ @Override
+ public int getVersion() {
+ return 1;
+ }
+
+ @Override
+ public @NonNull ITmfStateProvider getNewInstance() {
+ return new SpanLifeStateProvider(getTrace());
+ }
+
+ @Override
+ protected void eventHandle(@NonNull ITmfEvent event) {
+ ITmfStateSystemBuilder ss = getStateSystemBuilder();
+ if (ss == null) {
+ return;
+ }
+
+ long timestamp = event.getTimestamp().toNanos();
+ Long duration = event.getContent().getFieldValue(Long.class, IOpenTracingConstants.DURATION);
+ if (duration == null) {
+ return;
+ }
+
+ int quark;
+ String name = String.valueOf(TmfTraceUtils.resolveAspectOfNameForEvent(event.getTrace(), "Name", event)); //$NON-NLS-1$
+ String spanId = event.getContent().getFieldValue(String.class, IOpenTracingConstants.SPAN_ID);
+ String refId = event.getContent().getFieldValue(String.class, IOpenTracingConstants.REFERENCES + "/CHILD_OF"); //$NON-NLS-1$
+ if (refId == null) {
+ quark = ss.getQuarkAbsoluteAndAdd(name + '/' + spanId);
+ } else {
+ Integer parentQuark = spanMap.get(refId);
+ if (parentQuark == null) {
+ return;
+ }
+ quark = ss.getQuarkRelativeAndAdd(parentQuark, name + '/' + spanId);
+ }
+ ss.modifyAttribute(timestamp, name, quark);
+ ss.modifyAttribute(timestamp + duration, (Object) null, quark);
+ spanMap.put(event.getContent().getFieldValue(String.class, IOpenTracingConstants.SPAN_ID), quark);
+ }
+
+}
diff --git a/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/src/org/eclipse/tracecompass/incubator/internal/opentracing/core/trace/OpenTracingTrace.java b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/src/org/eclipse/tracecompass/incubator/internal/opentracing/core/trace/OpenTracingTrace.java
index 8682b55d..90efddbc 100644
--- a/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/src/org/eclipse/tracecompass/incubator/internal/opentracing/core/trace/OpenTracingTrace.java
+++ b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.core/src/org/eclipse/tracecompass/incubator/internal/opentracing/core/trace/OpenTracingTrace.java
@@ -21,13 +21,17 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.incubator.internal.opentracing.core.Activator;
+import org.eclipse.tracecompass.incubator.internal.opentracing.core.event.IOpenTracingConstants;
import org.eclipse.tracecompass.incubator.internal.opentracing.core.event.OpenTracingAspects;
import org.eclipse.tracecompass.incubator.internal.opentracing.core.event.OpenTracingEvent;
import org.eclipse.tracecompass.incubator.internal.opentracing.core.event.OpenTracingField;
import org.eclipse.tracecompass.incubator.jsontrace.core.trace.JsonTrace;
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
+import org.eclipse.tracecompass.tmf.core.event.ITmfLostEvent;
import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
import org.eclipse.tracecompass.tmf.core.io.BufferedRandomAccessFile;
+import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
import org.eclipse.tracecompass.tmf.core.trace.TraceValidationStatus;
@@ -187,4 +191,29 @@ public class OpenTracingTrace extends JsonTrace {
}
return null;
}
+
+ @Override
+ protected synchronized void updateAttributes(final ITmfContext context, final @NonNull ITmfEvent event) {
+ ITmfTimestamp timestamp = event.getTimestamp();
+ Long duration = event.getContent().getFieldValue(Long.class, IOpenTracingConstants.DURATION);
+ ITmfTimestamp endTime = duration != null ? TmfTimestamp.fromNanos(timestamp.toNanos() + duration) : timestamp;
+ if (event instanceof ITmfLostEvent) {
+ endTime = ((ITmfLostEvent) event).getTimeRange().getEndTime();
+ }
+ if (getStartTime().equals(TmfTimestamp.BIG_BANG) || (getStartTime().compareTo(timestamp) > 0)) {
+ setStartTime(timestamp);
+ }
+ if (getEndTime().equals(TmfTimestamp.BIG_CRUNCH) || (getEndTime().compareTo(endTime) < 0)) {
+ setEndTime(endTime);
+ }
+ if (context.hasValidRank()) {
+ long rank = context.getRank();
+ if (getNbEvents() <= rank) {
+ setNbEvents(rank + 1);
+ }
+ if (getIndexer() != null) {
+ getIndexer().updateIndex(context, timestamp);
+ }
+ }
+ }
}
diff --git a/tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui.swtbot.tests/META-INF/MANIFEST.MF b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui.swtbot.tests/META-INF/MANIFEST.MF
index 13eb6917..e4afb55b 100644
--- a/tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui.swtbot.tests/META-INF/MANIFEST.MF
+++ b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui.swtbot.tests/META-INF/MANIFEST.MF
@@ -15,4 +15,5 @@ Require-Bundle: org.eclipse.core.resources,
org.eclipse.ui.ide,
org.eclipse.ui.views,
org.junit
+Automatic-Module-Name: org.eclipse.tracecompass.incubator.opentracing.ui.swtbot.tests
diff --git a/tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui/META-INF/MANIFEST.MF b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui/META-INF/MANIFEST.MF
index c6aff8f0..033934f7 100644
--- a/tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui/META-INF/MANIFEST.MF
+++ b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui/META-INF/MANIFEST.MF
@@ -13,5 +13,10 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.tracecompass.common.core,
org.eclipse.tracecompass.incubator.opentracing.core,
org.eclipse.tracecompass.tmf.ui,
- org.eclipse.tracecompass.tmf.core
-Export-Package: org.eclipse.tracecompass.incubator.internal.opentracing.ui;x-internal:=true
+ org.eclipse.tracecompass.tmf.core,
+ org.eclipse.core.resources,
+ org.eclipse.jdt.annotation
+Export-Package: org.eclipse.tracecompass.incubator.internal.opentracing.ui;x-internal:=true,
+ org.eclipse.tracecompass.incubator.internal.opentracing.ui.view.spanlife;x-internal:=true
+Import-Package: com.google.common.collect
+Automatic-Module-Name: org.eclipse.tracecompass.incubator.opentracing.ui
diff --git a/tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui/icons/spanslife.png b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui/icons/spanslife.png
new file mode 100644
index 00000000..0465eb8a
--- /dev/null
+++ b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui/icons/spanslife.png
Binary files differ
diff --git a/tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui/icons/spanslife@2x.png b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui/icons/spanslife@2x.png
new file mode 100644
index 00000000..ca0bef41
--- /dev/null
+++ b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui/icons/spanslife@2x.png
Binary files differ
diff --git a/tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui/icons/spanslife@4x.png b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui/icons/spanslife@4x.png
new file mode 100644
index 00000000..9e77e97b
--- /dev/null
+++ b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui/icons/spanslife@4x.png
Binary files differ
diff --git a/tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui/plugin.xml b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui/plugin.xml
index 9fc49d8a..2eb2c37e 100644
--- a/tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui/plugin.xml
+++ b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui/plugin.xml
@@ -8,4 +8,25 @@
tracetype="org.eclipse.tracecompass.incubator.opentracing.core">
</type>
</extension>
+ <extension
+ point="org.eclipse.ui.views">
+ <view
+ category="org.eclipse.tracecompass.incubator.internal.opentracing.ui.view.life.SpanLifeView"
+ class="org.eclipse.tracecompass.incubator.internal.opentracing.ui.view.spanlife.SpanLifeView"
+ icon="icons/spanslife.png"
+ id="org.eclipse.tracecompass.incubator.opentracing.ui.view.life.spanlife.view"
+ name="Spans Life"
+ restorable="true">
+ </view>
+ </extension>
+ <extension
+ point="org.eclipse.linuxtools.tmf.core.analysis">
+ <output
+ class="org.eclipse.tracecompass.tmf.ui.analysis.TmfAnalysisViewOutput"
+ id="org.eclipse.tracecompass.incubator.opentracing.ui.view.life.spanlife.view">
+ <analysisModuleClass
+ class="org.eclipse.tracecompass.incubator.internal.opentracing.core.analysis.spanlife.SpanLifeAnalysis">
+ </analysisModuleClass>
+ </output>
+ </extension>
</plugin>
diff --git a/tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui/src/org/eclipse/tracecompass/incubator/internal/opentracing/ui/view/spanlife/SpanLifePresentationProvider.java b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui/src/org/eclipse/tracecompass/incubator/internal/opentracing/ui/view/spanlife/SpanLifePresentationProvider.java
new file mode 100644
index 00000000..ac99f886
--- /dev/null
+++ b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui/src/org/eclipse/tracecompass/incubator/internal/opentracing/ui/view/spanlife/SpanLifePresentationProvider.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.incubator.internal.opentracing.ui.view.spanlife;
+
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.StateItem;
+import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.TimeGraphPresentationProvider;
+import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent;
+import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeEvent;
+
+/**
+ * Object lifespan presentation provider
+ *
+ * @author Katherine Nadeau
+ */
+public class SpanLifePresentationProvider extends TimeGraphPresentationProvider {
+
+ /**
+ * Only state available
+ */
+ private static final StateItem[] STATE_TABLE = { new StateItem(new RGB(0, 0, 140), "Active") }; //$NON-NLS-1$
+
+ /**
+ * Constructor
+ */
+ public SpanLifePresentationProvider() {
+ super("Span"); //$NON-NLS-1$
+ }
+
+ @Override
+ public StateItem[] getStateTable() {
+ return STATE_TABLE;
+ }
+
+ @Override
+ public int getStateTableIndex(ITimeEvent event) {
+ return (event instanceof TimeEvent && ((TimeEvent) event).getValue() != Integer.MIN_VALUE) ? 0 : -1;
+ }
+}
diff --git a/tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui/src/org/eclipse/tracecompass/incubator/internal/opentracing/ui/view/spanlife/SpanLifeView.java b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui/src/org/eclipse/tracecompass/incubator/internal/opentracing/ui/view/spanlife/SpanLifeView.java
new file mode 100644
index 00000000..400945f9
--- /dev/null
+++ b/tracetypes/org.eclipse.tracecompass.incubator.opentracing.ui/src/org/eclipse/tracecompass/incubator/internal/opentracing/ui/view/spanlife/SpanLifeView.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.incubator.internal.opentracing.ui.view.spanlife;
+
+import org.eclipse.tracecompass.incubator.internal.opentracing.core.analysis.spanlife.SpanLifeAnalysis;
+import org.eclipse.tracecompass.incubator.internal.opentracing.core.analysis.spanlife.SpanLifeDataProvider;
+import org.eclipse.tracecompass.tmf.ui.views.timegraph.BaseDataProviderTimeGraphView;
+import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.TimeGraphPresentationProvider;
+
+/**
+ * Simple gantt chart to see the life of the spans
+ *
+ * @author Katherine Nadeau
+ */
+public class SpanLifeView extends BaseDataProviderTimeGraphView {
+
+ private static final String ID = "org.eclipse.tracecompass.incubator.opentracing.ui.view.life.spanlife.view"; //$NON-NLS-1$
+
+ /**
+ * Constructor
+ */
+ public SpanLifeView() {
+ this(ID, new SpanLifePresentationProvider(), SpanLifeAnalysis.ID + SpanLifeDataProvider.SUFFIX);
+ }
+
+ /**
+ * Extendable constructor
+ *
+ * @param id
+ * the view ID
+ * @param pres
+ * the presentation provider
+ * @param dpID
+ * the dataprovider ID
+ */
+ public SpanLifeView(String id, TimeGraphPresentationProvider pres, String dpID) {
+ super(id, pres, dpID);
+ }
+
+}

Back to the top