Skip to content

Commit

Permalink
feat(engine/admin): rename metrics to match sales wording
Browse files Browse the repository at this point in the history
- remove flow-node-instances-end
- rename flow-node-instances-start
- adapt code & tests

related to CAM-13636
  • Loading branch information
danielkelemen committed Mar 22, 2022
1 parent 391baae commit c72d817
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
enumValues = ["activity-instance-start",
"activity-instance-end",
"decision-instances",
"flow-node-instances-start",
"flow-node-instances-end",
"flow-node-instances",
"job-acquisition-attempt",
"job-acquired-success",
"job-acquired-failure",
Expand Down Expand Up @@ -83,11 +82,11 @@
array = true
desc = "Request successful."
examples = ['"example-1": {
"summary": "GET /metrics?name=flow-node-instances-end&startDate=1970-01-01T01:45:00.000%2b0200&endDate=1970-01-01T02:00:00.000%2b0200",
"summary": "GET /metrics?name=flow-node-instances&startDate=1970-01-01T01:45:00.000%2b0200&endDate=1970-01-01T02:00:00.000%2b0200",
"value": [
{
"timestamp":"1970-01-01T01:45:00.000+0200",
"name":"flow-node-instances-end",
"name":"flow-node-instances",
"reporter":"REPORTER",
"value":23
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
enumValues = ["activity-instance-start",
"activity-instance-end",
"decision-instances",
"flow-node-instances-start",
"flow-node-instances-end",
"flow-node-instances",
"job-acquisition-attempt",
"job-acquired-success",
"job-acquired-failure",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"metrics": {
"process-instances": { "count": 936 },
"flow-node-instances-start": { "count": 6125 },
"flow-node-instances": { "count": 6125 },
"decision-instances": { "count": 140 },
"executed-decision-elements": { "count": 732 }
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public void shouldGetTelemetryData() throws JsonProcessingException {
.body("product.internals.commands.FetchExternalTasksCmd.count", equalTo(100))
.body("product.internals.commands.StartProcessInstanceCmd.count", equalTo(40))
.body("product.internals.metrics.process-instances.count", equalTo(936))
.body("product.internals.metrics.flow-node-instances-start.count", equalTo(6125))
.body("product.internals.metrics.flow-node-instances.count", equalTo(6125))
.body("product.internals.metrics.executed-decision-elements.count", equalTo(732))
.body("product.internals.metrics.decision-instances.count", equalTo(140))
.body("product.internals.webapps[0]", equalTo("cockpit"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ public abstract class MockProvider {
.setCommands(Stream.of(new Object[][] { { "StartProcessInstanceCmd", 40 }, { "FetchExternalTasksCmd", 100 } })
.collect(Collectors.toMap(data -> (String) data[0], data -> new CommandImpl((Integer) data[1]))));
EXAMPLE_TELEMETRY_INTERNALS.setMetrics(Stream
.of(new Object[][] { { "process-instances", 936L }, { "flow-node-instances-start", 6125L },
.of(new Object[][] { { "process-instances", 936L }, { "flow-node-instances", 6125L },
{ "decision-instances", 140L }, { "executed-decision-elements", 732L } })
.collect(Collectors.toMap(data -> (String) data[0], data -> new MetricImpl((Long) data[1]))));
EXAMPLE_TELEMETRY_INTERNALS.setCamundaIntegration(Collections.singleton("spring-boot"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ public class MetricsUtil {
* @return the internal name
*/
public static String resolveInternalName(final String publicName) {
if (publicName == null) return null;
switch (publicName) {
case Metrics.TASK_USERS: return Metrics.UNIQUE_TASK_WORKERS;
case Metrics.PROCESS_INSTANCES: return Metrics.ROOT_PROCESS_INSTANCE_START;
case Metrics.DECISION_INSTANCES: return Metrics.EXECUTED_DECISION_INSTANCES;
case Metrics.FLOW_NODE_INSTANCES_START: return Metrics.ACTIVTY_INSTANCE_START;
case Metrics.FLOW_NODE_INSTANCES_END: return Metrics.ACTIVTY_INSTANCE_END;
case Metrics.FLOW_NODE_INSTANCES: return Metrics.ACTIVTY_INSTANCE_START;
default: return publicName;
}
}
Expand All @@ -44,12 +44,12 @@ public static String resolveInternalName(final String publicName) {
* @return the public name
*/
public static String resolvePublicName(final String internalName) {
if (internalName == null) return null;
switch (internalName) {
case Metrics.UNIQUE_TASK_WORKERS: return Metrics.TASK_USERS;
case Metrics.ROOT_PROCESS_INSTANCE_START: return Metrics.PROCESS_INSTANCES;
case Metrics.EXECUTED_DECISION_INSTANCES: return Metrics.DECISION_INSTANCES;
case Metrics.ACTIVTY_INSTANCE_START: return Metrics.FLOW_NODE_INSTANCES_START;
case Metrics.ACTIVTY_INSTANCE_END: return Metrics.FLOW_NODE_INSTANCES_END;
case Metrics.ACTIVTY_INSTANCE_START: return Metrics.FLOW_NODE_INSTANCES;
default: return internalName;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ public class Metrics {

public static final String ACTIVTY_INSTANCE_START = "activity-instance-start";
public static final String ACTIVTY_INSTANCE_END = "activity-instance-end";
public static final String FLOW_NODE_INSTANCES_START = "flow-node-instances-start";
public static final String FLOW_NODE_INSTANCES_END = "flow-node-instances-end";
public static final String FLOW_NODE_INSTANCES = "flow-node-instances";

/**
* Number of times job acquisition is performed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.camunda.bpm.engine.management.Metrics.DECISION_INSTANCES;
import static org.camunda.bpm.engine.management.Metrics.EXECUTED_DECISION_ELEMENTS;
import static org.camunda.bpm.engine.management.Metrics.FLOW_NODE_INSTANCES_START;
import static org.camunda.bpm.engine.management.Metrics.FLOW_NODE_INSTANCES;
import static org.camunda.bpm.engine.management.Metrics.PROCESS_INSTANCES;
import java.util.Map;
import org.camunda.bpm.engine.ProcessEngineException;
Expand Down Expand Up @@ -196,8 +196,8 @@ public void shouldStartWithMetricsCountZero() {

// then
Map<String, Metric> metrics = telemetryData.getProduct().getInternals().getMetrics();
assertThat(metrics).containsOnlyKeys(FLOW_NODE_INSTANCES_START, PROCESS_INSTANCES, EXECUTED_DECISION_ELEMENTS, DECISION_INSTANCES);
assertThat(metrics.get(FLOW_NODE_INSTANCES_START).getCount()).isZero();
assertThat(metrics).containsOnlyKeys(FLOW_NODE_INSTANCES, PROCESS_INSTANCES, EXECUTED_DECISION_ELEMENTS, DECISION_INSTANCES);
assertThat(metrics.get(FLOW_NODE_INSTANCES).getCount()).isZero();
assertThat(metrics.get(PROCESS_INSTANCES).getCount()).isZero();
assertThat(metrics.get(EXECUTED_DECISION_ELEMENTS).getCount()).isZero();
assertThat(metrics.get(DECISION_INSTANCES).getCount()).isZero();
Expand All @@ -215,7 +215,7 @@ public void shouldNotResetMetricsCount() {
TelemetryData telemetryData = managementService.getTelemetryData();

// then count should not reset
assertThat(telemetryData.getProduct().getInternals().getMetrics().get(FLOW_NODE_INSTANCES_START).getCount()).isEqualTo(2);
assertThat(telemetryData.getProduct().getInternals().getMetrics().get(FLOW_NODE_INSTANCES).getCount()).isEqualTo(2);
assertThat(telemetryData.getProduct().getInternals().getMetrics().get(PROCESS_INSTANCES).getCount()).isEqualTo(1);
}

Expand Down Expand Up @@ -339,7 +339,7 @@ public void shouldResetCollectedMetricsDataWhenTelemetryEnabled() {
// then metrics produced before telemetry was enabled should be deleted
Map<String, Metric> metrics = telemetryData.getProduct().getInternals().getMetrics();
assertThat(metrics.size()).isEqualTo(4);
assertThat(metrics.get(FLOW_NODE_INSTANCES_START).getCount()).isEqualTo(2);
assertThat(metrics.get(FLOW_NODE_INSTANCES).getCount()).isEqualTo(2);
assertThat(metrics.get(PROCESS_INSTANCES).getCount()).isEqualTo(1);
assertThat(metrics.get(DECISION_INSTANCES).getCount()).isEqualTo(0);
assertThat(metrics.get(EXECUTED_DECISION_ELEMENTS).getCount()).isEqualTo(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void testBpmnActivityInstances() {

// still 3 with the new metric name
assertEquals(3l, managementService.createMetricsQuery()
.name(Metrics.FLOW_NODE_INSTANCES_START)
.name(Metrics.FLOW_NODE_INSTANCES)
.sum());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public void testMeterQueryDefaultIntervalWhereName() {
metrics.remove(0);
for (MetricIntervalValue metric : metrics) {
assertEquals(name, metric.getName());
assertEquals(Metrics.FLOW_NODE_INSTANCES_START, metric.getName());
assertEquals(Metrics.FLOW_NODE_INSTANCES, metric.getName());
long nextTimestamp = metric.getTimestamp().getTime();
if (lastTimestamp != nextTimestamp) {
assertEquals(lastTimestamp, nextTimestamp + DEFAULT_INTERVAL_MILLIS);
Expand Down Expand Up @@ -268,7 +268,7 @@ public void testMeterQueryCustomIntervalWhereName() {
metrics.remove(0);
for (MetricIntervalValue metric : metrics) {
assertEquals(name, metric.getName());
assertEquals(Metrics.FLOW_NODE_INSTANCES_START, metric.getName());
assertEquals(Metrics.FLOW_NODE_INSTANCES, metric.getName());
long nextTimestamp = metric.getTimestamp().getTime();
if (lastTimestamp != nextTimestamp) {
assertEquals(lastTimestamp, nextTimestamp + interval);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void testStartAndEndMetricsAreEqual() {
.name(Metrics.ACTIVTY_INSTANCE_END)
.sum();
assertEquals(end, start);
assertEquals(end, managementService.createMetricsQuery().name(Metrics.FLOW_NODE_INSTANCES_END).sum());
assertEquals(start, managementService.createMetricsQuery().name(Metrics.FLOW_NODE_INSTANCES).sum());
}

@Test
Expand All @@ -126,7 +126,7 @@ public void testEndMetricWithWaitState() {
.name(Metrics.ACTIVTY_INSTANCE_END)
.sum();
assertNotEquals(end, start);
assertEquals(end, managementService.createMetricsQuery().name(Metrics.FLOW_NODE_INSTANCES_END).sum());
assertEquals(start, managementService.createMetricsQuery().name(Metrics.FLOW_NODE_INSTANCES).sum());
assertEquals(2, start);
assertEquals(1, end);

Expand All @@ -142,7 +142,7 @@ public void testEndMetricWithWaitState() {
.name(Metrics.ACTIVTY_INSTANCE_END)
.sum();
assertEquals(end, start);
assertEquals(end, managementService.createMetricsQuery().name(Metrics.FLOW_NODE_INSTANCES_END).sum());
assertEquals(start, managementService.createMetricsQuery().name(Metrics.FLOW_NODE_INSTANCES).sum());
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion webapps/ui/admin/client/scripts/pages/execution-metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ var Controller = [
flowNodes: function(cb) {
MetricsResource.sum(
{
name: 'flow-node-instances-start',
name: 'flow-node-instances',
startDate: fixDate($scope.startDate),
endDate: fixDate($scope.endDate)
},
Expand Down

0 comments on commit c72d817

Please sign in to comment.