Skip to content

Commit

Permalink
#32 true name for metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
vkuznetsov committed Jan 28, 2020
1 parent 361a4bc commit 8ad0a5a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,33 @@ import ru.fix.aggregating.profiler.Identity
object Metrics {
const val PENDING_REQUEST = "pending_request"

const val REACTOR_EXECUTION = "completable_reactor"
const val COMPLETABLE_REACTOR = "completable_reactor"

const val REACTOR_VERTEX_EXECUTION = "completable_reactor_vertices"
const val COMPLETABLE_REACTOR_GRAPH = "completable_reactor_graph"
}

object Tags {
const val MERGE = "merge"
const val MERGER = "merger"

const val HANDLE = "handle"
const val HANDLER = "handler"

const val REACHED_TERMINAL_STEP = "payload_reached_terminal_step"
const val SUBMIT = "submit"

const val FULLY_COMPLETED = "execution_graph_fully_completed"
const val EXECUTION = "execution"
}

object ProfilerIdentity {

fun mergeIdentity(payload: String?, vertexName: String?) =
Identity(
Metrics.REACTOR_VERTEX_EXECUTION,
tags(payload, Tags.MERGE, vertexName)
Metrics.COMPLETABLE_REACTOR_GRAPH,
tags(payload, Tags.MERGER, vertexName)
)

fun handlerIdentity(payload: String?, vertexName: String?) =
Identity(
Metrics.REACTOR_VERTEX_EXECUTION,
tags(payload, Tags.HANDLE, vertexName)
Metrics.COMPLETABLE_REACTOR_GRAPH,
tags(payload, Tags.HANDLER, vertexName)
)

private fun tags(payload: String?, operation: String, vertexName: String?) =
Expand All @@ -44,20 +44,20 @@ object ProfilerIdentity {
@JvmStatic
fun payloadIdentity(payload: String?) =
Identity(
Metrics.REACTOR_EXECUTION,
tags(payload, Tags.REACHED_TERMINAL_STEP)
Metrics.COMPLETABLE_REACTOR,
tags(payload, Tags.SUBMIT)
)

@JvmStatic
fun executionIdentity(payload: String?) =
Identity(
Metrics.REACTOR_EXECUTION,
tags(payload, Tags.FULLY_COMPLETED)
Metrics.COMPLETABLE_REACTOR,
tags(payload, Tags.EXECUTION)
)

private fun tags(payload: String?, operation: String) =
mapOf(
"payload" to payload,
"execution_cycle" to operation
"operation" to operation
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ static class SimpleGraph extends Graph<TracablePayload> {

}



@Test
public void trace_payload_if_payload_contain_special_id() throws Exception {

Expand Down Expand Up @@ -108,14 +106,14 @@ public void trace_payload_if_payload_contain_special_id() throws Exception {
assertEquals(80, identities.size());

List<Identity> expected = new ArrayList<>();
expected.addAll(vertexIdentities(Tags.HANDLE, "processor1", 10));
expected.addAll(vertexIdentities(Tags.HANDLE,"processor2", 10));
expected.addAll(vertexIdentities(Tags.HANDLE,"processor3", 10));
expected.addAll(vertexIdentities(Tags.MERGE, "processor1", 10));
expected.addAll(vertexIdentities(Tags.MERGE,"processor2", 10));
expected.addAll(vertexIdentities(Tags.MERGE,"processor3", 10));
expected.addAll(executionIdentity(Tags.REACHED_TERMINAL_STEP, 10));
expected.addAll(executionIdentity(Tags.FULLY_COMPLETED, 10));
expected.addAll(vertexIdentities(Tags.HANDLER, "processor1", 10));
expected.addAll(vertexIdentities(Tags.HANDLER,"processor2", 10));
expected.addAll(vertexIdentities(Tags.HANDLER,"processor3", 10));
expected.addAll(vertexIdentities(Tags.MERGER, "processor1", 10));
expected.addAll(vertexIdentities(Tags.MERGER,"processor2", 10));
expected.addAll(vertexIdentities(Tags.MERGER,"processor3", 10));
expected.addAll(executionIdentity(Tags.SUBMIT, 10));
expected.addAll(executionIdentity(Tags.EXECUTION, 10));

assertThat(identities, containsInAnyOrder(expected.toArray()));
}
Expand All @@ -127,7 +125,7 @@ private static List<Identity> vertexIdentities(String operation, String vertex,
tags.put("payload", TracablePayload.class.getName());
tags.put("operation", operation);
tags.put("vertex", vertex);
return new Identity(Metrics.REACTOR_VERTEX_EXECUTION, tags);
return new Identity(Metrics.COMPLETABLE_REACTOR_GRAPH, tags);
})
.collect(Collectors.toList());
}
Expand All @@ -137,8 +135,8 @@ private static List<Identity> executionIdentity(String operation, int number) {
.mapToObj(i -> {
Map<String, String> tags = new HashMap<>();
tags.put("payload", TracablePayload.class.getName());
tags.put("execution_cycle", operation);
return new Identity(Metrics.REACTOR_EXECUTION, tags);
tags.put("operation", operation);
return new Identity(Metrics.COMPLETABLE_REACTOR, tags);
})
.collect(Collectors.toList());
}
Expand Down

0 comments on commit 8ad0a5a

Please sign in to comment.