OpenTracingManager extends Helper { public boolean includePath(String path) { if (path.startsWith("/hawkular/apm")) { return false; } int dotPos = path.lastIndexOf('.'); int slashPos = path.lastIndexOf('/'); if (dotPos <= slashPos) { return true; } if (!fileExtensionWhitelist.isEmpty()) { String extension = path.substring(dotPos + 1); if (fileExtensionWhitelist.contains(extension)) { if (log.isLoggable(Level.FINER)) { log.finer("Path " + path + " not skipped, because of whitelist"); } return true; } } if (log.isLoggable(Level.FINER)) { log.finer("Path " + path + " skipped"); } return false; } OpenTracingManager(Rule rule); Format<TextMap> textMapFormat(); Tracer getTracer(); void startSpanWithParent(SpanBuilder spanBuilder, Span parent); void startSpanWithParent(SpanBuilder spanBuilder, Span parent, String id); void startSpanWithContext(SpanBuilder spanBuilder, SpanContext context); void startSpanWithContext(SpanBuilder spanBuilder, SpanContext context, String id); void startSpan(SpanBuilder spanBuilder); void startSpan(SpanBuilder spanBuilder, String id); void finishSpan(); boolean hasSpan(); boolean hasSpanWithId(String id); boolean isCurrentSpan(String id); Span getSpan(); void suspend(String id); void resume(String id); static void reset(); boolean includePath(String path); String getVariableAsString(String name); void setVariable(String name, Object value); boolean isInstanceOf(Object obj, Class<?> clz); String sanitizePaths(String baseUri, String resourcePath);  }
@Test public void testPathInclude() { OpenTracingManager otm = new OpenTracingManager(null); assertTrue(otm.includePath("/path/to/anything")); assertTrue(otm.includePath("/path.to/anything")); assertTrue(otm.includePath("/path.to/anything.jsp")); assertTrue(otm.includePath("anything")); assertFalse(otm.includePath("/hawkular/apm/anything")); assertFalse(otm.includePath("/path.to/anything.xjsp")); assertFalse(otm.includePath("myimage.png")); assertFalse(otm.includePath("/myimage.png")); assertFalse(otm.includePath("/location/myimage.png")); }
@Test public void testPathIncludeWhitelist() { OpenTracingManager.fileExtensionWhitelist.add("foo"); OpenTracingManager otm = new OpenTracingManager(null); assertTrue(otm.includePath("/quux/test.foo")); assertFalse(otm.includePath("/my/image.bar")); OpenTracingManager.fileExtensionWhitelist.clear(); }