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

newrelic config #88

Merged
merged 9 commits into from
Apr 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM cuenca/python:latest
FROM cuenca/python:0.0.1
LABEL maintainer="[email protected]"

# Install app
Expand All @@ -10,4 +10,4 @@ RUN make install
ADD . /arcusd/
RUN pip install -e .

CMD celery worker -A arcusd.daemon.tasks --loglevel=info -c ${ARCUSD_WORKERS:-0}
CMD newrelic-admin run-program celery worker -A arcusd.daemon.tasks --loglevel=info -c ${ARCUSD_WORKERS:-5}
6 changes: 4 additions & 2 deletions arcusd/daemon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
import sentry_sdk
from sentry_sdk.integrations.celery import CeleryIntegration

sentry_sdk.init(os.environ['ARCUSD_SENTRY_DSN'],
integrations=[CeleryIntegration()])

if os.environ.get('ARCUSD_PROD', 'true') == 'true':
sentry_sdk.init(os.environ['ARCUSD_SENTRY_DSN'],
integrations=[CeleryIntegration()])
7 changes: 7 additions & 0 deletions arcusd/daemon/tasks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from typing import Optional

import newrelic.agent

import arcusd.arcusactions
from arcusd.data_access.providers_mapping import get_biller_id
from .celery_app import app
Expand All @@ -8,6 +10,7 @@


@app.task
@newrelic.agent.background_task()
def topup(request_id: str, service_provider_code: str, phone_number: str,
amount: int, currency: str = 'MXN',
name_on_account: Optional[str] = None):
Expand All @@ -18,19 +21,22 @@ def topup(request_id: str, service_provider_code: str, phone_number: str,


@app.task
@newrelic.agent.background_task()
def query_bill(request_id: str, service_provider_code: str,
account_number: str):
execute_op(request_id, OperationType.query, arcusd.arcusactions.query_bill,
get_biller_id(service_provider_code), account_number)


@app.task
@newrelic.agent.background_task()
def pay_bill_id(request_id: str, bill_id: int):
execute_op(request_id, OperationType.payment,
arcusd.arcusactions.pay_bill_id, bill_id)


@app.task
@newrelic.agent.background_task()
def pay_bill(request_id: str, service_provider_code: str, account_number: str,
amount: Optional[int] = None):
execute_op(request_id, OperationType.payment, arcusd.arcusactions.pay_bill,
Expand All @@ -39,6 +45,7 @@ def pay_bill(request_id: str, service_provider_code: str, account_number: str,


@app.task
@newrelic.agent.background_task()
def cancel_transaction(request_id: str, transaction_id: int):
execute_op(request_id, OperationType.payment,
arcusd.arcusactions.cancel_transaction, transaction_id)
3 changes: 3 additions & 0 deletions arcusd/daemon/tasks_sync.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import newrelic.agent

import arcusd
from arcusd.data_access.providers_mapping import get_biller_id
from .celery_app import app
Expand All @@ -6,6 +8,7 @@


@app.task
@newrelic.agent.background_task()
def query_bill(service_provider_code: str, account_number: str) -> dict:
op_info = execute_op(None, OperationType.query,
arcusd.arcusactions.query_bill,
Expand Down
3 changes: 3 additions & 0 deletions env.template
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ ARCUSD_CALLBACK_SECRET=JKLMNOPQRS
ARCUSD_SENTRY_DSN=https://[email protected]/1
ARCUSD_WORKERS=0
TOPUP_BILLERS=20,30,40
NEW_RELIC_LICENSE_KEY=foo
MULTIDICT_NO_EXTENSIONS=1
ARCUSD_PROD=false
10 changes: 5 additions & 5 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
coveralls
pycodestyle
pytest
pytest-vcr==1.0.1
ipython
coveralls==2.0.0
pycodestyle==2.5.0
pytest==5.2.0
pytest-vcr==1.0.2
ipython==7.8.0
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
arcus==1.2.0
celery>=4.2,<4.3
pymongo==3.7.2
sentry-sdk==0.10.2
sentry-sdk==0.14.3
requests==2.21.0
click==7.0
dataclasses
newrelic>=5.4.1.134,<5.5.0.0