Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support to install newrelic #904

Closed
leroy0211 opened this issue Apr 5, 2024 · 4 comments · Fixed by #910
Closed

Support to install newrelic #904

leroy0211 opened this issue Apr 5, 2024 · 4 comments · Fixed by #910
Labels
enhancement New feature or request

Comments

@leroy0211
Copy link

Hi,

We use newrelic a lot in our projects, and I'm wondering if this is a great candidate to install with install-php-extensions.

This might be related to #784 , but it was closed with status completed.

@leroy0211 leroy0211 added the enhancement New feature or request label Apr 5, 2024
@mlocati
Copy link
Owner

mlocati commented Apr 5, 2024

I don't know newrelic... is it a PHP extension? How do you install it?

@leroy0211
Copy link
Author

leroy0211 commented Apr 12, 2024

newrelic is a APM monitoring tool, which uses a newrelic.ini file for configuration, located in $PHP_INI_DIR.

There are basically 2 ways of using the newrelic php daemon. Either as separate container, or in the same container as php is running. Both need the newrelic php agent installed in the image that is running php.

docs: https://docs.newrelic.com/docs/apm/agents/php-agent/advanced-installation/docker-other-container-environments-install-php-agent

The newrelic agent adds a few "native" php functions to interact with newrelic. see: https://docs.newrelic.com/docs/apm/agents/php-agent/php-agent-api/guide-using-php-agent-api/

We usually install newrelic in our images like so:

RUN cd ~ \
    && export NEWRELIC_VERSION="$(curl -sS https://download.newrelic.com/php_agent/release/ | sed -n 's/.*>\(.*linux\).tar.gz<.*/\1/p')" \
    && curl -sS "https://download.newrelic.com/php_agent/release/${NEWRELIC_VERSION}.tar.gz" | gzip -dc | tar xf - \
    && cd "${NEWRELIC_VERSION}" \
    && NR_INSTALL_SILENT=true ./newrelic-install install \
    && NR_SO_FILE=`readlink /usr/local/lib/php/extensions/no-debug-non-zts-*/newrelic.so` \
    && mv "${NR_SO_FILE}" /usr/local/lib/php/extensions/no-debug-non-zts-*/newrelic.so \
    && chown -R www-data:www-data /var/log/newrelic \
    && cd .. \
    && unset NEWRELIC_VERSION \
    && rm -rf "${NEWRELIC_VERSION}"

A few notes, this doesn't change the newrelic.ini file located in $PHP_INI_DIR, so neither a license key or application name is configured (which are the minimum requirements for this extension to work).

We often mount a separate newrelic.ini in our containers, which override the default newrelic.ini

What do you think? Would this be a php extension to add to docker-php-extension-installer?

@mlocati
Copy link
Owner

mlocati commented Apr 16, 2024

Thanks for the detailed instructions!
Done.

@ro0NL
Copy link
Contributor

ro0NL commented Apr 16, 2024

thank you, it works :shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants