This page is pulled from project's readme. Links could be broken.

Ansible Role Build Status GitHub tag license Donate Hire Typist Tech

Install New Relic PHP agent on Trellis servers

Requirements

Installation

Add this role to requirements.yml:

- src: TypistTech.trellis-newrelic-php # Case-sensitive!
  version: 0.4.0 # Check for latest version!

Run $ ansible-galaxy install -r requirements.yml to install this new role.

Role Variables

# group_vars/<environment>/vault.yml
# This file should be encrypted. See: https://roots.io/trellis/docs/vault/
##########################################################################

# New Relic License Key
## See: https://docs.newrelic.com/docs/accounts-partnerships/accounts/account-setup/license-key
vault_newrelic_license: xxxxxxxxxxx

# group_vars/<environment>/main.yml
###################################

# Indicates the desired package state.
# `latest` ensures that the latest version is installed.
# `present` does not update if already installed.
# Choices: present|latest
# Default: latest
newrelic_package_state: present

# Check for default values here: https://github.com/TypistTech/trellis-newrelic-php/blob/master/defaults/main.yml
# See also: https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-configuration
newrelic_config:
  appname: "My Awesome App {{ env }}"
  framework: no_framework
  transaction_tracer.detail: 1
  datastore_tracer.database_name_reporting.enabled: true

Hacking Trellis' Playbook

Add this role to dev.yml and server.yml immediately after role: php:

roles:
    # Some other Trellis roles ...
    - { role: php, tags: [php] }
    - { role: TypistTech.trellis-newrelic-php, tags: [php, newrelic-php] }
    # Some other Trellis roles ...

Common Errors

vault_newrelic_license is not defined

Encrypt your New Relic license key in group_vars/<environment>/vault.yml. See role variables.

New Relic merges multiple environments into single application

Solution: Define different appname for different environments.

Tips:

# group_vars/all/main.yml
#########################

newrelic_config:
  appname: "My Awesome App {{ env }}"

Error after upgrading PHP version

New Relic would fail and causes provision end up in errors when upgrading PHP minor releases (e.g: from 7.1 to 7.2).

After PHP minor release upgrade (i.e: when you see the error):

➜ ssh [email protected]
➜ sudo newrelic-install install
➜ sudo reboot

# Wait for server reboot and re-provision again
➜ ansible-playbook server.yml -e env=production

Limitations

  • Only one New Relic APM application per server

Pull requests are welcomed.

See Also

Support!

Donate

Love Trellis New Relic PHP Agent? Help me maintain it, a donation can help with it.

Why don't you hire me?

Ready to take freelance WordPress jobs. Contact me via the contact form here or, via email [email protected]

Want to help in other way? Want to be a sponsor?

Contact: Tang Rufus

Feedback

Please provide feedback! We want to make this library useful in as many projects as possible. Please submit an issue and point out what you do and don't like, or fork the project and make suggestions. No issue is too small.

Change log

Please see CHANGELOG for more information on what has changed recently.

Author Information

Trellis New Relic PHP Agent is a Typist Tech project and maintained by Tang Rufus, freelance developer for hire.

Special thanks to the Roots team whose Trellis make this project possible.

Full list of contributors can be found here.

Contributing

Please see CODE_OF_CONDUCT for details.

License

Trellis New Relic PHP Agent is released under the MIT License.