Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalization logs: remove json parse warnings #34978

Merged
merged 3 commits into from
Feb 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Stream<AirbyteMessage> toMessages(final String line) {
if (Strings.isEmpty(line)) {
return Stream.of(logMessage(Level.INFO, ""));
}
final Optional<JsonNode> json = Jsons.tryDeserialize(line);
final Optional<JsonNode> json = Jsons.tryDeserializeWithoutWarn(line);
if (json.isPresent()) {
return jsonToMessage(json.get());
} else {
Expand Down Expand Up @@ -96,7 +96,7 @@ private Stream<AirbyteMessage> jsonToMessage(final JsonNode jsonLine) {
*/
final String logLevel = (jsonLine.hasNonNull("level")) ? jsonLine.get("level").asText() : "";
String logMsg = jsonLine.hasNonNull("msg") ? jsonLine.get("msg").asText() : "";
Level level;
final Level level;
switch (logLevel) {
case "debug" -> level = Level.DEBUG;
case "info" -> level = Level.INFO;
Expand All @@ -117,15 +117,15 @@ private Stream<AirbyteMessage> jsonToMessage(final JsonNode jsonLine) {
}
}

private static AirbyteMessage logMessage(Level level, String message) {
private static AirbyteMessage logMessage(final Level level, final String message) {
return new AirbyteMessage()
.withType(Type.LOG)
.withLog(new AirbyteLogMessage()
.withLevel(level)
.withMessage(message));
}

public static void main(String[] args) {
public static void main(final String[] args) {
final NormalizationLogParser normalizationLogParser = new NormalizationLogParser();
final Stream<AirbyteMessage> airbyteMessageStream =
normalizationLogParser.create(new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8)));
Expand All @@ -135,8 +135,8 @@ public static void main(String[] args) {
final String dbtErrorStack = String.join("\n", errors);
if (!"".equals(dbtErrorStack)) {
final Map<ErrorMapKeys, String> errorMap = SentryExceptionHelper.getUsefulErrorMessageAndTypeFromDbtError(dbtErrorStack);
String internalMessage = errorMap.get(ErrorMapKeys.ERROR_MAP_MESSAGE_KEY);
AirbyteMessage traceMessage = new AirbyteMessage()
final String internalMessage = errorMap.get(ErrorMapKeys.ERROR_MAP_MESSAGE_KEY);
final AirbyteMessage traceMessage = new AirbyteMessage()
.withType(Type.TRACE)
.withTrace(new AirbyteTraceMessage()
.withType(AirbyteTraceMessage.Type.ERROR)
Expand Down
Loading