Skip to content

Spring boot: autodetect service name from environment#6663

Merged
amarziali merged 7 commits intomasterfrom
andrea.marziali/instrument-spring-boot-application
Feb 20, 2024
Merged

Spring boot: autodetect service name from environment#6663
amarziali merged 7 commits intomasterfrom
andrea.marziali/instrument-spring-boot-application

Conversation

@amarziali
Copy link
Copy Markdown
Contributor

@amarziali amarziali commented Feb 12, 2024

What Does This Do

This PR allows automatically set the default service name for a spring boot standalone application from the spring property spring.application.name

It applies only if:

  • The user did not provide a service name through DD_SERVICE or equivalents
  • The application is deployed as a standalone jar (no war packages deployed on app servers)
  • The user defined spring.application.name in the spring environment (args, properties, env variables, ...)

This PR modifies only the default service name generation replacing the use of the jar name with the spring application name that's more appropriate.

The instrumentation is still in beta and it has to be explicitly enabled. It can be done by setting:

  • The env DD_TRACE_INTEGRATION_SPRING_BOOT_ENABLED=true
  • The sysprop -Ddd.trace.integration.spring-boot.enabled=true

Motivation

Additional Notes

Jira ticket: AIT-9541

@amarziali amarziali added tag: breaking change Breaking changes inst: spring Spring instrumentation labels Feb 12, 2024
@amarziali amarziali requested a review from a team as a code owner February 12, 2024 08:20
@pr-commenter
Copy link
Copy Markdown

pr-commenter Bot commented Feb 12, 2024

Benchmarks

Startup

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch master andrea.marziali/instrument-spring-boot-application
git_commit_date 1708365605 1708369277
git_commit_sha f709af0 77923a8
release_version 1.31.0-SNAPSHOT~f709af0489 1.31.0-SNAPSHOT~77923a8247
See matching parameters
Baseline Candidate
application insecure-bank insecure-bank
ci_job_date 1708372148 1708372148
ci_job_id 437564144 437564144
ci_pipeline_id 28528411 28528411
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
module Agent Agent
parent None None
variant iast iast

Summary

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

Startup time reports for petclinic
gantt
    title petclinic - global startup overhead: candidate=1.31.0-SNAPSHOT~77923a8247, baseline=1.31.0-SNAPSHOT~f709af0489

    dateFormat X
    axisFormat %s
section tracing
Agent [baseline] (1.081 s) : 0, 1081252
Total [baseline] (9.229 s) : 0, 9228595
Agent [candidate] (1.087 s) : 0, 1087032
Total [candidate] (9.24 s) : 0, 9239509
section appsec
Agent [baseline] (1.183 s) : 0, 1183020
Total [baseline] (9.43 s) : 0, 9429707
Agent [candidate] (1.18 s) : 0, 1180176
Total [candidate] (9.321 s) : 0, 9320510
section iast
Agent [baseline] (1.201 s) : 0, 1201475
Total [baseline] (9.354 s) : 0, 9354338
Agent [candidate] (1.207 s) : 0, 1207018
Total [candidate] (9.36 s) : 0, 9360085
section profiling
Agent [baseline] (1.29 s) : 0, 1289650
Total [baseline] (9.38 s) : 0, 9379525
Agent [candidate] (1.294 s) : 0, 1293621
Total [candidate] (9.364 s) : 0, 9364189
Loading
  • baseline results
Module Variant Duration Δ tracing
Agent tracing 1.081 s -
Agent appsec 1.183 s 101.767 ms (9.4%)
Agent iast 1.201 s 120.223 ms (11.1%)
Agent profiling 1.29 s 208.398 ms (19.3%)
Total tracing 9.229 s -
Total appsec 9.43 s 201.112 ms (2.2%)
Total iast 9.354 s 125.744 ms (1.4%)
Total profiling 9.38 s 150.931 ms (1.6%)
  • candidate results
Module Variant Duration Δ tracing
Agent tracing 1.087 s -
Agent appsec 1.18 s 93.145 ms (8.6%)
Agent iast 1.207 s 119.986 ms (11.0%)
Agent profiling 1.294 s 206.589 ms (19.0%)
Total tracing 9.24 s -
Total appsec 9.321 s 81.001 ms (0.9%)
Total iast 9.36 s 120.575 ms (1.3%)
Total profiling 9.364 s 124.68 ms (1.3%)
gantt
    title petclinic - break down per module: candidate=1.31.0-SNAPSHOT~77923a8247, baseline=1.31.0-SNAPSHOT~f709af0489

    dateFormat X
    axisFormat %s
section tracing
BytebuddyAgent [baseline] (687.967 ms) : 0, 687967
BytebuddyAgent [candidate] (692.096 ms) : 0, 692096
GlobalTracer [baseline] (298.745 ms) : 0, 298745
GlobalTracer [candidate] (300.289 ms) : 0, 300289
AppSec [baseline] (51.67 ms) : 0, 51670
AppSec [candidate] (51.519 ms) : 0, 51519
Remote Config [baseline] (721.796 µs) : 0, 722
Remote Config [candidate] (714.36 µs) : 0, 714
Telemetry [baseline] (7.877 ms) : 0, 7877
Telemetry [candidate] (7.799 ms) : 0, 7799
section appsec
BytebuddyAgent [baseline] (690.101 ms) : 0, 690101
BytebuddyAgent [candidate] (687.857 ms) : 0, 687857
GlobalTracer [baseline] (298.955 ms) : 0, 298955
GlobalTracer [candidate] (299.008 ms) : 0, 299008
AppSec [baseline] (151.795 ms) : 0, 151795
AppSec [candidate] (151.424 ms) : 0, 151424
Remote Config [baseline] (642.064 µs) : 0, 642
Remote Config [candidate] (637.177 µs) : 0, 637
Telemetry [baseline] (6.959 ms) : 0, 6959
Telemetry [candidate] (6.937 ms) : 0, 6937
section iast
BytebuddyAgent [baseline] (795.612 ms) : 0, 795612
BytebuddyAgent [candidate] (799.086 ms) : 0, 799086
GlobalTracer [baseline] (287.99 ms) : 0, 287990
GlobalTracer [candidate] (289.798 ms) : 0, 289798
AppSec [baseline] (54.981 ms) : 0, 54981
AppSec [candidate] (55.732 ms) : 0, 55732
Remote Config [baseline] (620.014 µs) : 0, 620
Remote Config [candidate] (635.991 µs) : 0, 636
Telemetry [baseline] (8.127 ms) : 0, 8127
Telemetry [candidate] (8.205 ms) : 0, 8205
IAST [baseline] (19.841 ms) : 0, 19841
IAST [candidate] (19.173 ms) : 0, 19173
section profiling
BytebuddyAgent [baseline] (678.036 ms) : 0, 678036
BytebuddyAgent [candidate] (679.922 ms) : 0, 679922
GlobalTracer [baseline] (379.733 ms) : 0, 379733
GlobalTracer [candidate] (381.621 ms) : 0, 381621
AppSec [baseline] (52.916 ms) : 0, 52916
AppSec [candidate] (52.881 ms) : 0, 52881
Remote Config [baseline] (750.647 µs) : 0, 751
Remote Config [candidate] (841.364 µs) : 0, 841
Telemetry [baseline] (9.601 ms) : 0, 9601
Telemetry [candidate] (9.654 ms) : 0, 9654
ProfilingAgent [baseline] (112.619 ms) : 0, 112619
ProfilingAgent [candidate] (112.626 ms) : 0, 112626
Profiling [baseline] (112.643 ms) : 0, 112643
Profiling [candidate] (112.651 ms) : 0, 112651
Loading

Load

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
end_time 2024-02-19T19:25:29 2024-02-19T19:44:07
git_branch master andrea.marziali/instrument-spring-boot-application
git_commit_date 1708365605 1708369277
git_commit_sha f709af0 77923a8
release_version 1.31.0-SNAPSHOT~f709af0489 1.31.0-SNAPSHOT~77923a8247
start_time 2024-02-19T19:25:16 2024-02-19T19:43:54
See matching parameters
Baseline Candidate
application insecure-bank insecure-bank
ci_job_date 1708372148 1708372148
ci_job_id 437564144 437564144
ci_pipeline_id 28528411 28528411
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
variant iast iast

Summary

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

Request duration reports for petclinic
gantt
    title petclinic - request duration [CI 0.99] : candidate=1.31.0-SNAPSHOT~77923a8247, baseline=1.31.0-SNAPSHOT~f709af0489
    dateFormat X
    axisFormat %s
section baseline
no_agent (1.346 ms) : 1327, 1365
.   : milestone, 1346,
appsec (1.801 ms) : 1777, 1824
.   : milestone, 1801,
iast (1.537 ms) : 1514, 1561
.   : milestone, 1537,
profiling (1.552 ms) : 1526, 1578
.   : milestone, 1552,
tracing (1.493 ms) : 1470, 1517
.   : milestone, 1493,
section candidate
no_agent (1.358 ms) : 1339, 1378
.   : milestone, 1358,
appsec (1.777 ms) : 1753, 1801
.   : milestone, 1777,
iast (1.534 ms) : 1510, 1557
.   : milestone, 1534,
profiling (1.568 ms) : 1543, 1593
.   : milestone, 1568,
tracing (1.506 ms) : 1483, 1529
.   : milestone, 1506,
Loading
  • baseline results
Variant Request duration [CI 0.99] Δ no_agent
no_agent 1.346 ms [1.327 ms, 1.365 ms] -
appsec 1.801 ms [1.777 ms, 1.824 ms] 454.833 µs (33.8%)
iast 1.537 ms [1.514 ms, 1.561 ms] 191.47 µs (14.2%)
profiling 1.552 ms [1.526 ms, 1.578 ms] 206.112 µs (15.3%)
tracing 1.493 ms [1.47 ms, 1.517 ms] 147.715 µs (11.0%)
  • candidate results
Variant Request duration [CI 0.99] Δ no_agent
no_agent 1.358 ms [1.339 ms, 1.378 ms] -
appsec 1.777 ms [1.753 ms, 1.801 ms] 418.509 µs (30.8%)
iast 1.534 ms [1.51 ms, 1.557 ms] 175.266 µs (12.9%)
profiling 1.568 ms [1.543 ms, 1.593 ms] 209.752 µs (15.4%)
tracing 1.506 ms [1.483 ms, 1.529 ms] 147.547 µs (10.9%)
Request duration reports for insecure-bank
gantt
    title insecure-bank - request duration [CI 0.99] : candidate=1.31.0-SNAPSHOT~77923a8247, baseline=1.31.0-SNAPSHOT~f709af0489
    dateFormat X
    axisFormat %s
section baseline
no_agent (366.598 µs) : 346, 387
.   : milestone, 367,
iast (471.617 µs) : 451, 492
.   : milestone, 472,
iast_FULL (538.289 µs) : 518, 559
.   : milestone, 538,
iast_GLOBAL (504.221 µs) : 482, 526
.   : milestone, 504,
iast_HARDCODED_SECRET_DISABLED (480.964 µs) : 460, 502
.   : milestone, 481,
iast_INACTIVE (451.652 µs) : 432, 472
.   : milestone, 452,
iast_TELEMETRY_OFF (472.84 µs) : 452, 494
.   : milestone, 473,
tracing (447.718 µs) : 427, 469
.   : milestone, 448,
section candidate
no_agent (370.335 µs) : 349, 392
.   : milestone, 370,
iast (472.514 µs) : 452, 493
.   : milestone, 473,
iast_FULL (536.824 µs) : 517, 557
.   : milestone, 537,
iast_GLOBAL (495.812 µs) : 475, 516
.   : milestone, 496,
iast_HARDCODED_SECRET_DISABLED (476.221 µs) : 456, 496
.   : milestone, 476,
iast_INACTIVE (444.387 µs) : 424, 465
.   : milestone, 444,
iast_TELEMETRY_OFF (474.569 µs) : 453, 496
.   : milestone, 475,
tracing (445.969 µs) : 426, 466
.   : milestone, 446,
Loading
  • baseline results
Variant Request duration [CI 0.99] Δ no_agent
no_agent 366.598 µs [345.957 µs, 387.24 µs] -
iast 471.617 µs [450.947 µs, 492.288 µs] 105.019 µs (28.6%)
iast_FULL 538.289 µs [517.865 µs, 558.714 µs] 171.691 µs (46.8%)
iast_GLOBAL 504.221 µs [482.208 µs, 526.234 µs] 137.622 µs (37.5%)
iast_HARDCODED_SECRET_DISABLED 480.964 µs [459.976 µs, 501.952 µs] 114.366 µs (31.2%)
iast_INACTIVE 451.652 µs [431.531 µs, 471.774 µs] 85.054 µs (23.2%)
iast_TELEMETRY_OFF 472.84 µs [451.9 µs, 493.779 µs] 106.241 µs (29.0%)
tracing 447.718 µs [426.774 µs, 468.663 µs] 81.12 µs (22.1%)
  • candidate results
Variant Request duration [CI 0.99] Δ no_agent
no_agent 370.335 µs [349.143 µs, 391.527 µs] -
iast 472.514 µs [452.134 µs, 492.894 µs] 102.18 µs (27.6%)
iast_FULL 536.824 µs [516.606 µs, 557.041 µs] 166.489 µs (45.0%)
iast_GLOBAL 495.812 µs [475.166 µs, 516.458 µs] 125.478 µs (33.9%)
iast_HARDCODED_SECRET_DISABLED 476.221 µs [455.948 µs, 496.494 µs] 105.886 µs (28.6%)
iast_INACTIVE 444.387 µs [424.161 µs, 464.613 µs] 74.052 µs (20.0%)
iast_TELEMETRY_OFF 474.569 µs [453.203 µs, 495.936 µs] 104.235 µs (28.1%)
tracing 445.969 µs [425.561 µs, 466.378 µs] 75.635 µs (20.4%)

Base automatically changed from andrea.marziali/dynamic-config-preferred-service to master February 12, 2024 14:40
@amarziali amarziali force-pushed the andrea.marziali/instrument-spring-boot-application branch from 591d64b to 529341d Compare February 12, 2024 14:49
Copy link
Copy Markdown
Contributor

@PerfectSlayer PerfectSlayer left a comment

Choose a reason for hiding this comment

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

That’s great addition! 👍
Quick question for me: what’t the default service name when it’s not set by the customer?

Nitpick: props and args is a little hard to get from the tests. application-name-from-properties and application-name-from-cli-args would have been better 😓

@amarziali
Copy link
Copy Markdown
Contributor Author

e: what’t the default service name when it’s not set by the customer?

Usually it's the jar name (otherwise unnamed-java-service). Right now I will set that instrumentation disabled by default (to be safe). I will enable only on single step.
I'll apply also your suggestion before merging thanks

@amarziali amarziali force-pushed the andrea.marziali/instrument-spring-boot-application branch from 529341d to b9422a3 Compare February 19, 2024 15:38
@amarziali amarziali added tag: experimental Experimental changes and removed tag: breaking change Breaking changes labels Feb 19, 2024
@amarziali amarziali enabled auto-merge (squash) February 20, 2024 08:46
@amarziali amarziali merged commit 4ff3736 into master Feb 20, 2024
@amarziali amarziali deleted the andrea.marziali/instrument-spring-boot-application branch February 20, 2024 09:04
@github-actions github-actions Bot added this to the 1.31.0 milestone Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

inst: spring Spring instrumentation tag: experimental Experimental changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants