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

Added configuration for WordPress supportability #961

Draft
wants to merge 244 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
244 commits
Select commit Hold shift + click to select a range
3ac1784
Improved formatting in AllOptionsMetadata.php
SergeyKleyman Apr 20, 2023
6df7770
Improved formatting in Logger_tests.c
SergeyKleyman Apr 21, 2023
9c91f68
Improved formatting in src/ext/log.c
SergeyKleyman Apr 22, 2023
70182fc
Improved formatting in tests/ElasticApmTests/ComponentTests/Util/AllC…
SergeyKleyman Apr 22, 2023
ab0d7d6
Improved formatting in tests/ElasticApmTests/ComponentTests/Util/RawD…
SergeyKleyman Apr 22, 2023
53f54ae
Improved formatting in tests.ElasticApmTests.ComponentTests.ConfigSet…
SergeyKleyman Apr 22, 2023
4ffeec5
Improved formatting in tests/ElasticApmTests/ComponentTests/MySQLiTes…
SergeyKleyman Apr 22, 2023
6fe1b84
Improved formatting in tests/ElasticApmTests/ComponentTests/PDOTest.php
SergeyKleyman Apr 22, 2023
0be6600
Improved formatting in tests/ElasticApmTests/ComponentTests/MySQLiTes…
SergeyKleyman Apr 22, 2023
8c7a5db
Reverted references of ELASTIC_APM_EMPTY_STRING_VIEW back to makeEmpt…
SergeyKleyman Apr 23, 2023
6833f7e
Renamed BootstrapStageLogger::logLevel to logWithLevel
SergeyKleyman Apr 20, 2023
20b39e6
Renamed ELASTIC_APM_LOG_WRITE_TO_SYSLOG to ELASTIC_APM_LOG_TO_BACKGRO…
SergeyKleyman Apr 22, 2023
1c60e50
Fixed typo in local variable name
SergeyKleyman Apr 22, 2023
cc03a7a
Added Logger::if*LevelEnabledNoLine for all the remaining log levels
SergeyKleyman Apr 21, 2023
e7a028f
Added ability to inherit context from LoggerFactory
SergeyKleyman Apr 21, 2023
9905fc7
Make ArrayUtil::getValueIfKeyExists a template instead of mixed
SergeyKleyman Apr 21, 2023
16c9bea
Added ArrayUtil::append
SergeyKleyman Apr 21, 2023
44e8953
Marked captureInClassicFormatExcludeElasticApm $loggerFactory as null…
SergeyKleyman Apr 21, 2023
75a244e
Removed redundant type-hint
SergeyKleyman Apr 21, 2023
91734c8
Added ELASTIC_APM_BUILD_PHP_VERSION_ID
SergeyKleyman Apr 21, 2023
03fe723
Removed declaration of unused makeDynamicArray()
SergeyKleyman Apr 21, 2023
65d5bb2
Added src/ext/ArrayView.h
SergeyKleyman Apr 21, 2023
f1c387a
Added string related utility functions
SergeyKleyman Apr 21, 2023
ddd771c
Added string related utility functions (part 2)
SergeyKleyman Apr 21, 2023
664f54d
Split ConfigManager.h into multiple more manageable headers
SergeyKleyman Apr 21, 2023
56a4ad5
Split ConfigManager.h into multiple more manageable headers (part 2)
SergeyKleyman Apr 21, 2023
a2cb822
Split ConfigManager.h into multiple more manageable headers (part 3)
SergeyKleyman Apr 21, 2023
3049c13
Split ConfigManager.h into multiple more manageable headers (part 4)
SergeyKleyman Apr 21, 2023
87c25db
Added string related utility functions (part 3)
SergeyKleyman Apr 21, 2023
819f215
Split ConfigManager.h into multiple more manageable headers (part 5)
SergeyKleyman Apr 21, 2023
d389979
Split big header files into multiple more manageable headers (part 6)
SergeyKleyman Apr 21, 2023
05250f5
Split big header files into multiple more manageable headers (part 7)
SergeyKleyman Apr 21, 2023
a8a84d4
enum LogLevel to a separate header (LogLevel.h)
SergeyKleyman Apr 22, 2023
42c2c1f
Added maxEnabledLogLevel()
SergeyKleyman Apr 22, 2023
c356b98
Added ELASTIC_APM_LOG_DIRECT_INFO
SergeyKleyman Apr 22, 2023
afadc49
Added missing include
SergeyKleyman Apr 22, 2023
a740c29
Added // NOLINT for ELASTIC_APM_FOR_EACH_INDEX_START_END
SergeyKleyman Apr 22, 2023
032a36c
Clarified structure of a header added to each allocation for track it
SergeyKleyman Apr 22, 2023
e6f6f43
Extracted TextOutputStream_forward_decl.h from TextOutputStream.h
SergeyKleyman Apr 22, 2023
bf454c7
Extracted OptionalBool to its own header (OptionalBool.h)
SergeyKleyman Apr 22, 2023
ecf0255
Extracted TextOutputStream_forward_decl.h from TextOutputStream.h (pa…
SergeyKleyman Apr 22, 2023
39360de
Made implicit casts explcit
SergeyKleyman Apr 22, 2023
de15622
Added openFile to have "safe fopen" similar to fopen_s available on W…
SergeyKleyman Apr 22, 2023
873dc6d
Added openFile to have "safe fopen" similar to fopen_s available on W…
SergeyKleyman Apr 22, 2023
59ea499
Extracted TextOutputStream_forward_decl.h from TextOutputStream.h (pa…
SergeyKleyman Apr 22, 2023
dddbf0d
Added resultBufferIsTooSmall to ResultCode
SergeyKleyman Apr 22, 2023
a8be1e1
Renamed ELASTIC_APM_CALL_EARLY_GOTO_FINALLY_WITH_SUCCESS to ELASTIC_A…
SergeyKleyman Apr 22, 2023
1693d68
Added ELASTIC_APM_EMPTY_STRING_VIEW instead of makeEmptyStringView so…
SergeyKleyman Apr 22, 2023
da03ec2
Extracted TextOutputStream_forward_decl.h from TextOutputStream.h (pa…
SergeyKleyman Apr 22, 2023
dde1807
Split ConfigManager.h into multiple more manageable headers (part 6)
SergeyKleyman Apr 22, 2023
e4138ad
Split ConfigManager.h into multiple more manageable headers (part 7)
SergeyKleyman Apr 22, 2023
3d1f6b2
Removed unused ELASTIC_APM_PHP_PART_ON_PHP_ERROR_FUNC and ELASTIC_APM…
SergeyKleyman Apr 22, 2023
6c3512f
Split ConfigManager.h into multiple more manageable headers (part 8)
SergeyKleyman Apr 22, 2023
0e074e7
Added ELASTIC_APM_EMPTY_STRING_VIEW instead of makeEmptyStringView so…
SergeyKleyman Apr 22, 2023
89e6932
Extracted TextOutputStream_forward_decl.h from TextOutputStream.h (pa…
SergeyKleyman Apr 22, 2023
0107961
Added zend_string related utility functions
SergeyKleyman Apr 22, 2023
a012f8d
Added missing include-s
SergeyKleyman Apr 22, 2023
debae77
Refactored TextUtilForTests::iterateLines to allow finer control over…
SergeyKleyman Apr 22, 2023
626e1b4
Removed unused import (tests/ElasticApmTests/ComponentTests/Util/Reso…
SergeyKleyman Apr 22, 2023
d1a4c14
Replaced ComponentTestCaseBase::getMandatoryAppCodeArg + assertIs<exp…
SergeyKleyman Apr 22, 2023
7c31172
Removed unused import (tests/ElasticApmTests/Util/Deserialization/Ser…
SergeyKleyman Apr 22, 2023
2239ead
Added /* in,out */ to ArrayUtilForTests::append
SergeyKleyman Apr 22, 2023
a5044d5
Added AssertMessageBuilder::buildString
SergeyKleyman Apr 22, 2023
0b0029e
Removed unused import (tests/ElasticApmTests/Util/TestCaseBase.php)
SergeyKleyman Apr 22, 2023
0e4ea26
DataProviderForTestBuilder: Have keys included in logged data-set
SergeyKleyman Apr 22, 2023
84fbc85
Added MixedMap
SergeyKleyman Apr 22, 2023
930b267
Made IterableUtilForTests::iterableToGenerator a function template
SergeyKleyman Apr 22, 2023
aa0dae7
Added comments to calls of ArrayUtilForTests::append
SergeyKleyman Apr 22, 2023
72c0eea
Refactored TextUtilForTests::iterateLines to allow finer control over…
SergeyKleyman Apr 22, 2023
7418042
Fixed imports in ComponentTestCaseBase.php
SergeyKleyman Apr 24, 2023
cf56f81
Merge branch 'main' into 3__General_refactoring
SergeyKleyman Apr 24, 2023
0d4f1fb
Fixed incorrect merge
SergeyKleyman Apr 24, 2023
8df301f
Added missing include
SergeyKleyman Apr 24, 2023
6061ee6
Added retries on "composer install" has an intermittent failure
SergeyKleyman Apr 24, 2023
a989cfb
Log PhpUnitExtensionBase::$timestampBeforeTest when setting it
SergeyKleyman Apr 24, 2023
5065ddd
Use TimeUtilForTests::timestampToLoggable in assertLessThanOrEqualTim…
SergeyKleyman Apr 24, 2023
2c77db6
Applied runAndEscalateLogLevelOnFailure to testAllWaysToSetConfig
SergeyKleyman Apr 24, 2023
ab1b0c7
Added INTERNAL_CHECKS_LEVEL to OptionNames.php
SergeyKleyman Apr 20, 2023
96c4c06
Added maxNumberOfStackFrames as parameter to
SergeyKleyman Apr 20, 2023
41e91a8
Removed static from constructConfigManagerMetadata to have on stack t…
SergeyKleyman Apr 21, 2023
515af57
Log stack trace on failed ASSERT in native part
SergeyKleyman Apr 21, 2023
4aed9bd
Set g_elasticApmDirectLogLevel* to default values so that they can be…
SergeyKleyman Apr 22, 2023
0999fdb
Added documentation for configuration options
SergeyKleyman Apr 20, 2023
d1ae031
Added options to AllOptionsMetadata.php
SergeyKleyman Apr 20, 2023
e55e725
Added SPAN_COMPRESSION_* option names to OptionNames.php
SergeyKleyman Apr 20, 2023
64b9153
Added Span Compression options to Config/Snapshot.php
SergeyKleyman Apr 20, 2023
b281216
Added COMPRESSION_STRATEGY_* constants
SergeyKleyman Apr 21, 2023
2d65feb
Added implementation
SergeyKleyman Apr 21, 2023
9d915d3
Added Span Compression related options to src/ext/ConfigManager.c
SergeyKleyman Apr 21, 2023
124a5c7
Added Span Compression related options to src/ext/ConfigManager.h
SergeyKleyman Apr 21, 2023
77beb70
Added Span Compression related options to src/ext/elastic_apm.c
SergeyKleyman Apr 21, 2023
287bdd0
Added Span Compression related options to tests/ElasticApmTests/Compo…
SergeyKleyman Apr 22, 2023
24a829b
MySQLiTest: Disable Span Compression feature to have all the expected…
SergeyKleyman Apr 22, 2023
f99be04
PDOTest: Disable Span Compression feature to have all the expected sp…
SergeyKleyman Apr 22, 2023
97c92eb
Added tests/ElasticApmTests/ComponentTests/SpanCompressionComponentTe…
SergeyKleyman Apr 22, 2023
08dff81
Clarified comment about "Disable Span Compression"
SergeyKleyman Apr 22, 2023
9aa19cc
StackTraceComponentTest: Disable Span Compression feature to have all…
SergeyKleyman Apr 22, 2023
1b2ec3a
Added TracerUnitTestCaseBase::isCompatibleWithSpanCompression
SergeyKleyman Apr 22, 2023
3690d39
InferredSpansBuilderTest: Disable Span Compression feature to have al…
SergeyKleyman Apr 22, 2023
dcb6657
StackTraceUnitTest: Disable Span Compression feature to have all the …
SergeyKleyman Apr 22, 2023
1147ec3
Added tests/ElasticApmTests/UnitTests/SpanCompressionUnitTest.php
SergeyKleyman Apr 22, 2023
dbf59d6
Added tests\ElasticApmTests\Util\AssertValidTrait::assertValidNonNull…
SergeyKleyman Apr 22, 2023
1b9df61
Updated ElasticApmTests\Util\SpanDto
SergeyKleyman Apr 22, 2023
a7a469f
Updated SpanExpectations
SergeyKleyman Apr 22, 2023
0162006
Added optional dbgParamName for better diagnostics
SergeyKleyman Apr 20, 2023
235be20
Distinguish between plugin name and keywords
SergeyKleyman Apr 20, 2023
77b6108
Removed unused imports
SergeyKleyman Apr 21, 2023
12cb1e5
Added 'internal-func' to names related to existing instrumentation (p…
SergeyKleyman Apr 21, 2023
7b6845b
Added 'internal-func' to names related to existing instrumentation (p…
SergeyKleyman Apr 22, 2023
3c35e29
Added 'internal-func' to names related to existing instrumentation (p…
SergeyKleyman Apr 22, 2023
0a607d0
Added verifyExactArgsCount
SergeyKleyman Apr 20, 2023
f68ab36
Implemented WordPress instrumentation - part 1
SergeyKleyman Apr 20, 2023
3686c4a
Added AST_PROCESS_* options to AllOptionsMetadata.php
SergeyKleyman Apr 20, 2023
3c44cb0
Added option names to OptionNames.php
SergeyKleyman Apr 20, 2023
f9c0623
Added AST processing options to Config/Snapshot.php
SergeyKleyman Apr 20, 2023
a870f5b
Switch to span types wordpress_plugin and wordpress_theme
SergeyKleyman Apr 21, 2023
1e65b0b
Fixed issue with assertDirectoryDoesNotExist
SergeyKleyman Apr 21, 2023
22eb8b7
Removed unused imports
SergeyKleyman Apr 21, 2023
80f527f
Added isStringViewSuffix
SergeyKleyman Apr 21, 2023
384befe
Added new .c files to src/ext/config.m4
SergeyKleyman Apr 21, 2023
99930b6
Added AST processing related options to src/ext/ConfigManager.c
SergeyKleyman Apr 21, 2023
077dd14
Added AST processing related options to src/ext/ConfigManager.h
SergeyKleyman Apr 21, 2023
6c02d49
Added ELASTIC_APM_WORDPRESS_DIRECT_CALL_METHOD_SET_READY_TO_WRAP_FILT…
SergeyKleyman Apr 21, 2023
5900bc8
Added AST processing related options to src/ext/elastic_apm.c
SergeyKleyman Apr 21, 2023
13e5014
Added AST processing related API from extension (native part) to PHP …
SergeyKleyman Apr 21, 2023
b73184b
Added AST processing related APIs to src/ext/elastic_apm_API.h
SergeyKleyman Apr 21, 2023
153fc4c
Added calls for AST processing from lifecycle stages
SergeyKleyman Apr 21, 2023
bf085b9
Instrumentation using AST processing (files src/ext/tracer_PHP_part.c|h)
SergeyKleyman Apr 22, 2023
59c8adc
Removed duplicate isStringViewSuffix
SergeyKleyman Apr 22, 2023
b2ea347
Added streamZVal
SergeyKleyman Apr 22, 2023
ec437d6
Added ELASTIC_APM_PHP_TESTS_COMPARE_AST_CONVERTED_BACK_TO_SOURCE
SergeyKleyman Apr 22, 2023
909939f
Added AppCodeHostParams::setAgentOptionIfNotDefaultValue
SergeyKleyman Apr 22, 2023
76cd8ba
Added AppCodeHostParams::setAgentOptions
SergeyKleyman Apr 22, 2023
643394c
Excluded WordPress mock source from static analysis
SergeyKleyman Apr 22, 2023
8025370
Instrumentation using AST processing (file tests/ElasticApmTests/Comp…
SergeyKleyman Apr 22, 2023
2ef6781
Added ELASTIC_APM_PHP_TESTS_COMPARE_AST_CONVERTED_BACK_TO_SOURCE (par…
SergeyKleyman Apr 22, 2023
181d8a4
Added AppCodeHostParams::setAgentOptionIfNotDefaultValue (part 2)
SergeyKleyman Apr 22, 2023
bd832ec
Moved ArrayUtil::append back to ArrayUtilForTests::append
SergeyKleyman Apr 22, 2023
025cc0d
Removed unused imports
SergeyKleyman Apr 22, 2023
11ca7a7
Added AST processing related options to tests/ElasticApmTests/Compone…
SergeyKleyman Apr 22, 2023
bc849f7
Added testReferencesInArray
SergeyKleyman Apr 22, 2023
6e7a93d
Added FileUtilForTests::createTempSubDir
SergeyKleyman Apr 22, 2023
7a9f1eb
Added missing import
SergeyKleyman Apr 22, 2023
07cb674
Removed redundant local variable
SergeyKleyman Apr 27, 2023
d3cf1c5
Added clarifying comments
SergeyKleyman Apr 27, 2023
4fc9729
Reverted references of ELASTIC_APM_EMPTY_STRING_VIEW back to makeEmpt…
SergeyKleyman Apr 23, 2023
be3be81
Fixed incorrect merge
SergeyKleyman Apr 24, 2023
0f8350f
Reverted references of ELASTIC_APM_EMPTY_STRING_VIEW back to makeEmpt…
SergeyKleyman Apr 23, 2023
f40bff0
Fixed incorrect merge
SergeyKleyman Apr 24, 2023
f13a52f
Added documentation for configuration options
SergeyKleyman Apr 20, 2023
70e3a1d
Added options to AllOptionsMetadata.php
SergeyKleyman Apr 20, 2023
f9ff2be
Added SPAN_COMPRESSION_* option names to OptionNames.php
SergeyKleyman Apr 20, 2023
46931a1
Added Span Compression options to Config/Snapshot.php
SergeyKleyman Apr 20, 2023
9b7b9ce
Added COMPRESSION_STRATEGY_* constants
SergeyKleyman Apr 21, 2023
4681ba1
Added implementation
SergeyKleyman Apr 21, 2023
a54bc48
Added Span Compression related options to src/ext/ConfigManager.c
SergeyKleyman Apr 21, 2023
f4ee6ae
Added Span Compression related options to src/ext/ConfigManager.h
SergeyKleyman Apr 21, 2023
b378b5b
Added Span Compression related options to src/ext/elastic_apm.c
SergeyKleyman Apr 21, 2023
dbc4ba8
Added Span Compression related options to tests/ElasticApmTests/Compo…
SergeyKleyman Apr 22, 2023
b2ed672
MySQLiTest: Disable Span Compression feature to have all the expected…
SergeyKleyman Apr 22, 2023
adc6d2a
PDOTest: Disable Span Compression feature to have all the expected sp…
SergeyKleyman Apr 22, 2023
0da8ae6
Added tests/ElasticApmTests/ComponentTests/SpanCompressionComponentTe…
SergeyKleyman Apr 22, 2023
d1248b4
Clarified comment about "Disable Span Compression"
SergeyKleyman Apr 22, 2023
0559f93
StackTraceComponentTest: Disable Span Compression feature to have all…
SergeyKleyman Apr 22, 2023
c01f10e
Added TracerUnitTestCaseBase::isCompatibleWithSpanCompression
SergeyKleyman Apr 22, 2023
8ecb3b9
InferredSpansBuilderTest: Disable Span Compression feature to have al…
SergeyKleyman Apr 22, 2023
e2fc5b4
StackTraceUnitTest: Disable Span Compression feature to have all the …
SergeyKleyman Apr 22, 2023
1d3fc3f
Added tests/ElasticApmTests/UnitTests/SpanCompressionUnitTest.php
SergeyKleyman Apr 22, 2023
4f893d7
Added tests\ElasticApmTests\Util\AssertValidTrait::assertValidNonNull…
SergeyKleyman Apr 22, 2023
0c86cca
Updated ElasticApmTests\Util\SpanDto
SergeyKleyman Apr 22, 2023
9b6001a
Updated SpanExpectations
SergeyKleyman Apr 22, 2023
1b448e7
Removed unused imports
SergeyKleyman Apr 27, 2023
efc65a2
Extended span compression to spans without service target
SergeyKleyman May 4, 2023
7d04fa3
Removed redundant comment
SergeyKleyman May 4, 2023
ba5513f
Clarified docs
SergeyKleyman May 4, 2023
8297d63
Added workaround for false positives from static analysis
SergeyKleyman May 4, 2023
4b62526
Simplified parallel-lint invocation
SergeyKleyman May 4, 2023
54305a2
Fixed unit tests failing on PHP 7.2
SergeyKleyman May 4, 2023
813872f
Fixed issue found by static analysis
SergeyKleyman May 4, 2023
0dac410
Fixed formatting
SergeyKleyman May 4, 2023
3cc6490
Fixed formatting
SergeyKleyman May 4, 2023
6b8e727
Added --exclude ./tests/polyfills/
SergeyKleyman May 4, 2023
3ae000c
Removed TestCaseBaseShim
SergeyKleyman May 4, 2023
668257d
Fixed failing unit test
SergeyKleyman May 4, 2023
86747ad
Added ELASTIC_APM_PHP_TESTS_IS_LONG_RUN_MODE
SergeyKleyman May 4, 2023
c588fda
Reduced number of datasets from dataProviderForTestReasonsCompression…
SergeyKleyman May 4, 2023
0b87d3a
Run testOneCompressedSequence only in isLongRunMode
SergeyKleyman May 4, 2023
1ad47fd
Added check for isLongRunMode dataProviderForTestReasonsCompressionStops
SergeyKleyman May 4, 2023
301733a
Fixed static analysis issue
SergeyKleyman May 4, 2023
8306802
Fixed failing unit tests
SergeyKleyman May 4, 2023
37f69ca
Merge branch '5__Span_compression' into 6__Prepare_for_additional_ins…
SergeyKleyman May 4, 2023
f225c0a
Removed unused import
SergeyKleyman May 4, 2023
f9c8fad
Fixed merge
SergeyKleyman May 4, 2023
e52093c
Fixed merge
SergeyKleyman May 4, 2023
4fcf1ba
Fixed merge
SergeyKleyman May 4, 2023
5538b83
Fixed merge
SergeyKleyman May 4, 2023
b892be3
Merge branch '6__Prepare_for_additional_instrum_kind' into 7__WordPre…
SergeyKleyman May 4, 2023
3d20308
Temporarily hide TransactionMaxSpansUnitTest behind isLongRunMode
SergeyKleyman May 4, 2023
9c982e1
Merge branch '5__Span_compression' into 6__Prepare_for_additional_ins…
SergeyKleyman May 4, 2023
aea458b
Merge branch '6__Prepare_for_additional_instrum_kind' into 7__WordPre…
SergeyKleyman May 4, 2023
3c26cc5
Temporarily disable unit tests
SergeyKleyman May 5, 2023
e37129a
Fixed unit tests
SergeyKleyman May 6, 2023
0f52527
Added diagnostics
SergeyKleyman May 6, 2023
2499378
Fixed failing unit tests
SergeyKleyman May 7, 2023
3fddfba
Added re-run with escalated log level to HttpTransactionTest::testHtt…
SergeyKleyman May 7, 2023
fe54be3
Fixed failing component test
SergeyKleyman May 7, 2023
3ae9aff
Merge branch '5__Span_compression' into 6__Prepare_for_additional_ins…
SergeyKleyman May 7, 2023
bb0f6f3
Revert "Temporarily disable unit tests"
SergeyKleyman May 5, 2023
a36fa96
Merge branch '6__Prepare_for_additional_instrum_kind' into 7__WordPre…
SergeyKleyman May 7, 2023
354fb91
Re-enabled SpanCompressionUnitTest::testReasonsCompressionStops
SergeyKleyman May 8, 2023
797d74b
Merge branch '5__Span_compression' into 6__Prepare_for_additional_ins…
SergeyKleyman May 8, 2023
41964cc
Merge branch '6__Prepare_for_additional_instrum_kind' into 7__WordPre…
SergeyKleyman May 8, 2023
2a3d792
Fixed merge
SergeyKleyman May 8, 2023
9299114
Temporarily disabled component tests
SergeyKleyman May 8, 2023
a5b6d90
Fixed bad merge
SergeyKleyman May 8, 2023
09851d6
Temporarily run only PDOAutoInstrumentationTest
SergeyKleyman May 8, 2023
56d1190
Fixed merge
SergeyKleyman May 8, 2023
0a3baae
Re-enabled component tests
SergeyKleyman May 8, 2023
3a8ab45
Merge branch 'main' into 6__Prepare_for_additional_instrum_kind
SergeyKleyman May 8, 2023
3372547
Merge branch '6__Prepare_for_additional_instrum_kind' into 7__WordPre…
SergeyKleyman May 8, 2023
d51e571
Merge branch 'main' into 5__Span_compression
SergeyKleyman May 8, 2023
26f8b10
Merge branch '5__Span_compression' into 6__Prepare_for_additional_ins…
SergeyKleyman May 8, 2023
1802ad4
Merge branch '6__Prepare_for_additional_instrum_kind' into 7__WordPre…
SergeyKleyman May 8, 2023
1df6158
Merge branch 'main' into 5__Span_compression
SergeyKleyman May 8, 2023
4cf7391
Merge branch '5__Span_compression' into 6__Prepare_for_additional_ins…
SergeyKleyman May 8, 2023
da83ff3
Merge branch '6__Prepare_for_additional_instrum_kind' into 7__WordPre…
SergeyKleyman May 8, 2023
f3ae6ba
Merge branch 'main' into 6__Prepare_for_additional_instrum_kind
SergeyKleyman May 9, 2023
4e38d10
Merge branch '6__Prepare_for_additional_instrum_kind' into 7__WordPre…
SergeyKleyman May 9, 2023
20ae41f
Fixed line endings
SergeyKleyman May 9, 2023
5f56ff6
Merge branch '6__Prepare_for_additional_instrum_kind' into 7__WordPre…
SergeyKleyman May 9, 2023
9aff9be
Merge branch 'main'
SergeyKleyman May 15, 2023
4299168
Fixed line endings (CRLF -> LF)
SergeyKleyman May 15, 2023
d814a19
Merge branch '1__Fix_line_endings' into 3__Fix_no_clean_conn_data_in_…
SergeyKleyman May 15, 2023
617f104
Fixed not cleaning up connection data in sync backend comm. mode
SergeyKleyman May 15, 2023
58bef73
Fixed not joining background sender thread if there was fork
SergeyKleyman May 15, 2023
e9cc20c
Merge branch '2__Fix_no_join_sender_thread' into 7__WordPress_instrum…
SergeyKleyman May 15, 2023
bfcf210
Merge branch '3__Fix_no_clean_conn_data_in_sync_mode' into 7__WordPre…
SergeyKleyman May 15, 2023
29e03fa
Merge branch 'main' into 2__Fix_no_join_sender_thread
SergeyKleyman May 15, 2023
a23ec5d
Merge branch 'main'
SergeyKleyman May 15, 2023
429b0c5
Merge branch 'main'
SergeyKleyman May 15, 2023
12f7ee9
Merge branch '2__Fix_no_join_sender_thread' into 7__WordPress_instrum…
SergeyKleyman May 15, 2023
3e30339
Merge branch '3__Fix_no_clean_conn_data_in_sync_mode' into 7__WordPre…
SergeyKleyman May 15, 2023
86b85f0
Merge branch 'main' into 7__WordPress_instrumentation
SergeyKleyman May 15, 2023
98e7b36
Added option part 1
SergeyKleyman May 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions phpcs.xml.dist
Expand Up @@ -28,4 +28,7 @@

<exclude-pattern>*/polyfills/Stringable.php</exclude-pattern>
<exclude-pattern>*/polyfills/WeakMap.php</exclude-pattern>

<exclude-pattern>*/tests/ElasticApmTests/ComponentTests/WordPress/mock_src/*.php</exclude-pattern>
<exclude-pattern>*/tests/ElasticApmTests/ComponentTests/WordPress/expected_process_AST_output/*.php</exclude-pattern>
</ruleset>
2 changes: 2 additions & 0 deletions phpstan.neon
Expand Up @@ -10,6 +10,8 @@ parameters:
excludePaths:
- tests/polyfills/Stringable.php
- tests/polyfills/WeakMap.php
- tests/ElasticApmTests/ComponentTests/WordPress/mock_src/*.php
- tests/ElasticApmTests/ComponentTests/WordPress/expected_process_AST_output/*.php

ignoreErrors:
#
Expand Down
16 changes: 16 additions & 0 deletions src/ElasticApm/Impl/AutoInstrument/AutoInstrumentationBase.php
Expand Up @@ -55,6 +55,14 @@ public function isEnabled(?string &$reason = null): bool
return false;
}

$isUserlandCodeInstrumentationEnabled = $this->tracer->getConfig()->astProcessEnabled();
if ($this->requiresUserlandCodeInstrumentation() && (!$isUserlandCodeInstrumentationEnabled)) {
$reason = 'Instrumentation ' . $this->name() . ' needs userland code instrumentation'
. ' but AST-process is the only currently supported mechanism to instrument userland code and it is DISABLED'
. ' (via ' . OptionNames::AST_PROCESS_ENABLED . ' configuration option)';
return false;
}

$disabledInstrumentationsMatcher = $this->tracer->getConfig()->disableInstrumentations();
if ($disabledInstrumentationsMatcher === null) {
return true;
Expand Down Expand Up @@ -85,6 +93,14 @@ public function requiresAttachContextToExternalObjects(): bool
return false;
}

/**
* @return bool
*/
public function requiresUserlandCodeInstrumentation(): bool
{
return false;
}

/**
* @return string[]
*/
Expand Down
18 changes: 18 additions & 0 deletions src/ElasticApm/Impl/AutoInstrument/Autoloader.php
Expand Up @@ -83,7 +83,25 @@ public static function autoloadCodeForClass(string $fqClassName): void
__LINE__,
__FUNCTION__
);

/**
* elastic_apm_* functions are provided by the elastic_apm extension
*
* @noinspection PhpFullyQualifiedNameUsageInspection, PhpUndefinedFunctionInspection
* @phpstan-ignore-next-line
*/
\elastic_apm_before_loading_agent_php_code();

require $classSrcFileAbsolute;

/**
* elastic_apm_* functions are provided by the elastic_apm extension
*
* @noinspection PhpFullyQualifiedNameUsageInspection, PhpUndefinedFunctionInspection
* @phpstan-ignore-next-line
*/
\elastic_apm_after_loading_agent_php_code();

BootstrapStageLogger::logTrace(
"After require `$classSrcFileAbsolute' ...",
__LINE__,
Expand Down
14 changes: 14 additions & 0 deletions src/ElasticApm/Impl/AutoInstrument/BuiltinPlugin.php
Expand Up @@ -32,6 +32,9 @@
*/
final class BuiltinPlugin extends PluginBase
{
/** @var ?WordPressAutoInstrumentation */
private $wordPressAutoInstrumentationIfEnabled;

public function __construct(Tracer $tracer)
{
parent::__construct(
Expand All @@ -42,10 +45,21 @@ public function __construct(Tracer $tracer)
new MySQLiAutoInstrumentation($tracer),
]
);

$wordPressAutoInstrumentation = new WordPressAutoInstrumentation($tracer);
$this->wordPressAutoInstrumentationIfEnabled =
$this->checkIfInstrumentationEnabled($wordPressAutoInstrumentation)
? $wordPressAutoInstrumentation
: null;
}

public function getDescription(): string
{
return 'BUILT-IN';
}

public function getWordPressAutoInstrumentationIfEnabled(): ?WordPressAutoInstrumentation
{
return $this->wordPressAutoInstrumentationIfEnabled;
}
}
Expand Up @@ -37,4 +37,5 @@ final class InstrumentationNames
public const CURL = 'curl';
public const PDO = 'pdo';
public const MYSQLI = 'mysqli';
public const WORDPRESS = 'wordpress';
}
127 changes: 96 additions & 31 deletions src/ElasticApm/Impl/AutoInstrument/InterceptionManager.php
Expand Up @@ -27,6 +27,7 @@
use Elastic\Apm\Impl\Log\Logger;
use Elastic\Apm\Impl\Tracer;
use Elastic\Apm\Impl\Util\ArrayUtil;
use Elastic\Apm\Impl\Util\ClassNameUtil;
use Elastic\Apm\Impl\Util\DbgUtil;
use Throwable;

Expand All @@ -43,6 +44,9 @@ final class InterceptionManager
/** @var Logger */
private $logger;

/** @var BuiltinPlugin */
private $builtinPlugin;

/** @var int|null */
private $interceptedCallInProgressRegistrationId = null;

Expand All @@ -64,20 +68,12 @@ public function __construct(Tracer $tracer)

private function loadPlugins(Tracer $tracer): void
{
$this->builtinPlugin = new BuiltinPlugin($tracer);
$registerCtx = new RegistrationContext();
$this->loadPluginsImpl($tracer, $registerCtx);

$this->interceptedCallRegistrations = $registerCtx->interceptedCallRegistrations;
}

private function loadPluginsImpl(Tracer $tracer, RegistrationContext $registerCtx): void
{
$builtinPlugin = new BuiltinPlugin($tracer);
$registerCtx->dbgCurrentPluginIndex = 0;
$registerCtx->dbgCurrentPluginDesc = $builtinPlugin->getDescription();
$builtinPlugin->register($registerCtx);

// self::loadConfiguredPlugins();
$registerCtx->dbgCurrentPluginDesc = $this->builtinPlugin->getDescription();
$this->builtinPlugin->register($registerCtx);
$this->interceptedCallRegistrations = $registerCtx->interceptedCallRegistrations;
}

/**
Expand All @@ -101,8 +97,9 @@ public function internalFuncCallPreHook(
'interceptedCallArgs' => $this->logger->possiblySecuritySensitive($interceptedCallArgs),
]
);
($loggerProxy = $localLogger->ifTraceLevelEnabled(__LINE__, __FUNCTION__))
&& $loggerProxy->log('Entered');
$loggerProxyTrace = $localLogger->ifTraceLevelEnabledNoLine(__FUNCTION__);

$loggerProxyTrace && $loggerProxyTrace->log(__LINE__, 'Entered');

$interceptRegistration
= ArrayUtil::getValueIfKeyExistsElse($interceptRegistrationId, $this->interceptedCallRegistrations, null);
Expand All @@ -113,8 +110,7 @@ public function internalFuncCallPreHook(
}
$localLogger->addContext('interceptRegistration', $interceptRegistration);

($loggerProxy = $localLogger->ifTraceLevelEnabled(__LINE__, __FUNCTION__))
&& $loggerProxy->log('Calling preHook...');
$loggerProxyTrace && $loggerProxyTrace->log(__LINE__, 'Calling preHook...');
try {
$preHookRetVal = ($interceptRegistration->preHook)($thisObj, $interceptedCallArgs);
} catch (Throwable $throwable) {
Expand All @@ -133,8 +129,7 @@ public function internalFuncCallPreHook(
$this->interceptedCallInProgressPreHookRetVal = $preHookRetVal;
}

($loggerProxy = $localLogger->ifTraceLevelEnabled(__LINE__, __FUNCTION__))
&& $loggerProxy->log('preHook completed successfully', ['shouldCallPostHook' => $shouldCallPostHook]);
$loggerProxyTrace && $loggerProxyTrace->log(__LINE__, 'preHook completed successfully', ['shouldCallPostHook' => $shouldCallPostHook]);
return $shouldCallPostHook;
}

Expand All @@ -149,8 +144,14 @@ public function internalFuncCallPostHook(
bool $hasExitedByException,
$returnValueOrThrown
): void {
($loggerProxy = $this->logger->ifTraceLevelEnabled(__LINE__, __FUNCTION__))
&& $loggerProxy->log('Entered');
$localLogger = $this->logger->inherit()->addAllContext(
[
'interceptRegistrationId' => $this->interceptedCallInProgressRegistrationId,
'interceptRegistration' => $this->interceptedCallInProgressRegistration,
]
);
$loggerProxyTrace = $localLogger->ifTraceLevelEnabledNoLine(__FUNCTION__);
$loggerProxyTrace && $loggerProxyTrace->log(__LINE__, 'Entered');

if ($this->interceptedCallInProgressRegistrationId === null) {
($loggerProxy = $this->logger->ifErrorLevelEnabled(__LINE__, __FUNCTION__))
Expand All @@ -160,28 +161,92 @@ public function internalFuncCallPostHook(
assert($this->interceptedCallInProgressRegistration !== null);
assert($this->interceptedCallInProgressPreHookRetVal !== null);

$localLogger = $this->logger->inherit()->addAllContext(
[
'interceptRegistrationId' => $this->interceptedCallInProgressRegistrationId,
'interceptRegistration' => $this->interceptedCallInProgressRegistration,
]
);

$loggerProxyTrace && $loggerProxyTrace->log(__LINE__, 'Calling postHook...');
try {
($this->interceptedCallInProgressPreHookRetVal)(
$numberOfStackFramesToSkip + 1,
$hasExitedByException,
$returnValueOrThrown
);
$loggerProxyTrace && $loggerProxyTrace->log(__LINE__, 'postHook completed without throwing');
} catch (Throwable $throwable) {
($loggerProxy = $localLogger->ifErrorLevelEnabled(__LINE__, __FUNCTION__))
&& $loggerProxy->logThrowable(
$throwable,
'postHook has let a Throwable to escape'
);
&& $loggerProxy->logThrowable($throwable, 'postHook has thrown');
}

$this->interceptedCallInProgressRegistrationId = null;
$this->interceptedCallInProgressPreHookRetVal = null;
}

public function astInstrumentationDirectCall(string $method): void
{
$localLogger = $this->logger->inherit()->addAllContext(['method' => $method]);

$loggerProxyTrace = $localLogger->ifTraceLevelEnabledNoLine(__FUNCTION__);
$loggerProxyTrace && $loggerProxyTrace->log(__LINE__, 'Entered');

$wordPressAutoInstrumIfEnabled = $this->builtinPlugin->getWordPressAutoInstrumentationIfEnabled();
if ($wordPressAutoInstrumIfEnabled === null) {
static $loggedOnce = false;
if (!$loggedOnce) {
$loggerProxyTrace && $loggerProxyTrace->log(__LINE__, 'WordPress instrumentation is DISABLED');
$loggedOnce = true;
}
return;
}

static $dbgImplFuncDesc = null;
if ($dbgImplFuncDesc === null) {
$dbgImplFuncDesc = ClassNameUtil::fqToShort(WordPressAutoInstrumentation::class) . '->directCall';
}
/** @var string $dbgImplFuncDesc */
$loggerProxyTrace && $loggerProxyTrace->log(__LINE__, 'Calling ' . $dbgImplFuncDesc . '...');
try {
$wordPressAutoInstrumIfEnabled->directCall($method);
$loggerProxyTrace && $loggerProxyTrace->log(__LINE__, $dbgImplFuncDesc . ' completed without throwing');
} catch (Throwable $throwable) {
($loggerProxy = $localLogger->ifErrorLevelEnabled(__LINE__, __FUNCTION__)) && $loggerProxy->logThrowable($throwable, $dbgImplFuncDesc . ' has thrown');
}
}

/**
* @param ?string $instrumentedClassFullName
* @param string $instrumentedFunction
* @param mixed[] $capturedArgs
*
* @return null|callable(?Throwable $thrown, mixed $returnValue): void
*/
public function astInstrumentationPreHook(?string $instrumentedClassFullName, string $instrumentedFunction, array $capturedArgs): ?callable
{
$localLogger = $this->logger->inherit()->addAllContext(['instrumentedClassFullName' => $instrumentedClassFullName]);

$loggerProxyTrace = $localLogger->ifTraceLevelEnabledNoLine(__FUNCTION__);
$loggerProxyTrace && $loggerProxyTrace->log(__LINE__, 'Entered');

$wordPressAutoInstrumIfEnabled = $this->builtinPlugin->getWordPressAutoInstrumentationIfEnabled();
if ($wordPressAutoInstrumIfEnabled === null) {
static $loggedOnce = false;
if (!$loggedOnce) {
$loggerProxyTrace && $loggerProxyTrace->log(__LINE__, 'WordPress instrumentation is DISABLED');
$loggedOnce = true;
}
return null;
}

static $dbgImplFuncDesc = null;
if ($dbgImplFuncDesc === null) {
$dbgImplFuncDesc = ClassNameUtil::fqToShort(WordPressAutoInstrumentation::class) . '->preHook';
}
/** @var string $dbgImplFuncDesc */
$loggerProxyTrace && $loggerProxyTrace->log(__LINE__, 'Calling ' . $dbgImplFuncDesc . '...');
try {
$retVal = $wordPressAutoInstrumIfEnabled->preHook($instrumentedClassFullName, $instrumentedFunction, $capturedArgs);
$loggerProxyTrace && $loggerProxyTrace->log(__LINE__, $dbgImplFuncDesc . ' completed without throwing', ['retVal == null' => ($retVal == null)]);
return $retVal;
} catch (Throwable $throwable) {
($loggerProxy = $localLogger->ifErrorLevelEnabled(__LINE__, __FUNCTION__))
&& $loggerProxy->logThrowable($throwable, $dbgImplFuncDesc . ' has thrown');
return null;
}
}
}
32 changes: 32 additions & 0 deletions src/ElasticApm/Impl/AutoInstrument/PhpPartFacade.php
Expand Up @@ -515,4 +515,36 @@ private static function buildTracer(): ?Tracer
public static function emptyMethod(): void
{
}

/**
* Calls to this method are inserted by AST instrumentation.
* See src/ext/WordPress_instrumentation.c
*
* @noinspection PhpUnused
*
* @param ?string $instrumentedClassFullName
* @param string $instrumentedFunction
* @param mixed[] $capturedArgs
*
* @return null|callable(?Throwable $thrown, mixed $returnValue): void
*/
public static function astInstrumentationPreHook(?string $instrumentedClassFullName, string $instrumentedFunction, array $capturedArgs): ?callable
{
return (($interceptionManager = self::singletonInstance()->interceptionManager) !== null)
? $interceptionManager->astInstrumentationPreHook($instrumentedClassFullName, $instrumentedFunction, $capturedArgs)
: null;
}

/**
* Calls to this method are inserted by AST instrumentation.
* See src/ext/WordPress_instrumentation.c
*
* @noinspection PhpUnused
*/
public static function astInstrumentationDirectCall(string $method): void
{
if (($interceptionManager = self::singletonInstance()->interceptionManager) !== null) {
$interceptionManager->astInstrumentationDirectCall($method);
}
}
}