Skip to content
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

[Jaeger-V2] Add configurable index data layout and rollover frequency #5790

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

JaredTan95
Copy link

@JaredTan95 JaredTan95 commented Jul 30, 2024

make configure index datalayout and frequency in jaeger-v2

I think this way is a bit repetitive, as I am trying to contribute for the first time, there are better ways to achieve please guide~

@JaredTan95 JaredTan95 requested a review from a team as a code owner July 30, 2024 15:06
@JaredTan95 JaredTan95 force-pushed the configure-index-daltalayout-and-frequency branch from 5e66765 to f77bc5b Compare July 30, 2024 15:07
@JaredTan95 JaredTan95 changed the title [Jaeger-V2] configurable index daltalayout and frequency [Jaeger-V2] configurable index datalayout and frequency Jul 30, 2024
@JaredTan95 JaredTan95 changed the title [Jaeger-V2] configurable index datalayout and frequency [Jaeger-V2] configurable index data layout and frequency Jul 30, 2024
@JaredTan95 JaredTan95 changed the title [Jaeger-V2] configurable index data layout and frequency [Jaeger-V2] configurable index data layout and rollover frequency Jul 30, 2024
@JaredTan95 JaredTan95 force-pushed the configure-index-daltalayout-and-frequency branch from 0c67510 to d203d55 Compare August 1, 2024 02:59
pkg/es/config/config.go Outdated Show resolved Hide resolved
@JaredTan95 JaredTan95 force-pushed the configure-index-daltalayout-and-frequency branch 2 times, most recently from 01544c8 to 05d35bc Compare August 2, 2024 06:02
pkg/es/config/config.go Outdated Show resolved Hide resolved
pkg/es/config/config.go Outdated Show resolved Hide resolved
plugin/storage/es/factory.go Outdated Show resolved Hide resolved
plugin/storage/es/factory.go Outdated Show resolved Hide resolved
Copy link

codecov bot commented Aug 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.81%. Comparing base (9bdd368) to head (b712a72).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5790      +/-   ##
==========================================
- Coverage   96.82%   96.81%   -0.01%     
==========================================
  Files         345      345              
  Lines       16518    16570      +52     
==========================================
+ Hits        15993    16043      +50     
- Misses        339      340       +1     
- Partials      186      187       +1     
Flag Coverage Δ
badger_v1 8.02% <0.00%> (-0.01%) ⬇️
badger_v2 1.85% <0.00%> (+0.02%) ⬆️
cassandra-3.x-v1 16.57% <0.00%> (-0.05%) ⬇️
cassandra-3.x-v2 1.78% <0.00%> (+0.02%) ⬆️
cassandra-4.x-v1 16.57% <0.00%> (-0.05%) ⬇️
cassandra-4.x-v2 1.78% <0.00%> (+0.02%) ⬆️
elasticsearch-6.x-v1 19.08% <90.34%> (+0.29%) ⬆️
elasticsearch-7.x-v1 19.14% <90.34%> (+0.30%) ⬆️
elasticsearch-8.x-v1 19.35% <90.34%> (+0.30%) ⬆️
elasticsearch-8.x-v2 1.85% <0.00%> (+0.03%) ⬆️
grpc_v1 9.47% <0.00%> (-0.02%) ⬇️
grpc_v2 ?
kafka-v1 9.73% <0.00%> (-0.02%) ⬇️
kafka-v2 1.85% <0.00%> (+0.02%) ⬆️
memory_v2 1.85% <0.00%> (+0.03%) ⬆️
opensearch-1.x-v1 19.20% <90.34%> (+0.31%) ⬆️
opensearch-2.x-v1 19.20% <90.34%> (+0.30%) ⬆️
opensearch-2.x-v2 ?
tailsampling-processor 0.49% <0.00%> (+0.03%) ⬆️
unittests 95.31% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good, thanks for doing this.

cmd/esmapping-generator/app/flags.go Outdated Show resolved Hide resolved
pkg/es/config/config.go Outdated Show resolved Hide resolved
pkg/es/config/config.go Outdated Show resolved Hide resolved
pkg/es/config/config.go Outdated Show resolved Hide resolved
plugin/storage/es/mappings/mapping.go Outdated Show resolved Hide resolved
plugin/storage/es/options.go Outdated Show resolved Hide resolved
@JaredTan95 JaredTan95 force-pushed the configure-index-daltalayout-and-frequency branch from e89accf to 422a678 Compare August 7, 2024 13:53
@JaredTan95 JaredTan95 force-pushed the configure-index-daltalayout-and-frequency branch from 9f49a23 to 8d42129 Compare August 8, 2024 08:35
@JaredTan95 JaredTan95 force-pushed the configure-index-daltalayout-and-frequency branch from ad01a13 to 8d3ebb6 Compare August 13, 2024 10:53
@yurishkuro yurishkuro changed the title [Jaeger-V2] configurable index data layout and rollover frequency [Jaeger-V2] Add configurable index data layout and rollover frequency Sep 1, 2024
@yurishkuro yurishkuro force-pushed the configure-index-daltalayout-and-frequency branch from a33a5ac to 25d332c Compare September 1, 2024 19:51
@yurishkuro
Copy link
Member

Did you do a manual merge main? You should never do that, either do a rebase main or use GitHub Update Branch. Right now the branch is a mess with a whole bunch of other commits and the DCO linter is going nuts.

One brute force way to fix it is to (a) zip all the files in a repo, (b) recreate the branch off main head, (c) unzip the files back,
(d) commit (it's ok to subsume my commits), (e) force-push the local branch to the existing remote branch.

@JaredTan95 JaredTan95 force-pushed the configure-index-daltalayout-and-frequency branch from 3f164a4 to f2e1416 Compare September 2, 2024 12:00
@JaredTan95
Copy link
Author

JaredTan95 commented Sep 2, 2024

Did you do a manual merge main? You should never do that, either do a rebase main or use GitHub Update Branch. Right now the branch is a mess with a whole bunch of other commits and the DCO linter is going nuts.

One brute force way to fix it is to (a) zip all the files in a repo, (b) recreate the branch off main head, (c) unzip the files back, (d) commit (it's ok to subsume my commits), (e) force-push the local branch to the existing remote branch.

yes, I did git reabse main locally, maybe a merge conflict, and I was going to do it after you had reviewed it

Signed-off-by: Jared Tan <jian.tan@daocloud.io>
@JaredTan95 JaredTan95 force-pushed the configure-index-daltalayout-and-frequency branch from f2e1416 to 47c0a63 Compare September 2, 2024 12:14
pkg/es/config/config.go Outdated Show resolved Hide resolved
Signed-off-by: Jared Tan <jian.tan@daocloud.io>
@yurishkuro
Copy link
Member

OS/ES tests specifically are failing, most likely related to your changes.

@yurishkuro
Copy link
Member

for instance

🚧 🚧 🚧 jaeger-v2 error logs:
  2024/09/03 17:08:50 application version: git-commit=, git-version=, build-date=
  Error: failed to get config: cannot unmarshal the configuration: decoding failed due to the following error(s):
  
  error decoding 'extensions': error reading configuration for "jaeger_storage": decoding failed due to the following error(s):
  
  error decoding 'backends[another_storage]': decoding failed due to the following error(s):
  
  'elasticsearch.indices.spans' has invalid keys: index_prefix
  error decoding 'backends[some_storage]': decoding failed due to the following error(s):
  
  'elasticsearch.indices.spans' has invalid keys: index_prefix
  'elasticsearch.indices.services' has invalid keys: index_prefix
  'elasticsearch.indices.dependencies' has invalid keys: index_prefix
  2024/09/03 17:08:50 failed to get config: cannot unmarshal the configuration: decoding failed due to the following error(s):

@JaredTan95
Copy link
Author

for instance


🚧 🚧 🚧 jaeger-v2 error logs:

  2024/09/03 17:08:50 application version: git-commit=, git-version=, build-date=

  Error: failed to get config: cannot unmarshal the configuration: decoding failed due to the following error(s):

  

  error decoding 'extensions': error reading configuration for "jaeger_storage": decoding failed due to the following error(s):

  

  error decoding 'backends[another_storage]': decoding failed due to the following error(s):

  

  'elasticsearch.indices.spans' has invalid keys: index_prefix

  error decoding 'backends[some_storage]': decoding failed due to the following error(s):

  

  'elasticsearch.indices.spans' has invalid keys: index_prefix

  'elasticsearch.indices.services' has invalid keys: index_prefix

  'elasticsearch.indices.dependencies' has invalid keys: index_prefix

  2024/09/03 17:08:50 failed to get config: cannot unmarshal the configuration: decoding failed due to the following error(s):

ok,i will check it soon

Signed-off-by: Jared Tan <jian.tan@daocloud.io>
@JaredTan95 JaredTan95 force-pushed the configure-index-daltalayout-and-frequency branch from 2f587d5 to 037f479 Compare September 6, 2024 08:02
@yurishkuro
Copy link
Member

ES v7 failed with

=== RUN   TestIndexRollover_CreateIndicesWithILM/SetPolicyName/WithAdaptiveSampling
Error: template: mapping:5:8: executing "mapping" at <.IndexPrefix>: can't evaluate field IndexPrefix in type *mappings.IndexTemplateOptions

Signed-off-by: Jared Tan <jian.tan@daocloud.io>
@yurishkuro
Copy link
Member

rollover tests fail - it looks like somewhere the prefix is not being respected.

JaredTan95 and others added 5 commits September 8, 2024 14:58
Signed-off-by: Jared Tan <jian.tan@daocloud.io>
Signed-off-by: Jared Tan <jian.tan@daocloud.io>
Signed-off-by: Yuri Shkuro <github@ysh.us>
another_storage:
elasticsearch:
index_prefix: "jaeger-archive"
indices:
spans:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: is the services index being built at all when the storage is in the archive mode? I don't think it should be, but in this configuration services.prefix: "jaeger-main" would be the default, and the archive storage is not told in any way that it is indeed archive.

IndexPrefix: cfg.IndexPrefix,
IndexDateLayout: cfg.IndexDateLayoutDependencies,
IndexPrefix: cfg.Indices.Dependencies.Prefix,
IndexDateLayout: cfg.Indices.Dependencies.RolloverFrequency,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like a bug: RolloverFrequency -> DateLayout. Please re-check everywhere.

type IndexTemplateOptions struct {
UseILM bool
ILMPolicyName string
config.IndexOptions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I would recommend against embedding the whole struct, because it makes the templates tightly coupled with the configuration. E.g. it looks like only a couple of fields are actually used in the templates, prefix and priority, so I would define them explicitly in IndexTemplateOptions and copy from IndexOptions as needed. This way we won't have to change the templates just because we changed the config struct.

@@ -20,10 +20,35 @@ extensions:
backends:
some_storage:
elasticsearch:
index_prefix: "jaeger-main"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: we may want to rethink if we still want a single field in the config for index prefix, which would apply if the individual index options didn't override it explicitly. This would simplify the configuration while maintaining the flexibility.

Comment on lines +127 to +128
if prefix != "" {
return prefix + indexPrefixSeparator + index
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking at mapping.go I think this should be a bit smarter, e.g.

Suggested change
if prefix != "" {
return prefix + indexPrefixSeparator + index
if prefix != "" {
if !prefix.endsWith(indexPrefixSeparator) { prefix += indexPrefixSeparator }
return prefix + index

if prefix != "" {
prefix += indexPrefixSeparator
func getSpanAndServiceIndexFn(archive, useReadWriteAliases bool, spanIndexOpts, serviceIndexOpts cfg.IndexOptions) spanAndServiceIndexFn {
if spanIndexOpts.Prefix != "" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar to above

Suggested change
if spanIndexOpts.Prefix != "" {
if spanIndexOpts.Prefix != "" && !strings.HasSuffix(spanIndexOpts.Prefix, indexPrefixSeparator) {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we do this in multiple places I would extract into a single function. Ideally these kinds of adjustments should be done very early after parsing the config, not spread out across many places in the code. It could be even a helper function on the IndexOptions struct, e.g.

func (o IndexOptions) FullIndexName(name string) {
  if o.Prefix == "" {
    return name
  }
  if strings.HasSuffix(o.Prefix. indexPrefixSeparator) {
    return o.Prefix + name
  }
  return o.Prefix + indexPrefixSeparator + name
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:exprimental Change to an experimental part of the code storage/elasticsearch v2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants