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

Note changes to DD_TRACE_CLI_ENABLED and resource sampling #26379

Merged
merged 4 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions content/en/tracing/guide/trace-php-cli-scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ further_reading:

A short-running script typically runs for a few seconds or minutes. The expected behavior is to receive one trace each time the script is executed.

By default, tracing is disabled for PHP scripts that run from the command line. Opt in by setting `DD_TRACE_CLI_ENABLED` to `1`.

```
$ export DD_TRACE_CLI_ENABLED=1
# Optionally, set the agent host and port if different from localhost and 8126, respectively
$ export DD_AGENT_HOST=agent
$ export DD_TRACE_AGENT_PORT=8126
Expand Down Expand Up @@ -47,13 +44,9 @@ Once the script is run, the trace is generated and sent to the Datadog backend w

A long-running script runs for hours or days. Typically, such scripts repetitively execute a specific task, for example processing new incoming messages or new lines added to a table in a database. The expected behavior is that one trace is generated for each "unit of work", for example the processing of a message.

By default, tracing is disabled for PHP scripts that run from the command line. Opt in by setting `DD_TRACE_CLI_ENABLED` to `1`.

```
$ export DD_TRACE_CLI_ENABLED=1
# With this pair of settings, traces for each "unit of work" is sent as soon as the method execution terminates.
# With this setting, traces for each "unit of work" are sent as soon as the method execution terminates.
$ export DD_TRACE_GENERATE_ROOT_SPAN=0
$ export DD_TRACE_AUTO_FLUSH_ENABLED=1
# Optionally, set service name, env, etc...
$ export DD_SERVICE=my_service
# Optionally, set the agent host and port if different from localhost and 8126, respectively
Expand Down
12 changes: 1 addition & 11 deletions content/en/tracing/trace_collection/compatibility/php.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ Datadog is continuously adding more support for in-depth tracing for PHP web-fra

#### CLI library compatibility

Tracing from the CLI SAPI is disabled by default. To enable tracing of PHP CLI scripts, set `DD_TRACE_CLI_ENABLED=true`.
Tracing from the CLI SAPI is enabled by default. To selectively disable tracing of PHP CLI scripts, set `DD_TRACE_CLI_ENABLED=false`.

| Module | Versions | Support Type |
|:----------------|:--------------------|:---------------------------|
Expand Down Expand Up @@ -171,14 +171,6 @@ To request support for additional datastores, contact our awesome [support team]

To request support for additional libraries, contact our awesome [support team][3].

#### Deep call stacks on PHP 5

The call stack is limited on PHP 5. See the [deep call stack troubleshooting page][5] for more details.

### Generators

Instrumenting [generators][6] is not supported on PHP 5 and PHP 7.

### PCNTL

Datadog supports tracing forked processes using [pcntl][7]. When a call to `pcntl_fork` is detected, a dedicated span is created, and the forked process is instrumented. This can be disabled with `DD_TRACE_FORKED_PROCESS`. Refer to the [library configuration page][9] for more details.
Expand All @@ -193,8 +185,6 @@ If the application invokes `pcntl_unshare(CLONE_NEWUSER);` and the tracer is ins
[2]: https://www.datadoghq.com/support/
[3]: /help
[4]: https://pecl.php.net/package/mongo
[5]: /tracing/troubleshooting/php_5_deep_call_stacks
[6]: https://www.php.net/manual/en/language.generators.overview.php
[7]: https://www.php.net/manual/en/book.pcntl.php
[8]: https://man7.org/linux/man-pages/man2/unshare.2.html
[9]: /tracing/trace_collection/library_config/php/#environment-variable-configuration
Expand Down
4 changes: 2 additions & 2 deletions content/en/tracing/trace_collection/library_config/php.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,12 @@ The Agent URL; takes precedence over `DD_AGENT_HOST` and `DD_TRACE_AGENT_PORT`.

`DD_TRACE_AUTO_FLUSH_ENABLED`
: **INI**: `datadog.trace.auto_flush_enabled`<br>
**Default**: `0`<br>
**Default**: `0` (`1` in CLI environment)<br>
Automatically flush the tracer when all the spans are closed; set to `1` in conjunction with `DD_TRACE_GENERATE_ROOT_SPAN=0` to trace [long-running processes][14].

`DD_TRACE_CLI_ENABLED`
: **INI**: `datadog.trace.cli_enabled`<br>
**Default**: `0`<br>
**Default**: `1`<br>
Enable tracing of PHP scripts from the CLI. See [Tracing CLI scripts][15].

`DD_TRACE_DEBUG`
Expand Down
14 changes: 12 additions & 2 deletions content/en/tracing/trace_pipeline/ingestion_mechanisms.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,23 @@ Read more about sampling controls in the [Node.js tracing library documentation]
[1]: /tracing/trace_collection/dd_libraries/nodejs
{{% /tab %}}
{{% tab "PHP" %}}
**Remote configuration**

<div class="alert alert-info"><strong>Resource-based sampling rules are in Preview</strong>. Starting from version <a href="https://github.com/DataDog/dd-trace-php/releases/tag/1.4.0">1.4.0</a>, for PHP applications, set by-service and by-resource sampling rates from the <a href="https://app.datadoghq.com/apm/traces/ingestion-control">Ingestion Control Page</a>. Use <a href="https://www.datadoghq.com/product-preview/resource-based-sampling-adaptive-sampling/">this form</a> to request access today.</div>

Read more about how to remotely configure sampling rates by service and resource in the [Resource-based sampling guide][1].

**Note**: Remotely-set configuration takes precedence over local configuration.

**Local configuration**

For PHP applications, set a global sampling rate for the library using the `DD_TRACE_SAMPLE_RATE` environment variable. Set by-service sampling rates with the `DD_TRACE_SAMPLING_RULES` environment variable.

For example, to send 50% of the traces for the service named `my-service` and 10% for the rest of the traces:
For example, to send 50% of the traces for the service named `my-service`, 20% of other endpoints' traces, and 10% for the rest of the traces, set:

```
export DD_TRACE_SAMPLE_RATE=0.1
export DD_TRACE_SAMPLING_RULES='[{"service": "my-service", "sample_rate": 0.5}]'
export DD_TRACE_SAMPLING_RULES='[{"service": "my-service", "resource":"GET /checkout", "sample_rate": 1},{"service": "my-service", "sample_rate": 0.2}]'
```

Read more about sampling controls in the [PHP tracing library documentation][1].
Expand Down
Loading