Skip to content

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

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

Shriprasad-P wants to merge 2 commits 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

@greptile-apps

greptile-apps Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds opt-in tracing around periodic log uploads while preserving no-op behavior when tracing is disabled.

  • Keeps the upload inside the active span so its duration and nested instrumentation are captured.
  • Records upload size, changed-file count, elapsed time, return code, success, and exception type.
  • Extends the tracing context manager to expose the active span and adds coverage for enabled, disabled, failed, and exceptional uploads.

Confidence Score: 5/5

The PR appears safe to merge; the previously reported span-lifetime issue is fully fixed and no new actionable failures remain.

The upload now executes inside the traced context, completion attributes are attached before the span closes, disabled tracing remains a no-op, and upload exceptions remain non-fatal.

Important Files Changed

Filename Overview
metaflow/mflog/save_logs_periodically.py Wraps periodic uploads in an active trace and records outcome attributes without changing their non-fatal behavior.
metaflow/tracing/init.py Makes the disabled tracing context explicitly yield None for compatibility with span-aware callers.
metaflow/tracing/tracing_modules.py Exposes the active span from the tracing context manager so callers can add completion attributes.
test/unit/test_save_logs_periodically.py Covers disabled tracing, span lifetime, successful and failed return codes, and upload exceptions.

Reviews (3): Last reviewed commit: "Fix periodic log upload span lifetime" | Re-trigger Greptile

Comment thread metaflow/mflog/save_logs_periodically.py Outdated
@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
Shriprasad-P and others added 2 commits September 14, 2026 07:34
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
Keep the periodic upload attempt inside the traced context and expose the active span so upload outcome attributes are recorded before it closes. Preserve the sidecar's existing non-fatal upload exception handling.
@Shriprasad-P
Shriprasad-P force-pushed the cursor/add-opt-in-tracing-for-log-uploads-844c branch from 9aad30c to 6881d01 Compare September 14, 2026 02:45
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

2 participants