forked from brefphp/extra-php-extensions
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes brefphp#35
- Loading branch information
Showing
5 changed files
with
96 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,41 @@ | ||
# Configuring the Datadog Layer | ||
|
||
The Datadog layer provides the [Datadog Agent][] and [ddtrace extension for PHP][]. | ||
|
||
When using this layer, you must set the following environment variables: | ||
|
||
- `DD_API_KEY` | ||
|
||
It may be necessary to set the following environment variables when running | ||
PHP in a serverless environment: | ||
|
||
- `DD_TRACE_CLI_ENABLED` - set this value to `1` (the default is `0`) | ||
|
||
The following environment variables may be useful or necessary, depending on | ||
how you use Datadog: | ||
|
||
- `DD_SITE` - this defaults to `datadoghq.com` | ||
- `DD_LOG_LEVEL` - e.g., `trace`, `debug`, `info`, `warn`, `error`, `critical`, `off` | ||
- `DD_SERVICE` - the name of your service as it should appear in Datadog | ||
- `DD_VERSION` - the version of your service, for display and filtering in Datadog | ||
- `DD_ENV` - the environment your service is running in (i.e., staging, prod, etc.), | ||
for display and filtering in Datadog | ||
|
||
Using environment variables, you may set any of the [Datadog Agent environment | ||
variables][] or [PHP ddtrace environment variables][] in your `serverless.yml` | ||
configuration, or you may configure them using a custom PHP INI file with Bref, | ||
as described in the [Bref documentation][]. | ||
|
||
All values not set in your configuration will use the default [INI settings][] | ||
for the extension. | ||
|
||
See the [Datadog documentation][] for more information about serverless | ||
monitoring for AWS Lambda. | ||
|
||
[datadog agent]: https://docs.datadoghq.com/agent/ | ||
[ddtrace extension for php]: https://docs.datadoghq.com/tracing/trace_collection/dd_libraries/php/ | ||
[datadog agent environment variables]: https://docs.datadoghq.com/containers/docker/apm/?tab=linux#docker-apm-agent-environment-variables | ||
[php ddtrace environment variables]: https://docs.datadoghq.com/tracing/trace_collection/library_config/php/#environment-variable-configuration | ||
[bref documentation]: https://bref.sh/docs/environment/php.html | ||
[ini settings]: https://docs.datadoghq.com/tracing/trace_collection/library_config/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,35 @@ | ||
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 cp "$(php-config --extension-dir)/ddappsec.so" /tmp/ddappsec.so | ||
RUN cp "$(php-config --extension-dir)/datadog-profiling.so" /tmp/datadog-profiling.so | ||
RUN cp "$(php-config --ini-dir)/98-ddtrace.ini" /tmp/ext.ini | ||
|
||
RUN sed -i 's/extension = ddtrace\.so/extension = \/opt\/bref-extra\/ddtrace.so/' /tmp/ext.ini | ||
RUN sed -i 's/extension = ddappsec\.so/extension = \/opt\/bref-extra\/ddappsec.so/' /tmp/ext.ini | ||
RUN sed -i 's/extension = datadog-profiling\.so/;extension = \/opt\/bref-extra\/datadog-profiling.so/' /tmp/ext.ini | ||
RUN sed -i 's/datadog\.appsec\.enabled = On/datadog.appsec.enabled = Off/' /tmp/ext.ini | ||
|
||
FROM scratch | ||
|
||
COPY --from=ext /tmp/ddtrace.so /opt/bref-extra/ddtrace.so | ||
COPY --from=ext /tmp/ddappsec.so /opt/bref-extra/ddappsec.so | ||
COPY --from=ext /tmp/datadog-profiling.so /opt/bref-extra/datadog-profiling.so | ||
COPY --from=ext /tmp/ext.ini /opt/bref/etc/php/conf.d/98-ddtrace.ini | ||
COPY --from=ext /opt/datadog/ /opt/datadog | ||
|
||
# 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 |
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); |