Skip to content

feat: Add performance observability with tags/metrics separation#52

Open
sumedhsakdeo wants to merge 3 commits intolinkedin:li-0.11from
sumedhsakdeo:ssakdeo/perf-observability
Open

feat: Add performance observability with tags/metrics separation#52
sumedhsakdeo wants to merge 3 commits intolinkedin:li-0.11from
sumedhsakdeo:ssakdeo/perf-observability

Conversation

@sumedhsakdeo
Copy link
Copy Markdown
Collaborator

@sumedhsakdeo sumedhsakdeo commented Apr 12, 2026

Summary

  • Add a pluggable PerfObserver pattern for performance instrumentation of pyiceberg internals
  • New pyiceberg/observability.py module with PerfEvent, PerfObserver protocol, NullPerfObserver, LoggingPerfObserver, CompositeObserver, perf_timer context manager, and @timed decorator
  • PerfEvent separates tags (low-cardinality dimensions) from metrics (measured values) for Prometheus/OTEL/Kafka compatibility
  • Zero overhead when NullPerfObserver is active (skips time.monotonic() entirely)
  • Thread-safe global observer with threading.Lock
  • CompositeObserver isolates exceptions so one failing observer doesn't block others
  • @timed decorator injects _perf_ctx kwarg for runtime attribute setting
  • Instruments: arrow.read_file, arrow.to_record_batches, arrow.read_delete_files, scan.open_manifest, scan.plan_files, scan.plan_files_local, manifest.fetch_entries, manifest.read_list

Test plan

  • 28 unit tests pass (pytest tests/test_observability.py)
  • Tests cover PerfEvent, all observer types, perf_timer with tags/metrics, @timed decorator, CompositeObserver exception isolation, NullPerfObserver fast path
  • mypy, ruff, pydocstyle all pass

🤖 Generated with Claude Code

@sumedhsakdeo sumedhsakdeo changed the title fix: Resolve lint errors in observability module feat: Add performance observability with tags/metrics separation Apr 12, 2026
sumedhsakdeo and others added 3 commits April 12, 2026 10:56
Add a pluggable PerfObserver pattern to instrument ArrowScan, manifest
reading, delete file resolution, and scan planning with duration tracking
and typed attributes split into tags (dimensions) and metrics (values)
for compatibility with Prometheus/OTEL/Kafka backends.

Includes CompositeObserver with exception isolation, thread-safe global
observer, zero-overhead NullPerfObserver fast path, and @timed decorator
with _perf_ctx injection.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix mypy incompatible-types in LoggingPerfObserver by renaming loop
  variable to avoid str/int|float conflict
- Fix test fixture return type to Iterator[None] for generator fixture
- Remove unused type: ignore comment on yield
- Restructure test_emits_on_exception to avoid mypy unreachable-statement
  with pytest.raises
- Fix pydocstyle D401: use imperative mood in timed() docstring

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move pyiceberg.observability import after pyiceberg.manifest to satisfy
ruff import ordering (I001).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sumedhsakdeo sumedhsakdeo force-pushed the ssakdeo/perf-observability branch from 98b2c56 to 269a0c2 Compare April 12, 2026 17:57
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.

1 participant