Skip to content

Commit

Permalink
merge: #10073
Browse files Browse the repository at this point in the history
10073: Abbreviate Deployment Distribution records in compact logger r=pihme a=korthout

## Description

<!-- Please explain the changes you made here. -->

Many record types are abbreviated in the compact logger, but some of the more common (and also longer) ones aren't. 

See for example, this output after a failed test:

```
2 C DEPLOYMENT              DISTRIBUTE   - #1->-1 P1K2 - process.xml
3 C DEPLOYMENT              DISTRIBUTE   - #1->-1 P1K2 - process.xml
1 C DEPLOYMENT              CREATE       - #1->-1   -1 - 
1 E PROC                    CREATED      - #2->#1 P1K1 - process.xml -> "shouldR..ecovery" (version:1)
1 E DEPLOYMENT              CREATED      - #3->#1 P1K2 - process.xml
1 E DEPLOYMENT_DISTRIBUTION DISTRIBUTING - #4->#1 P1K2 - DeploymentDistributionRecord {"partitionId":2}
1 E DEPLOYMENT_DISTRIBUTION DISTRIBUTING - #5->#1 P1K2 - DeploymentDistributionRecord {"partitionId":3}
2 C DEPLOYMENT              DISTRIBUTE   - #2->-1 P1K2 - process.xml
3 C DEPLOYMENT              DISTRIBUTE   - #2->-1 P1K2 - process.xml
1 C DEPLOYMENT_DISTRIBUTION COMPLETE     - #6->-1 P1K2 - DeploymentDistributionRecord {"partitionId":2}
1 E DEPLOYMENT_DISTRIBUTION COMPLETED    - #7->#6 P1K2 - DeploymentDistributionRecord {"partitionId":2}
2 E DEPLOYMENT              DISTR        - #3->#1 P1K2 - process.xml
2 E DEPLOYMENT              DISTR        - #4->#2 P1K2 - process.xml
```

After this PR, the same log is outputted as:
```
2 C DPLY DISTRIBUTE   - #1->-1 P1K2 - process.xml
3 C DPLY DISTRIBUTE   - #1->-1 P1K2 - process.xml
1 C DPLY CREATE       - #1->-1   -1 - 
1 E PROC CREATED      - #2->#1 P1K1 - process.xml -> "shouldR..ecovery" (version:1)
1 E DPLY CREATED      - #3->#1 P1K2 - process.xml
1 E DSTR DISTRIBUTING - #4->#1 P1K2 - on partition 2
1 E DSTR DISTRIBUTING - #5->#1 P1K2 - on partition 3
2 C DPLY DISTRIBUTE   - #2->-1 P1K2 - process.xml
3 C DPLY DISTRIBUTE   - #2->-1 P1K2 - process.xml
1 C DSTR COMPLETE     - #6->-1 P1K2 - on partition 2
1 E DSTR COMPLETED    - #7->#6 P1K2 - on partition 2
2 E DPLY DISTRIBUTED  - #3->#1 P1K2 - process.xml
2 E DPLY DISTRIBUTED  - #4->#2 P1K2 - process.xml
```

## Related issues

<!-- Which issues are closed by this PR or are related -->

relates to #10064 



Co-authored-by: Nico Korthout <nico.korthout@camunda.com>
  • Loading branch information
zeebe-bors-camunda[bot] and korthout committed Aug 15, 2022
2 parents e1a5ee9 + 855769c commit 9992662
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import io.camunda.zeebe.protocol.record.intent.IncidentIntent;
import io.camunda.zeebe.protocol.record.intent.Intent;
import io.camunda.zeebe.protocol.record.value.DecisionEvaluationRecordValue;
import io.camunda.zeebe.protocol.record.value.DeploymentDistributionRecordValue;
import io.camunda.zeebe.protocol.record.value.DeploymentRecordValue;
import io.camunda.zeebe.protocol.record.value.ErrorRecordValue;
import io.camunda.zeebe.protocol.record.value.IncidentRecordValue;
Expand Down Expand Up @@ -62,14 +63,16 @@ public class CompactRecordLogger {
private static final Logger LOG = LoggerFactory.getLogger("io.camunda.zeebe.test");
private static final String BLOCK_SEPARATOR = " - ";

private static final Map<String, String> ABBREVIATIONS =
ofEntries(
// List rather than Map to preserve order
private static final List<Entry<String, String>> ABBREVIATIONS =
List.of(
entry("PROCESS", "PROC"),
entry("INSTANCE", "INST"),
entry("MESSAGE", "MSG"),
entry("SUBSCRIPTION", "SUB"),
entry("SEQUENCE", "SEQ"),
entry("DISTRIBUTED", "DISTR"),
entry("DEPLOYMENT_DISTRIBUTION", "DSTR"),
entry("DEPLOYMENT", "DPLY"),
entry("VARIABLE", "VAR"),
entry("ELEMENT_", ""),
entry("_ELEMENT", ""),
Expand All @@ -95,6 +98,7 @@ public class CompactRecordLogger {

{
valueLoggers.put(ValueType.DEPLOYMENT, this::summarizeDeployment);
valueLoggers.put(ValueType.DEPLOYMENT_DISTRIBUTION, this::summarizeDeploymentDistribution);
valueLoggers.put(ValueType.PROCESS, this::summarizeProcess);
valueLoggers.put(ValueType.INCIDENT, this::summarizeIncident);
valueLoggers.put(ValueType.JOB, this::summarizeJob);
Expand Down Expand Up @@ -281,6 +285,11 @@ private String summarizeDeployment(final Record<?> record) {
return Stream.concat(bpmnResources, dmnResources).collect(Collectors.joining(", "));
}

private String summarizeDeploymentDistribution(final Record<?> record) {
final var value = (DeploymentDistributionRecordValue) record.getValue();
return "on partition %d".formatted(value.getPartitionId());
}

private String summarizeProcess(final Record<?> record) {
final var value = (Process) record.getValue();
processes.add(value);
Expand Down Expand Up @@ -662,8 +671,8 @@ private String formatId(final String input) {
private String abbreviate(final String input) {
String result = input;

for (final String longForm : ABBREVIATIONS.keySet()) {
result = result.replace(longForm, ABBREVIATIONS.get(longForm));
for (final Entry<String, String> entry : ABBREVIATIONS) {
result = result.replace(entry.getKey(), entry.getValue());
}

return result;
Expand Down

0 comments on commit 9992662

Please sign in to comment.