import logging import os import sys import ujson as json import zlib from os import path import pymongo from flask import Flask, request, Response, jsonify import monitoring app = application = Flask("datadoghq") monitoring.monitor_flask(app) handler = logging.StreamHandler(sys.stderr) app.logger.addHandler(handler) app.logger.setLevel("INFO") record_dir = path.join(path.dirname(path.dirname(path.abspath(__file__))), "recorded") def get_collection(name: str): c = pymongo.MongoClient("192.168.254.241", 27017, connectTimeoutMS=5000) db = c.get_database("datadog") return db.get_collection(name) payload_names = [ "check_run", "series",
application.config["BACKUP_LOCK_KEY"] = EC.backup_lock_key SMART = SmartDatabaseClient # repositories repositories = RepositoriesRegister if __name__ == '__main__' or "gunicorn" in os.getenv("SERVER_SOFTWARE", ""): logging.basicConfig(level=EC.logging_level, stream=sys.stderr, format=EC.logging_formatter) fmt = logging.Formatter(EC.logging_formatter) handler = logging.StreamHandler(sys.stderr) handler.setFormatter(fmt) app.logger.addHandler(handler) app.logger.setLevel(EC.logging_level) monitoring.monitor_flask(application) SMART = SmartDatabaseClient(EC.db_uri) # repositories repositories = RepositoriesRegister(SMART) @application.route("/shutdown", methods=["POST"]) def shutdown(): """ Shutdown Shutdown the application --- tags: - ops responses: