Skip to content

Commit

Permalink
Add support for newrelic
Browse files Browse the repository at this point in the history
  • Loading branch information
mlocati committed Apr 16, 2024
1 parent 9eb0c12 commit b0c31f4
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ Here's the list of all the supported environment variables:
| http, intl, mongodb | `IPE_ICU_EN_ONLY=1` | Some extensions require the ICU library, use this flag to install a smaller, but English-only, ICU library on Alpine 3.16 and later |
| pspell | `IPE_ASPELL_LANGUAGES='...'` | Configure the languages to be made available (for example: `IPE_ASPELL_LANGUAGES='en fr'`). If omitted, we'll assume `en` |
| | `IPE_DEB_ARCHIVE` & `IPE_DEB_ARCHIVE_SECURITY` | The APT packages of very old Debian versions (eg Jessie) may have been archived: you can use these environment variables to specify custom URLs of these APT archives |
| newrelic | `NR_INSTALL_KEY` | Your New Relic license key |

## Special requirements

Expand Down
1 change: 1 addition & 0 deletions data/supported-extensions
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ msgpack 5.5 5.6 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3
mssql 5.5 5.6
mysql 5.5 5.6
mysqli 5.5 5.6 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3
newrelic 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3
oauth 5.5 5.6 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3
oci8 5.5 5.6 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3
odbc 5.5 5.6 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3
Expand Down
36 changes: 34 additions & 2 deletions install-php-extensions
Original file line number Diff line number Diff line change
Expand Up @@ -2364,6 +2364,32 @@ installCargo() {
fi
}

installNewRelic() {
printf '# Installing newrelic\n'
installNewRelic_search='\bnewrelic-php[0-9.]*-[0-9]+(\.[0-9]+)*-linux'
case "$DISTRO" in
alpine)
installNewRelic_search="$installNewRelic_search-musl"
;;
esac
installNewRelic_file="$(curl -sSLf -o- https://download.newrelic.com/php_agent/release/ | sed -E 's/<[^>]*>//g' | grep -Eo "$installNewRelic_search.tar.gz" | sort | head -1)"
installNewRelic_url="https://download.newrelic.com/php_agent/release/$installNewRelic_file"
installNewRelic_src="$(getPackageSource "$installNewRelic_url")"
cd -- "$installNewRelic_src"
NR_INSTALL_USE_CP_NOT_LN=1 NR_INSTALL_SILENT=1 ./newrelic-install install
cd - >/dev/null
cat <<EOT
NewRelic has been installed from $installNewRelic_url
You may need to:
- change the owner/permissions of /var/log/newrelic
(for example: chown -R www-data:www-data /var/log/newrelic)
- set the value of the newrelic.license configuration key in
$PHP_INI_DIR/conf.d/newrelic.ini
(if you didn't set the NR_INSTALL_KEY environment variable)
EOT
}

# Install a bundled PHP module given its handle
#
# Arguments:
Expand Down Expand Up @@ -3206,6 +3232,10 @@ installRemoteModule() {
fi
fi
;;
newrelic)
installNewRelic
installRemoteModule_manuallyInstalled=2
;;
oauth)
if test -z "$installRemoteModule_version"; then
if test $PHP_MAJMIN_VERSION -le 506; then
Expand Down Expand Up @@ -4190,8 +4220,10 @@ installRemoteModule() {
installPeclPackage "$installRemoteModule_module" "$installRemoteModule_version" "$installRemoteModule_cppflags" "$installRemoteModule_path"
fi
postProcessModule "$installRemoteModule_module"
checkModuleWorking "$installRemoteModule_module" "$installRemoteModule_ini_basename" "$installRemoteModule_ini_extra"
enablePhpExtension "$installRemoteModule_module" "$installRemoteModule_ini_basename" "$installRemoteModule_ini_extra"
if test $installRemoteModule_manuallyInstalled -lt 2; then
checkModuleWorking "$installRemoteModule_module" "$installRemoteModule_ini_basename" "$installRemoteModule_ini_extra"
enablePhpExtension "$installRemoteModule_module" "$installRemoteModule_ini_basename" "$installRemoteModule_ini_extra"
fi
}

# Check if a module/helper may be installed using the pecl archive
Expand Down
15 changes: 15 additions & 0 deletions scripts/tests/newrelic
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env php
<?php

require_once __DIR__ . '/_bootstrap.php';

$rc = 0;
echo 'Checking if newrelic_start_transaction() exists... ';
if (!function_exists('newrelic_start_transaction')) {
$rc = 1;
echo "NO!\n";
} else {
echo "yes.\n";
}

exit($rc);

0 comments on commit b0c31f4

Please sign in to comment.