-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Added IndexSpanAlias and IndexServiceAlias for explicit aliases #7550
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -126,6 +126,13 @@ type Configuration struct { | |||||||||||
// Use this option with Elasticsearch rollover API. It requires an external component | ||||||||||||
// to create aliases before startup and then performing its management. | ||||||||||||
UseReadWriteAliases bool `mapstructure:"use_aliases"` | ||||||||||||
// IndexSpanAlias is an explicit alias name for span indices. | ||||||||||||
// When set, Jaeger will use this alias directly instead of the prefix+wildcard pattern. | ||||||||||||
// This allows integration with existing Elasticsearch setups and custom index management. | ||||||||||||
IndexSpanAlias string `mapstructure:"index_span_alias"` | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's call this
Suggested change
|
||||||||||||
// IndexServiceAlias is an explicit alias name for service indices. | ||||||||||||
// When set, Jaeger will use this alias directly instead of the prefix+wildcard pattern. | ||||||||||||
IndexServiceAlias string `mapstructure:"index_service_alias"` | ||||||||||||
// ReadAliasSuffix is the suffix to append to the index name used for reading. | ||||||||||||
// This configuration only exists to provide backwards compatibility for jaeger-v1 | ||||||||||||
// which is why it is not exposed as a configuration option for jaeger-v2 | ||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,6 +120,8 @@ func (f *FactoryBase) GetSpanReaderParams() esSpanStore.SpanReaderParams { | |
UseReadWriteAliases: f.config.UseReadWriteAliases, | ||
ReadAliasSuffix: f.config.ReadAliasSuffix, | ||
RemoteReadClusters: f.config.RemoteReadClusters, | ||
SpanAlias: f.config.IndexSpanAlias, | ||
ServiceAlias: f.config.IndexServiceAlias, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use the same field names as in the config struct |
||
Logger: f.logger, | ||
Tracer: f.tracer.Tracer("esSpanStore.SpanReader"), | ||
} | ||
|
@@ -137,6 +139,8 @@ func (f *FactoryBase) GetSpanWriterParams() esSpanStore.SpanWriterParams { | |
TagDotReplacement: f.config.Tags.DotReplacement, | ||
UseReadWriteAliases: f.config.UseReadWriteAliases, | ||
WriteAliasSuffix: f.config.WriteAliasSuffix, | ||
SpanAlias: f.config.IndexSpanAlias, | ||
ServiceAlias: f.config.IndexServiceAlias, | ||
Logger: f.logger, | ||
MetricsFactory: f.metricsFactory, | ||
ServiceCacheTTL: f.config.ServiceCacheTTL, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,37 +124,78 @@ type SpanReaderParams struct { | |
ReadAliasSuffix string | ||
UseReadWriteAliases bool | ||
RemoteReadClusters []string | ||
Logger *zap.Logger | ||
Tracer trace.Tracer | ||
// SpanAlias is an explicit alias name for span indices. | ||
// When set, this alias will be used instead of the IndexPrefix pattern. | ||
SpanAlias string | ||
// ServiceAlias is an explicit alias name for service indices. | ||
// When set, this alias will be used instead of the IndexPrefix pattern. | ||
ServiceAlias string | ||
Logger *zap.Logger | ||
Tracer trace.Tracer | ||
} | ||
|
||
// NewSpanReader returns a new SpanReader with a metrics. | ||
func NewSpanReader(p SpanReaderParams) *SpanReader { | ||
// Determine span index prefix - use explicit alias if provided | ||
spanIndexPrefix := p.IndexPrefix.Apply(spanIndexBaseName) | ||
hasSpanAlias := p.SpanAlias != "" | ||
if hasSpanAlias { | ||
spanIndexPrefix = p.SpanAlias | ||
} | ||
|
||
// Determine service index prefix - use explicit alias if provided | ||
serviceIndexPrefix := p.IndexPrefix.Apply(serviceIndexBaseName) | ||
hasServiceAlias := p.ServiceAlias != "" | ||
if hasServiceAlias { | ||
serviceIndexPrefix = p.ServiceAlias | ||
} | ||
|
||
// When using explicit aliases, treat them like read/write aliases | ||
// (no time-based index selection) | ||
useAliasMode := p.UseReadWriteAliases || hasSpanAlias || hasServiceAlias | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't introduce this implicit behavior, instead raise an error overrides are provided but UseReadWriteAliases is false. |
||
|
||
maxSpanAge := p.MaxSpanAge | ||
// Setting the maxSpanAge to a large duration will ensure all spans in the "read" alias are accessible by queries (query window = [now - maxSpanAge, now]). | ||
// When read/write aliases are enabled, which are required for index rollovers, only the "read" alias is queried and therefore should not affect performance. | ||
if p.UseReadWriteAliases { | ||
// When read/write aliases or explicit aliases are enabled, only the alias is queried and therefore should not affect performance. | ||
if useAliasMode { | ||
maxSpanAge = dawnOfTimeSpanAge | ||
} | ||
|
||
// Create custom time range function that handles explicit aliases independently | ||
var timeRangeFn TimeRangeIndexFn | ||
if hasSpanAlias || hasServiceAlias { | ||
// For explicit aliases, we need to check each index prefix individually | ||
// to determine if it's an alias (and should be returned as-is) or a regular prefix (needs date-based logic) | ||
baseTimeRangeFn := TimeRangeIndicesFn(p.UseReadWriteAliases, p.ReadAliasSuffix, p.RemoteReadClusters) | ||
timeRangeFn = func(indexPrefix, indexDateLayout string, startTime, endTime time.Time, reduceDuration time.Duration) []string { | ||
// Check if this indexPrefix matches one of our explicit aliases | ||
if (hasSpanAlias && indexPrefix == spanIndexPrefix) || (hasServiceAlias && indexPrefix == serviceIndexPrefix) { | ||
// This is an explicit alias, return it as-is | ||
return []string{indexPrefix} | ||
} | ||
// Not an explicit alias, use standard time-based logic | ||
return baseTimeRangeFn(indexPrefix, indexDateLayout, startTime, endTime, reduceDuration) | ||
} | ||
} else { | ||
// Use standard time range function | ||
timeRangeFn = TimeRangeIndicesFn(p.UseReadWriteAliases, p.ReadAliasSuffix, p.RemoteReadClusters) | ||
} | ||
|
||
return &SpanReader{ | ||
client: p.Client, | ||
maxSpanAge: maxSpanAge, | ||
serviceOperationStorage: NewServiceOperationStorage(p.Client, p.Logger, 0), // the decorator takes care of metrics | ||
spanIndexPrefix: p.IndexPrefix.Apply(spanIndexBaseName), | ||
serviceIndexPrefix: p.IndexPrefix.Apply(serviceIndexBaseName), | ||
spanIndexPrefix: spanIndexPrefix, | ||
serviceIndexPrefix: serviceIndexPrefix, | ||
spanIndex: p.SpanIndex, | ||
serviceIndex: p.ServiceIndex, | ||
timeRangeIndices: LoggingTimeRangeIndexFn( | ||
p.Logger, | ||
TimeRangeIndicesFn(p.UseReadWriteAliases, p.ReadAliasSuffix, p.RemoteReadClusters), | ||
), | ||
sourceFn: getSourceFn(p.MaxDocCount), | ||
maxDocCount: p.MaxDocCount, | ||
useReadWriteAliases: p.UseReadWriteAliases, | ||
logger: p.Logger, | ||
tracer: p.Tracer, | ||
dotReplacer: dbmodel.NewDotReplacer(p.TagDotReplacement), | ||
timeRangeIndices: LoggingTimeRangeIndexFn(p.Logger, timeRangeFn), | ||
sourceFn: getSourceFn(p.MaxDocCount), | ||
maxDocCount: p.MaxDocCount, | ||
useReadWriteAliases: useAliasMode, | ||
logger: p.Logger, | ||
tracer: p.Tracer, | ||
dotReplacer: dbmodel.NewDotReplacer(p.TagDotReplacement), | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add validation that if SpanIndexOverride is not empty then UseReadWriteAliases must be true, otherwise throw an error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similarly, add validation that if any of the other fields like prefix / suffix are defined that an error is thrown saying they are incompatible with Override setting.