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

Add sourcemap periodic refresh tracing #11116

Merged
merged 7 commits into from
Jul 3, 2023

Conversation

dmathieu
Copy link
Member

@dmathieu dmathieu commented Jun 30, 2023

Motivation/summary

Sourcemap periodic refreshes are making external calls to ES. Those calls produce spans, but they can't generate any data, as there is no parent transaction.
This creates a transaction for each sync run, so we can observe them.

Checklist

For functional changes, consider:

  • Is it observable through the addition of either logging or metrics?
  • Is its use being published in telemetry to enable product improvement?
  • Have system tests been added to avoid regression?

How to test these changes

Outside of unit tests, I have been testing these changes by running apm-server with tilt and rum/self instrumentation enabled.

Screenshot 2023-06-30 at 09 42 52

I'm not 100% sure about the initialSearch and scrollSearch spans, since they do nothing but wrap the ES call. They also help in figuring out which method makes those calls though.

Related issues

See #1014.

@dmathieu dmathieu force-pushed the sourcemap-transaction branch from 4f68696 to e17364e Compare June 30, 2023 07:46
@mergify
Copy link
Contributor

mergify bot commented Jun 30, 2023

This pull request does not have a backport label. Could you fix it @dmathieu? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-7.x is the label to automatically backport to the 7.x branch.
  • backport-7./d is the label to automatically backport to the 7./d branch. /d is the digit

NOTE: backport-skip has been added to this pull request.

@mergify mergify bot added the backport-skip Skip notification from the automated backport with mergify label Jun 30, 2023
@apmmachine
Copy link
Contributor

apmmachine commented Jun 30, 2023

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2023-07-03T08:30:49.320+0000

  • Duration: 6 min 12 sec

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /package : Generate and publish the docker images.

  • /test windows : Build & tests on Windows.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@apmmachine
Copy link
Contributor

apmmachine commented Jun 30, 2023

📚 Go benchmark report

Diff with the main branch

goos: linux
goarch: amd64
pkg: github.com/elastic/apm-server/internal/agentcfg
cpu: 12th Gen Intel(R) Core(TM) i5-12500
                                  │ build/main/bench.out │             bench.out             │
                                  │        sec/op        │   sec/op     vs base              │
geomean                                      66.65n        66.84n       +0.28%

                                  │ build/main/bench.out │             bench.out              │
                                  │         B/op         │    B/op     vs base                │
geomean                                                ²               +0.00%               ²
¹ all samples are equal
² summaries must be >0 to compute geomean

                                  │ build/main/bench.out │             bench.out              │
                                  │      allocs/op       │ allocs/op   vs base                │
geomean                                                ²               +0.00%               ²
¹ all samples are equal
² summaries must be >0 to compute geomean

pkg: github.com/elastic/apm-server/internal/beater/request
                                             │ build/main/bench.out │             bench.out              │
                                             │        sec/op        │    sec/op     vs base              │
ContextResetContentEncoding/empty-12                   130.7n ±  1%   131.4n ±  1%  +0.54% (p=0.039 n=6)
geomean                                                910.0n         935.7n        +2.83%

                                             │ build/main/bench.out │              bench.out               │
                                             │         B/op         │     B/op      vs base                │
geomean                                                           ²                 +0.00%               ²
¹ all samples are equal
² summaries must be >0 to compute geomean

                                             │ build/main/bench.out │             bench.out              │
                                             │      allocs/op       │ allocs/op   vs base                │
geomean                                                           ²               +0.00%               ²
¹ all samples are equal
² summaries must be >0 to compute geomean

pkg: github.com/elastic/apm-server/internal/publish
             │ build/main/bench.out │          bench.out          │
             │        sec/op        │   sec/op    vs base         │

             │ build/main/bench.out │           bench.out            │
             │         B/op         │     B/op       vs base         │

             │ build/main/bench.out │           bench.out           │
             │      allocs/op       │  allocs/op    vs base         │

pkg: github.com/elastic/apm-server/x-pack/apm-server/aggregation/spanmetrics
                 │ build/main/bench.out │             bench.out             │
                 │        sec/op        │   sec/op     vs base              │
AggregateSpan-12            881.0n ± 2%   913.8n ± 4%  +3.71% (p=0.002 n=6)

                 │ build/main/bench.out │            bench.out            │
                 │         B/op         │     B/op      vs base           │
¹ all samples are equal

                 │ build/main/bench.out │           bench.out           │
                 │      allocs/op       │ allocs/op   vs base           │
¹ all samples are equal

pkg: github.com/elastic/apm-server/x-pack/apm-server/aggregation/txmetrics
                        │ build/main/bench.out │          bench.out           │
                        │        sec/op        │   sec/op     vs base         │

                        │ build/main/bench.out │           bench.out           │
                        │         B/op         │    B/op     vs base           │
¹ all samples are equal

                        │ build/main/bench.out │           bench.out           │
                        │      allocs/op       │ allocs/op   vs base           │
¹ all samples are equal

pkg: github.com/elastic/apm-server/x-pack/apm-server/sampling
               │ build/main/bench.out │             bench.out              │
               │        sec/op        │    sec/op     vs base              │
geomean                  453.6n         468.1n        +3.20%

               │ build/main/bench.out │              bench.out               │
               │         B/op         │     B/op      vs base                │
geomean                    381.1          380.6       -0.13%
¹ all samples are equal

               │ build/main/bench.out │             bench.out              │
               │      allocs/op       │ allocs/op   vs base                │
geomean                    4.123        4.123       +0.00%
¹ all samples are equal

pkg: github.com/elastic/apm-server/x-pack/apm-server/sampling/eventstorage
                                            │ build/main/bench.out │               bench.out               │
                                            │        sec/op        │     sec/op      vs base               │
WriteTransaction/json_codec-12                       1.809µ ±  19%    1.344µ ±  62%  -25.68% (p=0.015 n=6)
ReadEvents/json_codec_big_tx/399_events-12           1.228m ±   3%    1.263m ±   2%   +2.87% (p=0.041 n=6)
ReadEvents/json_codec_big_tx/1000_events-12          3.068m ±   2%    2.989m ±   4%   -2.57% (p=0.026 n=6)
ReadEvents/nop_codec/10_events-12                    10.22µ ±  21%    14.35µ ±  28%  +40.44% (p=0.015 n=6)
geomean                                              15.16µ           15.17µ          +0.06%

                                            │ build/main/bench.out │               bench.out               │
                                            │         B/op         │     B/op       vs base                │
ReadEvents/json_codec_big_tx/10_events-12            42.31Ki ±  0%   42.33Ki ±  0%  +0.04% (p=0.041 n=6)
ReadEvents/nop_codec_big_tx/199_events-12            122.0Ki ±  1%   122.8Ki ±  0%  +0.63% (p=0.015 n=6)
geomean                                              11.33Ki         11.38Ki        +0.49%
¹ all samples are equal

                                            │ build/main/bench.out │              bench.out              │
                                            │      allocs/op       │  allocs/op   vs base                │
geomean                                                 127.4         127.4       -0.00%
¹ all samples are equal

report generated with https://pkg.go.dev/golang.org/x/perf/cmd/benchstat

@dmathieu
Copy link
Member Author

System tests failed once du to a flaky test. They passed on a second run, but somehow, the System Tests Results is still marked as failed. And rerunning it doesn't change anything.

@dmathieu dmathieu requested a review from a team June 30, 2023 08:13
@@ -17,3 +17,4 @@ https://github.com/elastic/apm-server/compare/8.9\...main[View commits]

[float]
==== Added
- Add a transaction to the source map periodic refresh action. {pull}11116[11116]
Copy link
Member

Choose a reason for hiding this comment

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

Would be great to mention this is for instrumentation only.

Copy link
Member Author

Choose a reason for hiding this comment

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

How about now?

@dmathieu dmathieu enabled auto-merge (squash) July 3, 2023 08:30
@dmathieu dmathieu merged commit e6e8485 into elastic:main Jul 3, 2023
@dmathieu dmathieu deleted the sourcemap-transaction branch July 3, 2023 08:54
@axw axw self-assigned this Aug 29, 2023
@axw
Copy link
Member

axw commented Aug 29, 2023

Verified with 8.10.0-BC1. Running apm-server under Tilt, I configured instrumentation.enabled: true and apm-server.rum.enabled: true and observed the "MetadataESFetcher.sync" traces being captured:

image

I think the transaction name could mention sourcemaps somewhere, but this is good enough for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-skip Skip notification from the automated backport with mergify test-plan test-plan-ok v8.10.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants