Skip to content

Add versioning logging #18618

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

Merged
merged 1 commit into from
Oct 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -8,9 +8,13 @@
import io.airbyte.commons.protocol.AirbyteMessageVersionedMigratorFactory;
import io.airbyte.commons.version.Version;
import java.io.BufferedWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class VersionedAirbyteMessageBufferedWriterFactory implements AirbyteMessageBufferedWriterFactory {

private static final Logger LOGGER = LoggerFactory.getLogger(VersionedAirbyteMessageBufferedWriterFactory.class);

private final AirbyteMessageSerDeProvider serDeProvider;
private final AirbyteMessageVersionedMigratorFactory migratorFactory;
private final Version protocolVersion;
Expand All @@ -25,6 +29,11 @@ public VersionedAirbyteMessageBufferedWriterFactory(final AirbyteMessageSerDePro

@Override
public AirbyteMessageBufferedWriter createWriter(BufferedWriter bufferedWriter) {
final boolean needMigration = !protocolVersion.getMajorVersion().equals(migratorFactory.getMostRecentVersion().getMajorVersion());
LOGGER.info(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class is a factory so I am assuming that it is called only once per sync and not once per message. Could you confirm that? If not, we need to switch this log to debug to ensure that we won't generate gigantic logs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is called once per sync.

"Writing messages to protocol version {}{}",
protocolVersion.serialize(),
needMigration ? ", messages will be downgraded from protocol version " + migratorFactory.getMostRecentVersion().serialize() : "");
return new VersionedAirbyteMessageBufferedWriter<>(
bufferedWriter,
serDeProvider.getSerializer(protocolVersion).orElseThrow(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ public Stream<AirbyteMessage> create(final BufferedReader bufferedReader) {
initializeForProtocolVersion(fallbackVersion);
}
}

final boolean needMigration = !protocolVersion.getMajorVersion().equals(migratorFactory.getMostRecentVersion().getMajorVersion());
logger.info(
"Reading messages from protocol version {}{}",
protocolVersion.serialize(),
needMigration ? ", messages will be upgraded to protocol version " + migratorFactory.getMostRecentVersion().serialize() : "");
return super.create(bufferedReader);
}

Expand Down