From 361b1909e43939507d1db2e092623e472e2cb25f Mon Sep 17 00:00:00 2001 From: Pawel Filipczak Date: Mon, 3 Feb 2025 14:12:14 +0100 Subject: [PATCH] Inferred spans (#152) --- docs/configure.md | 28 +- prod/native/CMakeLists.txt | 3 - prod/native/extension/code/Hooking.cpp | 41 +- prod/native/extension/code/Hooking.h | 24 +- prod/native/extension/code/ModuleEntry.cpp | 14 +- .../native/extension/code/ModuleFunctions.cpp | 22 + .../extension/code/ModuleIniEntries.cpp | 6 + prod/native/extension/code/ModuleInit.cpp | 7 +- prod/native/libcommon/code/AgentGlobals.cpp | 30 +- prod/native/libcommon/code/AgentGlobals.h | 7 +- .../libcommon/code/ConfigurationManager.h | 7 +- .../libcommon/code/ConfigurationSnapshot.h | 12 + prod/native/libcommon/code/InferredSpans.h | 96 ++++ .../libcommon/code/PeriodicTaskExecutor.h | 6 +- prod/native/libcommon/code/RequestScope.h | 29 +- .../test/PeriodicTaskExecutorTest.cpp | 10 +- prod/native/libphpbridge/code/PhpBridge.cpp | 56 +-- prod/native/libphpbridge/code/PhpBridge.h | 2 +- .../InferredSpans/InferredSpans.php | 411 ++++++++++++++++++ prod/php/ElasticOTel/PhpPartFacade.php | 37 +- 20 files changed, 799 insertions(+), 49 deletions(-) create mode 100644 prod/native/libcommon/code/InferredSpans.h create mode 100644 prod/php/ElasticOTel/InferredSpans/InferredSpans.php diff --git a/docs/configure.md b/docs/configure.md index a9dc85b..29722d4 100644 --- a/docs/configure.md +++ b/docs/configure.md @@ -55,20 +55,46 @@ _Currently there are no additional `OTEL_` options waiting to be contributed ups `ELASTIC_OTEL_` options that are specific to Elastic and will always live in EDOT PHP (in other words, they will _not_ be added upstream): +#### General configuration #### | Option(s) | Default | Accepted values | Description | |---|---|---|---| |ELASTIC_OTEL_ENABLED|true|true or false|Enables the automatic bootstrapping of instrumentation code| + +#### Asynchronous data sending configuration #### + +| Option(s) | Default | Accepted values | Description | +|---|---|---|---| |ELASTIC_OTEL_ASYNC_TRANSPORT|true| true or false | Use asynchronous (background) transfer of traces, metrics and logs. If false - brings back original OpenTelemetry SDK transfer modes| -|ELASTIC_OTEL_ASYNC_TRANSPORT_SHUTDOWN_TIMEOUT| 30s | interger numberwith time duration. Set to 0 to disable the timeout. Optional units: ms (default), s, m | Timeout after which the asynchronous (background) transfer will interrupt data transmission during process termination| +|ELASTIC_OTEL_ASYNC_TRANSPORT_SHUTDOWN_TIMEOUT| 30s | interger number with time duration. Set to 0 to disable the timeout. Optional units: ms (default), s, m | Timeout after which the asynchronous (background) transfer will interrupt data transmission during process termination| |ELASTIC_OTEL_MAX_SEND_QUEUE_SIZE|2MB| integer number with optional units: B, MB or GB | Set the maximum buffer size for asynchronous (background) transfer. It is set per worker process.| |ELASTIC_OTEL_VERIFY_SERVER_CERT|true|true or false|Enables server certificate verification for asynchronous sending| + +#### Logging configuration #### + +| Option(s) | Default | Accepted values | Description | +|---|---|---|---| |ELASTIC_OTEL_LOG_FILE||Filesystem path|Log file name. You can use the %p placeholder where the process ID will appear in the file name, and %t where the timestamp will appear. Please note that the PHP process must have write permissions for the specified path.| |ELASTIC_OTEL_LOG_LEVEL_FILE|OFF|OFF, CRITICAL, ERROR, WARNING, INFO, DEBUG, TRACE|Log level for file sink. Set to OFF if you don't want to log to file. |ELASTIC_OTEL_LOG_LEVEL_STDERR|OFF|OFF, CRITICAL, ERROR, WARNING, INFO, DEBUG, TRACE|Log level for the stderr sink. Set to OFF if you don't want to log to a file. This sink is recommended when running the application in a container. |ELASTIC_OTEL_LOG_LEVEL_SYSLOG|OFF|OFF, CRITICAL, ERROR, WARNING, INFO, DEBUG, TRACE|Log level for file sink. Set to OFF if you don't want to log to file. This sink is recommended when you don't have write access to file system. |ELASTIC_OTEL_LOG_FEATURES||Comma separated string with FEATURE=LEVEL pairs.
Supported features:
ALL, MODULE, REQUEST, TRANSPORT, BOOTSTRAP, HOOKS, INSTRUMENTATION|Allows selective setting of log level for features. For example, "ALL=info,TRANSPORT=trace" will result in all other features logging at the info level, while the TRANSPORT feature logs at the trace level. It should be noted that the appropriate log level must be set for the sink - for our example, this would be TRACE. + +#### Transaction span configuration #### + +| Option(s) | Default | Accepted values | Description | +|---|---|---|---| |ELASTIC_OTEL_TRANSACTION_SPAN_ENABLED|true|true or false|Enables automatic creation of transaction (root) spans for the webserver SAPI. The name of the span will correspond to the request method and path.| |ELASTIC_OTEL_TRANSACTION_SPAN_ENABLED_CLI|true|true or false|Enables automatic creation of transaction (root) spans for the CLI SAPI. The name of the span will correspond to the script name.| |ELASTIC_OTEL_TRANSACTION_URL_GROUPS||Comma-separated list of wildcard expressions|Allows grouping multiple URL paths using wildcard expressions, such as `/user/*`. For example, `/user/Alice` and `/user/Bob` will be mapped to the transaction name `/user/*`.| |