@Override protected Control createContents(Composite parent) { ColorController.assignMethodColors(parent.getDisplay(), mReader.getMethods()); SelectionController selectionController = new SelectionController(); GridLayout gridLayout = new GridLayout(1, false); gridLayout.marginWidth = 0; gridLayout.marginHeight = 0; gridLayout.horizontalSpacing = 0; gridLayout.verticalSpacing = 0; parent.setLayout(gridLayout); Display display = parent.getDisplay(); Color darkGray = display.getSystemColor(SWT.COLOR_DARK_GRAY); // Create a sash form to separate the timeline view (on top) // and the profile view (on bottom) SashForm sashForm1 = new SashForm(parent, SWT.VERTICAL); sashForm1.setBackground(darkGray); sashForm1.SASH_WIDTH = 3; GridData data = new GridData(GridData.FILL_BOTH); sashForm1.setLayoutData(data); // Create the timeline view new TimeLineView(sashForm1, mReader, selectionController); // Create the profile view new ProfileView(sashForm1, mReader, selectionController); return sashForm1; }
/** * Simple metrics writing and reading check, that uses the standard wrapping in the {@link * PhoenixMetricsSink} * * @throws Exception on failure */ @Test public void writeMetrics() throws Exception { // hook up a phoenix sink PhoenixMetricsSink sink = new PhoenixMetricsSink(); Connection conn = getConnectionWithoutTracing(); sink.initForTesting(conn); // create a simple metrics record long traceid = 987654; String description = "Some generic trace"; long spanid = 10; long parentid = 11; long startTime = 12; long endTime = 13; String annotation = "test annotation for a span"; String hostnameValue = "host-name.value"; MetricsRecord record = createRecord( traceid, parentid, spanid, description, startTime, endTime, hostnameValue, annotation); // actually write the record to the table sink.putMetrics(record); sink.flush(); // make sure we only get expected stat entry (matcing the trace id), otherwise we could the // stats for the update as well TraceReader reader = new TraceReader(conn); Collection<TraceHolder> traces = reader.readAll(10); assertEquals("Wrong number of traces in the tracing table", 1, traces.size()); // validate trace TraceHolder trace = traces.iterator().next(); // we are just going to get an orphan span b/c we don't send in a parent assertEquals("Didn't get expected orphaned spans!" + trace.orphans, 1, trace.orphans.size()); assertEquals(traceid, trace.traceid); SpanInfo spanInfo = trace.orphans.get(0); assertEquals(description, spanInfo.description); assertEquals(parentid, spanInfo.getParentIdForTesting()); assertEquals(startTime, spanInfo.start); assertEquals(endTime, spanInfo.end); assertEquals(hostnameValue, spanInfo.hostname); assertEquals("Wrong number of tags", 0, spanInfo.tagCount); assertEquals("Wrong number of annotations", 1, spanInfo.annotationCount); }
public static void main(String[] args) { TraceReader reader = null; boolean regression = false; // ping the usage server String revision = getRevision(); if (revision != null) { new SdkStatsService().ping(PING_NAME, revision); } // Process command line arguments int argc = 0; int len = args.length; while (argc < len) { String arg = args[argc]; if (arg.charAt(0) != '-') { break; } if (arg.equals("-r")) { regression = true; } else { break; } argc++; } if (argc != len - 1) { System.out.printf("Usage: java %s [-r] trace%n", MainWindow.class.getName()); System.out.printf(" -r regression only%n"); return; } String traceName = args[len - 1]; File file = new File(traceName); if (file.exists() && file.isDirectory()) { System.out.printf("Qemu trace files not supported yet.\n"); System.exit(1); // reader = new QtraceReader(traceName); } else { // If the filename as given doesn't exist... if (!file.exists()) { // Try appending .trace. if (new File(traceName + ".trace").exists()) { traceName = traceName + ".trace"; // Next, see if it is the old two-file trace. } else if (new File(traceName + ".data").exists() && new File(traceName + ".key").exists()) { try { traceName = makeTempTraceFile(traceName); } catch (IOException e) { System.err.printf("cannot convert old trace file '%s'\n", traceName); System.exit(1); } // Otherwise, give up. } else { System.err.printf("trace file '%s' not found\n", traceName); System.exit(1); } } try { reader = new DmTraceReader(traceName, regression); } catch (IOException e) { System.err.printf("Failed to read the trace file"); e.printStackTrace(); System.exit(1); return; } } reader.getTraceUnits().setTimeScale(TraceUnits.TimeScale.MilliSeconds); Display.setAppName("Traceview"); new MainWindow(traceName, reader).run(); }
private void showProperties() { PropertiesDialog dialog = new PropertiesDialog(getShell()); dialog.setProperties(mReader.getProperties()); dialog.open(); }