use of com.palantir.tritium.event.metrics.TaggedMetricsServiceInvocationEventHandler in project tritium by palantir.
the class InstrumentationBuilder method withTaggedMetrics.
/**
* Supplies a TaggedMetricRegistry and a name prefix to be used across service invocations.
*
* <p>Uses a {@link TaggedMetricsServiceInvocationEventHandler} object for handling invocations, so metric names
* are chosen based off of the interface name and invoked method.
*
* @param metricRegistry - TaggedMetricsRegistry used for this application.
* @param prefix - Metrics name prefix to be used
* @return - InstrumentationBuilder
*/
public InstrumentationBuilder<T, U> withTaggedMetrics(TaggedMetricRegistry metricRegistry, @Nullable String prefix) {
checkNotNull(metricRegistry, "metricRegistry");
String serviceName = prefix == null || prefix.isEmpty() ? interfaceClass.getName() : prefix;
return withHandler(new TaggedMetricsServiceInvocationEventHandler(metricRegistry, serviceName));
}
use of com.palantir.tritium.event.metrics.TaggedMetricsServiceInvocationEventHandler in project tritium by palantir.
the class InstrumentationTest method testStackDepth_notFunctionOfHandlers.
@Test
void testStackDepth_notFunctionOfHandlers() {
StackTraceSupplier stackTraceSupplier = () -> cleanStackTrace(new Exception().getStackTrace());
StackTraceSupplier singleHandlerInstrumentedStackSupplier = Instrumentation.builder(StackTraceSupplier.class, stackTraceSupplier).withHandler(new TaggedMetricsServiceInvocationEventHandler(new DefaultTaggedMetricRegistry(), "test0")).build();
StackTraceSupplier multipleHandlerInstrumentedStackSupplier = Instrumentation.builder(StackTraceSupplier.class, stackTraceSupplier).withHandler(new TaggedMetricsServiceInvocationEventHandler(new DefaultTaggedMetricRegistry(), "test1")).withHandler(new MetricsInvocationEventHandler(new MetricRegistry(), "test2")).build();
StackTraceElement[] singleHandlerInstrumentedStackTrace = singleHandlerInstrumentedStackSupplier.get();
StackTraceElement[] multipleHandlerInstrumentedStack = multipleHandlerInstrumentedStackSupplier.get();
// Tritium frames should not scale with the number of registered InvocationEventHandler instances.
assertThat(singleHandlerInstrumentedStackTrace).hasSameSizeAs(multipleHandlerInstrumentedStack);
}
Aggregations