Skip to content

Add structured logs and Prometheus metrics for blobstore and packer operations - #5575

Open
WeiQuan0605 wants to merge 2 commits into
mainfrom
observability-blobstore-packing-logs
Open

WeiQuan0605 wants to merge 2 commits into
mainfrom
observability-blobstore-packing-logs

Conversation

@WeiQuan0605

Copy link
Copy Markdown
Contributor
  • A short explanation of the proposed change:
    Add structured log entries and Prometheus metrics to blobstore and packer operations. cp_to_blobstore now emits cp-start, cp-finish, cp-skip, and cp-error log events with destination key, duration, and blob size. cp_r_to_blobstore emits per-phase timing logs (blobstore.cp_r.digest, .exists, .upload). Three new Prometheus metrics track storage-cli subprocess invocations: cc_storage_cli_operations_total, cc_storage_cli_duration_seconds, and cc_storage_cli_blob_size_bytes.

  • An explanation of the use cases your change solves
    Blobstore upload failures are currently silent: operators cannot tell from logs whether a droplet/package upload was attempted, skipped, or how long it took. This change makes every upload observable: structured logs allow filtering by destination key or bucket in Kibana, and Prometheus metrics enable alerting on non-zero exit codes and latency spikes across operations (put, get, exists, delete, etc.).

  • I have reviewed the contributing guide

  • I have viewed, signed, and submitted the Contributor License Agreement

  • I have made this pull request to the main branch

  • I have run all the unit tests using bundle exec rake

  • I have run CF Acceptance Tests

…invocation

Log one structured entry per storage-cli subprocess call on
cc.blobstore.storage_cli_client with operation, bucket, resource_type,
operation-specific fields (key/source_path/destination_key etc.),
duration_seconds, exit_code, and success. Linked to vcap-request-id
so all storage-cli calls for a CF API request are traceable in Kibana,
comparable to CCDB statement logs.

@stephanme stephanme left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are number of unrelated files touched in this PR.

exit_code = resolve_exit_code(status)
success = status.success? || (allow_exit_code_three && status.exitstatus == 3)

logger.info('storage_cli.call.finish',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to have the operation and maybe the important args directly on the log msg. The complete storage-cli cmd line is logged on debug level only and this is ok (don't need every detail on info).

E.g.:
storage_cli.call.finish put local-file.txt remote-object.txt
storage_cli.call.finish exists remote-object.txt


def capture_cli(command, args, start_time)
Open3.capture3(@cli_path, '-s', @storage_type, '-c', @config_file, *additional_flags, command, *args)
rescue StandardError => e

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it ensured that an exceptionally failing storage-cli call gets logged? Maybe it is logged by an exception handler of the caller.

Maybe its safer to log additionally in the rescue.

DELAYED_JOBS_TABLE = /(?:[`"]?\w+[`"]?\.)?[`"]?delayed_jobs[`"]?/i
HANDLER_COLUMN = /[`"]?handler[`"]?/i
DELAYED_JOBS_TABLE = /(?:[`"]?\w+[`"]?\.)?[`"]?delayed_jobs[`"]?(?=\W|$)/i
HANDLER_COLUMN = /\b[`"]?handler[`"]?/i

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is delayed_jobs_log_redaction.rb changed in this PR?

This branch has not been deployed

No deployments
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.

2 participants