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

Expose cache ttl for es span writer index+service #2737

Merged
merged 3 commits into from
Jan 21, 2021

Conversation

necrolyte2
Copy link
Contributor

Which problem is this PR solving?

  • Unable to specify a cache duration for the service or index caches
  • Our use case requires that we can set these

Short description of the changes

  • Added ability to pass ttl duration for both service and index caches for the elastic spanstore writer
  • If not specified it will use the previous defaults of 12h and 48h

@necrolyte2 necrolyte2 requested a review from a team as a code owner January 21, 2021 13:36
Signed-off-by: Tyghe Vallard <vallardt@gmail.com>
Signed-off-by: Tyghe Vallard <tyghe.vallard@target.com>
@codecov
Copy link

codecov bot commented Jan 21, 2021

Codecov Report

Merging #2737 (b8afaff) into master (fe2a8ab) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2737      +/-   ##
==========================================
+ Coverage   95.83%   95.84%   +0.01%     
==========================================
  Files         217      217              
  Lines        9650     9656       +6     
==========================================
+ Hits         9248     9255       +7     
  Misses        331      331              
+ Partials       71       70       -1     
Impacted Files Coverage Δ
plugin/storage/es/spanstore/writer.go 100.00% <100.00%> (ø)
cmd/collector/app/server/zipkin.go 73.07% <0.00%> (-3.85%) ⬇️
cmd/query/app/static_handler.go 96.77% <0.00%> (+1.61%) ⬆️

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 fe2a8ab...b8afaff. Read the comment docs.

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.

  • please add test coverage
  • how would someone use this functionality? it is not exposed via CLI flags

Comment on lines 68 to 69
ServiceCacheDuration string
IndexCacheDuration string
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ServiceCacheDuration string
IndexCacheDuration string
ServiceCacheDuration time.Duration
IndexCacheDuration time.Duration

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You cannot check if a time.Duration is set or not since it would be 0, but you can check if a string is empty which is why I went the path I did there.

Anybody directly using the writer in their own code can use it and if later somebody wants to plumb in the ability for a flag for the apps to be able to set these could do that in a separate PR

I'm not sure how to test this since everything is in a private property and I cannot check if they are set in a test

Copy link
Member

Choose a reason for hiding this comment

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

What's wrong with 0? 0 is not a valid value for these parameters, so it works perfectly well as "unset" value.

Tests run in the private package namespace and can test those values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

0 is a valid value and would indicate caching forever so you still would not be able to differentiate from cache forever and not being set. Unless you want to assume that nobody would ever want to cache forever(which could be a valid thing, but I would rather be able to know for sure)

I did figure out how to test and just pushed those

Copy link
Member

@yurishkuro yurishkuro Jan 21, 2021

Choose a reason for hiding this comment

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

0 is a valid value and would indicate caching forever

Technically, for the LRU cache that is used under the hood, the ttl=0 is a valid param. But in the context of the specific caching scenarios here (index and service names) I do not believe 0 is a valid value, because these caches grow over time. So we can use 0 as "undefined". If people want to cache "forever" they can still do it by providing a very long duration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good. I can make the change

Copy link
Member

Choose a reason for hiding this comment

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

If you really want to support "undefined" then the other alternative is to use a pointer.

Signed-off-by: Tyghe Vallard <tyghe.vallard@target.com>
Signed-off-by: Tyghe Vallard <tyghe.vallard@target.com>
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.

Thanks!

@yurishkuro yurishkuro changed the title cache ttl for es span writer index+service Expose cache ttl for es span writer index+service Jan 21, 2021
@yurishkuro yurishkuro merged commit 2ff0a3d into jaegertracing:master Jan 21, 2021
bhiravabhatla pushed a commit to bhiravabhatla/jaeger that referenced this pull request Jan 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants