Skip to content

Commit c05907f

Browse files
committed
chore(converter): use message type as label for conversin duration metric
1 parent 8cadecf commit c05907f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

converter/converter/converter.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,22 @@ def raise_error(message, code: int = 400):
3232
return jsonify({"error": message}), code
3333

3434

35+
def extract_message_type_from_paylaod():
36+
data = request.get_json(silent=True) or {}
37+
edxl_json = data.get("edxl")
38+
message_content = extract_message_content(edxl_json)
39+
return extract_message_type_from_message_content(message_content)
40+
41+
3542
@app.route("/convert", methods=["POST"])
3643
@metrics.do_not_track()
3744
@metrics.histogram(
3845
"conversion_duration_seconds",
3946
"The number of seconds it took to the /convert endpoint to answer",
40-
labels={"status": lambda r: r.status_code},
47+
labels={
48+
"status": lambda r: r.status_code,
49+
"message_type": extract_message_type_from_paylaod,
50+
},
4151
)
4252
def convert():
4353
if not request.is_json:

0 commit comments

Comments
 (0)