Skip to content

Commit

Permalink
merge: #10079
Browse files Browse the repository at this point in the history
10079: [Backport stable/1.3] Abbreviate Deployment Distribution records in compact logger r=korthout a=korthout

# Description
Manual backport of #10073 to `stable/1.3`.

relates to #10064

I've resolved conflicts in b9beaad

Co-authored-by: Nico Korthout <nico.korthout@camunda.com>
  • Loading branch information
zeebe-bors-camunda[bot] and korthout committed Aug 17, 2022
2 parents b21cde5 + 10252e5 commit 8b67c16
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import io.camunda.zeebe.protocol.record.ValueType;
import io.camunda.zeebe.protocol.record.intent.IncidentIntent;
import io.camunda.zeebe.protocol.record.intent.Intent;
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 @@ -56,14 +57,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 @@ -87,6 +90,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 @@ -266,6 +270,11 @@ private String summarizeDeployment(final Record<?> record) {
.collect(Collectors.joining(", "));
}

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

private String summarizeProcess(final Record<?> record) {
final var value = (Process) record.getValue();
processes.add(value);
Expand Down Expand Up @@ -601,8 +610,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 8b67c16

Please sign in to comment.