Skip to content

Conversation

pipiland2612
Copy link
Contributor

@pipiland2612 pipiland2612 commented Jul 26, 2025

Which problem is this PR solving?

Description of the changes

  • Add python script to generate metrics_summary
  • Add action to Generate metrics summary

How was this change tested?

Checklist

@pipiland2612 pipiland2612 requested a review from a team as a code owner July 26, 2025 08:15
@pipiland2612 pipiland2612 requested a review from albertteoh July 26, 2025 08:15
Copy link

codecov bot commented Jul 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.46%. Comparing base (2bbb1e4) to head (68451d0).
⚠️ Report is 17 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #7376       +/-   ##
===========================================
+ Coverage   20.65%   96.46%   +75.81%     
===========================================
  Files         201      375      +174     
  Lines       12834    22958    +10124     
===========================================
+ Hits         2651    22147    +19496     
+ Misses       9995      613     -9382     
- Partials      188      198       +10     
Flag Coverage Δ
badger_v1 9.06% <ø> (-0.06%) ⬇️
badger_v2 1.71% <ø> (-0.02%) ⬇️
cassandra-4.x-v1-manual 11.76% <ø> (?)
cassandra-4.x-v2-auto 1.70% <ø> (?)
cassandra-4.x-v2-manual 1.70% <ø> (?)
cassandra-5.x-v1-manual 11.76% <ø> (?)
cassandra-5.x-v2-auto 1.70% <ø> (?)
cassandra-5.x-v2-manual 1.70% <ø> (?)
elasticsearch-6.x-v1 16.71% <ø> (?)
elasticsearch-7.x-v1 16.75% <ø> (?)
elasticsearch-8.x-v1 16.89% <ø> (?)
elasticsearch-8.x-v2 1.80% <ø> (?)
elasticsearch-9.x-v2 1.71% <ø> (?)
grpc_v1 10.29% <ø> (-0.07%) ⬇️
grpc_v2 1.71% <ø> (-0.02%) ⬇️
kafka-3.x-v1 9.74% <ø> (+0.46%) ⬆️
kafka-3.x-v2 1.71% <ø> (?)
memory_v2 1.71% <ø> (?)
opensearch-1.x-v1 16.80% <ø> (?)
opensearch-2.x-v1 16.80% <ø> (?)
opensearch-2.x-v2 1.71% <ø> (?)
opensearch-3.x-v2 1.71% <ø> (?)
query 1.71% <ø> (-0.02%) ⬇️
tailsampling-processor 0.47% <ø> (?)
unittests 95.44% <ø> (?)

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.

@pipiland2612
Copy link
Contributor Author

Hi @yurishkuro, do you have any idea to test if this action actually works ?

@yurishkuro yurishkuro added the changelog:ci Change related to continuous integration / testing label Jul 26, 2025
@pipiland2612
Copy link
Contributor Author

pipiland2612 commented Jul 26, 2025

I don't know why it's not reporting anything, still debugging

@pipiland2612
Copy link
Contributor Author

Let's wait to see if it actually reporting

@pipiland2612
Copy link
Contributor Author

Let's wait to see if it actually reporting

Ok, nothing is happening :-)

@yurishkuro
Copy link
Member

The run is here https://github.com/jaegertracing/jaeger/actions/runs/16543493108/job/46788110217?pr=7376

Doesn't say if any commands were executed - if they were in a script with set -ex then we would see execution logs

@pipiland2612 pipiland2612 force-pushed the post_metrics_summary branch from 56e5df3 to f3d0172 Compare July 27, 2025 09:27
@pipiland2612 pipiland2612 force-pushed the post_metrics_summary branch from d1604a5 to 1f4f283 Compare July 27, 2025 09:43
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

Why do you try to comment on issue and not on PR?

There are some popular gh actions for posting comments and I recall seeing a notice there that for forks the permissions are insufficient (since our main gh token is not accessible when running ci on a pr from a fork - the pr can use that to steal the secrets). Did you research the proper way for of doing that?

Indeed let me try researching it.

@pipiland2612
Copy link
Contributor Author

Ah, I see the current workflow is indeed a pull request

on:
  merge_group:
  push:
    branches: [main]

  pull_request:
    branches: [main]

I think we would need another separate workflow to upload the comment

@yurishkuro
Copy link
Member

Some thougts

  • https://github.com/thollander/actions-comment-pull-request is designed to comment on pull requests, including using the "upsert" behavior. It probably makes your JS script unnecessary
  • It also warns about not having token permissions when running on a fork and recommends using pull_request_target even instead of pull_request. However, it is unsafe to run code from PR branch in pull_request_target mode, so if we go this route we will need to merge your action to main branch first.
  • On a related note, I think it would simplify the whole setup if we didn't have the diffing / summary logic spread out across workflows. I can imagine the following setup:
    • The code from PR runs e2e tests and only uploads the metrics files artifacts
    • Then a separate action via pull_request_target event runs with primary repo context (token with permissions to post). This action no longer needs access to code from the PR, it only needs to download the metrics artifacts, also download same ones from the main branch, do the diffs, compose a report, and post a comment.
    • Such setup will allow to consolidate most of the diffing / reporting code in one place (e2e workflows only scrape metrics and upload them), and it will make the diffing / reporting code much easier to test locally since all it needs it two directories with main & PR metric dumps.

BTW, I appreciate you working on this, it's one of those gnarly issues that are not easy to get right but pay off in the long run as a protection against bugs.

@pipiland2612
Copy link
Contributor Author

pipiland2612 commented Jul 27, 2025

  • On a related note, I think it would simplify the whole setup if we didn't have the diffing / summary logic spread out across workflows. I can imagine the following setup:

    • The code from PR runs e2e tests and only uploads the metrics files artifacts
    • Then a separate action via pull_request_target event runs with primary repo context (token with permissions to post). This action no longer needs access to code from the PR, it only needs to download the metrics artifacts, also download same ones from the main branch, do the diffs, compose a report, and post a comment.
    • Such setup will allow to consolidate most of the diffing / reporting code in one place (e2e workflows only scrape metrics and upload them), and it will make the diffing / reporting code much easier to test locally since all it needs it two directories with main & PR metric dumps.

Yup, I agree with this, the current setup is actually really complex and not intuitive, it will be hard to maintain and develop

@pipiland2612
Copy link
Contributor Author

pipiland2612 commented Jul 28, 2025

Hi @yurishkuro, I'd propose that we should keep the current work: calculate the diff for every single e2e test, because this is much more easier (it is related to id and other thing as well). Then we can aggregate download all the diff artifact together and make a summary, post a PR comment.

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

Why is my newly-added workflow is not running ?

@pipiland2612 pipiland2612 marked this pull request as draft July 28, 2025 08:54
@pipiland2612 pipiland2612 reopened this Jul 28, 2025
@yurishkuro
Copy link
Member

It's not running for two reasons:

  1. as it's trigger is workflow-run you need to actually call it explicitly from all-e2e
  2. Even if you call it now the code sync in that workflow is from main where it does not exist yet.

@pipiland2612
Copy link
Contributor Author

It's not running for two reasons:

  1. as it's trigger is workflow-run you need to actually call it explicitly from all-e2e
  2. Even if you call it now the code sync in that workflow is from main where it does not exist yet.

Do you have any idea to test it for now ?

@yurishkuro
Copy link
Member

Do you have any idea to test it for now ?

We have two functions we want to test, one is the processing of the metrics results and generation of a report, and the other is posting that report as a comment. Only the second one requires token permissions. So we can merge the PR with just the first part, still happening in the regular workflows without PR comments. Then you can separately test a comment-posting workflow. And finally we'd add them together.

@pipiland2612
Copy link
Contributor Author

pipiland2612 commented Jul 30, 2025

Do you have any idea to test it for now ?

We have two functions we want to test, one is the processing of the metrics results and generation of a report, and the other is posting that report as a comment. Only the second one requires token permissions. So we can merge the PR with just the first part, still happening in the regular workflows without PR comments. Then you can separately test a comment-posting workflow. And finally we'd add them together.

Hi @yurishkuro, so I think this pull request will solve the first part, but how can we test the first part actually ?

Signed-off-by: pipiland2612 <nguyen.t.dang.minh@gmail.com>
Signed-off-by: pipiland2612 <nguyen.t.dang.minh@gmail.com>
@pipiland2612 pipiland2612 marked this pull request as ready for review July 30, 2025 13:31
@pipiland2612 pipiland2612 changed the title [WIP] [CI] Add metrics summary action [CI] Add metrics summary action Jul 30, 2025
@pipiland2612
Copy link
Contributor Author

pipiland2612 commented Jul 31, 2025

Hi @yurishkuro, can you review this ?

Signed-off-by: Yuri Shkuro <github@ysh.us>
@yurishkuro yurishkuro enabled auto-merge August 1, 2025 01:05
Comment on lines +57 to +61
if python3 ./scripts/e2e/compare_metrics.py --file1 ./.metrics/${{ inputs.snapshot }}.txt --file2 ./.metrics/baseline_${{ inputs.snapshot }}.txt --output ./.metrics/diff_${{ inputs.snapshot }}.txt; then
echo "No differences found in metrics"
else
echo "🛑 Differences found in metrics"
echo "has_diff=true" >> $GITHUB_OUTPUT
Copy link
Contributor

Choose a reason for hiding this comment

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

The error handling logic has been changed in this PR. Previously, the script would exit with code 1 when differences were found, and the workflow would fail. Now, the script returns exit code 0 for no differences and exit code 1 for differences found, with the has_diff output variable being set only in the latter case.

This approach works for the current use case, but consider handling other potential failure modes. If the script fails for reasons other than finding differences (e.g., file not found, permission issues), the has_diff output won't be set, but the step will still succeed due to continue-on-error: true. This could mask actual errors in the comparison process.

Consider adding more robust error handling to distinguish between "differences found" and "script execution failed for other reasons".

Suggested change
if python3 ./scripts/e2e/compare_metrics.py --file1 ./.metrics/${{ inputs.snapshot }}.txt --file2 ./.metrics/baseline_${{ inputs.snapshot }}.txt --output ./.metrics/diff_${{ inputs.snapshot }}.txt; then
echo "No differences found in metrics"
else
echo "🛑 Differences found in metrics"
echo "has_diff=true" >> $GITHUB_OUTPUT
exit_code=0
python3 ./scripts/e2e/compare_metrics.py --file1 ./.metrics/${{ inputs.snapshot }}.txt --file2 ./.metrics/baseline_${{ inputs.snapshot }}.txt --output ./.metrics/diff_${{ inputs.snapshot }}.txt || exit_code=$?
if [ $exit_code -eq 0 ]; then
echo "No differences found in metrics"
elif [ $exit_code -eq 1 ]; then
echo "🛑 Differences found in metrics"
echo "has_diff=true" >> $GITHUB_OUTPUT
else
echo "❌ Error executing comparison script (exit code: $exit_code)"
echo "has_diff=true" >> $GITHUB_OUTPUT
exit $exit_code
fi

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

@yurishkuro yurishkuro added this pull request to the merge queue Aug 1, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 1, 2025
@yurishkuro yurishkuro merged commit 7ffe35d into jaegertracing:main Aug 1, 2025
63 checks passed
@pipiland2612 pipiland2612 deleted the post_metrics_summary branch August 1, 2025 05:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:ci Change related to continuous integration / testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants