You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After installing the layer and the agent, you must configure the Datadog extension by adding the following key/value pair to a Lambda environment variable:
18
+
19
+
-`DD_ENV=<enviroment>`
20
+
-`DD_SERVICE=<service>`
21
+
-`DD_SITE=<datadoghq.eu|datadoghq.com>` (depending on your Datadog account region)
22
+
-`DD_API_KEY=<api_key>`
23
+
-`DD_SERVICE=<your service name>`
24
+
-`DD_VERSION=<your service version>`
25
+
26
+
For more details about the configuration, see https://docs.datadoghq.com/tracing/trace_collection/library_config/php/
27
+
28
+
You should also consider adding similar AWS tags to your Lambda function to link APM and Infrastructure data together using the tag/value syntax:
29
+
30
+
-`Env=<the same as DD_ENV>`
31
+
-`Service=<the same as DD_SERVICE>`
32
+
-`Team=<the team name>` (use `a-z0-9\-` pattern)
33
+
-`Tier=<A|B|C|...>` (to indicate how important the service is)
- Enroll in free technical sessions at https://www.datadoghq.com/technical-enablement/sessions/
39
+
40
+
## Custom instrumentation
41
+
42
+
DataDog works out of the box with the php-xx-fpm runtime. However, if you are using the php-xx runtime and BREF_LOOP_MAX>1, you must add custom instrumentation.
43
+
Otherwise, DataDog will wait until the end of a loop and only send one trace.
44
+
To add custom instrumentation, create an `instrumentation.php` file and add the following code:
45
+
46
+
```php
47
+
<?php
48
+
49
+
\DDTrace\trace_method(
50
+
'Bref\Runtime\Invoker',
51
+
'invoke',
52
+
function (\DDTrace\SpanData $span, $args, $ret, $exception) {
53
+
$span->service = getenv('DD_SERVICE');
54
+
$span->type = \DDTrace\Type::CLI;
55
+
$span->name = 'invoke';
56
+
}
57
+
);
58
+
```
59
+
60
+
This code will enable you to see all traces.
61
+
62
+
*do not forget to add `instrumentation.php` to a `composer.json` file
63
+
64
+
For EventBridge Lambdas, add the following code to the function above:
65
+
66
+
```php
67
+
<?php
68
+
if ($args[0] instanceof \Bref\Event\EventBridge\EventBridgeEvent) {
69
+
$span->resource = $args[0]->getDetailType();
70
+
}
71
+
```
72
+
73
+
This code will name your traces with the EventBridge event name.
74
+
75
+
For more information about custom instrumentation, refer to the following resources:
0 commit comments