Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chenhao Ma
core
Commits
1e531ac5
Commit
1e531ac5
authored
9 years ago
by
Nathaniel Kofalt
Browse files
Options
Downloads
Plain Diff
Merge pull request #72 from scitran/newrelic
Allow for custom newrelic.ini path
parents
8989c5cd
845c5dc1
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/api.py
+1
-5
1 addition, 5 deletions
api/api.py
bin/api.wsgi
+16
-9
16 additions, 9 deletions
bin/api.wsgi
with
17 additions
and
14 deletions
api/api.py
+
1
−
5
View file @
1e531ac5
...
...
@@ -129,10 +129,6 @@ def dispatcher(router, request, response):
response
.
headers
[
'
Content-Type
'
]
=
'
application/json; charset=utf-8
'
try
:
import
newrelic.agent
app
=
newrelic
.
agent
.
WSGIApplicationWrapper
(
webapp2
.
WSGIApplication
(
routes
))
except
ImportError
:
app
=
webapp2
.
WSGIApplication
(
routes
)
app
=
webapp2
.
WSGIApplication
(
routes
)
app
.
router
.
set_dispatcher
(
dispatcher
)
This diff is collapsed.
Click to expand it.
bin/api.wsgi
+
16
−
9
View file @
1e531ac5
# vim: filetype=python
import
os
import
sys
import
toml
import
logging
import
argparse
...
...
@@ -19,6 +20,7 @@ ap.add_argument('--insecure', help='allow user info as urlencoded param', action
ap
.
add_argument
(
'
--central_uri
'
,
help
=
'
scitran central api
'
,
default
=
'
https://sdmc.scitran.io/api
'
)
ap
.
add_argument
(
'
--log_level
'
,
help
=
'
log level [info]
'
,
default
=
'
info
'
)
ap
.
add_argument
(
'
--drone_secret
'
,
help
=
'
shared drone secret
'
)
ap
.
add_argument
(
'
--new_relic
'
,
help
=
'
path to New Relic .ini file
'
)
ap
.
add_argument
(
'
--config
'
,
help
=
'
path to config file
'
)
...
...
@@ -73,15 +75,6 @@ from api import api
from
api
import
centralclient
,
jobs
from
api
import
jobs
try
:
import
newrelic.agent
newrelic
.
agent
.
initialize
(
'
../../newrelic.ini
'
)
log
.
info
(
'
New Relic detected and loaded. Monitoring enabled.
'
)
except
ImportError
:
log
.
info
(
'
New Relic not detected. Monitoring disabled.
'
)
except
newrelic
.
api
.
exceptions
.
ConfigurationError
:
log
.
warn
(
'
New Relic detected but configuration was not valid. Please ensure newrelic.ini is present. Monitoring disabled.
'
)
log
.
setLevel
(
getattr
(
logging
,
args
.
log_level
.
upper
()))
api
.
app
.
config
=
vars
(
args
)
...
...
@@ -102,6 +95,20 @@ if not os.path.exists(api.app.config['data_path']):
api
.
app
.
db
=
mongo
.
db
if
args
.
new_relic
is
not
None
:
try
:
import
newrelic.agent
,
newrelic
.
api
.
exceptions
newrelic
.
agent
.
initialize
(
args
.
new_relic
)
api
.
app
=
newrelic
.
agent
.
WSGIApplicationWrapper
(
api
.
app
)
log
.
info
(
'
New Relic detected and loaded. Monitoring enabled.
'
)
except
ImportError
:
log
.
critical
(
'
New Relic libraries not found.
'
)
sys
.
exit
(
1
)
except
newrelic
.
api
.
exceptions
.
ConfigurationError
:
log
.
critical
(
'
New Relic detected, but configuration invalid.
'
)
sys
.
exit
(
1
)
if
__name__
==
'
__main__
'
:
api
.
app
.
debug
=
True
# send stack trace for uncaught exceptions to client
paste
.
httpserver
.
serve
(
api
.
app
,
host
=
args
.
host
,
port
=
args
.
port
,
ssl_pem
=
args
.
ssl_cert
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment