fix(repository-elasticsearch): sanitize orgId/envId per OTel data stream rules#17246
Open
remibaptistegio wants to merge 1 commit into
Open
fix(repository-elasticsearch): sanitize orgId/envId per OTel data stream rules#17246remibaptistegio wants to merge 1 commit into
remibaptistegio wants to merge 1 commit into
Conversation
…eam rules The OTel collector elasticsearchexporter (mapping.mode: otel) runs each data stream component through sanitizeDataStreamField before writing — disallowed runes (including the hyphen) become '_' and the result is lowercased. The Gravitee-side lookup used the generic IndexNameUtils.format which only lowercases, so any org/env id with a hyphen produced a different index name on read than the collector wrote, and every query missed. Adds OtelDataStreamIndexUtils mirroring the exporter's algorithm (see opentelemetry-collector-contrib/exporter/elasticsearchexporter/ data_stream_router.go) and routes both ElasticsearchTracingRepository and ElasticsearchOtelLogRepository through it. Always applies the dataset rule (the stricter superset over namespace) to every placeholder, regardless of position in the template — losing cosmetic hyphens in namespace-position values is preferable to miscategorising a placeholder.
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Issue
Hyphenated org / env ids (e.g.
my-org-1,prod-eu) silently returned zero results from the OTel-mode tracing + logs Elasticsearch lookups.Description
The OTel collector's
elasticsearchexporter(inmapping.mode: otel) runs each data-stream component throughsanitizeDataStreamFieldbefore writing — disallowed runes (including the hyphen) become_, the rest is lowercased, truncated to 100 bytes. The Gravitee-side lookup used the genericIndexNameUtils.formatwhich only lowercases, so any org / env id with a hyphen produced a different index name on read than the collector had written, and every query missed.This PR adds
OtelDataStreamIndexUtilsmirroring the exporter's algorithm and routes bothElasticsearchTracingRepositoryandElasticsearchOtelLogRepositorythrough it.Design note: always applies the dataset rule (the stricter superset over namespace) to every placeholder regardless of position in the template. Losing potential cosmetic hyphens in a namespace-position placeholder is preferable to miscategorising the position; both sides agree on the substitution and the look-up works.
Additional context
opentelemetry-collector-contrib/exporter/elasticsearchexporter/data_stream_router.go— seesanitizeDataStreamField,disallowedDatasetRunes,disallowedNamespaceRunes,maxDataStreamBytes.elastic/apm-dataimplements the same sanitization (verified via source), so this also works against Elastic Cloud managed OTLP intake.OtelDataStreamIndexUtils(hyphens, mixed case, full disallowed-rune set, structural separators preserved, multi-substitution, 100-byte truncation, edge cases).test-org→test_org).