Skip to content
This repository was archived by the owner on Sep 12, 2018. It is now read-only.

Commit fca770e

Browse files
author
Olivier Gambier
committed
New relic support
Introduce two new environment configuration variables: NEW_RELIC_INI and NEW_RELIC_STAGE Added new extra "newrelic" installation opt-in. Docker-DCO-1.1-Signed-off-by: Olivier Gambier <[email protected]> (github: dmp42)
1 parent aa8b05c commit fca770e

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ add ./config/boto.cfg /etc/boto.cfg
2525
run pip install /docker-registry/depends/docker-registry-core
2626

2727
# Install registry
28-
run pip install file:///docker-registry#egg=docker-registry[bugsnag]
28+
run pip install file:///docker-registry#egg=docker-registry[bugsnag,newrelic]
2929

3030
env DOCKER_REGISTRY_CONFIG /docker-registry/config/config_sample.yml
3131
env SETTINGS_FLAVOR dev

docker_registry/server/env.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
'GUNICORN_ACCESS_LOG_FILE': '"-"',
1616
'GUNICORN_ERROR_LOG_FILE': '"-"',
1717
'GUNICORN_OPTS': '[]',
18+
'NEW_RELIC_INI': '',
19+
'NEW_RELIC_STAGE': 'dev'
1820
}
1921

2022

docker_registry/wsgi.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4+
from .server import env
45
import logging
56

6-
from .run import app
7-
from .server import env
7+
newini = env.source('NEW_RELIC_INI')
8+
if newini:
9+
try:
10+
import newrelic.agent
11+
newrelic.agent.initialize(
12+
env.source('NEW_RELIC_INI'),
13+
env.source('NEW_RELIC_STAGE'))
14+
except Exception as e:
15+
raise(Exception('Failed to init new relic agent %s' % e))
816

17+
from .run import app
918

1019
if __name__ == '__main__':
1120
# Bind to PORT if defined, otherwise default to 5000.

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
install_requires=requirements,
8080
tests_require=open('./requirements/test.txt').read(),
8181
extras_require={
82-
'bugsnag': ['bugsnag>=2.0.1,<2.1']
82+
'bugsnag': ['bugsnag>=2.0,<2.1'],
83+
'newrelic': ['newrelic>=2.22,<2.23']
8384
}
8485
)

0 commit comments

Comments
 (0)