Skip to content

Add event logging#1092

Merged
wfchandler merged 2 commits intomainfrom
wc/logging-exec-hook
May 8, 2025
Merged

Add event logging#1092
wfchandler merged 2 commits intomainfrom
wc/logging-exec-hook

Conversation

@wfchandler
Copy link
Copy Markdown
Collaborator

when debug logging is enabled. Adding debug logging for all requests will enable users to troubleshoot issues on any API endpoint.

To do this, we use the newly added exec hook feature in Progenitor to capture the details of the API call.

In addition to the log event, we also create a Span. This is ignored by the CLI, but may be useful for other consumers of the SDK that want to integrate it with their monitoring infrastructure.

An example event:

{
"timestamp": "2025-05-07T19:51:02.464942Z",
"level": "DEBUG",
"message": "request succeeded",
"url": "https://oxide.sys.r3.oxide-preview.com/v1/instances?project=will",
"path": "/v1/instances",
"operation_id": "instance_list",
"remote_addr": "45.154.216.35:443",
"http.request.method": "GET",
"http.response.content_length": 2377,
"http.response.status_code": 200,
"start_time": "2025-05-07T19:51:02.079228Z",
"duration_ms": 385,
"oxide.request_id": "1ff7d872-3a14-4604-8392-1e9d6e2ba8fd",
"target": "oxide"
}

Closes #1014

when debug logging is enabled. Adding debug logging for all requests
will enable users to troubleshoot issues on any API endpoint.

To do this, we use the newly added exec hook feature in Progenitor to
capture the details of the API call.

In addition to the log event, we also create a `Span`. This is ignored
by the CLI, but may be useful for other consumers of the SDK that want
to integrate it with their monitoring infrastructure.

An example event:

  {
    "timestamp": "2025-05-07T19:51:02.464942Z",
    "level": "DEBUG",
    "message": "request succeeded",
    "url": "https://oxide.sys.r3.oxide-preview.com/v1/instances?project=will",
    "path": "/v1/instances",
    "operation_id": "instance_list",
    "remote_addr": "45.154.216.35:443",
    "http.request.method": "GET",
    "http.response.content_length": 2377,
    "http.response.status_code": 200,
    "start_time": "2025-05-07T19:51:02.079228Z",
    "duration_ms": 385,
    "oxide.request_id": "1ff7d872-3a14-4604-8392-1e9d6e2ba8fd",
    "target": "oxide"
  }

Closes #1014
@wfchandler
Copy link
Copy Markdown
Collaborator Author

Sanity check

% ./target/debug/oxide --debug disk list --project=will  2> >(jq .) >/dev/null
{
  "timestamp": "2025-05-07T20:03:21.792135Z",
  "level": "DEBUG",
  "message": "request succeeded",
  "url": "https://oxide.sys.r3.oxide-preview.com/v1/disks?project=will",
  "path": "/v1/disks",
  "operation_id": "disk_list",
  "remote_addr": "45.154.216.37:443",
  "http.request.method": "GET",
  "http.response.content_length": 5236,
  "http.response.status_code": 200,
  "start_time": "2025-05-07T20:03:21.298320Z",
  "duration_ms": 493,
  "oxide.request_id": "630f8c0c-bd5c-4e5e-9ed2-2c0eac574329",
  "target": "oxide"
}
{
  "timestamp": "2025-05-07T20:03:21.937408Z",
  "level": "DEBUG",
  "message": "request succeeded",
  "url": "https://oxide.sys.r3.oxide-preview.com/v1/disks?page_token=eyJ2IjoidjEiLCJwYWdlX3N0YXJ0Ijp7InNvcnRfYnkiOiJuYW1lX2FzY2VuZGluZyIsInByb2plY3QiOiJ3aWxsIiwibGFzdF9zZWVuIjoid2luZG93cy13aW5kb3dzLXNlcnZlci0yMDIyLTFjMWMxNiJ9fQ%3D%3D",
  "path": "/v1/disks",
  "operation_id": "disk_list",
  "remote_addr": "45.154.216.37:443",
  "http.request.method": "GET",
  "http.response.content_length": 29,
  "http.response.status_code": 200,
  "start_time": "2025-05-07T20:03:21.796870Z",
  "duration_ms": 140,
  "oxide.request_id": "1921f018-c6dc-44fc-91d5-843bcb6e3e8d",
  "target": "oxide"
}

Comment thread sdk/src/lib.rs
@wfchandler wfchandler merged commit 119a714 into main May 8, 2025
16 checks passed
@wfchandler wfchandler deleted the wc/logging-exec-hook branch May 8, 2025 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

debug could make the CLI more chatty about API requests

2 participants