Skip to content

Commit

Permalink
Merge pull request #12 from lsst-dm/tickets/DM-43646
Browse files Browse the repository at this point in the history
DM-43646: Add nextVisit info to fan-out status logs
  • Loading branch information
hsinfang authored May 28, 2024
2 parents 5039b5a + 55f7ad8 commit 593f8df
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ async def knative_request(
knative_serving_url: str,
headers: dict[str, str],
body: bytes,
next_visit_group_id,
info: str,
) -> None:
"""Makes knative http request.
Expand All @@ -116,6 +116,9 @@ async def knative_request(
The headers to pass to knative.
body: `bytes`
The next visit message body.
info: `str`
Information such as some fields of the next visit message to identify
this request and to log with.
"""
in_process_requests_gauge.inc()

Expand All @@ -127,13 +130,13 @@ async def knative_request(
)

logging.info(
f"group id {next_visit_group_id} status code {result.status_code} for initial request {result.content}"
f"nextVisit {info} status code {result.status_code} for initial request {result.content}"
)

'''
if result.status_code == 502 or result.status_code == 503:
logging.info(
f"retry after status code {result.status_code} for group id {next_visit_group_id}"
f"retry after status code {result.status_code} for nextVisit {info}"
)
retry_result = await client.post(
knative_serving_url,
Expand All @@ -142,7 +145,7 @@ async def knative_request(
timeout=None,
)
logging.info(
f"group id {next_visit_group_id} retried request {retry_result.content}"
f"nextVisit {info} retried request {retry_result.content}"
)
'''

Expand Down Expand Up @@ -407,6 +410,9 @@ async def main() -> None:
logging.info(f"data after json dump {data_json}")
event = CloudEvent(attributes, data_json)
headers, body = to_structured(event)
info = {
key: data[key] for key in ["instrument", "groupId", "detector"]
}

task = asyncio.create_task(
knative_request(
Expand All @@ -415,7 +421,7 @@ async def main() -> None:
knative_serving_url,
headers,
body,
next_visit_message_updated.groupId,
str(info),
)
)
tasks.add(task)
Expand Down

0 comments on commit 593f8df

Please sign in to comment.