Skip to content

Conversation

pipiland2612
Copy link
Contributor

Which problem is this PR solving?

Description of the changes

  • Add implementation for GetLatencies method in metricstore/elasticsearch/reader.go
  • Add corresponding unit tests
  • Refactor code that duplicates with getCallRate

How was this change tested?

  • make lint test

Proof of this new feature

  • Check out my own repository https://github.com/pipiland2612/spm-elasticsearch
  • When I run this setup with the spanmetricsconnector enabled, along with Prometheus and Elasticsearch as metrics backends, the results value from Prometheus quite aligned with what I see in Jaeger UI (although the trends appears to be different at first because Prometheus zoom in the value-axis)

Screenshot 2025-07-02 at 22 17 40
Screenshot 2025-07-02 at 22 17 56
Screenshot 2025-07-02 at 22 18 08
Screenshot 2025-07-02 at 22 18 16

Screenshot 2025-07-02 at 22 20 56
Screenshot 2025-07-02 at 22 21 22
Screenshot 2025-07-02 at 22 21 31
Screenshot 2025-07-02 at 22 21 43

Screenshot 2025-07-02 at 22 18 56
Screenshot 2025-07-02 at 22 19 05
Screenshot 2025-07-02 at 22 19 14
Screenshot 2025-07-02 at 22 19 38

Checklist

Signed-off-by: pipiland2612 <nguyen.t.dang.minh@gmail.com>
Signed-off-by: pipiland2612 <nguyen.t.dang.minh@gmail.com>
Signed-off-by: pipiland2612 <nguyen.t.dang.minh@gmail.com>
Signed-off-by: pipiland2612 <nguyen.t.dang.minh@gmail.com>
Signed-off-by: pipiland2612 <nguyen.t.dang.minh@gmail.com>
Signed-off-by: pipiland2612 <nguyen.t.dang.minh@gmail.com>
Signed-off-by: pipiland2612 <nguyen.t.dang.minh@gmail.com>
Signed-off-by: pipiland2612 <nguyen.t.dang.minh@gmail.com>
@pipiland2612
Copy link
Contributor Author

During testing, I found a bug in JaegerUI when calculating the mean of getLatencies or getCallRate. That is, the denominator when calculating also includes the count for NaN values, thus undervalue the mean.

Copy link

codecov bot commented Jul 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.15%. Comparing base (95285ec) to head (c85a7f5).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7290      +/-   ##
==========================================
- Coverage   96.16%   96.15%   -0.01%     
==========================================
  Files         374      374              
  Lines       22696    22750      +54     
==========================================
+ Hits        21825    21876      +51     
- Misses        657      659       +2     
- Partials      214      215       +1     
Flag Coverage Δ
badger_v1 9.03% <ø> (ø)
badger_v2 1.77% <0.00%> (-0.01%) ⬇️
cassandra-4.x-v1-manual 11.93% <ø> (ø)
cassandra-4.x-v2-auto 1.77% <0.00%> (-0.01%) ⬇️
cassandra-4.x-v2-manual 1.77% <0.00%> (-0.01%) ⬇️
cassandra-5.x-v1-manual 11.93% <ø> (ø)
cassandra-5.x-v2-auto 1.77% <0.00%> (-0.01%) ⬇️
cassandra-5.x-v2-manual 1.77% <0.00%> (-0.01%) ⬇️
elasticsearch-6.x-v1 16.69% <ø> (ø)
elasticsearch-7.x-v1 16.73% <ø> (ø)
elasticsearch-8.x-v1 16.89% <ø> (ø)
elasticsearch-8.x-v2 1.77% <0.00%> (-0.01%) ⬇️
grpc_v1 10.43% <ø> (ø)
grpc_v2 1.77% <0.00%> (-0.01%) ⬇️
kafka-3.x-v1 9.35% <ø> (ø)
kafka-3.x-v2 1.77% <0.00%> (-0.01%) ⬇️
memory_v2 1.77% <0.00%> (-0.01%) ⬇️
opensearch-1.x-v1 16.78% <ø> (ø)
opensearch-2.x-v1 16.78% <ø> (ø)
opensearch-2.x-v2 1.77% <0.00%> (-0.01%) ⬇️
query 1.77% <0.00%> (-0.01%) ⬇️
tailsampling-processor 0.49% <0.00%> (-0.01%) ⬇️
unittests 95.08% <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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Signed-off-by: pipiland2612 <nguyen.t.dang.minh@gmail.com>
@pipiland2612
Copy link
Contributor Author

closes and reopens pr to rerun codecov

@yurishkuro yurishkuro added the changelog:exprimental Change to an experimental part of the code label Jul 2, 2025
@pipiland2612 pipiland2612 requested a review from yurishkuro July 4, 2025 08:50
Signed-off-by: pipiland2612 <nguyen.t.dang.minh@gmail.com>
Signed-off-by: pipiland2612 <nguyen.t.dang.minh@gmail.com>
pipiland2612 and others added 3 commits July 4, 2025 21:39
Signed-off-by: pipiland2612 <nguyen.t.dang.minh@gmail.com>
Signed-off-by: pipiland2612 <nguyen.t.dang.minh@gmail.com>
Signed-off-by: pipiland2612 <nguyen.t.dang.minh@gmail.com>
@pipiland2612 pipiland2612 requested a review from yurishkuro July 4, 2025 19:32
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.

could you split refactoring changes to GetRates into a separate smaller PR?

@pipiland2612
Copy link
Contributor Author

Alright, that makes sense to first refactor changes related to GetCallRate then we can continue working with this PR.

@pipiland2612
Copy link
Contributor Author

Refactoring at #7295

pipiland2612 and others added 4 commits July 5, 2025 20:58
Signed-off-by: pipiland2612 <nguyen.t.dang.minh@gmail.com>
Signed-off-by: pipiland2612 <nguyen.t.dang.minh@gmail.com>
@pipiland2612
Copy link
Contributor Author

pipiland2612 commented Jul 5, 2025

Hi @yurishkuro, I have merge with main and resolves conflict. I have also remove the indirection from GetLatencies. It should be good now! Thanks for your feedbacks.

@pipiland2612 pipiland2612 requested a review from yurishkuro July 5, 2025 19:11
Signed-off-by: Yuri Shkuro <github@ysh.us>
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.

potential future refactoring suggestions:

  • you reuse dateHistAggName constant in two files, that's a sign of abstraction leak
  • it might be useful to create another file query.go which has a struct that deals with constructing queries and retrieving the results. It would know about things like dateHistAggName, while neither Reader nor Transformer would have to know, they would just delegate to that Query struct.
  • The separation of responsibilities between Reader and Transformer is unclear. Retrieving data from ES results should be part of the Query. Transformer then transforms those results. But you have a lot of business logic in the Reader which also does transformation. Please try to define (write struct comments) very clear definition of what each struct is responsible for.

@yurishkuro yurishkuro enabled auto-merge July 6, 2025 16:26
@pipiland2612
Copy link
Contributor Author

pipiland2612 commented Jul 6, 2025

Hi @yurishkuro, really thank you for your time for my pull request. For the refactoring, I will definitely invest time in it and soon make a follow up pr soon!

auto-merge was automatically disabled July 6, 2025 16:40

Head branch was pushed to by a user without write access

Signed-off-by: pipiland2612 <nguyen.t.dang.minh@gmail.com>
@pipiland2612
Copy link
Contributor Author

Hi @yurishkuro, I have added test to increse coverage to over 95%. Can you merge it again? Thank you for your time!

@yurishkuro yurishkuro added this pull request to the merge queue Jul 6, 2025
Merged via the queue into jaegertracing:main with commit 762eaad Jul 6, 2025
60 checks passed
@pipiland2612 pipiland2612 deleted the GetLatencies branch July 6, 2025 18:13
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.

2 participants