Skip to content

Commit

Permalink
Updates from PR feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Nied <peternied@hotmail.com>
  • Loading branch information
peternied committed Aug 15, 2024
1 parent 2e7f43b commit a152666
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,6 @@ public void testDocumentMigration(
}
}

// @Test
// public void testDocumentMigrationForBigMonolithicShardWorks() throws Exception {
// testDocumentMigration(1,
// SearchClusterContainer.OS_V2_14_0.getImageName(),
// SearchClusterContainer.OS_V2_14_0,
// GENERATOR_BASE_IMAGE,
// new String[]{"tail", "-f", "/dev/null"});
// }

private void verifyWorkMetrics(DocumentMigrationTestContext rootContext, int numWorkers, int numRuns) {
var workMetrics = rootContext.inMemoryInstrumentationBundle.getFinishedMetrics();
var migrationMetrics = rootContext.inMemoryInstrumentationBundle.getFinishedMetrics();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ public class RootWorkCoordinationContext extends RootOtelContext {
public final WorkCoordinationContexts.CompleteWorkItemContext.MetricInstruments completeWorkMetrics;
public final WorkCoordinationContexts.AcquireNextWorkItemContext.MetricInstruments acquireNextWorkMetrics;

public RootWorkCoordinationContext(OpenTelemetry sdk, IContextTracker contextTracker) {
this(sdk, contextTracker, null);
}

public RootWorkCoordinationContext(OpenTelemetry sdk,
IContextTracker contextTracker,
RootOtelContext enclosingScope)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public static void main(String[] args) throws Exception {
var activeContextLogger = LoggerFactory.getLogger(ALL_ACTIVE_CONTEXTS_MONITOR_LOGGER);
var params = parseArgs(args);
URI uri;
final var workerId = UUID.randomUUID().toString();
final var workerId = ProcessHelpers.getNodeInstanceName();
System.err.println("Starting Traffic Replayer with id=" + workerId);
System.err.println("Got args: " + String.join("; ", args));
try {
Expand Down Expand Up @@ -263,7 +263,7 @@ public static void main(String[] args) throws Exception {
var topContext = new RootReplayerContext(
RootOtelContext.initializeOpenTelemetryWithCollectorOrAsNoop(params.otelCollectorEndpoint,
"replay",
ProcessHelpers.getNodeInstanceName()),
workerId),
contextTrackers
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class RootOtelContext implements IRootOtelContext {
public static OpenTelemetry initializeOpenTelemetryForCollector(
@NonNull String collectorEndpoint,
@NonNull String serviceName,
String nodeName
@NonNull String nodeName
) {
final var spanProcessor = BatchSpanProcessor.builder(
OtlpGrpcSpanExporter.builder().setEndpoint(collectorEndpoint).setTimeout(2, TimeUnit.SECONDS).build()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,21 @@
package org.opensearch.migrations.utils;

import java.util.Optional;
import java.util.UUID;

import lombok.experimental.UtilityClass;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@UtilityClass
public class ProcessHelpers {
private static final String DEFAULT_NODE_ID = UUID.randomUUID().toString();

public static String getNodeInstanceName() {
String id = null;
try {
id = System.getenv("ECS_TASK_ID"); // for ECS deployments
if (id != null) {
return id;
}
id = System.getenv("HOSTNAME"); // for any kubernetes deployed pod
if (id != null) {
return id;
}
// add additional fallbacks here
id = DEFAULT_NODE_ID;
return id;
} finally {
if (id != null) {
String finalId = id;
log.atInfo().setMessage(() -> "getNodeInstanceName()=" + finalId).log();
}
}
var nodeId = Optional.of("ECS_TASK_ID").map(System::getenv)
.or(() -> Optional.of("HOSTNAME").map(System::getenv))
.orElse(DEFAULT_NODE_ID);
log.atInfo().setMessage(() -> "getNodeInstanceName()=" + nodeId).log();
return nodeId;
}
}

0 comments on commit a152666

Please sign in to comment.