Package zipkin2.elasticsearch.internal
Class IndexNameFormatter
- java.lang.Object
-
- zipkin2.elasticsearch.internal.IndexNameFormatter
-
public abstract class IndexNameFormatter extends java.lang.Object
Index-Prefix/type delimiter
When Elasticsearch dropped support for multiple type indexes, we introduced a delimited naming convention to distinguish between span, dependency and autocomplete documents. Originally, this was a colon prefix pattern. In version 7, Elasticsearch dropped support for colons in indexes. To keep existing writes consistent, we still use colon in versions prior to ES 7, eventhough starting at version 7, we change to hyphens.zipkin2.elasticsearch.IndexTemplates
is responsible for this decision.Creating indexes
Using the default index prefix of "zipkin", when indexes are created, they look like the following, based on the version.- ES up to v6: zipkin:span-2019-05-03 zipkin:dependency-2019-05-03 zipkin:autocomplete-2019-05-03
- ES v7: zipkin-span-2019-05-03 zipkin-dependency-2019-05-03 zipkin-autocomplete-2019-05-03
We can allow an index prefix of up to 231 UTF-8 encoded bytes, subject to the index naming constraints. This is the normal 255 limit minus the longest suffix (ex. -autocomplete-2019-05-03).
Reading indexes
While ES 7 cannot write new indexes with a colons, it can read them. Upon upgrade, some sites will have a mixed read state where some indexes delimit types with a colon and others a hyphen. Accordingly, we use * in read patterns in place of a type delimiter. We use * because there is no support for single character wildcards in ES.Elasticsearch 7 naming constraints
According to a recent reference, the following index naming constraints apply to index names as of ES 7:- No more than 255 UTF-8 encoded bytes
- Cannot be . or ..
- Cannot contain : or #
- Cannot start with _ - or +
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
IndexNameFormatter.Builder
-
Constructor Summary
Constructors Constructor Description IndexNameFormatter()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.String
formatType(java.lang.String type)
java.util.List<java.lang.String>
formatTypeAndRange(java.lang.String type, long beginMillis, long endMillis)
Returns a set of index patterns that represent the range provided.java.lang.String
formatTypeAndTimestamp(java.lang.String type, long timestampMillis)
java.lang.String
formatTypeAndTimestampForInsert(java.lang.String type, char indexTypeDelimiter, long timestampMillis)
On insert, require a version-specific index-type delimiter as ES 7+ dropped colonsabstract java.lang.String
index()
static IndexNameFormatter.Builder
newBuilder()
long
parseDate(java.lang.String timestamp)
abstract IndexNameFormatter.Builder
toBuilder()
-
-
-
Method Detail
-
newBuilder
public static IndexNameFormatter.Builder newBuilder()
-
toBuilder
public abstract IndexNameFormatter.Builder toBuilder()
-
index
public abstract java.lang.String index()
-
formatTypeAndRange
public java.util.List<java.lang.String> formatTypeAndRange(@Nullable java.lang.String type, long beginMillis, long endMillis)
Returns a set of index patterns that represent the range provided. Notably, this compresses months or years using wildcards (in order to send smaller API calls).For example, if
beginMillis
is 2016-11-30 andendMillis
is 2017-01-02, the result will be 2016-11-30, 2016-12-*, 2017-01-01 and 2017-01-02.
-
formatTypeAndTimestampForInsert
public java.lang.String formatTypeAndTimestampForInsert(java.lang.String type, char indexTypeDelimiter, long timestampMillis)
On insert, require a version-specific index-type delimiter as ES 7+ dropped colons
-
formatTypeAndTimestamp
public java.lang.String formatTypeAndTimestamp(@Nullable java.lang.String type, long timestampMillis)
-
parseDate
public long parseDate(java.lang.String timestamp)
-
formatType
public java.lang.String formatType(@Nullable java.lang.String type)
-
-