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

Make ES index name configurable #1009

Merged
merged 9 commits into from
Aug 22, 2018

Conversation

pavolloffay
Copy link
Member

@pavolloffay pavolloffay commented Aug 20, 2018

Resolves #799

Dependency job PR: jaegertracing/spark-dependencies#38

@pavolloffay
Copy link
Member Author

pavolloffay commented Aug 20, 2018

Prefix foo- creates foo-jaeger-<type>-<date>. The prefix is added directly to the name, we could add separator - or :.

We could make jaeger the default prefix. But I think it's better to keep fixed jaeger in the index name.

@codecov
Copy link

codecov bot commented Aug 21, 2018

Codecov Report

Merging #1009 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #1009   +/-   ##
======================================
  Coverage     100%    100%           
======================================
  Files         139     139           
  Lines        6399    6414   +15     
======================================
+ Hits         6399    6414   +15
Impacted Files Coverage Δ
plugin/storage/es/options.go 100% <100%> (ø) ⬆️
plugin/storage/es/dependencystore/storage.go 100% <100%> (ø) ⬆️
plugin/storage/es/spanstore/writer.go 100% <100%> (ø) ⬆️
plugin/storage/es/factory.go 100% <100%> (ø) ⬆️
plugin/storage/es/spanstore/reader.go 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 40a3cc9...ddd8ad0. Read the comment docs.

Copy link
Contributor

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

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

Looks sane to me, but I'm not up to speed with the storage parts.

@pavolloffay
Copy link
Member Author

I have changed a couple of things.

  • It 's backward compatible - if there is no index prefix it uses the same naming pattern jaeger-<type>..
  • if the index prefix is specified it adds : at the end. e.g. prefix foo creates foo:jaeger-<type>..

@pavolloffay
Copy link
Member Author

@yurishkuro @black-adder @vprithvi would you like to have a look?

func indexName(date time.Time) string {
return dependencyIndexPrefix + date.UTC().Format("2006-01-02")
func indexName(prefix string, date time.Time) string {
return prefix + dependencyIndex + date.UTC().Format("2006-01-02")
Copy link
Member

Choose a reason for hiding this comment

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

nit: we're doing this for every span write? lots of GC pressure. At least we can pre-concatenate the prefix with the constant string in the constructor. Ideally we would cache the mapping from date (sans time) to string.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's per span write. Will update not sure if the cache would make a significant difference

@@ -8,16 +8,23 @@

def main():
if len(sys.argv) == 1:
print('USAGE: [TIMEOUT=(default 120)] %s NUM_OF_DAYS HOSTNAME[:PORT] ...' % sys.argv[0])
print('USAGE: [TIMEOUT=(default 120)] [INDEX_PREFIX=(default \'\')] %s NUM_OF_DAYS HOSTNAME[:PORT] ...' % sys.argv[0])
Copy link
Member

Choose a reason for hiding this comment

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

could just say default ""

@@ -74,16 +74,16 @@ func (f *Factory) Initialize(metricsFactory metrics.Factory, logger *zap.Logger)
// CreateSpanReader implements storage.Factory
func (f *Factory) CreateSpanReader() (spanstore.Reader, error) {
cfg := f.primaryConfig
return esSpanStore.NewSpanReader(f.primaryClient, f.logger, cfg.GetMaxSpanAge(), f.metricsFactory), nil
return esSpanStore.NewSpanReader(f.primaryClient, f.logger, cfg.GetMaxSpanAge(), f.metricsFactory, cfg.GetIndexPrefix()), nil
Copy link
Member

Choose a reason for hiding this comment

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

I think this reached the point of needing its own type SpanReaderParams struct{}

Copy link
Member Author

Choose a reason for hiding this comment

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

I will keep the current form for the simplicity. If it grows we can refactor

flagSet.String(
nsConfig.namespace+suffixIndexPrefix,
nsConfig.IndexPrefix,
"The prefix of Jaeger indices. For example \"production\" creates \"production:jaeger-*\". (Default unset)")
Copy link
Member

Choose a reason for hiding this comment

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

nit: Optional prefix for index names. (don't need "Default unset")

@@ -147,33 +152,33 @@ func (s *SpanReader) unmarshalJSONSpan(esSpanRaw *elastic.SearchHit) (*jModel.Sp
}

// Returns the array of indices that we need to query, based on query params
func findIndices(prefix string, startTime time.Time, endTime time.Time) []string {
func (s *SpanReader) findIndices(indexName string, startTime time.Time, endTime time.Time) []string {
Copy link
Member

Choose a reason for hiding this comment

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

nit: change method name, e.g. indicesForTimeRange

It allow simple multitenancy - index per tenant or k8s namespace.

Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
@pavolloffay pavolloffay merged commit 75af597 into jaegertracing:master Aug 22, 2018
@ghost ghost removed the review label Aug 22, 2018
isaachier pushed a commit to isaachier/jaeger that referenced this pull request Sep 3, 2018
* Make ES index name configurable

It allow simple multitenancy - index per tenant or k8s namespace.

Signed-off-by: Pavol Loffay <ploffay@redhat.com>

* docs

Signed-off-by: Pavol Loffay <ploffay@redhat.com>

* Fix comment

Signed-off-by: Pavol Loffay <ploffay@redhat.com>

* index prefix

Signed-off-by: Pavol Loffay <ploffay@redhat.com>

* Fix index cleaner and add prefix delimiter

Signed-off-by: Pavol Loffay <ploffay@redhat.com>

* Fix dependency storage

Signed-off-by: Pavol Loffay <ploffay@redhat.com>

* Fmt and help message

Signed-off-by: Pavol Loffay <ploffay@redhat.com>

* increase converage

Signed-off-by: Pavol Loffay <ploffay@redhat.com>

* review fixes

Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants