-
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?
Added IndexSpanAlias and IndexServiceAlias for explicit aliases #7550
Conversation
| if p.SpanAlias != "" || p.ServiceAlias != "" { | ||
| return func(_ time.Time) (string, string) { | ||
| return spanIndexPrefix, serviceIndexPrefix | ||
| } | ||
| } |
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.
There's a logical issue in this conditional block. When either p.SpanAlias or p.ServiceAlias is set (but not both), the function will return both indices without date suffixes. This creates inconsistent behavior where an index without an explicit alias will lose its date suffix.
Consider refactoring to handle each index type independently:
return func(date time.Time) (string, string) {
spanIndex := spanIndexPrefix
serviceIndex := serviceIndexPrefix
// Only apply date suffix to indices without explicit aliases
if p.SpanAlias == "" {
spanIndex = indexWithDate(spanIndexPrefix, p.SpanIndex.DateLayout, date)
}
if p.ServiceAlias == "" {
serviceIndex = indexWithDate(serviceIndexPrefix, p.ServiceIndex.DateLayout, date)
}
return spanIndex, serviceIndex
}This ensures that date suffixes are only omitted for indices with explicit aliases configured.
Spotted by Graphite Agent
Is this helpful? React 👍 or 👎 to let us know.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7550 +/- ##
==========================================
- Coverage 96.59% 96.58% -0.02%
==========================================
Files 384 384
Lines 19404 19431 +27
==========================================
+ Hits 18744 18767 +23
- Misses 477 480 +3
- Partials 183 184 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Metrics Comparison SummaryTotal changes across all snapshots: 53 Detailed changes per snapshotsummary_metrics_snapshot_cassandra📊 Metrics Diff SummaryTotal Changes: 53
🆕 Added Metrics
View diff sample+http_server_request_body_size_bytes{http_request_method="GET",http_response_status_code="503",le="+Inf",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.63.0",server_address="localhost",server_port="13133",url_scheme="http"}
+http_server_request_body_size_bytes{http_request_method="GET",http_response_status_code="503",le="0",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.63.0",server_address="localhost",server_port="13133",url_scheme="http"}
+http_server_request_body_size_bytes{http_request_method="GET",http_response_status_code="503",le="10",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.63.0",server_address="localhost",server_port="13133",url_scheme="http"}
+http_server_request_body_size_bytes{http_request_method="GET",http_response_status_code="503",le="100",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.63.0",server_address="localhost",server_port="13133",url_scheme="http"}
+http_server_request_body_size_bytes{http_request_method="GET",http_response_status_code="503",le="1000",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.63.0",server_address="localhost",server_port="13133",url_scheme="http"}
+http_server_request_body_size_bytes{http_request_method="GET",http_response_status_code="503",le="10000",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.63.0",server_address="localhost",server_port="13133",url_scheme="http"}
+http_server_request_body_size_bytes{http_request_method="GET",http_response_status_code="503",le="25",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.63.0",server_address="localhost",server_port="13133",url_scheme="http"}
...View diff sample+http_server_request_duration_seconds{http_request_method="GET",http_response_status_code="503",le="+Inf",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.63.0",server_address="localhost",server_port="13133",url_scheme="http"}
+http_server_request_duration_seconds{http_request_method="GET",http_response_status_code="503",le="0.005",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.63.0",server_address="localhost",server_port="13133",url_scheme="http"}
+http_server_request_duration_seconds{http_request_method="GET",http_response_status_code="503",le="0.01",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.63.0",server_address="localhost",server_port="13133",url_scheme="http"}
+http_server_request_duration_seconds{http_request_method="GET",http_response_status_code="503",le="0.025",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.63.0",server_address="localhost",server_port="13133",url_scheme="http"}
+http_server_request_duration_seconds{http_request_method="GET",http_response_status_code="503",le="0.05",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.63.0",server_address="localhost",server_port="13133",url_scheme="http"}
+http_server_request_duration_seconds{http_request_method="GET",http_response_status_code="503",le="0.075",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.63.0",server_address="localhost",server_port="13133",url_scheme="http"}
+http_server_request_duration_seconds{http_request_method="GET",http_response_status_code="503",le="0.1",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.63.0",server_address="localhost",server_port="13133",url_scheme="http"}
...View diff sample+http_server_response_body_size_bytes{http_request_method="GET",http_response_status_code="503",le="+Inf",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.63.0",server_address="localhost",server_port="13133",url_scheme="http"}
+http_server_response_body_size_bytes{http_request_method="GET",http_response_status_code="503",le="0",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.63.0",server_address="localhost",server_port="13133",url_scheme="http"}
+http_server_response_body_size_bytes{http_request_method="GET",http_response_status_code="503",le="10",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.63.0",server_address="localhost",server_port="13133",url_scheme="http"}
+http_server_response_body_size_bytes{http_request_method="GET",http_response_status_code="503",le="100",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.63.0",server_address="localhost",server_port="13133",url_scheme="http"}
+http_server_response_body_size_bytes{http_request_method="GET",http_response_status_code="503",le="1000",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.63.0",server_address="localhost",server_port="13133",url_scheme="http"}
+http_server_response_body_size_bytes{http_request_method="GET",http_response_status_code="503",le="10000",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.63.0",server_address="localhost",server_port="13133",url_scheme="http"}
+http_server_response_body_size_bytes{http_request_method="GET",http_response_status_code="503",le="25",network_protocol_name="http",network_protocol_version="1.1",otel_scope_name="go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp",otel_scope_schema_url="",otel_scope_version="0.63.0",server_address="localhost",server_port="13133",url_scheme="http"}
... |
| if p.UseReadWriteAliases { | ||
| return func(_ time.Time) (string, string) { | ||
| return spanIndexPrefix + writeAlias, serviceIndexPrefix + writeAlias | ||
| } | ||
| } |
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.
When both UseReadWriteAliases and explicit aliases are configured, the current implementation will append the write alias suffix to the explicit aliases. This behavior may be inconsistent with the purpose of explicit aliases, which are typically intended to be used exactly as provided.
Consider one of these approaches:
- Check for explicit aliases before checking
UseReadWriteAliasesto prioritize the explicit alias behavior - Add logic to handle the combination of both settings explicitly
- Document the current behavior in the configuration comments to clarify that explicit aliases will still receive the write suffix when
UseReadWriteAliasesis enabled
This would ensure the behavior is either consistent with user expectations or clearly documented.
| if p.UseReadWriteAliases { | |
| return func(_ time.Time) (string, string) { | |
| return spanIndexPrefix + writeAlias, serviceIndexPrefix + writeAlias | |
| } | |
| } | |
| if p.SpanIndexAlias != "" && p.ServiceIndexAlias != "" { | |
| return func(_ time.Time) (string, string) { | |
| return p.SpanIndexAlias, p.ServiceIndexAlias | |
| } | |
| } | |
| if p.UseReadWriteAliases { | |
| return func(_ time.Time) (string, string) { | |
| return spanIndexPrefix + writeAlias, serviceIndexPrefix + writeAlias | |
| } | |
| } |
Spotted by Graphite Agent
Is this helpful? React 👍 or 👎 to let us know.
|
Hii @yurishkuro, |
|
Hii @yurishkuro, |
|
Hii @yurishkuro , |
Signed-off-by: Somil Jain <[email protected]>
…ndices Signed-off-by: Somil Jain <[email protected]>
Signed-off-by: Somil Jain <[email protected]>
Signed-off-by: Somil Jain <[email protected]>
bcc7b86 to
83eb73c
Compare
|
Hii @yurishkuro , |
|
Hii @yurishkuro , I have resolved comments. Please review here! |
| serviceIndexPrefix = p.ServiceIndexOverride | ||
| } | ||
|
|
||
| useAliasMode := p.UseReadWriteAliases || hasSpanOverride || hasServiceOverride |
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.
| useAliasMode := p.UseReadWriteAliases || hasSpanOverride || hasServiceOverride | |
| useAliasMode := p.UseReadWriteAliases |
| useAliasMode := p.UseReadWriteAliases || hasSpanOverride || hasServiceOverride | ||
|
|
||
| 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]). |
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.
why are comments removed?
| } | ||
|
|
||
| var timeRangeFn TimeRangeIndexFn | ||
| if hasSpanOverride || hasServiceOverride { |
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.
spaghetti. Keep all index logic in TimeRangeIndicesFn
| hasSpanOverride := p.SpanIndexOverride != "" | ||
| if hasSpanOverride { | ||
| spanIndexPrefix = p.SpanIndexOverride | ||
| } |
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.
why is this needed? There is a very simple function in L133 if p.UseReadWriteAliases { which covers the overrides condition and where overrides can be applied instead of composing index name from pieces
| // SpanIndexOverride allows full control over the name of the index alias. | ||
| // Overrides any index prefix / suffix settings. | ||
| // Can only be used with UseReadWriteAliases=true. | ||
| SpanIndexOverride string `mapstructure:"span_index_override"` |
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.
how is this supposed to work with UseReadWriteAliases=true? When aliases are used the read and write indices are still different. So what does it mean to have a single SpanIndexOverride?
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.
When set, it replaces the prefix but read/write suffixes are still appended.
doesn't that go against the requirement expressed by the user?
Signed-off-by: Somil Jain <[email protected]>
|
Hii @yurishkuro , |
Signed-off-by: Somil Jain <[email protected]>
| hasSpanAliases := c.SpanReadAlias != "" || c.SpanWriteAlias != "" | ||
| hasServiceAliases := c.ServiceReadAlias != "" || c.ServiceWriteAlias != "" | ||
|
|
||
| if hasSpanAliases && (c.SpanReadAlias == "" || c.SpanWriteAlias == "") { | ||
| return errors.New("both span_read_alias and span_write_alias must be set together") | ||
| } | ||
|
|
||
| if hasServiceAliases && (c.ServiceReadAlias == "" || c.ServiceWriteAlias == "") { | ||
| return errors.New("both service_read_alias and service_write_alias must be set together") | ||
| } |
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.
The validation logic enforces paired read/write aliases (for spans and services separately), but doesn't enforce consistency between span and service aliases. This creates a potential scenario where a user configures only span aliases without service aliases, or vice versa.
Consider enhancing the validation to either:
- Require all four aliases to be set when any are used, or
- Document the expected behavior when only span aliases or only service aliases are configured
The current implementation in reader.go handles this case by using explicit aliases when provided and falling back to prefix patterns, but this mixed approach should be clearly documented if it's the intended behavior.
| hasSpanAliases := c.SpanReadAlias != "" || c.SpanWriteAlias != "" | |
| hasServiceAliases := c.ServiceReadAlias != "" || c.ServiceWriteAlias != "" | |
| if hasSpanAliases && (c.SpanReadAlias == "" || c.SpanWriteAlias == "") { | |
| return errors.New("both span_read_alias and span_write_alias must be set together") | |
| } | |
| if hasServiceAliases && (c.ServiceReadAlias == "" || c.ServiceWriteAlias == "") { | |
| return errors.New("both service_read_alias and service_write_alias must be set together") | |
| } | |
| hasSpanAliases := c.SpanReadAlias != "" || c.SpanWriteAlias != "" | |
| hasServiceAliases := c.ServiceReadAlias != "" || c.ServiceWriteAlias != "" | |
| hasAnyAliases := hasSpanAliases || hasServiceAliases | |
| if hasSpanAliases && (c.SpanReadAlias == "" || c.SpanWriteAlias == "") { | |
| return errors.New("both span_read_alias and span_write_alias must be set together") | |
| } | |
| if hasServiceAliases && (c.ServiceReadAlias == "" || c.ServiceWriteAlias == "") { | |
| return errors.New("both service_read_alias and service_write_alias must be set together") | |
| } | |
| if hasAnyAliases && (!hasSpanAliases || !hasServiceAliases) { | |
| return errors.New("all aliases (span_read_alias, span_write_alias, service_read_alias, service_write_alias) must be set together") | |
| } | |
Spotted by Graphite Agent
Is this helpful? React 👍 or 👎 to let us know.
|
Hii @yurishkuro |
|
Hii @yurishkuro |
Which problem is this PR solving?
#7223
Description of the changes
a. Add IndexSpanAlias and IndexServiceAlias config fields
b. Use explicit aliases when provided instead of prefix pattern
How was this change tested?
Through local testing
Checklist
jaeger:make lint testjaeger-ui:npm run lintandnpm run test