diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index e3055bc..3caa24b 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -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: diff --git a/platform_in/app/__init__.py b/platform_in/app/__init__.py index 8c7d1ea..dd702e8 100644 --- a/platform_in/app/__init__.py +++ b/platform_in/app/__init__.py @@ -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"} @@ -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/", methods=["POST"]) - def putdata(id): + def post_measurement_data(id): try: # data = request.get_data() @@ -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(), ) diff --git a/platform_in/requirements.txt b/platform_in/requirements.txt index 9c5a5a6..6c9b9bb 100644 --- a/platform_in/requirements.txt +++ b/platform_in/requirements.txt @@ -11,8 +11,6 @@ Jinja2 pytest requests certifi -pyrsistent==0.16.1;python_version<"3.0" -pyrsistent;python_version>"3.0" -jsonschema -protobuf -pydantic \ No newline at end of file +pyrsistent +pydantic +sentry-sdk[flask] \ No newline at end of file