Skip to content

Commit

Permalink
Merge pull request #7 from infinite-options/ss_1209
Browse files Browse the repository at this point in the history
fixed registry in prometheus
  • Loading branch information
saumya4751 authored Dec 16, 2024
2 parents 74cebd2 + f1aaec9 commit 64494f2
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions caption_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,24 +155,27 @@
# ['endpoint', 'status_code', 'client_ip']
# )

logging.getLogger('werkzeug').setLevel(logging.ERROR)
app_env = os.getenv("app_env")
print(app_env)

logging.basicConfig(level=logging.INFO, format='%(asctime)s %(levelname)s %(message)s')
logger = logging.getLogger(__name__)
if app_env == "production":
logging.getLogger('werkzeug').setLevel(logging.ERROR)
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(levelname)s %(message)s')
logger = logging.getLogger(__name__)

registry = CollectorRegistry()

REQUEST_COUNTER = Counter(
'capshnz_http_requests_total',
'Total HTTP requests by method, endpoint, status code, and client IP',
['method', 'endpoint', 'status_code', 'client_ip', 'user_agent', 'request_size', 'response_size']
# registry=registry
['method', 'endpoint', 'status_code', 'client_ip', 'user_agent', 'request_size', 'response_size'],
registry=registry
)
LATENCY_SUMMARY = Summary(
'capshnz_http_request_latency_seconds',
'Request latency by endpoint',
['endpoint', 'method']
# registry=registry
['endpoint', 'method'],
registry=registry
)


Expand Down Expand Up @@ -2632,7 +2635,7 @@ def handle_exception(e):

class Metrics(Resource):
def get(self):
return Response(generate_latest(), mimetype=CONTENT_TYPE_LATEST)
return Response(generate_latest(registry), mimetype=CONTENT_TYPE_LATEST)

# -- DEFINE APIS -------------------------------------------------------------------------------

Expand Down

0 comments on commit 64494f2

Please sign in to comment.