Skip to content

Commit

Permalink
Rename DDTRACE_EXT_VERSION to DDTRACE_EXT_PHP_API and update the defa…
Browse files Browse the repository at this point in the history
…ult value to 20210902
  • Loading branch information
josephwynn-sc committed Dec 16, 2022
1 parent db0aaf1 commit f0d7ddc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@ heroku buildpacks:add --app <your-app-name> https://github.com/SpeedCurve-Metric

## Configuration

This buildpack accepts several config vars:
This buildpack accepts several config vars. All of them are optional:

- `DDTRACE_EXT_VERSION` - The extension version that PHP is compiled with. Defaults to `20180731`.
- `DDTRACE_EXT_RELEASE` - The release name of [dd-trace-php](https://github.com/DataDog/dd-trace-php/releases/) to download. Defaults to `0.54.0`.
- `DDTRACE_EXT_PHP_API` - The PHP API version that your application uses. Defaults to `20210902`. Use `phpinfo()` to find the API version if you're not sure.
- `DDTRACE_EXT_RELEASE` - The release name of [dd-trace-php](https://github.com/DataDog/dd-trace-php/releases/) to download. Defaults to `0.82.0`.
- `DDTRACE_EXT_PKG_URL` - The URL to a dd-trace-php `.deb` file. This option overides `DDTRACE_EXT_RELEASE`.

### More information: `DDTRACE_EXT_VERSION`
### More information: `DDTRACE_EXT_PHP_API`

PHP on Heroku is compiled with a specific version of the ddtrace extension. By default, this buildpack enables version `20190902` of the extension. If PHP was compiled with a different version, you will see warnings like this in your application logs:
This buildpack does not determine that PHP API version automatically. The default value should work for most PHP versions, but if the version is wrong then you will see warnings like this in your application logs:

```
PHP Warning: PHP Startup: ddtrace: Unable to initialize module
Module compiled with module API=20180731
PHP compiled with module API=20190902
Module compiled with module API=20210902
PHP compiled with module API=20220829
These options need to match
```

You can change the extension version that is enabled by this buildpack by setting the `DDTRACE_EXT_VERSION` config var in Heroku. For example:
You can change the version by setting the `DDTRACE_EXT_VERSION` config var in Heroku. For example:

```
heroku config:set --app <your-app-name> DDTRACE_EXT_VERSION=20190902
heroku config:set --app <your-app-name> DDTRACE_EXT_VERSION=20220829
```
14 changes: 6 additions & 8 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ else
if [[ -n ${DDTRACE_EXT_RELEASE:-} ]]; then
echo "Using dd-trace-php release '$DDTRACE_EXT_RELEASE' (from "'$DDTRACE_EXT_RELEASE env var).' | indent
else
export DDTRACE_EXT_RELEASE="0.54.0"
export DDTRACE_EXT_RELEASE="0.82.0"
echo "Using dd-trace-php release '$DDTRACE_EXT_RELEASE' (default value)." | indent
fi
export DDTRACE_EXT_PKG_URL="https://github.com/DataDog/dd-trace-php/releases/download/"$DDTRACE_EXT_RELEASE"/datadog-php-tracer_"$DDTRACE_EXT_RELEASE"_amd64.deb"
Expand All @@ -69,18 +69,16 @@ dpkg -x $PACKAGE_FILE $BUILD_DIR/.apt/

topic "Enabling ddtrace PHP extension"

if [[ -n ${DDTRACE_EXT_VERSION:-} ]]; then
echo "Using version '$DDTRACE_EXT_VERSION' (from "'$DDTRACE_EXT_VERSION env var).' | indent
if [[ -n ${DDTRACE_EXT_PHP_API:-} ]]; then
echo "Using version '$DDTRACE_EXT_PHP_API' (from "'$DDTRACE_EXT_PHP_API env var).' | indent
else
export DDTRACE_EXT_VERSION="20190902"
echo "Using version '$DDTRACE_EXT_VERSION' (default value)." | indent
export DDTRACE_EXT_PHP_API="20210902"
echo "Using version '$DDTRACE_EXT_PHP_API' (default value)." | indent
fi

touch /app/.heroku/php/etc/php/conf.d/datadog-php-custom.ini
echo "[PHP]" >> /app/.heroku/php/etc/php/conf.d/datadog-php-custom.ini
echo "extension=/app/.apt/opt/datadog-php/extensions/ddtrace-$DDTRACE_EXT_VERSION.so" >> /app/.heroku/php/etc/php/conf.d/datadog-php-custom.ini
echo "extension=/app/.apt/opt/datadog-php/extensions/ddtrace-$DDTRACE_EXT_PHP_API.so" >> /app/.heroku/php/etc/php/conf.d/datadog-php-custom.ini
echo "ddtrace.request_init_hook=/app/.apt/opt/datadog-php/dd-trace-sources/bridge/dd_wrap_autoloader.php" >> /app/.heroku/php/etc/php/conf.d/datadog-php-custom.ini

echo "Done" | indent


0 comments on commit f0d7ddc

Please sign in to comment.