Skip to content

Commit

Permalink
Add probe update metadata logging
Browse files Browse the repository at this point in the history
  • Loading branch information
LDiazN committed Feb 19, 2025
1 parent f864660 commit 4857fe3
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class Metrics:
labelnames=["state", "detail", "login"]
)

PROBE_UPDATE_INFO = Info(
"probe_update_info", "Information reported in the probe update endpoint",
)

class ProbeLogin(BaseModel):
# Allow None username and password
# to deliver informational 401 error when they're missing
Expand Down Expand Up @@ -173,4 +177,17 @@ class ProbeUpdateResponse(BaseModel):
@router.put("/update/{client_id}", tags=["ooniprobe"])
def probe_update_post(probe_update: ProbeUpdate) -> ProbeUpdateResponse:
log.info("update successful")

# Log update metadata into prometheus
probe_update_dict = probe_update.model_dump(exclude_none=True)

# Info doesn't allows list, if we have a list we have to convert it
# to string
if probe_update_dict['supported_tests'] is not None:
tests = probe_update_dict['supported_tests']
tests_str = ";".join(tests)
probe_update_dict['supported_tests'] = tests_str

Metrics.PROBE_UPDATE_INFO.info(probe_update_dict)

return ProbeUpdateResponse(status="ok")

0 comments on commit 4857fe3

Please sign in to comment.