Skip to content

Commit

Permalink
Add support for using ElasticSearch index alias to read the spans from
Browse files Browse the repository at this point in the history
 * Added ES_USE_READ_ALIAS flag to use 'jaeger-span-read' index alias instead of indexDate postfixed one
 * Added range query to only fetch the spans for the last 24 hours (based on startTimeMillies field)

Signed-off-by: Christian Rohmann <[email protected]>
  • Loading branch information
frittentheke committed Apr 14, 2022
1 parent a41f173 commit 7ed1ba2
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public static final class Builder {
Boolean nodesWanOnly = Boolean.parseBoolean(Utils.getEnv("ES_NODES_WAN_ONLY", "false"));
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"));

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

Expand Down Expand Up @@ -166,6 +167,7 @@ private static String getSystemPropertyAsFileResource(String key) {
private final SparkConf conf;
private final String indexPrefix;
private final String spanRange;
private final Boolean useReadAlias;

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

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

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

String[] indexDate(String index) {
Expand Down

0 comments on commit 7ed1ba2

Please sign in to comment.