Skip to content

Commit

Permalink
Merged v1.9.0 tag into 1.x branch (#1002)
Browse files Browse the repository at this point in the history
* Fixed a few formatting issues (#925)

* Improved formatting in AllOptionsMetadata.php

* Improved formatting in Logger_tests.c

* Improved formatting in src/ext/log.c

* Improved formatting in tests/ElasticApmTests/ComponentTests/Util/AllComponentTestsOptionsMetadata.php

* Improved formatting in tests/ElasticApmTests/ComponentTests/Util/RawDataFromAgent.php

* Improved formatting in tests.ElasticApmTests.ComponentTests.ConfigSettingTest.php

* Improved formatting in tests/ElasticApmTests/ComponentTests/MySQLiTest.php

* Improved formatting in tests/ElasticApmTests/ComponentTests/PDOTest.php

* Improved formatting in tests/ElasticApmTests/ComponentTests/MySQLiTest.php (part 2)

* Reverted references of ELASTIC_APM_EMPTY_STRING_VIEW back to makeEmptyStringView()

since ELASTIC_APM_EMPTY_STRING_VIEW is added in a later PR

* Fixed a few naming issues (#926)

* Improved formatting in AllOptionsMetadata.php

* Improved formatting in Logger_tests.c

* Improved formatting in src/ext/log.c

* Improved formatting in tests/ElasticApmTests/ComponentTests/Util/AllComponentTestsOptionsMetadata.php

* Improved formatting in tests/ElasticApmTests/ComponentTests/Util/RawDataFromAgent.php

* Improved formatting in tests.ElasticApmTests.ComponentTests.ConfigSettingTest.php

* Improved formatting in tests/ElasticApmTests/ComponentTests/MySQLiTest.php

* Improved formatting in tests/ElasticApmTests/ComponentTests/PDOTest.php

* Improved formatting in tests/ElasticApmTests/ComponentTests/MySQLiTest.php (part 2)

* Reverted references of ELASTIC_APM_EMPTY_STRING_VIEW back to makeEmptyStringView()

since ELASTIC_APM_EMPTY_STRING_VIEW is added in a later PR

* Renamed BootstrapStageLogger::logLevel to logWithLevel

* Renamed ELASTIC_APM_LOG_WRITE_TO_SYSLOG to ELASTIC_APM_LOG_TO_BACKGROUND_SINK

* Fixed typo in local variable name

* Added clarification in the online documentation that log_* configuration is for supportability only (#939)

* Clarified that log_* is for supportability only

* Apply suggestions from code review

Co-authored-by: Brandon Morelli <[email protected]>

---------

Co-authored-by: Brandon Morelli <[email protected]>

* Refactored some code (#927)

* Improved formatting in AllOptionsMetadata.php

* Improved formatting in Logger_tests.c

* Improved formatting in src/ext/log.c

* Improved formatting in tests/ElasticApmTests/ComponentTests/Util/AllComponentTestsOptionsMetadata.php

* Improved formatting in tests/ElasticApmTests/ComponentTests/Util/RawDataFromAgent.php

* Improved formatting in tests.ElasticApmTests.ComponentTests.ConfigSettingTest.php

* Improved formatting in tests/ElasticApmTests/ComponentTests/MySQLiTest.php

* Improved formatting in tests/ElasticApmTests/ComponentTests/PDOTest.php

* Improved formatting in tests/ElasticApmTests/ComponentTests/MySQLiTest.php (part 2)

* Reverted references of ELASTIC_APM_EMPTY_STRING_VIEW back to makeEmptyStringView()

since ELASTIC_APM_EMPTY_STRING_VIEW is added in a later PR

* Renamed BootstrapStageLogger::logLevel to logWithLevel

* Renamed ELASTIC_APM_LOG_WRITE_TO_SYSLOG to ELASTIC_APM_LOG_TO_BACKGROUND_SINK

* Fixed typo in local variable name

* Added Logger::if*LevelEnabledNoLine for all the remaining log levels

* Added ability to inherit context from LoggerFactory

* Make ArrayUtil::getValueIfKeyExists a template instead of mixed

* Added ArrayUtil::append

* Marked captureInClassicFormatExcludeElasticApm $loggerFactory as nullable

StackTraceUtil::captureInClassicFormatExcludeElasticApm

* Removed redundant type-hint

* Added ELASTIC_APM_BUILD_PHP_VERSION_ID

* Removed declaration of unused makeDynamicArray()

* Added src/ext/ArrayView.h

* Added string related utility functions

* Added string related utility functions (part 2)

* Split ConfigManager.h into multiple more manageable headers

* Split ConfigManager.h into multiple more manageable headers (part 2)

* Split ConfigManager.h into multiple more manageable headers (part 3)

* Split ConfigManager.h into multiple more manageable headers (part 4)

* Added string related utility functions (part 3)

* Split ConfigManager.h into multiple more manageable headers (part 5)

* Split big header files into multiple more manageable headers (part 6)

* Split big header files into multiple more manageable headers (part 7)

* enum LogLevel to a separate header (LogLevel.h)

* Added maxEnabledLogLevel()

* Added ELASTIC_APM_LOG_DIRECT_INFO

* Added missing include

* Added // NOLINT for ELASTIC_APM_FOR_EACH_INDEX_START_END

* Clarified structure of a header added to each allocation for track it

* Extracted TextOutputStream_forward_decl.h from TextOutputStream.h

* Extracted OptionalBool to its own header (OptionalBool.h)

* Extracted TextOutputStream_forward_decl.h from TextOutputStream.h (part 2)

* Made implicit casts explcit

* Added openFile to have "safe fopen" similar to fopen_s available on Windows

* Added openFile to have "safe fopen" similar to fopen_s available on Windows (part 2)

* Extracted TextOutputStream_forward_decl.h from TextOutputStream.h (part 3)

* Added resultBufferIsTooSmall to ResultCode

* Renamed ELASTIC_APM_CALL_EARLY_GOTO_FINALLY_WITH_SUCCESS to ELASTIC_APM_SET_RESULT_CODE_TO_SUCCESS_AND_GOTO_FINALLY

* Added ELASTIC_APM_EMPTY_STRING_VIEW instead of makeEmptyStringView so it can be used to init static

* Extracted TextOutputStream_forward_decl.h from TextOutputStream.h (part 4)

* Split ConfigManager.h into multiple more manageable headers (part 6)

* Split ConfigManager.h into multiple more manageable headers (part 7)

* Removed unused ELASTIC_APM_PHP_PART_ON_PHP_ERROR_FUNC and ELASTIC_APM_PHP_PART_SET_LAST_THROWN_FUNC

* Split ConfigManager.h into multiple more manageable headers (part 8)

* Added ELASTIC_APM_EMPTY_STRING_VIEW instead of makeEmptyStringView so it can be used to init static (part 2)

* Extracted TextOutputStream_forward_decl.h from TextOutputStream.h (part 5)

* Added zend_string related utility functions

* Added missing include-s

* Refactored TextUtilForTests::iterateLines to allow finer control over end-of-line part

* Removed unused import (tests/ElasticApmTests/ComponentTests/Util/ResourcesClient.php)

* Replaced ComponentTestCaseBase::getMandatoryAppCodeArg + assertIs<expected type> by get<expected type>FromMap

* Removed unused import (tests/ElasticApmTests/Util/Deserialization/ServerApiSchemaValidator.php)

* Added /* in,out */ to ArrayUtilForTests::append

* Added AssertMessageBuilder::buildString

* Removed unused import (tests/ElasticApmTests/Util/TestCaseBase.php)

* DataProviderForTestBuilder: Have keys included in logged data-set

* Added MixedMap

* Made IterableUtilForTests::iterableToGenerator a function template

instead of being based on mixed type-hint

* Added comments to calls of ArrayUtilForTests::append

* Refactored TextUtilForTests::iterateLines to allow finer control over end-of-line part (part 2)

* Fixed imports in ComponentTestCaseBase.php

* Fixed incorrect merge

* Added missing include

* Added retries on "composer install" has an intermittent failure

* Log PhpUnitExtensionBase::$timestampBeforeTest when setting it

* Use TimeUtilForTests::timestampToLoggable in assertLessThanOrEqualTimestamp

* Applied runAndEscalateLogLevelOnFailure to testAllWaysToSetConfig

from ConfigSettingTest class

* Improved supportability (#941)

* Reverted references of ELASTIC_APM_EMPTY_STRING_VIEW back to makeEmptyStringView()

since ELASTIC_APM_EMPTY_STRING_VIEW is added in a later PR

* Fixed incorrect merge

* Added INTERNAL_CHECKS_LEVEL to OptionNames.php

* Added maxNumberOfStackFrames as parameter to 

LoggableStackTrace::buildForCurrent instead having hardcoded

* Removed static from constructConfigManagerMetadata to have on stack trace

* Log stack trace on failed ASSERT in native part

* Set g_elasticApmDirectLogLevel* to default values so that they can be used even before configuration is parsed

* Documented that agent uses PHP's error_reporting (#938)

* Documented that agent uses PHP's error_reporting

* Reworded part of "PHP errors as APM error events" section

* Made sure all the supported configuration options are documented (#940)

* Documented that agent uses PHP's error_reporting

* Clarified that log_* is for supportability only

* Documented capture_errors

* Fixed incorrect quotes placement

* Improved description for disable_instrumentations

* Apply suggestions from code review

Co-authored-by: Brandon Morelli <[email protected]>

* Fixed merge

---------

Co-authored-by: Brandon Morelli <[email protected]>

* Update supported-technologies.asciidoc (#952)

Added Laravel 10 to the list of versions of Laravel

* Update supported-technologies.asciidoc (#952)

Added Laravel 10 to the list of versions of Laravel

* Update supported-technologies.asciidoc (#952)

Added Laravel 10 to the list of versions of Laravel

* Fixed addDelayToAbsTimeSpec for the case when (#953)

when delayInNanoseconds >= NANOSECONDS_IN_SECOND

* Extended span compression support to spans without service target (#944)

* Reverted references of ELASTIC_APM_EMPTY_STRING_VIEW back to makeEmptyStringView()

since ELASTIC_APM_EMPTY_STRING_VIEW is added in a later PR

* Fixed incorrect merge

* Reverted references of ELASTIC_APM_EMPTY_STRING_VIEW back to makeEmptyStringView()

since ELASTIC_APM_EMPTY_STRING_VIEW is added in a later PR

* Fixed incorrect merge

* Added documentation for configuration options

* Added options to AllOptionsMetadata.php

* Added SPAN_COMPRESSION_* option names to OptionNames.php

* Added Span Compression options to Config/Snapshot.php

* Added COMPRESSION_STRATEGY_* constants

* Added implementation

* Added Span Compression related options to src/ext/ConfigManager.c

* Added Span Compression related options to src/ext/ConfigManager.h

* Added Span Compression related options to src/ext/elastic_apm.c

* Added Span Compression related options to tests/ElasticApmTests/ComponentTests/ConfigSettingTest.php

* MySQLiTest: Disable Span Compression feature to have all the expected spans individually

* PDOTest: Disable Span Compression feature to have all the expected spans individually

* Added tests/ElasticApmTests/ComponentTests/SpanCompressionComponentTest.php

* Clarified comment about "Disable Span Compression"

* StackTraceComponentTest: Disable Span Compression feature to have all the expected spans individually

* Added TracerUnitTestCaseBase::isCompatibleWithSpanCompression

* InferredSpansBuilderTest: Disable Span Compression feature to have all the expected spans individually

* StackTraceUnitTest: Disable Span Compression feature to have all the expected spans individually

* Added tests/ElasticApmTests/UnitTests/SpanCompressionUnitTest.php

* Added tests\ElasticApmTests\Util\AssertValidTrait::assertValidNonNullableString

* Updated ElasticApmTests\Util\SpanDto

* Updated SpanExpectations

* Removed unused imports

* Extended span compression to spans without service target

* Removed redundant comment

* Clarified docs

* Added workaround for false positives from static analysis

* Simplified parallel-lint invocation

* Fixed unit tests failing on PHP 7.2

* Fixed issue found by static analysis

* Fixed formatting

* Fixed formatting

* Added --exclude ./tests/polyfills/

* Removed TestCaseBaseShim

* Fixed failing unit test

* Added ELASTIC_APM_PHP_TESTS_IS_LONG_RUN_MODE

* Reduced number of datasets from dataProviderForTestReasonsCompressionStops

* Run testOneCompressedSequence only in isLongRunMode

* Added check for isLongRunMode dataProviderForTestReasonsCompressionStops

* Fixed static analysis issue

* Fixed failing unit tests

* Temporarily hide TransactionMaxSpansUnitTest behind isLongRunMode

* Fixed unit tests

* Added diagnostics

* Fixed failing unit tests

* Added re-run with escalated log level to HttpTransactionTest::testHttpStatus

* Fixed failing component test

* Re-enabled SpanCompressionUnitTest::testReasonsCompressionStops

* chore: Updated the content of the file "/tmp/updatecli/github/elastic... (#942)

... /apm-agent-php/tests/APM_Agents_shared/gherkin-specs/otel_bridge.feature"

Made with ❤️️ by updatecli

Co-authored-by: apmmachine <[email protected]>

* Prepare for additional instrumentation kind (#946)

* Improved formatting in AllOptionsMetadata.php

* Improved formatting in Logger_tests.c

* Improved formatting in src/ext/log.c

* Improved formatting in tests/ElasticApmTests/ComponentTests/Util/AllComponentTestsOptionsMetadata.php

* Improved formatting in tests/ElasticApmTests/ComponentTests/Util/RawDataFromAgent.php

* Improved formatting in tests.ElasticApmTests.ComponentTests.ConfigSettingTest.php

* Improved formatting in tests/ElasticApmTests/ComponentTests/MySQLiTest.php

* Improved formatting in tests/ElasticApmTests/ComponentTests/PDOTest.php

* Improved formatting in tests/ElasticApmTests/ComponentTests/MySQLiTest.php (part 2)

* Reverted references of ELASTIC_APM_EMPTY_STRING_VIEW back to makeEmptyStringView()

since ELASTIC_APM_EMPTY_STRING_VIEW is added in a later PR

* Renamed BootstrapStageLogger::logLevel to logWithLevel

* Renamed ELASTIC_APM_LOG_WRITE_TO_SYSLOG to ELASTIC_APM_LOG_TO_BACKGROUND_SINK

* Fixed typo in local variable name

* Added Logger::if*LevelEnabledNoLine for all the remaining log levels

* Added ability to inherit context from LoggerFactory

* Make ArrayUtil::getValueIfKeyExists a template instead of mixed

* Added ArrayUtil::append

* Marked captureInClassicFormatExcludeElasticApm $loggerFactory as nullable

StackTraceUtil::captureInClassicFormatExcludeElasticApm

* Removed redundant type-hint

* Added ELASTIC_APM_BUILD_PHP_VERSION_ID

* Removed declaration of unused makeDynamicArray()

* Added src/ext/ArrayView.h

* Added string related utility functions

* Added string related utility functions (part 2)

* Split ConfigManager.h into multiple more manageable headers

* Split ConfigManager.h into multiple more manageable headers (part 2)

* Split ConfigManager.h into multiple more manageable headers (part 3)

* Split ConfigManager.h into multiple more manageable headers (part 4)

* Added string related utility functions (part 3)

* Split ConfigManager.h into multiple more manageable headers (part 5)

* Split big header files into multiple more manageable headers (part 6)

* Split big header files into multiple more manageable headers (part 7)

* enum LogLevel to a separate header (LogLevel.h)

* Added maxEnabledLogLevel()

* Added ELASTIC_APM_LOG_DIRECT_INFO

* Added missing include

* Added // NOLINT for ELASTIC_APM_FOR_EACH_INDEX_START_END

* Clarified structure of a header added to each allocation for track it

* Extracted TextOutputStream_forward_decl.h from TextOutputStream.h

* Extracted OptionalBool to its own header (OptionalBool.h)

* Extracted TextOutputStream_forward_decl.h from TextOutputStream.h (part 2)

* Made implicit casts explcit

* Added openFile to have "safe fopen" similar to fopen_s available on Windows

* Added openFile to have "safe fopen" similar to fopen_s available on Windows (part 2)

* Extracted TextOutputStream_forward_decl.h from TextOutputStream.h (part 3)

* Added resultBufferIsTooSmall to ResultCode

* Renamed ELASTIC_APM_CALL_EARLY_GOTO_FINALLY_WITH_SUCCESS to ELASTIC_APM_SET_RESULT_CODE_TO_SUCCESS_AND_GOTO_FINALLY

* Added ELASTIC_APM_EMPTY_STRING_VIEW instead of makeEmptyStringView so it can be used to init static

* Extracted TextOutputStream_forward_decl.h from TextOutputStream.h (part 4)

* Split ConfigManager.h into multiple more manageable headers (part 6)

* Split ConfigManager.h into multiple more manageable headers (part 7)

* Removed unused ELASTIC_APM_PHP_PART_ON_PHP_ERROR_FUNC and ELASTIC_APM_PHP_PART_SET_LAST_THROWN_FUNC

* Split ConfigManager.h into multiple more manageable headers (part 8)

* Added ELASTIC_APM_EMPTY_STRING_VIEW instead of makeEmptyStringView so it can be used to init static (part 2)

* Extracted TextOutputStream_forward_decl.h from TextOutputStream.h (part 5)

* Added zend_string related utility functions

* Added missing include-s

* Refactored TextUtilForTests::iterateLines to allow finer control over end-of-line part

* Removed unused import (tests/ElasticApmTests/ComponentTests/Util/ResourcesClient.php)

* Replaced ComponentTestCaseBase::getMandatoryAppCodeArg + assertIs<expected type> by get<expected type>FromMap

* Removed unused import (tests/ElasticApmTests/Util/Deserialization/ServerApiSchemaValidator.php)

* Added /* in,out */ to ArrayUtilForTests::append

* Added AssertMessageBuilder::buildString

* Removed unused import (tests/ElasticApmTests/Util/TestCaseBase.php)

* DataProviderForTestBuilder: Have keys included in logged data-set

* Added MixedMap

* Made IterableUtilForTests::iterableToGenerator a function template

instead of being based on mixed type-hint

* Added comments to calls of ArrayUtilForTests::append

* Refactored TextUtilForTests::iterateLines to allow finer control over end-of-line part (part 2)

* Fixed imports in ComponentTestCaseBase.php

* Fixed incorrect merge

* Added missing include

* Added retries on "composer install" has an intermittent failure

* Log PhpUnitExtensionBase::$timestampBeforeTest when setting it

* Use TimeUtilForTests::timestampToLoggable in assertLessThanOrEqualTimestamp

* Applied runAndEscalateLogLevelOnFailure to testAllWaysToSetConfig

from ConfigSettingTest class

* Added INTERNAL_CHECKS_LEVEL to OptionNames.php

* Added maxNumberOfStackFrames as parameter to 

LoggableStackTrace::buildForCurrent instead having hardcoded

* Removed static from constructConfigManagerMetadata to have on stack trace

* Log stack trace on failed ASSERT in native part

* Set g_elasticApmDirectLogLevel* to default values so that they can be used even before configuration is parsed

* Added documentation for configuration options

* Added options to AllOptionsMetadata.php

* Added SPAN_COMPRESSION_* option names to OptionNames.php

* Added Span Compression options to Config/Snapshot.php

* Added COMPRESSION_STRATEGY_* constants

* Added implementation

* Added Span Compression related options to src/ext/ConfigManager.c

* Added Span Compression related options to src/ext/ConfigManager.h

* Added Span Compression related options to src/ext/elastic_apm.c

* Added Span Compression related options to tests/ElasticApmTests/ComponentTests/ConfigSettingTest.php

* MySQLiTest: Disable Span Compression feature to have all the expected spans individually

* PDOTest: Disable Span Compression feature to have all the expected spans individually

* Added tests/ElasticApmTests/ComponentTests/SpanCompressionComponentTest.php

* Clarified comment about "Disable Span Compression"

* StackTraceComponentTest: Disable Span Compression feature to have all the expected spans individually

* Added TracerUnitTestCaseBase::isCompatibleWithSpanCompression

* InferredSpansBuilderTest: Disable Span Compression feature to have all the expected spans individually

* StackTraceUnitTest: Disable Span Compression feature to have all the expected spans individually

* Added tests/ElasticApmTests/UnitTests/SpanCompressionUnitTest.php

* Added tests\ElasticApmTests\Util\AssertValidTrait::assertValidNonNullableString

* Updated ElasticApmTests\Util\SpanDto

* Updated SpanExpectations

* Added optional dbgParamName for better diagnostics

* Distinguish between plugin name and keywords

Both name and keywords can be used to disable a plugin

* Removed unused imports

* Added 'internal-func' to names related to existing instrumentation (part 2)

to distinguish from other instrumentation mechanisms (for example the upcoming AST processing based)

* Added 'internal-func' to names related to existing instrumentation (part 3)

to distinguish from other instrumentation mechanisms (for example the upcoming AST processing based)

* Reverted references of ELASTIC_APM_EMPTY_STRING_VIEW back to makeEmptyStringView()

since ELASTIC_APM_EMPTY_STRING_VIEW is added in a later PR

* Fixed incorrect merge

* Reverted references of ELASTIC_APM_EMPTY_STRING_VIEW back to makeEmptyStringView()

since ELASTIC_APM_EMPTY_STRING_VIEW is added in a later PR

* Fixed incorrect merge

* Added documentation for configuration options

* Added options to AllOptionsMetadata.php

* Added SPAN_COMPRESSION_* option names to OptionNames.php

* Added Span Compression options to Config/Snapshot.php

* Added COMPRESSION_STRATEGY_* constants

* Added implementation

* Added Span Compression related options to src/ext/ConfigManager.c

* Added Span Compression related options to src/ext/ConfigManager.h

* Added Span Compression related options to src/ext/elastic_apm.c

* Added Span Compression related options to tests/ElasticApmTests/ComponentTests/ConfigSettingTest.php

* MySQLiTest: Disable Span Compression feature to have all the expected spans individually

* PDOTest: Disable Span Compression feature to have all the expected spans individually

* Added tests/ElasticApmTests/ComponentTests/SpanCompressionComponentTest.php

* Clarified comment about "Disable Span Compression"

* StackTraceComponentTest: Disable Span Compression feature to have all the expected spans individually

* Added TracerUnitTestCaseBase::isCompatibleWithSpanCompression

* InferredSpansBuilderTest: Disable Span Compression feature to have all the expected spans individually

* StackTraceUnitTest: Disable Span Compression feature to have all the expected spans individually

* Added tests/ElasticApmTests/UnitTests/SpanCompressionUnitTest.php

* Added tests\ElasticApmTests\Util\AssertValidTrait::assertValidNonNullableString

* Updated ElasticApmTests\Util\SpanDto

* Updated SpanExpectations

* Removed unused imports

* Extended span compression to spans without service target

* Removed redundant comment

* Clarified docs

* Added workaround for false positives from static analysis

* Simplified parallel-lint invocation

* Fixed unit tests failing on PHP 7.2

* Fixed issue found by static analysis

* Fixed formatting

* Fixed formatting

* Added --exclude ./tests/polyfills/

* Removed TestCaseBaseShim

* Fixed failing unit test

* Added ELASTIC_APM_PHP_TESTS_IS_LONG_RUN_MODE

* Reduced number of datasets from dataProviderForTestReasonsCompressionStops

* Run testOneCompressedSequence only in isLongRunMode

* Added check for isLongRunMode dataProviderForTestReasonsCompressionStops

* Fixed static analysis issue

* Fixed failing unit tests

* Removed unused import

* Fixed merge

* Fixed merge

* Fixed merge

* Fixed merge

* Temporarily hide TransactionMaxSpansUnitTest behind isLongRunMode

* Fixed unit tests

* Added diagnostics

* Fixed failing unit tests

* Added re-run with escalated log level to HttpTransactionTest::testHttpStatus

* Fixed failing component test

* Re-enabled SpanCompressionUnitTest::testReasonsCompressionStops

* Fixed merge

* Fixed line endings

* Fixed line endings (CRLF -> LF) (#956)

* Fixed not joining background sender thread if there was fork after module init (#959)

* Fixed line endings (CRLF -> LF)

* Fixed not joining background sender thread if there was fork

Fixed not joining background sender thread if there was fork after module init

* Fixed not cleaning up connection data in sync backend comm. mode (#957)

* Fixed line endings (CRLF -> LF)

* Fixed not cleaning up connection data in sync backend comm. mode

* Fixed registration of pthread_atfork handlers (876) (#964)

* Fixed verify_server_cert=false not disabling all the checks related to HTTPS certificate (#965)

* Fixed verify_server_cert=false not disabling all the checks

* Removed setting CURLOPT_SSL_VERIFYSTATUS to 0 since 0 is the default

* Prevent deadloop in exception and error handlers (#955)

* added logging in case of potential deadloop
 * moved hook registration into MINIT/MSHUTDOWN

* Prepared for 1.8.4 release (#967)

* fix: add docker container id discovery for SystemData (#966)

* fix: add docker container id discovery for SystemData

* Refactor to handle possible false from file_get_contents

* fix semantic error and change priority from cgroups to mountinfo

* Fix tests to know about container.id in SystemData

* Fixed issue found by static analysis

* Refactored MetadataDiscoverer::detectContainerId to make it testable

* Added unit test for MetadataDiscoverer::detectContainerId

---------

Co-authored-by: Sergey Kleyman <[email protected]>

* Added dev_internal_backend_comm_log_verbose to use CURLOPT_VERBOSE on demand (#407)

* Added CURLOPT_VERBOSE

* Added CURLOPT_VERBOSE

* Redirected libcurl's verbose output to file and then syslog

* Fixed merge

* Added dev_internal_backend_comm_log_verbose

* Fixed default in documentation for dev_internal_backend_comm_log_verbose (#972)

* Added ELASTIC_APM_PHP_TESTS_ESCALATED_RERUNS_PROD_CODE_LOG_LEVEL_OPTION_NAME option (#971)

* Added ELASTIC_APM_PHP_TESTS_ESCALATED_RERUNS_PROD_CODE_LOG_LEVEL_OPTION_NAME

* Fixed option name in metadata

* On after failure re-run escalate all log levels on CentOS

* Fixed $escalatedRerunsProdCodeLogLevelOptionName declared type

* Fixed not unregistering signal handler on module shutdown (#960)

* Simplified logging of the current process command line (#973)

* Added logging curl info (#974)

* Added curl info when logging curl related errors

* Log curlOptionId also as used constant

* Made logged curl info have JSON-like structure

* Log curl info on initConnectionData entry

* Simplified logging of the current process command line

* Fixed metadata container ID detected but not stored (#975)

* Fixed system.container.id being detected but not stored in metadata

* Added component test for metadata's system.container.id detection

* Updated docs for service_node_name configuration option

* WordPress instrumentation (capturing plugins, hooks and theme) (#948)

* Renamed BootstrapStageLogger::logLevel to logWithLevel

* Renamed ELASTIC_APM_LOG_WRITE_TO_SYSLOG to ELASTIC_APM_LOG_TO_BACKGROUND_SINK

* Fixed typo in local variable name

* Added Logger::if*LevelEnabledNoLine for all the remaining log levels

* Added ability to inherit context from LoggerFactory

* Make ArrayUtil::getValueIfKeyExists a template instead of mixed

* Added ArrayUtil::append

* Marked captureInClassicFormatExcludeElasticApm $loggerFactory as nullable

StackTraceUtil::captureInClassicFormatExcludeElasticApm

* Removed redundant type-hint

* Added ELASTIC_APM_BUILD_PHP_VERSION_ID

* Removed declaration of unused makeDynamicArray()

* Added src/ext/ArrayView.h

* Added string related utility functions

* Added string related utility functions (part 2)

* Split ConfigManager.h into multiple more manageable headers

* Split ConfigManager.h into multiple more manageable headers (part 2)

* Split ConfigManager.h into multiple more manageable headers (part 3)

* Split ConfigManager.h into multiple more manageable headers (part 4)

* Added string related utility functions (part 3)

* Split ConfigManager.h into multiple more manageable headers (part 5)

* Split big header files into multiple more manageable headers (part 6)

* Split big header files into multiple more manageable headers (part 7)

* enum LogLevel to a separate header (LogLevel.h)

* Added maxEnabledLogLevel()

* Added ELASTIC_APM_LOG_DIRECT_INFO

* Added missing include

* Added // NOLINT for ELASTIC_APM_FOR_EACH_INDEX_START_END

* Clarified structure of a header added to each allocation for track it

* Extracted TextOutputStream_forward_decl.h from TextOutputStream.h

* Extracted OptionalBool to its own header (OptionalBool.h)

* Extracted TextOutputStream_forward_decl.h from TextOutputStream.h (part 2)

* Made implicit casts explcit

* Added openFile to have "safe fopen" similar to fopen_s available on Windows

* Added openFile to have "safe fopen" similar to fopen_s available on Windows (part 2)

* Extracted TextOutputStream_forward_decl.h from TextOutputStream.h (part 3)

* Added resultBufferIsTooSmall to ResultCode

* Renamed ELASTIC_APM_CALL_EARLY_GOTO_FINALLY_WITH_SUCCESS to ELASTIC_APM_SET_RESULT_CODE_TO_SUCCESS_AND_GOTO_FINALLY

* Added ELASTIC_APM_EMPTY_STRING_VIEW instead of makeEmptyStringView so it can be used to init static

* Extracted TextOutputStream_forward_decl.h from TextOutputStream.h (part 4)

* Split ConfigManager.h into multiple more manageable headers (part 6)

* Split ConfigManager.h into multiple more manageable headers (part 7)

* Removed unused ELASTIC_APM_PHP_PART_ON_PHP_ERROR_FUNC and ELASTIC_APM_PHP_PART_SET_LAST_THROWN_FUNC

* Split ConfigManager.h into multiple more manageable headers (part 8)

* Added ELASTIC_APM_EMPTY_STRING_VIEW instead of makeEmptyStringView so it can be used to init static (part 2)

* Extracted TextOutputStream_forward_decl.h from TextOutputStream.h (part 5)

* Added zend_string related utility functions

* Added missing include-s

* Refactored TextUtilForTests::iterateLines to allow finer control over end-of-line part

* Removed unused import (tests/ElasticApmTests/ComponentTests/Util/ResourcesClient.php)

* Replaced ComponentTestCaseBase::getMandatoryAppCodeArg + assertIs<expected type> by get<expected type>FromMap

* Removed unused import (tests/ElasticApmTests/Util/Deserialization/ServerApiSchemaValidator.php)

* Added /* in,out */ to ArrayUtilForTests::append

* Added AssertMessageBuilder::buildString

* Removed unused import (tests/ElasticApmTests/Util/TestCaseBase.php)

* DataProviderForTestBuilder: Have keys included in logged data-set

* Added MixedMap

* Made IterableUtilForTests::iterableToGenerator a function template

instead of being based on mixed type-hint

* Added comments to calls of ArrayUtilForTests::append

* Refactored TextUtilForTests::iterateLines to allow finer control over end-of-line part (part 2)

* Fixed imports in ComponentTestCaseBase.php

* Fixed incorrect merge

* Added missing include

* Added retries on "composer install" has an intermittent failure

* Log PhpUnitExtensionBase::$timestampBeforeTest when setting it

* Use TimeUtilForTests::timestampToLoggable in assertLessThanOrEqualTimestamp

* Applied runAndEscalateLogLevelOnFailure to testAllWaysToSetConfig

from ConfigSettingTest class

* Added INTERNAL_CHECKS_LEVEL to OptionNames.php

* Added maxNumberOfStackFrames as parameter to 

LoggableStackTrace::buildForCurrent instead having hardcoded

* Removed static from constructConfigManagerMetadata to have on stack trace

* Log stack trace on failed ASSERT in native part

* Set g_elasticApmDirectLogLevel* to default values so that they can be used even before configuration is parsed

* Added documentation for configuration options

* Added options to AllOptionsMetadata.php

* Added SPAN_COMPRESSION_* option names to OptionNames.php

* Added Span Compression options to Config/Snapshot.php

* Added COMPRESSION_STRATEGY_* constants

* Added implementation

* Added Span Compression related options to src/ext/ConfigManager.c

* Added Span Compression related options to src/ext/ConfigManager.h

* Added Span Compression related options to src/ext/elastic_apm.c

* Added Span Compression related options to tests/ElasticApmTests/ComponentTests/ConfigSettingTest.php

* MySQLiTest: Disable Span Compression feature to have all the expected spans individually

* PDOTest: Disable Span Compression feature to have all the expected spans individually

* Added tests/ElasticApmTests/ComponentTests/SpanCompressionComponentTest.php

* Clarified comment about "Disable Span Compression"

* StackTraceComponentTest: Disable Span Compression feature to have all the expected spans individually

* Added TracerUnitTestCaseBase::isCompatibleWithSpanCompression

* InferredSpansBuilderTest: Disable Span Compression feature to have all the expected spans individually

* StackTraceUnitTest: Disable Span Compression feature to have all the expected spans individually

* Added tests/ElasticApmTests/UnitTests/SpanCompressionUnitTest.php

* Added tests\ElasticApmTests\Util\AssertValidTrait::assertValidNonNullableString

* Updated ElasticApmTests\Util\SpanDto

* Updated SpanExpectations

* Added optional dbgParamName for better diagnostics

* Distinguish between plugin name and keywords

Both name and keywords can be used to disable a plugin

* Removed unused imports

* Added 'internal-func' to names related to existing instrumentation (part 2)

to distinguish from other instrumentation mechanisms (for example the upcoming AST processing based)

* Added 'internal-func' to names related to existing instrumentation (part 3)

to distinguish from other instrumentation mechanisms (for example the upcoming AST processing based)

* Added 'internal-func' to names related to existing instrumentation (part 3)

to distinguish from other instrumentation mechanisms (for example the upcoming AST processing based)

* Added verifyExactArgsCount

* Implemented WordPress instrumentation - part 1

* Added AST_PROCESS_* options to AllOptionsMetadata.php

* Added option names to OptionNames.php

* Added AST processing options to Config/Snapshot.php

* Switch to span types wordpress_plugin and wordpress_theme

* Fixed issue with assertDirectoryDoesNotExist

assertDirectoryDoesNotExist that was added only in PHPUnit 9 and it does not exist in PHPUnit 8.5 that we still use when testing under older PHP versions

* Removed unused imports

* Added isStringViewSuffix

* Added new .c files to src/ext/config.m4

* Added AST processing related options to src/ext/ConfigManager.c

* Added AST processing related options to src/ext/ConfigManager.h

* Added ELASTIC_APM_WORDPRESS_DIRECT_CALL_METHOD_SET_READY_TO_WRAP_FILTER_CALLBACKS* constants

* Added AST processing related options to src/ext/elastic_apm.c

* Added AST processing related API from extension (native part) to PHP part of the agent

* Added AST processing related APIs to src/ext/elastic_apm_API.h

* Added calls for AST processing from lifecycle stages

* Instrumentation using AST processing (files src/ext/tracer_PHP_part.c|h)

files src/ext/tracer_PHP_part.h and src/ext/tracer_PHP_part.c)

* Removed duplicate isStringViewSuffix

* Added streamZVal

* Added ELASTIC_APM_PHP_TESTS_COMPARE_AST_CONVERTED_BACK_TO_SOURCE

* Added AppCodeHostParams::setAgentOptionIfNotDefaultValue

* Added AppCodeHostParams::setAgentOptions

* Excluded WordPress mock source from static analysis

* Instrumentation using AST processing (file tests/ElasticApmTests/ComponentTests/Util/ComponentTestCaseBase.php)

* Added ELASTIC_APM_PHP_TESTS_COMPARE_AST_CONVERTED_BACK_TO_SOURCE (part 2)

* Added AppCodeHostParams::setAgentOptionIfNotDefaultValue (part 2)

* Moved ArrayUtil::append back to ArrayUtilForTests::append

* Removed unused imports

* Added AST processing related options to tests/ElasticApmTests/ComponentTests/ConfigSettingTest.php

* Added testReferencesInArray

* Added FileUtilForTests::createTempSubDir

* Added missing import

* Removed redundant local variable

* Added clarifying comments

* Reverted references of ELASTIC_APM_EMPTY_STRING_VIEW back to makeEmptyStringView()

since ELASTIC_APM_EMPTY_STRING_VIEW is added in a later PR

* Fixed incorrect merge

* Reverted references of ELASTIC_APM_EMPTY_STRING_VIEW back to makeEmptyStringView()

since ELASTIC_APM_EMPTY_STRING_VIEW is added in a later PR

* Fixed incorrect merge

* Added documentation for configuration options

* Added options to AllOptionsMetadata.php

* Added SPAN_COMPRESSION_* option names to OptionNames.php

* Added Span Compression options to Config/Snapshot.php

* Added COMPRESSION_STRATEGY_* constants

* Added implementation

* Added Span Compression related options to src/ext/ConfigManager.c

* Added Span Compression related options to src/ext/ConfigManager.h

* Added Span Compression related options to src/ext/elastic_apm.c

* Added Span Compression related options to tests/ElasticApmTests/ComponentTests/ConfigSettingTest.php

* MySQLiTest: Disable Span Compression feature to have all the expected spans individually

* PDOTest: Disable Span Compression feature to have all the expected spans individually

* Added tests/ElasticApmTests/ComponentTests/SpanCompressionComponentTest.php

* Clarified comment about "Disable Span Compression"

* StackTraceComponentTest: Disable Span Compression feature to have all the expected spans individually

* Added TracerUnitTestCaseBase::isCompatibleWithSpanCompression

* InferredSpansBuilderTest: Disable Span Compression feature to have all the expected spans individually

* StackTraceUnitTest: Disable Span Compression feature to have all the expected spans individually

* Added tests/ElasticApmTests/UnitTests/SpanCompressionUnitTest.php

* Added tests\ElasticApmTests\Util\AssertValidTrait::assertValidNonNullableString

* Updated ElasticApmTests\Util\SpanDto

* Updated SpanExpectations

* Removed unused imports

* Extended span compression to spans without service target

* Removed redundant comment

* Clarified docs

* Added workaround for false positives from static analysis

* Simplified parallel-lint invocation

* Fixed unit tests failing on PHP 7.2

* Fixed issue found by static analysis

* Fixed formatting

* Fixed formatting

* Added --exclude ./tests/polyfills/

* Removed TestCaseBaseShim

* Fixed failing unit test

* Added ELASTIC_APM_PHP_TESTS_IS_LONG_RUN_MODE

* Reduced number of datasets from dataProviderForTestReasonsCompressionStops

* Run testOneCompressedSequence only in isLongRunMode

* Added check for isLongRunMode dataProviderForTestReasonsCompressionStops

* Fixed static analysis issue

* Fixed failing unit tests

* Removed unused import

* Fixed merge

* Fixed merge

* Fixed merge

* Fixed merge

* Temporarily hide TransactionMaxSpansUnitTest behind isLongRunMode

* Temporarily disable unit tests

* Fixed unit tests

* Added diagnostics

* Fixed failing unit tests

* Added re-run with escalated log level to HttpTransactionTest::testHttpStatus

* Fixed failing component test

* Revert "Temporarily disable unit tests"

This reverts commit 3c26cc5095d8eb53631e1300da054e3c7437f208.

* Re-enabled SpanCompressionUnitTest::testReasonsCompressionStops

* Fixed merge

* Temporarily disabled component tests

* Fixed bad merge

* Temporarily run only PDOAutoInstrumentationTest

* Fixed merge

* Re-enabled component tests

* Fixed line endings

* Fixed line endings (CRLF -> LF)

* Fixed not cleaning up connection data in sync backend comm. mode

* Fixed not joining background sender thread if there was fork

Fixed not joining background sender thread if there was fork after module init

* Fixed system.container.id being detected but not stored in metadata

* Added component test for metadata's system.container.id detection

* Updated docs for service_node_name configuration option

* Set metadata's service.framework to WordPress/<version>

* Added check for stack trace to WordPressAutoInstrumentationTest

* Fixed ErrorComponentTest

* Fixed ErrorComponentTest

* Added WordPress and MySQLi to supported technologies

* Converted file path to Linux directory separators

* Added count for number of calls to WordPressFilterCallbackWrapper ctor/dtor

For supportability and component tests

* Replaced emalloc in cloneAstDecl with an array on stack

* Run composer install with retries for unit tests as well (#979)

* Documented TransactionInterface->ensureParentId() API (#981)

* Refactored call stack trace capturing code (#992)

* Marked captureInClassicFormatExcludeElasticApm $loggerFactory as nullable

StackTraceUtil::captureInClassicFormatExcludeElasticApm

* Removed redundant type-hint

* Added ELASTIC_APM_BUILD_PHP_VERSION_ID

* Removed declaration of unused makeDynamicArray()

* Added src/ext/ArrayView.h

* Added string related utility functions

* Added string related utility functions (part 2)

* Split ConfigManager.h into multiple more manageable headers

* Split ConfigManager.h into multiple more manageable headers (part 2)

* Split ConfigManager.h into multiple more manageable headers (part 3)

* Split ConfigManager.h into multiple more manageable headers (part 4)

* Added string related utility functions (part 3)

* Split ConfigManager.h into multiple more manageable headers (part 5)

* Split big header files into multiple more manageable headers (part 6)

* Split big header files into multiple more manageable headers (part 7)

* enum LogLevel to a separate header (LogLevel.h)

* Added maxEnabledLogLevel()

* Added ELASTIC_APM_LOG_DIRECT_INFO

* Added missing include

* Added // NOLINT for ELASTIC_APM_FOR_EACH_INDEX_START_END

* Clarified structure of a header added to each allocation for track it

* Extracted TextOutputStream_forward_decl.h from TextOutputStream.h

* Extracted OptionalBool to its own header (OptionalBool.h)

* Extracted TextOutputStream_forward_decl.h from TextOutputStream.h (part 2)

* Made implicit casts explcit

* Added openFile to have "safe fopen" similar to fopen_s available on Windows

* Added openFile to have "safe fopen" similar to fopen_s available on Windows (part 2)

* Extracted TextOutputStream_forward_decl.h from TextOutputStream.h (part 3)

* Added resultBufferIsTooSmall to ResultCode

* Renamed ELASTIC_APM_CALL_EARLY_GOTO_FINALLY_WITH_SUCCESS to ELASTIC_APM_SET_RESULT_CODE_TO_SUCCESS_AND_GOTO_FINALLY

* Added ELASTIC_APM_EMPTY_STRING_VIEW instead of makeEmptyStringView so it can be used to init static

* Extracted TextOutputStream_forward_decl.h from TextOutputStream.h (part 4)

* Split ConfigManager.h into multiple more manageable headers (part 6)

* Split ConfigManager.h into multiple more manageable headers (part 7)

* Removed unused ELASTIC_APM_PHP_PART_ON_PHP_ERROR_FUNC and ELASTIC_APM_PHP_PART_SET_LAST_THROWN_FUNC

* Split ConfigManager.h into multiple more manageable headers (part 8)

* Added ELASTIC_APM_EMPTY_STRING_VIEW instead of makeEmptyStringView so it can be used to init static (part 2)

* Extracted TextOutputStream_forward_decl.h from TextOutputStream.h (part 5)

* Added zend_string related utility functions

* Added missing include-s

* Refactored TextUtilForTests::iterateLines to allow finer control over end-of-line part

* Removed unused import (tests/ElasticApmTests/ComponentTests/Util/ResourcesClient.php)

* Replaced ComponentTestCaseBase::getMandatoryAppCodeArg + assertIs<expected type> by get<expected type>FromMap

* Removed unused import (tests/ElasticApmTests/Util/Deserialization/ServerApiSchemaValidator.php)

* Added /* in,out */ to ArrayUtilForTests::append

* Added AssertMessageBuilder::buildString

* Removed unused import (tests/ElasticApmTests/Util/TestCaseBase.php)

* DataProviderForTestBuilder: Have keys included in logged data-set

* Added MixedMap

* Made IterableUtilForTests::iterableToGenerator a function template

instead of being based on mixed type-hint

* Added comments to calls of ArrayUtilForTests::append

* Refactored TextUtilForTests::iterateLines to allow finer control over end-of-line part (part 2)

* Fixed imports in ComponentTestCaseBase.php

* Fixed incorrect merge

* Added missing include

* Added retries on "composer install" has an intermittent failure

* Log PhpUnitExtensionBase::$timestampBeforeTest when setting it

* Use TimeUtilForTests::timestampToLoggable in assertLessThanOrEqualTimestamp

* Applied runAndEscalateLogLevelOnFailure to testAllWaysToSetConfig

from ConfigSettingTest class

* Added INTERNAL_CHECKS_LEVEL to OptionNames.php

* Added maxNumberOfStackFrames as parameter to 

LoggableStackTrace::buildForCurrent instead having hardcoded

* Removed static from constructConfigManagerMetadata to have on stack trace

* Log stack trace on failed ASSERT in native part

* Set g_elasticApmDirectLogLevel* to default values so that they can be used even before configuration is parsed

* Added documentation for configuration options

* Added options to AllOptionsMetadata.php

* Added SPAN_COMPRESSION_* option names to OptionNames.php

* Added Span Compression options to Config/Snapshot.php

* Added COMPRESSION_STRATEGY_* constants

* Added implementation

* Added Span Compression related options to src/ext/ConfigManager.c

* Added Span Compression related options to src/ext/ConfigManager.h

* Added Span Compression related options to src/ext/elastic_apm.c

* Added Span Compression related options to tests/ElasticApmTests/ComponentTests/ConfigSettingTest.php

* MySQLiTest: Disable Span Compression feature to have all the expected spans individually

* PDOTest: Disable Span Compression feature to have all the expected spans individually

* Added tests/ElasticApmTests/ComponentTests/SpanCompressionComponentTest.php

* Clarified comment about "Disable Span Compression"

* StackTraceComponentTest: Disable Span Compression feature to have all the expected spans individually

* Added TracerUnitTestCaseBase::isCompatibleWithSpanCompression

* InferredSpansBuilderTest: Disable Span Compression feature to have all the expected spans individually

* StackTraceUnitTest: Disable Span Compression feature to have all the expected spans individually

* Added tests/ElasticApmTests/UnitTests/SpanCompressionUnitTest.php

* Added tests\ElasticApmTests\Util\AssertValidTrait::assertValidNonNullableString

* Updated ElasticApmTests\Util\SpanDto

* Updated SpanExpectations

* Added optional dbgParamName for better diagnostics

* Distinguish between plugin name and keywords

Both name and keywords can be used to disable a plugin

* Removed unused imports

* Added 'internal-func' to names related to existing instrumentation (part 2)

to distinguish from other instrumentation mechanisms (for example the upcoming AST processing based)

* Added 'internal-func' to names related to existing instrumentation (part 3)

to distinguish from other instrumentation mechanisms (for example the upcoming AST processing based)

* Added 'internal-func' to names related to existing instrumentation (part 3)

to distinguish from other instrumentation mechanisms (for example the upcoming AST processing based)

* Added verifyExactArgsCount

* Implemented WordPress instrumentation - part 1

* Added AST_PROCESS_* options to AllOptionsMetadata.php

* Added option names to OptionNames.php

* Added AST processing options to Config/Snapshot.php

* Switch to span types wordpress_plugin and wordpress_theme

* Fixed issue with assertDirectoryDoesNotExist

assertDirectoryDoesNotExist that was added only in PHPUnit 9 and it does not exist in PHPUnit 8.5 that we still use when testing under older PHP versions

* Removed unused imports

* Added isStringViewSuffix

* Added new .c files to src/ext/config.m4

* Added AST processing related options to src/ext/ConfigManager.c

* Added AST processing related options to src/ext/ConfigManager.h

* Added ELASTIC_APM_WORDPRESS_DIRECT_CALL_METHOD_SET_READY_TO_WRAP_FILTER_CALLBACKS* constants

* Added AST processing related options to src/ext/elastic_apm.c

* Added AST processing related API from extension (native part) to PHP part of the agent

* Added AST processing related APIs to src/ext/elastic_apm_API.h

* Added calls for AST processing from lifecycle stages

* Instrumentation using AST processing (files src/ext/tracer_PHP_part.c|h)

files src/ext/tracer_PHP_part.h and src/ext/tracer_PHP_part.c)

* Removed duplicate isStringViewSuffix

* Added streamZVal

* Added ELASTIC_APM_PHP_TESTS_COMPARE_AST_CONVERTED_BACK_TO_SOURCE

* Added AppCodeHostParams::setAgentOptionIfNotDefaultValue

* Added AppCodeHostParams::setAgentOptions

* Excluded WordPress mock source from static analysis

* Instrumentation using AST processing (file tests/ElasticApmTests/ComponentTests/Util/ComponentTestCaseBase.php)

* Added ELASTIC_APM_PHP_TESTS_COMPARE_AST_CONVERTED_BACK_TO_SOURCE (part 2)

* Added AppCodeHostParams::setAgentOptionIfNotDefaultValue (part 2)

* Moved ArrayUtil::append back to ArrayUtilForTests::append

* Removed unused imports

* Added AST processing related options to tests/ElasticApmTests/ComponentTests/ConfigSettingTest.php

* Added testReferencesInArray

* Added FileUtilForTests::createTempSubDir

* Added missing import

* Removed redundant local variable

* Added clarifying comments

* Reverted references of ELASTIC_APM_EMPTY_STRING_VIEW back to makeEmptyStringView()

since ELASTIC_APM_EMPTY_STRING_VIEW is added in a later PR

* Fixed incorrect merge

* Reverted references of ELASTIC_APM_EMPTY_STRING_VIEW back to makeEmptyStringView()

since ELASTIC_APM_EMPTY_STRING_VIEW is added in a later PR

* Fixed incorrect merge

* Added documentation for configuration options

* Added options to AllOptionsMetadata.php

* Added SPAN_COMPRESSION_* option names to OptionNames.php

* Added Span Compression options to Config/Snapshot.php

* Added COMPRESSION_STRATEGY_* constants

* Added implementation

* Added Span Compression related options to src/ext/ConfigManager.c

* Added Span Compression related options to src/ext/ConfigManager.h

* Added Span Compression related options to src/ext/elastic_apm.c

* Added Span Compression related options to tests/ElasticApmTests/ComponentTests/ConfigSettingTest.php

* MySQLiTest: Disable Span Compression feature to have all the expected spans individually

* PDOTest: Disable Span Compression feature to have all the expected spans individually

* Added tests/ElasticApmTests/ComponentTests/SpanCompressionComponentTest.php

* Clarified comment about "Disable Span Compression"

* StackTraceComponentTest: Disable Span Compression feature to have all the expected spans individually

* Added TracerUnitTestCaseBase::isCompatibleWithSpanCompression

* InferredSpansBuilderTest: Disable Span Compression feature to have all the expected spans individually

* StackTraceUnitTest: Disable Span Compression feature to have all the expected spans individually

* Added tests/ElasticApmTests/UnitTests/SpanCompressionUnitTest.php

* Added tests\ElasticApmTests\Util\AssertValidTrait::assertValidNonNullableString

* Updated ElasticApmTests\Util\SpanDto

* Updated SpanExpectations

* Removed unused imports

* Extended span compression to spans without service target

* Removed redundant comment

* Clarified docs

* Added workaround for false positives from static analysis

* Simplified parallel-lint invocation

* Fixed unit tests failing on PHP 7.2

* Fixed issue found by static analysis

* Fixed formatting

* Fixed formatting

* Added --exclude ./tests/polyfills/

* Removed TestCaseBaseShim

* Fixed failing unit test

* Added ELASTIC_APM_PHP_TESTS_IS_LONG_RUN_MODE

* Reduced number of datasets from dataProviderForTestReasonsCompressionStops

* Run testOneCompressedSequence only in isLongRunMode

* Added check for isLongRunMode dataProviderForTestReasonsCompressionStops

* Fixed static analysis issue

* Fixed failing unit tests

* Removed unused import

* Fixed merge

* Fixed merge

* Fixed merge

* Fixed merge

* Temporarily hide TransactionMaxSpansUnitTest behind isLongRunMode

* Temporarily disable unit tests

* Fixed unit tests

* Added diagnostics

* Fixed failing unit tests

* Added re-run with escalated log level to HttpTransactionTest::testHttpStatus

* Fixed failing component test

* Revert "Temporarily disable unit tests"

This reverts commit 3c26cc5095d8eb53631e1300da054e3c7437f208.

* Re-enabled SpanCompressionUnitTest::testReasonsCompressionStops

* Fixed merge

* Temporarily disabled component tests

* Fixed bad merge

* Temporarily run only PDOAutoInstrumentationTest

* Fixed merge

* Re-enabled component tests

* Fixed line endings

* Fixed line endings (CRLF -> LF)

* Fixed not cleaning up connection data in sync backend comm. mode

* Fixed not joining background sender thread if there was fork

Fixed not joining background sender thread if there was fork after module init

* Fixed system.container.id being detected but not stored in metadata

* Added component test for metadata's system.container.id detection

* Updated docs for service_node_name configuration option

* Set metadata's service.framework to WordPress/<version>

* Added check for stack trace to WordPressAutoInstrumentationTest

* Fixed ErrorComponentTest

* Fixed ErrorComponentTest

* Added WordPress and MySQLi to supported technologies

* Converted file path to Linux directory separators

* Added count for number of calls to WordPressFilterCallbackWrapper ctor/dtor

For supportability and component tests

* Replaced emalloc in cloneAstDecl with an array on stack

* Make all properties of StackTraceFrameExpectations be Optional

* Made StackTraceUtil instance class

* Refactored call stack trace capturing code

* Refactor AutoInstrumentationUtil->captureCurrentSpan

* Fixed static analysis failure

* Improved testing of stack trace capture part of WordPress auto instrumentation (#994)

* Added string related utility functions (part 2)

* Split ConfigManager.h into multiple more manageable headers

* Split ConfigManager.h into multiple more manageable headers (part 2)

* Split ConfigManager.h into multiple more manageable headers (part 3)

* Split ConfigManager.h into multiple more manageable headers (part 4)

* Added string related utility functions (part 3)

* Split ConfigManager.h into multiple more manageable headers (part 5)

* Split big header files into multiple more manageable headers (part 6)

* Split big header files into multiple more manageable headers (part 7)

* enum LogLevel to a separate header (LogLevel.h)

* Added maxEnabledLogLevel()

* Added ELASTIC_APM_LOG_DIRECT_INFO

* Added missing include

* Added // NOLINT for ELASTIC_APM_FOR_EACH_INDEX_START_END

* Clarified structure of a header added to each allocation for track it

* Extracted TextOutputStream_forward_decl.h from TextOutputStream.h

* Extracted OptionalBool to its own header (OptionalBool.h)

* Extracted TextOutputStream_forward_decl.h from TextOutputStream.h (part 2)

* Made implicit casts explcit

* Added openFile to have "safe fopen" similar to fopen_s available on Windows

* Added openFile to have "safe fopen" similar to fopen_s available on Windows (part 2)

* Extracted TextOutputStream_forward_decl.h from TextOutputStream.h (part 3)

* Added resultBufferIsTooSmall to ResultCode

* Renamed ELASTIC_APM_CALL_EARLY_GOTO_FINALLY_WITH_SUCCESS to ELASTIC_APM_SET_RESULT_CODE_TO_SUCCESS_AND_GOTO_FINALLY

* Added ELASTIC_APM_EMPTY_STRING_VIEW instead of makeEmptyStringView so it can be used to init static

* Extracted TextOutputStream_forward_decl.h from TextOutputStream.h (part 4)

* Split ConfigManager.h into multiple more manageable headers (part 6)

* Split ConfigManager.h into multiple more manageable headers (part 7)

* Removed unused ELASTIC_APM_PHP_PART_ON_PHP_ERROR_FUNC and ELASTIC_APM_PHP_PART_SET_LAST_THROWN_FUNC

* Split ConfigManager.h into multiple more manageable headers (part 8)

* Added ELASTIC_APM_EMPTY_STRING_VIEW instead of makeEmptyStringView so it can be used to init static (part 2)

* Extracted TextOutputStream_forward_decl.h from TextOutputStream.h (part 5)

* Added zend_string related utility functions

* Added missing include-s

* Refactored TextUtilForTests::iterateLines to allow finer control over end-of-line part

* Removed unused import (tests/ElasticApmTests/ComponentTests/Util/ResourcesClient.php)

* Replaced ComponentTestCaseBase::getMandatoryAppCodeArg + assertIs<expected type> by get<expected type>FromMap

* Removed unused import (tests/ElasticApmTests/Util/Deserialization/ServerApiSchemaValidator.php)

* Added /* in,out */ to ArrayUtilForTests::append

* Added AssertMessageBuilder::buildString

* Removed unused import (tests/ElasticApmTests/Util/TestCaseBase.php)

* DataProviderForTestBuilder: Have keys included in logged data-set

* Added MixedMap

* Made IterableUtilForTests::iterableToGenerator a function template

instead of being based on mixed type-hint

* Added comments to calls of ArrayUtilForTests::append

* Refactored TextUtilForTests::iterateLines to allow finer control over end-of-line part (part 2)

* Fixed imports in ComponentTestCaseBase.php

* Fixed incorrect merge

* Added missing include

* Added retries on "composer install" has an intermittent failure

* Log PhpUnitExtensionBase::$timestampBeforeTest when setting it

* Use TimeUtilForTests::timestampToLoggable in assertLessThanOrEqualTimestamp

* Applied runAndEscalateLogLevelOnFailure to testAllWaysToSetConfig

from ConfigSettingTest class

* Added INTERNAL_CHECKS_LEVEL to OptionNames.php

* Added maxNumberOfStackFrames as parameter to 

LoggableStackTrace::buildForCurrent instead having hardcoded

* Removed static from constructConfigManagerMetadata to have on stack trace

* Log stack trace on failed ASSERT in native part

* Set g_elasticApmDirectLogLevel* to default values so that they can be used even before configuration is parsed

* Added documentation for configuration options

* Added options to AllOptionsMetadata.php

* Added SPAN_COMPRESSION_* option names to OptionNames.php

* Added Span Compression options to Config/Snapshot.php

* Added COMPRESSION_STRATEGY_* constants

* Added implementation

* Added Span Compression related options to src/ext/ConfigManager.c

* Added Span Compression related options to src/ext/ConfigManager.h

* Added Span Compression related options to src/ext/elastic_apm.c

* Added Span Compression related options to tests/ElasticApmTests/ComponentTests/ConfigSettingTest.php

* MySQLiTest: Disable Span Compression feature to have all the expected spans individually

* PDOTest: Disable Span Compression feature to have all the expected spans individually

* Added tests/ElasticApmTests/ComponentTests/SpanCompressionComponentTest.php

* Clarified comment about "Disable Span Compression"

* StackTraceComponentTest: Disable Span Compression feature to have all the expected spans individually

* Added TracerUnitTestCaseBase::isCompatibleWithSpanCompression

* InferredSpansBuilderTest: Disable Span Compression feature to have all the expected spans individually

* StackTraceUnitTest: Disable Span Compression feature to have all the expected spans individually

* Added tests/ElasticApmTests/UnitTests/SpanCompressionUnitTest.php

* Added tests\ElasticApmTests\Util\AssertValidTrait::assertValidNonNullableString

* Updated ElasticApmTests\Util\SpanDto

* Updated SpanExpectations

* Added optional dbgParamName for better diagnostics

* Distinguish between plugin name and keywords

Both name and keywords can be used to disable a plugin

* Removed unused imports

* Added 'internal-func' to names related to existing instrumentation (part 2)

to distinguish from other instrumentation mechanisms (for example the upcoming AST processing based)

* Added 'internal-func' to names related to existing instrumentation (part 3)

to distinguish from other instrumentation mechanisms (for example the upcoming AST processing based)

* Added 'internal-func' to names related to existing instrumentation (part 3)

to distinguish from other instrumentation mechanisms (for example the upcoming AST processing based)

* Added verifyExactArgsCount

* Implemented WordPress instrumentation - part 1

* Added AST_PROCESS_* options to AllOptionsMetadata.php

* Added option names to OptionNames.php

* Added AST processing options to Config/Snapshot.php

* Switch to span types wordpress_plugin and wordpress_theme

* Fixed issue with assertDirectoryDoesNotExist

assertDirectoryDoesNotExist that was added only in PHPUnit 9 and it does not exist in PHPUnit 8.5 that we still use when testing under older PHP versions

* Removed unused imports

* Added isStringViewSuffix

* Added new .c files to src/ext/config.m4

* Added AST processing related options to src/ext/ConfigManager.c

* Added AST processing related options to src/ext/ConfigManager.h

* Added ELASTIC_APM_WORDPRESS_DIRECT_CALL_METHOD_SET_READY_TO_WRAP_FILTER_CALLBACKS* constants

* Added AST processing related options to src/ext/elastic_apm.c

* Added AST processing related API from extension (native part) to PHP part of the agent

* Added AST processing related APIs to src/ext/elastic_apm_API.h

* Added calls for AST processing from lifecycle stages

* Instrumentation using AST processing (files src/ext/tracer_PHP_part.c|h)

files src/ext/tracer_PHP_part.h and src/ext/tracer_PHP_part.c)

* Removed duplicate isStringViewSuffix

* Added streamZVal

* Added ELASTIC_APM_PHP_TESTS_COMPARE_AST_CONVERTED_BACK_TO_SOURCE

* Added AppCodeHostParams::setAgentOptionIfNotDefaultValue

* Added AppCodeHostParams::setAgentOptions

* Excluded WordPress mock source from static analysis

* Instrumentation using AST processing (file tests/ElasticApmTests/ComponentTests/Util/ComponentTestCaseBase.php)

* Added ELASTIC_APM_PHP_TESTS_COMPARE_AST_CONVERTED_BACK_TO_SOURCE (part 2)

* Added AppCodeHostParams::setAgentOptionIfNotDefaultValue (part 2)

* Moved ArrayUtil::append back to ArrayUtilForTests::append

* Removed unused imports

* Added AST processing related options to tests/ElasticApmTests/ComponentTests/ConfigSettingTest.php

* Added testReferencesInArray

* Added FileUtilForTests::createTempSubDir

* Added missing import

* Removed redundant local variable

* Added clarifying comments

* Reverted references of ELASTIC_APM_EMPTY_STRING_VIEW back to makeEmptyStringView()

since ELASTIC_APM_EMPTY_STRING_VIEW is added in a later PR

* Fixed incorrect merge

* Reverted references of ELASTIC_APM_EMPTY_STRING_VIEW back to makeEmptyStringView()

since ELASTIC_APM_EMPTY_STRING_VIEW is added in a later PR

* Fixed incorrect merge

* Added documentation for configuration options

* Added options to AllOptionsMetadata.php

* Added SPAN_COMPRESSION_* option names to OptionNames.php

* Added Span Compression options to Config/Snapshot.php

* Added COMPRESSION_STRATEGY_* constants

* Added implementation

* Added Span Compression related options to src/ext/ConfigManager.c

* Added Span Compression related options to src/ext/ConfigManager.h

* Added Span Compression related options to src/ext/elastic_apm.c

* Added Span Compression related options to tests/ElasticApmTests/ComponentTests/ConfigSettingTest.php

* MySQLiTest: Disable Span Compression feature to have all the expected spans individually

* PDOTest: Disable Span Compression feature to have all the expected spans individually

* Added tests/ElasticApmTests/ComponentTests/SpanCompressionComponentTest.php

* Clarified comment about "Disable Span Compression"

* StackTraceComponentTest: Disable Span Compression feature to have all the expected spans individually

* Added TracerUnitTestCaseBase::isCompatibleWithSpanCompression

* InferredSpansBuilderTest: Disable Span Compression feature to have all the expected spans individually

* StackTraceUnitTest: Disable Span Compression feature to have all the expected spans individually

* Added tests/ElasticApmTests/UnitTests/SpanCompressionUnitTest.php

* Added tests\ElasticApmTests\Util\AssertValidTrait::assertValidNonNullableString

* Updated ElasticApmTests\Util\SpanDto

* Updated SpanExpectations

* Removed unused imports

* Extended span compression to spans without service target

* Removed redundant comment

* Clarified docs

* Added workaround for false positives from static analysis

* Simplified parallel-lint invocation

* Fixed unit tests failing on PHP 7.2

* Fixed issue found by static analysis

* Fixed formatting

* Fixed formatting

* Added --exclude ./tests/polyfills/

* Removed TestCaseBaseShim

* Fixed failing unit test

* Added ELASTIC_APM_PHP_TESTS_IS_LONG_RUN_MO…
  • Loading branch information
7 people authored Jun 22, 2023
1 parent 8a18c84 commit 38d1277
Show file tree
Hide file tree
Showing 200 changed files with 16,647 additions and 2,690 deletions.
24 changes: 20 additions & 4 deletions .ci/run_docker_with_component_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ function shouldPassEnvVarToDocker () {
}

function buildDockerEnvVarsCommandLinePart () {
# $1 should be the name of the environment variable to hold the result
# local -n makes `result' reference to the variable named by $1
local -n result=$1
result=()
# Iterate over environment variables
Expand Down Expand Up @@ -79,6 +81,8 @@ function onScriptExit () {
}

function main () {
local dockerToRunImageName=${1:?}

if [ -z "${ELASTIC_APM_PHP_TESTS_MATRIX_ROW}" ] ; then
echo "ELASTIC_APM_PHP_TESTS_MATRIX_ROW environment variable should be set before calling ${BASH_SOURCE[0]}"
exit 1
Expand All @@ -96,12 +100,24 @@ function main () {

repoRootDir="$( realpath "${thisScriptDir}/.." )"

buildDockerEnvVarsCommandLinePart dockerRunCmdVariablePart
buildDockerEnvVarsCommandLinePart dockerRunCmdLineArgs

# Let the tests know that are being run inside a container
dockerRunCmdLineArgs=("${dockerRunCmdLineArgs[@]}" -e "ELASTIC_APM_PHP_TESTS_IS_IN_CONTAINER=true")

# ELASTIC_APM_PHP_TESTS_THIS_CONTAINER_IMAGE_NAME is used by tests to find container ID
dockerRunCmdLineArgs=("${dockerRunCmdLineArgs[@]}" -e "ELASTIC_APM_PHP_TESTS_THIS_CONTAINER_IMAGE_NAME=${dockerToRunImageName}")

if [ "${shouldStartExternalServices}" == "true" ] ; then
dockerRunCmdVariablePart=("${dockerRunCmdVariablePart[@]}" "--network=elastic-apm-php-external-services-for-component-tests-net")
dockerRunCmdLineArgs=("${dockerRunCmdLineArgs[@]}" "--network=elastic-apm-php-external-services-for-component-tests-net")
fi
# shellcheck disable=SC2154 # dockerRunCmdVariablePart is assigned by buildDockerEnvVarsCommandLinePart
docker run --rm -v "${repoRootDir}:/app" -w /app "${dockerRunCmdVariablePart[@]}" "$@"

dockerRunCmdLineArgs=("${dockerRunCmdLineArgs[@]}" -v /var/run/docker.sock:/var/run/docker.sock)
dockerRunCmdLineArgs=("${dockerRunCmdLineArgs[@]}" -v "${repoRootDir}:/app")
dockerRunCmdLineArgs=("${dockerRunCmdLineArgs[@]}" -w /app)

# shellcheck disable=SC2154 # dockerRunCmdLineArgs is assigned by buildDockerEnvVarsCommandLinePart
docker run --rm -w /app "${dockerRunCmdLineArgs[@]}" "$@"
}

main "$@"
19 changes: 19 additions & 0 deletions .ci/shared.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,22 @@ function copySyslogFilesAndPrintTheMostRecentOne () {
done
fi
}

function runPhpCoposerInstall () {
local run_command_with_timeout_and_retries_args=(--max-tries=3)
run_command_with_timeout_and_retries_args=(--retry-on-error=yes "${run_command_with_timeout_and_retries_args[@]}")
local initialTimeoutInMinutes=5
local initialTimeoutInSeconds=$((initialTimeoutInMinutes*60))
run_command_with_timeout_and_retries_args=(--timeout="${initialTimeoutInSeconds}" "${run_command_with_timeout_and_retries_args[@]}")
run_command_with_timeout_and_retries_args=(--increase-timeout-exponentially=yes "${run_command_with_timeout_and_retries_args[@]}")
run_command_with_timeout_and_retries_args=(--wait-time-before-retry="${initialTimeoutInSeconds}" "${run_command_with_timeout_and_retries_args[@]}")

set +e
.ci/run_command_with_timeout_and_retries.sh "${run_command_with_timeout_and_retries_args[@]}" -- composer install
local composerCommandExitCode=$?
set -e

if [ ${composerCommandExitCode} -ne 0 ] ; then
exit ${composerCommandExitCode}
fi
}
31 changes: 25 additions & 6 deletions .ci/static-check-unit-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,38 @@ trap onScriptExit EXIT

ensureSyslogIsRunning

## This make runs PHPT
# Disable agent for auxiliary PHP processes to reduce noise in logs
export ELASTIC_APM_ENABLED=false

PHP_EXECUTABLE=$(which php)

RUN_TESTS=$APP_FOLDER/src/ext/tests/run-tests.php
AGENT_EXTENSION_DIR=$APP_FOLDER/src/ext/modules
AGENT_EXTENSION=$AGENT_EXTENSION_DIR/elastic_apm.so

# ## This runs PHPT
# # Disable agent for auxiliary PHP processes to reduce noise in logs
export ELASTIC_APM_ENABLED=true
for phptFile in ./tests/*.phpt; do
msg="Running tests in \`${phptFile}' ..."
echo "${msg}"
this_script_name="$( basename "${BASH_SOURCE[0]}" )"
logger -t "${this_script_name}" "${msg}"

# Disable exit-on-error
set +e
make test TESTS="--show-all ${phptFile}"
# set +e
TESTS="--show-all ${phptFile}"

INI_FILE=`php -d 'display_errors=stderr' -r 'echo php_ini_loaded_file();' 2> /dev/null`

if test "$INI_FILE"; then
egrep -h -v $PHP_DEPRECATED_DIRECTIVES_REGEX "$INI_FILE" > /tmp/tmp-php.ini
else
echo > /tmp/tmp-php.ini
fi

TEST_PHP_SRCDIR=$APP_FOLDER/src/ext TEST_PHP_EXECUTABLE=$PHP_EXECUTABLE $PHP_EXECUTABLE -n -c /tmp/tmp-php.ini $PHP_TEST_SETTINGS $RUN_TESTS -n -c /tmp/tmp-php.ini -d extension_dir=$AGENT_EXTENSION_DIR -d extension=$AGENT_EXTENSION $PHP_TEST_SHARED_EXTENSIONS $TESTS
exitCode=$?
rm /tmp/tmp-php.ini


if [ ${exitCode} -ne 0 ] ; then
echo "Tests in \`${phptFile}' failed"
Expand Down Expand Up @@ -94,7 +113,7 @@ echo 'Set Elastic related environment variables:'
env | grep ELASTIC || true

# Install 3rd party dependencies
composer install
runPhpCoposerInstall

# Run static checks
composer run-script static_check
Expand Down
21 changes: 1 addition & 20 deletions .ci/validate_agent_installation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function printInfoAboutEnvironment () {
echo 'Installed PHP extensions:'
php -m
echo 'Set Elastic related environment variables:'
env | grep ELASTIC || true
env | grep -i elastic | sort || true
}

function runComponentTests () {
Expand Down Expand Up @@ -61,25 +61,6 @@ function runComponentTests () {
exit ${composerCommandExitCode}
}

function runPhpCoposerInstall () {
local run_command_with_timeout_and_retries_args=(--max-tries=3)
run_command_with_timeout_and_retries_args=(--retry-on-error=yes "${run_command_with_timeout_and_retries_args[@]}")
local initialTimeoutInMinutes=5
local initialTimeoutInSeconds=$((initialTimeoutInMinutes*60))
run_command_with_timeout_and_retries_args=(--timeout="${initialTimeoutInSeconds}" "${run_command_with_timeout_and_retries_args[@]}")
run_command_with_timeout_and_retries_args=(--increase-timeout-exponentially=yes "${run_command_with_timeout_and_retries_args[@]}")
run_command_with_timeout_and_retries_args=(--wait-time-before-retry="${initialTimeoutInSeconds}" "${run_command_with_timeout_and_retries_args[@]}")

set +e
.ci/run_command_with_timeout_and_retries.sh "${run_command_with_timeout_and_retries_args[@]}" -- composer install
local composerCommandExitCode=$?
set -e

if [ ${composerCommandExitCode} -ne 0 ] ; then
exit ${composerCommandExitCode}
fi
}

function main () {
thisScriptDir="$( dirname "${BASH_SOURCE[0]}" )"
thisScriptDir="$( realpath "${thisScriptDir}" )"
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ endif::[]
// Using the template above, release notes go here.
// CHANGELOG_AUTOMATION_KEYWORD
[[release-notes-v1.9.0]]
=== v1.9.0 - 2023/06/22
[float]
==== Features
* Added container ID detection {pull}966[#966]
* Extended span compression support to spans without service target {pull}944[#944]
* Added auto-instrumentation for capturing WordPress filters/actions callbacks and the active theme {pull}948[#948]
* Added configuration option STACK_TRACE_LIMIT {pull}995[#995]
* Added SPAN_STACK_TRACE_MIN_DURATION configuration option {pull}996[#996]
* Implemented backoff on failure in communication to APM Server {pull}999[#999]
==== Bug fixes
* Fixed not cleaning up connection data in sync backend comm. mode {pull}957[#957]
* Fixed crash when https://www.php.net/manual/en/function.opcache-reset.php[`opcache_reset()`] is used {pull}1000[#1000]
[[release-notes-v1.8.4]]
=== v1.8.4 - 2023/05/17
[float]
Expand Down
7 changes: 1 addition & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG PHP_VERSION=7.2
FROM php:${PHP_VERSION}-fpm
FROM php:${PHP_VERSION}-fpm-buster

RUN apt-get -qq update \
&& apt-get -qq -y --no-install-recommends install \
Expand Down Expand Up @@ -52,8 +52,3 @@ CMD phpize \

# Create a link to extensions directory to make it easier accessible (paths are different between php releases)
RUN ln -s `find /usr/local/lib/php/extensions/ -name opcache.so | head -n1 | xargs dirname` /tmp/extensions

# Patch run-tests.php to handle SKIPIF correctly in tests with agent debug logs enabled
RUN find /usr/local/lib/php/ -name run-tests.php | xargs sed -i 's#if (!strncasecmp(\x27skip\x27, ltrim(\$output), 4))#if (!strncasecmp(\x27skip\x27, ltrim(\$output), 4) || strstr(\$output, \x27ElasticApmSkipTest\x27))#g'

RUN find /usr/local/lib/php/ -name run-tests.php | xargs sed -i 's#system_with_timeout("\$extra \$php \$pass_options -q \$ini_settings \$no_file_cache -d display_errors=0 \\"\$test_skipif\\"", \$env)#system_with_timeout("\$extra \$php \$pass_options -q \$ini_settings \$no_file_cache -d display_errors=0 \\"\$test_skipif\\" 2>\&1", \$env)#g'
5 changes: 0 additions & 5 deletions Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,3 @@ CMD export CFLAGS="-std=gnu99 ${CFLAGS}" ; \

# Create a link to extensions directory to make it easier accessible (paths are different between php releases)
RUN ln -s `find /usr/local/lib/php/extensions/ -name opcache.so | head -n1 | xargs dirname` /tmp/extensions

# Patch run-tests.php to handle SKIPIF correctly in tests with agent debug logs enabled
RUN find /usr/local/lib/php/ -name run-tests.php | xargs sed -i 's#if (!strncasecmp(\x27skip\x27, ltrim(\$output), 4))#if (!strncasecmp("skip", ltrim(\$output), 4) || strstr(\$output, "ElasticApmSkipTest"))#g'

RUN find /usr/local/lib/php/ -name run-tests.php | xargs sed -i 's#system_with_timeout("\$extra \$php \$pass_options -q \$ini_settings \$no_file_cache -d display_errors=0 \\"\$test_skipif\\"", \$env)#system_with_timeout("\$extra \$php \$pass_options -q \$ini_settings \$no_file_cache -d display_errors=0 \\"\$test_skipif\\" 2>\&1", \$env)#g'
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"psr/log": "^1.0"
},
"require-dev": {
"clue/docker-react": "^1.4",
"ext-ctype": "*",
"ext-curl": "*",
"ext-mysqli": "*",
Expand All @@ -29,6 +30,7 @@
"phpstan/phpstan": "1.10.14",
"phpstan/phpstan-phpunit": "^1.1.1",
"phpunit/phpunit": "^8.5||^9.5",
"react/async": "^3.0",
"react/http": "^1.6",
"slevomat/coding-standard": "8.11.1",
"squizlabs/php_codesniffer": "3.7.2"
Expand Down
63 changes: 61 additions & 2 deletions docs/configuration.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,10 @@ Characters in service name that don't match regular expression will be replaced
|============

If it's set, this name is used to distinguish between different nodes of a service.
If it's not set, data aggregations will be done based on the reported
hostname (automatically discovered or manually configured using <<config-hostname>>).
If it's not set, data aggregations will be done based on the container ID
if the monitored application runs in a container.
Otherwise data aggregations will be done based on the reported hostname
(automatically discovered or manually configured using <<config-hostname>>).

[float]
[[config-service-version]]
Expand Down Expand Up @@ -681,6 +683,63 @@ This configuration option supports the duration suffixes: `ms`, `s` and `m`.
For example: `10ms`.
This option's default unit is `ms`, so `5` is interpreted as `5ms`.

[float]
[[config-span-stack-trace-min-duration]]
==== `span_stack_trace_min_duration`

[options="header"]
|============
| Environment variable name | Option name in `php.ini`
| `ELASTIC_APM_SPAN_STACK_TRACE_MIN_DURATION` | `elastic_apm.span_stack_trace_min_duration`
|============

[options="header"]
|============
| Default | Type
| `5ms` | Duration
|============

While it might be very helpful to have stack trace attached to a span,
collecting stack traces does have some overhead.
This configuration controls the minimum span duration at which stack traces are collected.
A higher value means lower overhead as stack trace collection is skipped for quick spans.

Set this config to:

- any positive value (e.g. `5ms`) - to limit stack trace collection to spans with duration
equal to or greater than the given value (e.g. 5 milliseconds)
- `0` (or `0` with any duration units e.g. `0ms`) - to collect stack traces
for spans with any duration
- any negative value (e.g. `-1ms`) - to disable stack trace collection for spans completely

This configuration option supports the duration suffixes: `ms`, `s` and `m`.
For example: `10ms`.
This option's default unit is `ms`, so `5` is interpreted as `5ms`.

[float]
[[config-stack-trace-limit]]
==== `stack_trace_limit`

[options="header"]
|============
| Environment variable name | Option name in `php.ini`
| `ELASTIC_APM_STACK_TRACE_LIMIT` | `elastic_apm.stack_trace_limit`
|============

[options="header"]
|============
| Default | Type
| `50` | Integer
|============

This option controls how many frames are included in stack traces captured by the agent.

Set this config to:

- any positive integer - to define the maximum number of frames included in stack traces
- `0` - to disable stack trace capturing
- any negative integer - to capture all frames

[float]
[[config-transaction-ignore-urls]]
==== `transaction_ignore_urls`
Expand Down
40 changes: 40 additions & 0 deletions docs/public-api.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,46 @@ Example:
$parentId = $transaction->getParentId();
----

[float]
[[api-transaction-interface-ensure-parent-id]]
==== `TransactionInterface->ensureParentId()`
If the transaction does not have a parent-ID yet,
calling this method generates a new ID,
sets it as the parent-ID of this transaction,
and returns it as a `string`.

This enables the correlation of the spans the JavaScript Real User Monitoring (RUM) agent creates for the initial page load
with the transaction of the backend service.
If your backend service generates the HTML page dynamically,
initializing the JavaScript RUM agent with the value of this method allows analyzing the time spent in the browser vs in the backend services.

An example of using this API in Laravel application can be found at https://github.com/elastic/opbeans-php/.

Add `isElasticApmEnabled`, `elasticApmCurrentTransaction` properties to the view
(https://github.com/elastic/opbeans-php/blob/22df4af76a879d8ce7237d90e953e312fb98e792/app/Providers/AppServiceProvider.php#L33[see the relevant part in opbeans-php's `AppServiceProvider.php`])
and add a snippet similar to the following one to the body of your HTML page,
preferably before other JS libraries
(https://github.com/elastic/opbeans-php/blob/22df4af76a879d8ce7237d90e953e312fb98e792/resources/views/rendered_by_frontend.blade.php[see opbeans-php's `rendered_by_frontend.blade.php`])
:

[source,html]
----
@if ($isElasticApmEnabled)
<script>
window.rumConfig = {
serviceName: "{{ $elasticApmJsServiceName }}",
serviceVersion: "{{ $elasticApmJsServiceVersion }}",
serverUrl: "{{ $elasticApmJsServerUrl }}",
pageLoadTraceId: "{{ $elasticApmCurrentTransaction->getTraceId() }}",
pageLoadSpanId: "{{ $elasticApmCurrentTransaction->ensureParentId() }}",
pageLoadSampled: {{ $elasticApmCurrentTransaction->isSampled() ? "true" : "false" }}
}
</script>
@endif
----

See the {apm-rum-ref}[JavaScript RUM agent documentation] for more information.

[float]
[[api-transaction-interface-set-result]]
==== `TransactionInterface->setResult`
Expand Down
1 change: 1 addition & 0 deletions docs/release-notes.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[[release-notes]]
== Release notes

* <<release-notes-v1.9.0>>
* <<release-notes-v1.8.4>>
* <<release-notes-v1.8.3>>
* <<release-notes-v1.8.2>>
Expand Down
11 changes: 10 additions & 1 deletion docs/supported-technologies.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ We support automatic instrumentation for the following web frameworks.
|Laravel
|6, 7, 8, 9, 10

|WordPress
|5, 6

|===

[float]
Expand All @@ -51,10 +54,16 @@ We support automatic instrumentation for the following data access technologies.
|===
|Data access technology |Supported versions |Notes


|PHP Data Objects (PDO)
|
|any version bundled with a supported PHP version
|The agent automatically creates DB spans for all your PDO queries. This includes PDO queries executed by object relational mappers (ORM) like Doctrine & Eloquent.


|MySQLi
|any version bundled with a supported PHP version
|

|===

[float]
Expand Down
Loading

0 comments on commit 38d1277

Please sign in to comment.