Skip to content

Commit

Permalink
fix(mce-consumer): abbreviate overly verbose logging
Browse files Browse the repository at this point in the history
  • Loading branch information
darnaut committed Apr 3, 2024
1 parent 522a508 commit cd8d7b2
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,6 @@ static <T> Map<String, Map<String, T>> merge(
Collectors.mapping(
Pair::getValue, Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))));
}

String toAbbreviatedString(int maxWidth);
}
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ public List<UpdateAspectResult> ingestAspects(
return Collections.emptyList();
}

log.info("Ingesting aspects batch to database, items: {}", aspectsBatch.getItems());
log.info("Ingesting aspects batch to database: {}", aspectsBatch.toAbbreviatedString(2048));
Timer.Context ingestToLocalDBTimer =
MetricUtils.timer(this.getClass(), "ingestAspectsToLocalDB").time();
List<UpdateAspectResult> ingestResults = ingestAspectsToLocalDB(aspectsBatch, overwrite);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.linkedin.metadata.aspect.plugins.validation.ValidationExceptionCollection;
import com.linkedin.mxe.MetadataChangeProposal;
import com.linkedin.util.Pair;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
Expand All @@ -22,6 +23,7 @@
import lombok.Builder;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

@Slf4j
@Getter
Expand Down Expand Up @@ -148,4 +150,20 @@ public int hashCode() {
public String toString() {
return "AspectsBatchImpl{" + "items=" + items + '}';
}

public String toAbbreviatedString(int maxWidth) {
List<String> itemsAbbreviated = new ArrayList<String>();
items.forEach(
item -> {
if (item instanceof ChangeItemImpl) {
itemsAbbreviated.add(((ChangeItemImpl) item).toAbbreviatedString());
} else {
itemsAbbreviated.add(item.toString());
}
});
return "AspectsBatchImpl{"
+ "items="
+ StringUtils.abbreviate(itemsAbbreviated.toString(), maxWidth)
+ '}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import lombok.Setter;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

@Slf4j
@Getter
Expand Down Expand Up @@ -239,4 +240,20 @@ public String toString() {
+ systemMetadata
+ '}';
}

public String toAbbreviatedString() {
return "ChangeItemImpl{"
+ "changeType="
+ changeType
+ ", urn="
+ urn
+ ", aspectName='"
+ aspectName
+ '\''
+ ", recordTemplate="
+ StringUtils.abbreviate(recordTemplate.toString(), 256)
+ ", systemMetadata="
+ StringUtils.abbreviate(systemMetadata.toString(), 128)
+ '}';
}
}

0 comments on commit cd8d7b2

Please sign in to comment.