Skip to content

feat: opt-in tracing for periodic log uploads - #3373

Open
Shriprasad-P wants to merge 1 commit into
Netflix:masterfrom
Shriprasad-P:cursor/add-opt-in-tracing-for-log-uploads-844c
Open

feat: opt-in tracing for periodic log uploads#3373
Shriprasad-P wants to merge 1 commit into
Netflix:masterfrom
Shriprasad-P:cursor/add-opt-in-tracing-for-log-uploads-844c

Conversation

@Shriprasad-P

Copy link
Copy Markdown

Fixes

Fixes #3307

Summary

Wraps periodic log upload work in Metaflow's existing traced() helper so uploads emit spans only when tracing is already enabled. Default behavior stays a no-op.

Test plan

  • Unit tests for disabled tracing (no-op) and enabled attribute capture
  • Existing save_logs_periodically tests still pass

This commit adds optional tracing instrumentation to the SaveLogsPeriodicallySidecar
to help diagnose issues where logs stop updating while the sidecar is still running.

Changes:
- Import traced context manager from metaflow.tracing
- Wrap periodic upload invocations in traced() spans
- Capture key observability attributes: elapsed_seconds, total_bytes, files_changed,
  returncode, success status, and exception type (if any)
- Add unit tests verifying tracing is opt-in and doesn't interfere with normal operation

The tracing is completely opt-in via existing Metaflow tracing configuration
(OTEL_ENDPOINT, ZIPKIN_ENDPOINT, or CONSOLE_TRACE_ENABLED). When tracing is
disabled (the default), the traced() context manager is a no-op.

Fixes Netflix#3307
@greptile-apps

greptile-apps Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds opt-in tracing and upload-result attributes to periodic log uploads, with tests covering disabled and enabled tracing. However, the upload still completes before the empty traced context begins, so the previous finding remains unresolved.

  • Records elapsed time, byte count, changed-file count, return code, success, and exception type.
  • Adds unit coverage for tracing-disabled behavior and captured attributes.
  • Makes no changes since the previous review.

Confidence Score: 4/5

The PR is not yet safe to merge because the upload remains outside the traced context, leaving the existing blocking tracing defect unresolved.

The previous finding remains outstanding: _call_save_logs() completes before traced(...) is entered, and the context body is empty, so the span cannot measure the upload, provide active trace context to nested instrumentation, or directly record upload failures.

Files Needing Attention: metaflow/mflog/save_logs_periodically.py

Important Files Changed

Filename Overview
metaflow/mflog/save_logs_periodically.py Adds upload tracing attributes, but the traced context still does not enclose the upload operation.
test/unit/test_save_logs_periodically.py Adds tracing tests, though they verify invocation and attributes rather than that the upload executes inside the span.

Reviews (2): Last reviewed commit: "Add opt-in tracing for periodic log uplo..." | Re-trigger Greptile

Comment on lines +135 to +136
with traced("save_logs_periodically.upload", attrs=attrs):
pass

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Span Excludes Upload

When tracing is enabled, _call_save_logs() finishes before this context manager is entered, and the context body is empty. The resulting span has near-zero duration and cannot provide active trace context for the upload or capture its nested instrumentation and failures. Move the upload into the traced context and attach its outcome attributes to the active span.

Knowledge Base Used: Task logging and sidecars

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@Shriprasad-P
Shriprasad-P force-pushed the cursor/add-opt-in-tracing-for-log-uploads-844c branch from 895e11a to 9aad30c Compare September 12, 2026 19:28
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.

Add opt-in tracing for periodic log uploads

1 participant