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

PROF-9791: Use heuristics to start the profiler when requested through SSI #4322

Merged
merged 11 commits into from
May 30, 2024

Conversation

szegedi
Copy link
Contributor

@szegedi szegedi commented May 17, 2024

What does this PR do?

With this change, when DD_INJECTION_ENABLED has profiler among its comma-separated values then profiler will be started as soon as the application both created a tracing span and has reached a 30 second lifetime. This will ensure SSI profiling enablement doesn't profile either tracing-unaware applications or those that run for only a short period of time.

Motivation

Adding profiler integration to SSI.

Copy link

github-actions bot commented May 17, 2024

Overall package size

Self size: 6.54 MB
Deduped: 61.8 MB
No deduping: 62.08 MB

Dependency sizes

name version self size total size
@datadog/native-appsec 8.0.1 15.59 MB 15.6 MB
@datadog/native-iast-taint-tracking 2.1.0 14.91 MB 14.92 MB
@datadog/pprof 5.3.0 9.85 MB 10.22 MB
protobufjs 7.2.5 2.77 MB 6.56 MB
@datadog/native-iast-rewriter 2.3.1 2.15 MB 2.24 MB
@opentelemetry/core 1.14.0 872.87 kB 1.47 MB
@datadog/native-metrics 2.0.0 898.77 kB 1.3 MB
@opentelemetry/api 1.8.0 1.21 MB 1.21 MB
import-in-the-middle 1.7.4 70.19 kB 739.86 kB
msgpack-lite 0.1.26 201.16 kB 281.59 kB
opentracing 0.14.7 194.81 kB 194.81 kB
semver 7.5.4 93.4 kB 123.8 kB
pprof-format 2.1.0 111.69 kB 111.69 kB
@datadog/sketches-js 2.1.0 109.9 kB 109.9 kB
lodash.sortby 4.7.0 75.76 kB 75.76 kB
lru-cache 7.14.0 74.95 kB 74.95 kB
ignore 5.2.4 51.22 kB 51.22 kB
int64-buffer 0.1.10 49.18 kB 49.18 kB
shell-quote 1.8.1 44.96 kB 44.96 kB
istanbul-lib-coverage 3.2.0 29.34 kB 29.34 kB
tlhunter-sorted-set 0.1.0 24.94 kB 24.94 kB
limiter 1.1.5 23.17 kB 23.17 kB
dc-polyfill 0.1.4 23.1 kB 23.1 kB
retry 0.13.1 18.85 kB 18.85 kB
jest-docblock 29.7.0 8.99 kB 12.76 kB
crypto-randomuuid 1.0.0 11.18 kB 11.18 kB
path-to-regexp 0.1.7 6.78 kB 6.78 kB
koalas 1.0.2 6.47 kB 6.47 kB
module-details-from-path 1.0.3 4.47 kB 4.47 kB

🤖 This report was automatically generated by heaviest-objects-in-the-universe

Copy link

codecov bot commented May 17, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 26 lines in your changes are missing coverage. Please review.

Project coverage is 62.86%. Comparing base (8bedb23) to head (96b13bb).
Report is 5 commits behind head on master.

Current head 96b13bb differs from pull request most recent head 9ca48ce

Please upload reports for the commit 9ca48ce to get more accurate results.

Files Patch % Lines
packages/dd-trace/src/profiling/ssi-heuristics.js 36.36% 14 Missing ⚠️
packages/dd-trace/src/proxy.js 52.94% 8 Missing ⚠️
packages/dd-trace/src/config.js 90.00% 1 Missing ⚠️
packages/dd-trace/src/profiler.js 0.00% 1 Missing ⚠️
packages/dd-trace/src/profiling/config.js 0.00% 1 Missing ⚠️
packages/dd-trace/src/profiling/profiler.js 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #4322       +/-   ##
===========================================
+ Coverage   18.61%   62.86%   +44.24%     
===========================================
  Files           6      243      +237     
  Lines         736    10308     +9572     
  Branches       33       33               
===========================================
+ Hits          137     6480     +6343     
- Misses        599     3828     +3229     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@szegedi szegedi force-pushed the szegedi/profiler-heuristics branch from dd67713 to 1bdd8b6 Compare May 22, 2024 09:59
@pr-commenter
Copy link

pr-commenter bot commented May 22, 2024

Benchmarks

Benchmark execution time: 2024-05-29 12:42:08

Comparing candidate commit 9ca48ce in PR branch szegedi/profiler-heuristics with baseline commit ad081db in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 260 metrics, 6 unstable metrics.

@szegedi szegedi force-pushed the szegedi/profiler-heuristics branch 3 times, most recently from 62af38e to 96b13bb Compare May 23, 2024 10:44
@szegedi szegedi marked this pull request as ready for review May 24, 2024 14:32
@szegedi szegedi requested a review from a team as a code owner May 24, 2024 14:32
@szegedi szegedi force-pushed the szegedi/profiler-heuristics branch from 96b13bb to cddcbd6 Compare May 27, 2024 12:27
@szegedi szegedi force-pushed the szegedi/profiler-heuristics branch from cddcbd6 to 33003e2 Compare May 28, 2024 13:12
@szegedi szegedi force-pushed the szegedi/profiler-heuristics branch from 33003e2 to e76c79e Compare May 28, 2024 14:10
@szegedi szegedi requested review from Qard and nsavoire May 28, 2024 14:30
@@ -663,6 +667,17 @@ class Config {
this._setBoolean(env, 'profiling.enabled', coalesce(DD_EXPERIMENTAL_PROFILING_ENABLED, DD_PROFILING_ENABLED))
this._setString(env, 'profiling.exporters', DD_PROFILING_EXPORTERS)
this._setBoolean(env, 'profiling.sourceMap', DD_PROFILING_SOURCE_MAP && !isFalse(DD_PROFILING_SOURCE_MAP))
if (DD_INJECTION_ENABLED) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it ok to put logic here? this seems to stray from the simple this._setBoolean/Value sequence of statement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think yes. There's some other if statements in the method already.

if (DD_INJECTION_ENABLED.split(',').includes('profiler')) {
this._setBoolean(env, 'profiling.heuristicsEnabled', true)
}
if (DD_INTERNAL_PROFILING_LONG_LIVED_THRESHOLD) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Having two different naming for the same thing (long lived / short lived threshold) feels weird.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know – it already was there as "short lived" for telemetry, but we usually mentioned a "long-lived" process so this felt more natural. I was vacillating on renaming the internal variable but then thought I might do it in a separate step later to keep this smaller. I might add a commit to fix this though.

@@ -13,17 +11,16 @@ const EnablementChoice = {
MANUALLY_ENABLED: Symbol('SSITelemetry.EnablementChoice.MANUALLY_ENABLED'),
SSI_ENABLED: Symbol('SSITelemetry.EnablementChoice.SSI_ENABLED'),
SSI_NOT_ENABLED: Symbol('SSITelemetry.EnablementChoice.SSI_NOT_ENABLED'),
DISABLED: Symbol('SSITelemetry.EnablementChoice.MANUALLY_DISABLED')
DISABLED: Symbol('SSITelemetry.EnablementChoice.DISABLED')
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is a MANUALLY_DISABLED reference left in the file

@szegedi szegedi requested a review from nsavoire May 29, 2024 12:34
@szegedi szegedi enabled auto-merge (squash) May 30, 2024 12:32
@szegedi szegedi merged commit 2f90a64 into master May 30, 2024
115 checks passed
@szegedi szegedi deleted the szegedi/profiler-heuristics branch May 30, 2024 12:33
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.

None yet

2 participants