Skip to content

Commit

Permalink
Add flag ES_USE_WRITE_ALIAS to allow using the alias jaeger-dependenc…
Browse files Browse the repository at this point in the history
…ies-write to store the dependencies

Signed-off-by: Christian Rohmann <[email protected]>
  • Loading branch information
frittentheke committed Feb 8, 2022
1 parent 22702cd commit 819856a
Showing 1 changed file with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public static final class Builder {
String indexPrefix = Utils.getEnv("ES_INDEX_PREFIX", null);
String spanRange = Utils.getEnv("ES_TIME_RANGE", "24h");
Boolean useReadAlias = Boolean.parseBoolean(Utils.getEnv("ES_USE_READ_ALIAS", "false"));
Boolean useWriteAlias = Boolean.parseBoolean(Utils.getEnv("ES_USE_WRITE_ALIAS", "false"));

final Map<String, String> sparkProperties = new LinkedHashMap<>();

Expand Down Expand Up @@ -168,6 +169,7 @@ private static String getSystemPropertyAsFileResource(String key) {
private final String indexPrefix;
private final String spanRange;
private final Boolean useReadAlias;
private final Boolean useWriteAlias;

ElasticsearchDependenciesJob(Builder builder) {
this.day = builder.day;
Expand Down Expand Up @@ -198,6 +200,7 @@ private static String getSystemPropertyAsFileResource(String key) {
this.indexPrefix = builder.indexPrefix;
this.spanRange = builder.spanRange;
this.useReadAlias = builder.useReadAlias;
this.useWriteAlias = builder.useWriteAlias;
}

/**
Expand All @@ -212,12 +215,27 @@ private static String prefix(String prefix) {
}

public void run(String peerServiceTag) {
if (this.useReadAlias) {
run(new String[]{prefix(indexPrefix) + "jaeger-span-read", prefixBefore19(indexPrefix) + "jaeger-span-read"}, indexDate("jaeger-dependencies") ,peerServiceTag);

String[] readIndices;
String[] writeIndex;

// read spans from alias index name
if (this.useReadAlias) {
readIndices = new String[]{prefix(indexPrefix) + "jaeger-span-read", prefixBefore19(indexPrefix) + "jaeger-span-read"};
}
else {
run(indexDate("jaeger-span"), indexDate("jaeger-dependencies") ,peerServiceTag);
}
else {
readIndices = indexDate("jaeger-span");
}

// write dependencies to alias index name
if (this.useWriteAlias) {
writeIndex = new String[] {prefix(indexPrefix) + "jaeger-dependencies-write"};
}
else {
writeIndex = indexDate("jaeger-dependencies");
}

run(readIndices, writeIndex, peerServiceTag);
}

String[] indexDate(String index) {
Expand Down

0 comments on commit 819856a

Please sign in to comment.