Skip to content

Commit

Permalink
incorporate sentry + add topic name
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheena Puthanpurayil committed Sep 6, 2021
1 parent 497e2d7 commit 37b706c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
context: ./platform_in/
dockerfile: Dockerfile.prod
command: gunicorn --bind 0.0.0.0:5002 manage:app
restart: always
#restart: always
#volumes:
# - ./platform_in/:/project/
expose:
Expand Down
32 changes: 22 additions & 10 deletions platform_in/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@
import json
import certifi
from kafka import KafkaProducer
import sentry_sdk

from sentry_sdk.integrations.flask import FlaskIntegration

if os.getenv("SENTRY_DSN"):
sentry_sdk.init(
dsn=os.getenv("SENTRY_DSN"),
integrations=[FlaskIntegration()]
)

from os import path


success_response_object = {"status": "success"}
Expand Down Expand Up @@ -50,8 +57,13 @@ def ctx():
def hello_world():
return jsonify(health="ok")

@app.route('/debug-sentry')
def trigger_error():
division_by_zero = 1 / 0


@app.route("/c2/v1/<id>", methods=["POST"])
def putdata(id):
def post_measurement_data(id):

try:
# data = request.get_data()
Expand All @@ -66,16 +78,16 @@ def putdata(id):
received_data = json.loads(data)


if "data" in received_data.keys():
#received measurement type data
key = received_data["n"]
elif "ref" in received_data.keys():
#received alarm or event type data
key = received_data["n"]
# if "data" in received_data.keys():
# #received measurement type data
# key = received_data["n"]
# elif "ref" in received_data.keys():
# #received alarm or event type data
# key = received_data["n"]

producer.send(
topic="test.sputhan",
key="",
topic="finest.json.c2light",
key=id,
value=request.get_json(),
)

Expand Down
8 changes: 3 additions & 5 deletions platform_in/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ Jinja2
pytest
requests
certifi
pyrsistent==0.16.1;python_version<"3.0"
pyrsistent;python_version>"3.0"
jsonschema
protobuf
pydantic
pyrsistent
pydantic
sentry-sdk[flask]

0 comments on commit 37b706c

Please sign in to comment.