Skip to content

Fix MDC scope #19501

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 6 commits into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -36,7 +36,7 @@
public class DefaultAirbyteDestination implements AirbyteDestination {

private static final Logger LOGGER = LoggerFactory.getLogger(DefaultAirbyteDestination.class);
private static final MdcScope.Builder CONTAINER_LOG_MDC_BUILDER = new Builder()
public static final MdcScope.Builder CONTAINER_LOG_MDC_BUILDER = new Builder()
.setLogPrefix("destination")
.setPrefixColor(Color.YELLOW_BACKGROUND);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class DefaultAirbyteSource implements AirbyteSource {
private static final Duration HEARTBEAT_FRESH_DURATION = Duration.of(5, ChronoUnit.MINUTES);
private static final Duration GRACEFUL_SHUTDOWN_DURATION = Duration.of(1, ChronoUnit.MINUTES);

private static final MdcScope.Builder CONTAINER_LOG_MDC_BUILDER = new Builder()
public static final MdcScope.Builder CONTAINER_LOG_MDC_BUILDER = new Builder()
.setLogPrefix("source")
.setPrefixColor(Color.BLUE_BACKGROUND);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import datadog.trace.api.Trace;
import io.airbyte.commons.features.FeatureFlags;
import io.airbyte.commons.json.Jsons;
import io.airbyte.commons.logging.MdcScope;
import io.airbyte.commons.protocol.AirbyteMessageSerDeProvider;
import io.airbyte.commons.protocol.AirbyteMessageVersionedMigratorFactory;
import io.airbyte.commons.temporal.TemporalUtils;
Expand Down Expand Up @@ -120,7 +121,8 @@ public Optional<String> runJob() throws Exception {
final AirbyteSource airbyteSource =
WorkerConstants.RESET_JOB_SOURCE_DOCKER_IMAGE_STUB.equals(sourceLauncherConfig.getDockerImage()) ? new EmptyAirbyteSource(
featureFlags.useStreamCapableState())
: new DefaultAirbyteSource(sourceLauncher, getStreamFactory(sourceLauncherConfig.getProtocolVersion()));
: new DefaultAirbyteSource(sourceLauncher,
getStreamFactory(sourceLauncherConfig.getProtocolVersion(), DefaultAirbyteSource.CONTAINER_LOG_MDC_BUILDER));

MetricClientFactory.initialize(MetricEmittingApps.WORKER);
final MetricClient metricClient = MetricClientFactory.getMetricClient();
Expand All @@ -132,7 +134,8 @@ public Optional<String> runJob() throws Exception {
Math.toIntExact(jobRunConfig.getAttemptId()),
airbyteSource,
new NamespacingMapper(syncInput.getNamespaceDefinition(), syncInput.getNamespaceFormat(), syncInput.getPrefix()),
new DefaultAirbyteDestination(destinationLauncher, getStreamFactory(destinationLauncherConfig.getProtocolVersion()),
new DefaultAirbyteDestination(destinationLauncher, getStreamFactory(destinationLauncherConfig.getProtocolVersion(),
DefaultAirbyteDestination.CONTAINER_LOG_MDC_BUILDER),
new VersionedAirbyteMessageBufferedWriterFactory(serDeProvider, migratorFactory, destinationLauncherConfig.getProtocolVersion())),
new AirbyteMessageTracker(),
new RecordSchemaValidator(WorkerUtils.mapStreamNamesToSchemas(syncInput)),
Expand All @@ -146,10 +149,10 @@ public Optional<String> runJob() throws Exception {
return Optional.of(Jsons.serialize(replicationOutput));
}

private AirbyteStreamFactory getStreamFactory(final Version protocolVersion) {
private AirbyteStreamFactory getStreamFactory(final Version protocolVersion, final MdcScope.Builder mdcScope) {
return protocolVersion != null
? new VersionedAirbyteStreamFactory<>(serDeProvider, migratorFactory, protocolVersion)
: new DefaultAirbyteStreamFactory();
? new VersionedAirbyteStreamFactory(serDeProvider, migratorFactory, protocolVersion, mdcScope)
: new DefaultAirbyteStreamFactory(mdcScope);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ private CheckedSupplier<Worker<StandardSyncInput, ReplicationOutput>, Exception>
WorkerConstants.RESET_JOB_SOURCE_DOCKER_IMAGE_STUB.equals(sourceLauncherConfig.getDockerImage())
? new EmptyAirbyteSource(featureFlags.useStreamCapableState())
: new DefaultAirbyteSource(sourceLauncher,
new VersionedAirbyteStreamFactory<>(serDeProvider, migratorFactory, sourceLauncherConfig.getProtocolVersion()));
new VersionedAirbyteStreamFactory<>(serDeProvider, migratorFactory, sourceLauncherConfig.getProtocolVersion(),
DefaultAirbyteSource.CONTAINER_LOG_MDC_BUILDER));
MetricClientFactory.initialize(MetricEmittingApps.WORKER);
final MetricClient metricClient = MetricClientFactory.getMetricClient();
final WorkerMetricReporter metricReporter = new WorkerMetricReporter(metricClient, sourceLauncherConfig.getDockerImage());
Expand All @@ -287,7 +288,8 @@ private CheckedSupplier<Worker<StandardSyncInput, ReplicationOutput>, Exception>
airbyteSource,
new NamespacingMapper(syncInput.getNamespaceDefinition(), syncInput.getNamespaceFormat(), syncInput.getPrefix()),
new DefaultAirbyteDestination(destinationLauncher,
new VersionedAirbyteStreamFactory<>(serDeProvider, migratorFactory, destinationLauncherConfig.getProtocolVersion()),
new VersionedAirbyteStreamFactory<>(serDeProvider, migratorFactory, destinationLauncherConfig.getProtocolVersion(),
DefaultAirbyteDestination.CONTAINER_LOG_MDC_BUILDER),
new VersionedAirbyteMessageBufferedWriterFactory(serDeProvider, migratorFactory, destinationLauncherConfig.getProtocolVersion())),
new AirbyteMessageTracker(),
new RecordSchemaValidator(WorkerUtils.mapStreamNamesToSchemas(syncInput)),
Expand Down