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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Web Tests Errors Detection #2666

Merged
merged 13 commits into from
May 27, 2024
Merged

fix: Web Tests Errors Detection #2666

merged 13 commits into from
May 27, 2024

Conversation

PROFeNoM
Copy link
Contributor

@PROFeNoM PROFeNoM commented May 17, 2024

Description

AIDM-104

This commit fixes this issue.

  • If the .env file doesn't exist, then Laravel bootstrapping procedure (which we trigger) will fail:
#0 /home/circleci/app/tests/Frameworks/Laravel/Version_5_8/vendor/vlucas/phpdotenv/src/Loader.php(147): file_get_contents('/home/circleci/...')
#1 /home/circleci/app/tests/Frameworks/Laravel/Version_5_8/vendor/vlucas/phpdotenv/src/Loader.php(127): Dotenv\Loader::readFromFile('/home/circleci/...')
#2 /home/circleci/app/tests/Frameworks/Laravel/Version_5_8/vendor/vlucas/phpdotenv/src/Loader.php(91): Dotenv\Loader::findAndRead(Array)
#3 /home/circleci/app/tests/Frameworks/Laravel/Version_5_8/vendor/vlucas/phpdotenv/src/Dotenv.php(123): Dotenv\Loader->load()
#4 /home/circleci/app/tests/Frameworks/Laravel/Version_5_8/vendor/vlucas/phpdotenv/src/Dotenv.php(93): Dotenv\Dotenv->loadData()
#5 /home/circleci/app/tests/Frameworks/Laravel/Version_5_8/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadEnvironmentVariables.php(32): Dotenv\Dotenv->safeLoad()
#6 /home/circleci/app/src/DDTrace/Integrations/Laravel/LaravelIntegration.php(92): Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables->bootstrap(Object(Illuminate\Foundation\Application))
#7 /home/circleci/app/tests/Frameworks/Laravel/Version_5_8/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(203): DDTrace\Integrations\Laravel\LaravelIntegration->DDTrace\Integrations\Laravel\{closure}(Object(Illuminate\Foundation\Application), 'Illuminate\\Foun...', Array, NULL, NULL)
#8 /home/circleci/app/tests/Frameworks/Laravel/Version_5_8/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(162): Illuminate\Foundation\Application->bootstrapWith(Array)
#9 /home/circleci/app/tests/Frameworks/Laravel/Version_5_8/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(146): Illuminate\Foundation\Http\Kernel->bootstrap()
#10 /home/circleci/app/tests/Frameworks/Laravel/Version_5_8/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#11 /home/circleci/app/tests/Frameworks/Laravel/Version_5_8/public/index.php(55): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#12 {main}

This commit fixes this issue

  • The wp_get_active_and_valid_themes simply doesn't exist before 5.1. I proposed another way of retrieving the themes.

This commit fixes this issue

  • The event flow is LoadEnvironmentVariables --> LoadConfiguration --> Other Events...
  • If .env isn't set, then config(app.name) will fail until the configuration is loaded (only the first time!). This means that the first three laravel.event.handle spans will have their service name set to laravel if no service is set (and not laravel_test_app like the tests pretend - they are NOT checking the service 馃拃 -, which was the opportunity to move them to snapshots).
    This led me to change the other check so that the name, error, service, and resources are checked if set, even when using SpanAssertion:::exists. Currently, we can pass them as arguments, but they aren't checked, which makes no sense. (Additionally, I just discovered the existence of SpanAssertion::NOT_TESTED.)

The latter led me to the other changes, which mostly accommodated the fact that some checks weren't done before.

Now that the checks were actually made, this commit fixes the "service propagation" in OTel when both APIs are used. This happened because if the root span were an OTel span, the service name would be set using the resource info and the service.name special tag, but it wasn't set on the internal DD span, so the child spans weren't using this information.

The Symfony tests checked for an error that wasn't meant to exist.

Considering that the tests now do actually check existing tags (existence), I slightly modified one Elasticsearch test, because it was currently expecting the _dd.p.tid on each and every spans, while this tag is only present at the top of each trace chunks

Reviewer checklist

  • Test coverage seems ok.
  • Appropriate labels assigned.

@PROFeNoM PROFeNoM self-assigned this May 17, 2024
@codecov-commenter
Copy link

codecov-commenter commented May 17, 2024

Codecov Report

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

Project coverage is 79.29%. Comparing base (48190be) to head (f5be1dc).
Report is 2 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #2666   +/-   ##
=========================================
  Coverage     79.29%   79.29%           
- Complexity     2215     2223    +8     
=========================================
  Files           199      199           
  Lines         22107    22118   +11     
=========================================
+ Hits          17530    17539    +9     
- Misses         4577     4579    +2     
Flag Coverage 螖
tracer-extension 78.55% <酶> (酶)
tracer-php 80.33% <90.62%> (+<0.01%) 猬嗭笍

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage 螖
src/DDTrace/OpenTelemetry/Span.php 86.26% <100.00%> (+0.15%) 猬嗭笍
...egrations/WordPress/WordPressIntegrationLoader.php 87.12% <96.00%> (-0.02%) 猬囷笍
...DTrace/Integrations/Laravel/LaravelIntegration.php 80.88% <60.00%> (-0.19%) 猬囷笍

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
螖 = absolute <relative> (impact), 酶 = not affected, ? = missing data
Powered by Codecov. Last update 48190be...f5be1dc. Read the comment docs.

@pr-commenter
Copy link

pr-commenter bot commented May 17, 2024

Benchmarks

Benchmark execution time: 2024-05-22 09:55:52

Comparing candidate commit f5be1dc in PR branch alex/fix/errors-detection with baseline commit 48190be in branch master.

Found 1 performance improvements and 2 performance regressions! Performance is the same for 175 metrics, 0 unstable metrics.

scenario:ContextPropagationBench/benchInject64Bit-opcache

  • 馃煡 execution_time [+180.209ns; +425.791ns] or [+2.562%; +6.054%]

scenario:EmptyFileBench/benchEmptyFileBaseline

  • 馃煩 execution_time [-185.753碌s; -60.347碌s] or [-7.507%; -2.439%]

scenario:PDOBench/benchPDOOverheadWithDBM-opcache

  • 馃煡 execution_time [+13.256碌s; +15.157碌s] or [+4.205%; +4.809%]

Copy link

Snapshots difference summary

The following differences have been observed in committed snapshots. It is meant to help the reviewer.
The diff is simplistic, so please check some files anyway while we improve it.

If you need to update snapshots, please refer to CONTRIBUTING.md

6 occurrences of :

- "span_id": 13
+ "span_id": 14

6 occurrences of :

- "span_id": 14
+ "span_id": 15

6 occurrences of :

- "span_id": 15
+ "span_id": 16

6 occurrences of :

- "span_id": 7
+ {
+ "name": "load_theme"
+ "service": "wordpress_test_app"
+ "resource": "Twentyseventeen (theme)"
+ "trace_id": 0
+ "span_id": 7
+ "parent_id": 1
+ "type": "web"
+ "meta": {
+ "component": "wordpress"
+ "wordpress.theme": "Twentyseventeen"
+ }
+ }
+ "span_id": 8

2 occurrences of :

- "span_id": 16
- "parent_id": 7
+ "span_id": 17
+ "parent_id": 8

3 occurrences of :

- "span_id": 17
- "parent_id": 7
+ "span_id": 18
+ "parent_id": 8

6 occurrences of :

- "span_id": 8
+ "span_id": 9

2 occurrences of :

- "span_id": 18
- "parent_id": 8
+ "span_id": 19
+ "parent_id": 9

6 occurrences of :

- "span_id": 9
+ "span_id": 10

3 occurrences of :

- "span_id": 19
- "parent_id": 9
+ "span_id": 20
+ "parent_id": 10

3 occurrences of :

- "span_id": 20
- "parent_id": 9
+ "span_id": 21
+ "parent_id": 10

3 occurrences of :

- "span_id": 21
- "parent_id": 9
+ "span_id": 22
+ "parent_id": 10

2 occurrences of :

- "span_id": 32
- "parent_id": 21
+ "span_id": 33
+ "parent_id": 22

3 occurrences of :

- "span_id": 22
- "parent_id": 9
+ "span_id": 23
+ "parent_id": 10

3 occurrences of :

- "span_id": 23
- "parent_id": 9
+ "span_id": 24
+ "parent_id": 10

3 occurrences of :

- "span_id": 24
- "parent_id": 9
+ "span_id": 25
+ "parent_id": 10

3 occurrences of :

- "span_id": 25
- "parent_id": 9
+ "span_id": 26
+ "parent_id": 10

3 occurrences of :

- "span_id": 26
- "parent_id": 9
+ "span_id": 27
+ "parent_id": 10

3 occurrences of :

- "span_id": 27
- "parent_id": 9
+ "span_id": 28
+ "parent_id": 10

6 occurrences of :

- "span_id": 10
+ "span_id": 11

2 occurrences of :

- "span_id": 28
- "parent_id": 10
+ "span_id": 29
+ "parent_id": 11

6 occurrences of :

- "span_id": 11
+ "span_id": 12

2 occurrences of :

- "span_id": 29
- "parent_id": 11
+ "span_id": 30
+ "parent_id": 12

3 occurrences of :

- "span_id": 30
- "parent_id": 11
+ "span_id": 31
+ "parent_id": 12

6 occurrences of :

- "span_id": 12
+ "span_id": 13

3 occurrences of :

- "span_id": 31
- "parent_id": 12
+ "span_id": 32
+ "parent_id": 13

2 occurrences of :

- "span_id": 16
+ "span_id": 17

1 occurrences of :

- "span_id": 18
- "parent_id": 7
+ "span_id": 19
+ "parent_id": 8

1 occurrences of :

- "span_id": 19
- "parent_id": 8
+ "span_id": 20
+ "parent_id": 9

1 occurrences of :

- "span_id": 44
- "parent_id": 22
+ "span_id": 45
+ "parent_id": 23

1 occurrences of :

- "span_id": 28
- "parent_id": 9
+ "span_id": 29
+ "parent_id": 10

1 occurrences of :

- "span_id": 29
- "parent_id": 10
+ "span_id": 30
+ "parent_id": 11

1 occurrences of :

- "span_id": 31
- "parent_id": 11
+ "span_id": 32
+ "parent_id": 12

1 occurrences of :

- "span_id": 32
- "parent_id": 11
+ "span_id": 33
+ "parent_id": 12

1 occurrences of :

- "span_id": 33
- "parent_id": 11
+ "span_id": 34
+ "parent_id": 12

1 occurrences of :

- "span_id": 34
- "parent_id": 11
+ "span_id": 35
+ "parent_id": 12

1 occurrences of :

- "span_id": 35
- "parent_id": 11
+ "span_id": 36
+ "parent_id": 12

1 occurrences of :

- "span_id": 36
- "parent_id": 11
+ "span_id": 37
+ "parent_id": 12

1 occurrences of :

- "span_id": 37
- "parent_id": 12
+ "span_id": 38
+ "parent_id": 13

1 occurrences of :

- "span_id": 45
- "parent_id": 37
+ "span_id": 46
+ "parent_id": 38

1 occurrences of :

- "span_id": 46
- "parent_id": 37
+ "span_id": 47
+ "parent_id": 38

1 occurrences of :

- "span_id": 47
- "parent_id": 37
+ "span_id": 48
+ "parent_id": 38

1 occurrences of :

- "span_id": 48
- "parent_id": 37
+ "span_id": 49
+ "parent_id": 38

1 occurrences of :

- "span_id": 49
- "parent_id": 37
+ "span_id": 50
+ "parent_id": 38

1 occurrences of :

- "span_id": 50
- "parent_id": 37
+ "span_id": 51
+ "parent_id": 38

1 occurrences of :

- "span_id": 38
- "parent_id": 12
+ "span_id": 39
+ "parent_id": 13

1 occurrences of :

- "span_id": 39
- "parent_id": 12
+ "span_id": 40
+ "parent_id": 13

1 occurrences of :

- "span_id": 51
- "parent_id": 39
+ "span_id": 52
+ "parent_id": 40

1 occurrences of :

- "span_id": 54
- "parent_id": 51
+ "span_id": 55
+ "parent_id": 52

1 occurrences of :

- "span_id": 58
- "parent_id": 54
+ "span_id": 59
+ "parent_id": 55

1 occurrences of :

- "span_id": 59
- "parent_id": 54
+ "span_id": 60
+ "parent_id": 55

1 occurrences of :

- "span_id": 60
- "parent_id": 54
+ "span_id": 61
+ "parent_id": 55

1 occurrences of :

- "span_id": 61
- "parent_id": 54
+ "span_id": 62
+ "parent_id": 55

1 occurrences of :

- "span_id": 62
- "parent_id": 54
+ "span_id": 63
+ "parent_id": 55

1 occurrences of :

- "span_id": 63
- "parent_id": 54
+ "span_id": 64
+ "parent_id": 55

1 occurrences of :

- "span_id": 64
- "parent_id": 54
+ "span_id": 65
+ "parent_id": 55

1 occurrences of :

- "span_id": 65
- "parent_id": 54
+ "span_id": 66
+ "parent_id": 55

1 occurrences of :

- "span_id": 66
- "parent_id": 54
+ "span_id": 67
+ "parent_id": 55

1 occurrences of :

- "span_id": 67
- "parent_id": 54
+ "span_id": 68
+ "parent_id": 55

1 occurrences of :

- "span_id": 68
- "parent_id": 54
+ "span_id": 69
+ "parent_id": 55

1 occurrences of :

- "span_id": 69
- "parent_id": 54
+ "span_id": 70
+ "parent_id": 55

1 occurrences of :

- "span_id": 70
- "parent_id": 54
+ "span_id": 71
+ "parent_id": 55

1 occurrences of :

- "span_id": 71
- "parent_id": 54
+ "span_id": 72
+ "parent_id": 55

1 occurrences of :

- "span_id": 72
- "parent_id": 54
+ "span_id": 73
+ "parent_id": 55

1 occurrences of :

- "span_id": 73
- "parent_id": 54
+ "span_id": 74
+ "parent_id": 55

1 occurrences of :

- "span_id": 74
- "parent_id": 54
+ "span_id": 75
+ "parent_id": 55

1 occurrences of :

- "span_id": 75
- "parent_id": 54
+ "span_id": 76
+ "parent_id": 55

1 occurrences of :

- "span_id": 76
- "parent_id": 54
+ "span_id": 77
+ "parent_id": 55

1 occurrences of :

- "span_id": 77
- "parent_id": 54
+ "span_id": 78
+ "parent_id": 55

1 occurrences of :

- "span_id": 78
- "parent_id": 54
+ "span_id": 79
+ "parent_id": 55

1 occurrences of :

- "span_id": 79
- "parent_id": 54
+ "span_id": 80
+ "parent_id": 55

1 occurrences of :

- "span_id": 80
- "parent_id": 54
+ "span_id": 81
+ "parent_id": 55

1 occurrences of :

- "span_id": 81
- "parent_id": 54
+ "span_id": 82
+ "parent_id": 55

1 occurrences of :

- "span_id": 82
- "parent_id": 54
+ "span_id": 83
+ "parent_id": 55

1 occurrences of :

- "span_id": 83
- "parent_id": 54
+ "span_id": 84
+ "parent_id": 55

1 occurrences of :

- "span_id": 84
- "parent_id": 54
+ "span_id": 85
+ "parent_id": 55

1 occurrences of :

- "span_id": 85
- "parent_id": 54
+ "span_id": 86
+ "parent_id": 55

1 occurrences of :

- "span_id": 55
- "parent_id": 51
+ "span_id": 56
+ "parent_id": 52

1 occurrences of :

- "span_id": 56
- "parent_id": 51
+ "span_id": 57
+ "parent_id": 52

1 occurrences of :

- "span_id": 40
- "parent_id": 12
+ "span_id": 41
+ "parent_id": 13

1 occurrences of :

- "span_id": 41
- "parent_id": 12
+ "span_id": 42
+ "parent_id": 13

1 occurrences of :

- "span_id": 52
- "parent_id": 41
+ "span_id": 53
+ "parent_id": 42

1 occurrences of :

- "span_id": 42
- "parent_id": 12
+ "span_id": 43
+ "parent_id": 13

1 occurrences of :

- "span_id": 53
- "parent_id": 42
+ "span_id": 54
+ "parent_id": 43

1 occurrences of :

- "span_id": 57
- "parent_id": 53
+ "span_id": 58
+ "parent_id": 54

1 occurrences of :

- "span_id": 86
- "parent_id": 57
+ "span_id": 87
+ "parent_id": 58

1 occurrences of :

- "span_id": 87
- "parent_id": 57
+ "span_id": 88
+ "parent_id": 58

1 occurrences of :

- "span_id": 88
- "parent_id": 57
+ "span_id": 89
+ "parent_id": 58

1 occurrences of :

- "span_id": 43
- "parent_id": 13
+ "span_id": 44
+ "parent_id": 14

2 occurrences of :

- "span_id": 16
- "parent_id": 9
+ "span_id": 17
+ "parent_id": 10

3 occurrences of :

- "span_id": 17
- "parent_id": 9
+ "span_id": 18
+ "parent_id": 10

3 occurrences of :

- "span_id": 18
- "parent_id": 9
+ "span_id": 19
+ "parent_id": 10

2 occurrences of :

- "span_id": 21
- "parent_id": 18
+ "span_id": 22
+ "parent_id": 19

2 occurrences of :

- "span_id": 19
- "parent_id": 11
+ "span_id": 20
+ "parent_id": 12

3 occurrences of :

- "span_id": 20
- "parent_id": 11
+ "span_id": 21
+ "parent_id": 12

1 occurrences of :

- "span_id": 33
- "parent_id": 19
+ "span_id": 34
+ "parent_id": 20

1 occurrences of :

- "span_id": 21
- "parent_id": 11
+ "span_id": 22
+ "parent_id": 12

1 occurrences of :

- "span_id": 22
- "parent_id": 11
+ "span_id": 23
+ "parent_id": 12

1 occurrences of :

- "span_id": 23
- "parent_id": 11
+ "span_id": 24
+ "parent_id": 12

1 occurrences of :

- "span_id": 24
- "parent_id": 11
+ "span_id": 25
+ "parent_id": 12

1 occurrences of :

- "span_id": 25
- "parent_id": 11
+ "span_id": 26
+ "parent_id": 12

1 occurrences of :

- "span_id": 26
- "parent_id": 11
+ "span_id": 27
+ "parent_id": 12

1 occurrences of :

- "span_id": 27
- "parent_id": 12
+ "span_id": 28
+ "parent_id": 13

1 occurrences of :

- "span_id": 28
- "parent_id": 12
+ "span_id": 29
+ "parent_id": 13

1 occurrences of :

- "span_id": 29
- "parent_id": 12
+ "span_id": 30
+ "parent_id": 13

1 occurrences of :

- "span_id": 34
- "parent_id": 29
+ "span_id": 35
+ "parent_id": 30

1 occurrences of :

- "span_id": 37
- "parent_id": 34
+ "span_id": 38
+ "parent_id": 35

1 occurrences of :

- "span_id": 41
- "parent_id": 37
+ "span_id": 42
+ "parent_id": 38

1 occurrences of :

- "span_id": 38
- "parent_id": 34
+ "span_id": 39
+ "parent_id": 35

1 occurrences of :

- "span_id": 39
- "parent_id": 34
+ "span_id": 40
+ "parent_id": 35

1 occurrences of :

- "span_id": 30
- "parent_id": 12
+ "span_id": 31
+ "parent_id": 13

1 occurrences of :

- "span_id": 35
- "parent_id": 31
+ "span_id": 36
+ "parent_id": 32

1 occurrences of :

- "span_id": 32
- "parent_id": 12
+ "span_id": 33
+ "parent_id": 13

1 occurrences of :

- "span_id": 36
- "parent_id": 32
+ "span_id": 37
+ "parent_id": 33

1 occurrences of :

- "span_id": 40
- "parent_id": 36
+ "span_id": 41
+ "parent_id": 37

@PROFeNoM PROFeNoM added the 馃悰 bug Something isn't working label May 21, 2024
@PROFeNoM PROFeNoM marked this pull request as ready for review May 22, 2024 10:01
@PROFeNoM PROFeNoM requested review from a team as code owners May 22, 2024 10:01
Copy link
Contributor

@pablomartinezbernardo pablomartinezbernardo left a comment

Choose a reason for hiding this comment

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

LGTM

Curious to know, how were all these errors detected? Are they things we have known for a bit and just got the time to get to them? Are they customer escalations?

@PROFeNoM
Copy link
Contributor Author

@pablomartinezbernardo

After checking for the errors in the web tests (WebServer.php changes) and enabling the debug logs, errors starting started being detected.

These weren't known errors as far as I was concerned, but they aren't critical errors either.

I mainly discovered the issue on the fly with this PR (which is also the reason why it's a bit all over the place)

@bwoebi bwoebi merged commit a40f7af into master May 27, 2024
553 of 556 checks passed
@bwoebi bwoebi deleted the alex/fix/errors-detection branch May 27, 2024 12:34
@bwoebi bwoebi added this to the 1.0.0 milestone May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
馃悰 bug Something isn't working dev/testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants