Skip to content
This repository was archived by the owner on Nov 3, 2024. It is now read-only.
This repository was archived by the owner on Nov 3, 2024. It is now read-only.

New Relic service #102

@mglaman

Description

@mglaman

I'll document adding New Relic as a service. So far I have this:

.ddev/docker-compose.newrelic.yaml:

---
# Adds New Relic support for performance profiling.
version: '3.6'
services:
  newrelic:
    image: newrelic/php-daemon
    container_name: ddev-${DDEV_SITENAME}-newrelic
    ports: ['31339']
    labels:
      com.ddev.site-name: ${DDEV_SITENAME}
      com.ddev.approot: $DDEV_APPROOT

  web:
    args:
      NEW_RELIC_AGENT_VERSION: "9.2.0.247"
      NEW_RELIC_LICENSE_KEY: "NEW_RELIC_LICENSE_KEY"
      NEW_RELIC_APPNAME: ${DDEV_SITENAME}
      NEW_RELIC_DAEMON_ADDRESS: "newrelic:31339"
    links:
      - newrelic:$DDEV_HOSTNAME

And in .ddev/web-build/Dockerfile

ARG BASE_IMAGE
FROM $BASE_IMAGE

# Install New Relic
# @see https://docs.newrelic.com/docs/agents/php-agent/advanced-installation/docker-other-container-environments-install-php-agent
ARG NEW_RELIC_AGENT_VERSION
ARG NEW_RELIC_LICENSE_KEY
ARG NEW_RELIC_APPNAME

RUN curl -L https://download.newrelic.com/php_agent/archive/${NEW_RELIC_AGENT_VERSION}/newrelic-php5-${NEW_RELIC_AGENT_VERSION}-linux.tar.gz | tar -C /tmp -zx \
    && export NR_INSTALL_USE_CP_NOT_LN=1 \
    && export NR_INSTALL_SILENT=1 \
    && /tmp/newrelic-php5-${NEW_RELIC_AGENT_VERSION}-linux/newrelic-install install \
    && rm -rf /tmp/newrelic-php5-* /tmp/nrinstall*

RUN sed -i -e "s/REPLACE_WITH_REAL_KEY/${NEW_RELIC_LICENSE_KEY}/" \
    -e "s/newrelic.appname[[:space:]]=[[:space:]].*/newrelic.appname=\"${NEW_RELIC_APPNAME}\"/" \
    -e '$anewrelic.distributed_tracing_enabled=true' \
    -e '$anewrelic.daemon.address="newrelic-php-daemon:31339"' \
    $(php -r "echo(PHP_CONFIG_FILE_SCAN_DIR);")/newrelic.ini

Once I know it all works I'll open a PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions