-
-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #35
- Loading branch information
Showing
5 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Configuring Datadog extensions | ||
|
||
This layer provides two Datadog extensions: | ||
|
||
- `ddtrace.so` for application performance monitoring (APM) | ||
- `ddappsec.so` for application security management (ASM) | ||
|
||
The [Continous Profiler extension][] is not available on serverless platforms. | ||
|
||
The _ddtrace_ extension is enabled by default, and the [INI settings][] for the | ||
extension are set to their default values. | ||
|
||
To enable the _ddappsec_ extension, follow the [Bref documentation][] to create | ||
a custom PHP INI file. For example, you might create a file in your project at | ||
`php/conf.d/datadog.ini`. To this INI file, add the following line: | ||
|
||
```ini | ||
extension=/opt/bref-extra/ddappsec.so | ||
``` | ||
|
||
As an alternative, you may pass the environment variable `DD_APPSEC_ENABLED=true` | ||
to your application. See [PHP Getting Started with ASM][] for more details. | ||
|
||
If you wish to configure any of the INI settings, check the Datadog | ||
documentation for [Configuring the PHP Tracing Library][ini settings]. You may | ||
pass many of the settings to your application through environment variables, or | ||
you may configure them using a custom PHP INI file with Bref, as described | ||
above. | ||
|
||
See the [Datadog documentation][] for more information about serverless | ||
monitoring for AWS Lambda. | ||
|
||
[continous profiler extension]: https://docs.datadoghq.com/profiler/enabling/php/ | ||
[ini settings]: https://docs.datadoghq.com/tracing/trace_collection/library_config/php/ | ||
[bref documentation]: https://bref.sh/docs/environment/php.html | ||
[php getting started with asm]: https://docs.datadoghq.com/security/application_security/getting_started/php/ | ||
[datadog documentation]: https://docs.datadoghq.com/serverless/aws_lambda |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
ARG PHP_VERSION | ||
FROM bref/build-php-$PHP_VERSION:1.7.14 AS ext | ||
|
||
ENV DDTRACE_BUILD_DIR=${BUILD_DIR}/ddtrace | ||
|
||
RUN set -xe; \ | ||
mkdir -p ${DDTRACE_BUILD_DIR}; \ | ||
curl -Ls -o ${DDTRACE_BUILD_DIR}/datadog-setup.php https://github.com/DataDog/dd-trace-php/releases/latest/download/datadog-setup.php | ||
|
||
WORKDIR ${DDTRACE_BUILD_DIR} | ||
|
||
RUN php datadog-setup.php --php-bin=all | ||
|
||
RUN cp "$(php-config --extension-dir)/ddtrace.so" /tmp/ddtrace.so | ||
RUN echo 'extension=/opt/bref-extra/ddtrace.so' > /tmp/ext.ini | ||
|
||
FROM scratch | ||
|
||
COPY --from=ext /tmp/ddtrace.so /opt/bref-extra/ddtrace.so | ||
COPY --from=ext /tmp/ext.ini /opt/bref/etc/php/conf.d/98-ddtrace.ini | ||
|
||
# This adds the Datadog Agent to the layer. | ||
# Refer to https://gallery.ecr.aws/datadog/lambda-extension | ||
COPY --from=public.ecr.aws/datadog/lambda-extension:latest /opt/extensions/ /opt/extensions | ||
|
||
ENV DD_AGENT_HOST=127.0.0.1 | ||
ENV DD_APM_ENABLED=1 | ||
ENV DD_LOG_LEVEL=info | ||
ENV DD_SITE=datadoghq.com | ||
ENV DD_TRACE_CLI_ENABLED=0 | ||
ENV DD_TRACE_DEBUG=0 | ||
ENV DD_TRACE_ENABLED=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"php": [ | ||
"80", | ||
"81", | ||
"82" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
if (!function_exists($func = '\DDTrace\trace_method')) { | ||
echo sprintf('FAIL: Function "%s" does not exist.', $func).PHP_EOL; | ||
exit(1); | ||
} | ||
|
||
exit(0); |