Skip to content

PoC for bespoke tracing#2033

Draft
huitseeker wants to merge 3 commits into0xMiden:mirko/tracingfrom
huitseeker:tracing_loc
Draft

PoC for bespoke tracing#2033
huitseeker wants to merge 3 commits into0xMiden:mirko/tracingfrom
huitseeker:tracing_loc

Conversation

@huitseeker
Copy link
Copy Markdown
Contributor

@huitseeker huitseeker commented May 3, 2026

This keeps Miden's tracing policy, but uses more of the Rust tracing ecosystem for the common parts: tracing::instrument, tracing_error::ErrorLayer, tracing_panic::panic_hook, tracing_subscriber::reload, fmt::Layer, and strum.

Returned errors and panics are now span-level signals with useful context. Returned errors record the full error report on the span and avoid the duplicate exception event from native #[instrument(err)]. Panics become span attributes plus span error status.

Local stdout stays separate from OTel export. User-facing output is a tracing layer with explicit user span/event selection. Selected OTel-side user fields are bridged into miden.user.fields so fmt::Layer can print them.

Runtime filter reload now uses tracing_subscriber::reload. Target policy lives in miden-node-tracing-targets, so the macro and runtime filters share one allowlist. Control-plane events still bypass user filters, but third-party targets stay blocked.

Diff shape:

  • Non-test code, config, and docs: +1,320/-888, net +432
  • Tests: +760/-60, net +700
  • Total: +2,080/-948, net +1,132

New capabilities and their direct tests:

Capability Tests
Returned errors record one span-level full error report, without the duplicate exception event from native #[instrument(err)] span::tests::native_instrument_err_uses_top_level_error_and_emits_an_event, span::tests::instrument_macro_records_returned_errors, span::tests::instrument_macro_records_alias_returned_errors_with_err_marker
Panics record span attributes and span error status through tracing-panic control-plane events internal::tests::control_plane_layer_records_panic_fields_on_current_span, internal::tests::control_plane_layer_bridges_panic_status_to_tracing_error_field
Panics attach to the nearest exported parent when the current child span is disabled or filtered out internal::tests::control_plane_layer_selects_panic_span_from_event_scope, internal::tests::control_plane_layer_records_panic_on_active_parent_when_child_span_is_disabled, internal::tests::control_plane_layer_skips_scope_child_filtered_from_exporters
Raw panic/control-plane plumbing is hidden from normal output and OTel export internal::tests::control_plane_event_filter_rejects_tracing_panic_events, exporter::tests::plumbing_layers_do_not_enable_miden_callsites_when_exporters_are_off
Selected OTel-side user fields render in tracing-side formatted output exporter::stdout::tests::fmt_layer_does_not_render_open_telemetry_span_attributes, exporter::stdout::tests::user_facing_span_data_can_be_rendered_by_fmt_layer
User-facing stdout has explicit span/event selection separate from OTel export exporter::stdout::tests::layer_logs_user_spans_and_events, exporter::stdout::tests::layer_ignores_non_user_spans_and_events, exporter::stdout::tests::layer_does_not_inherit_user_event_marker_from_span
Runtime filter updates use tracing_subscriber::reload and keep filter readback filter::tests::dynamic_filter_tracks_current_value, filter::tests::dynamic_filter_set_enables_previously_disabled_callsites, filter::tests::tracing_subscriber_reload_enables_previously_disabled_callsites, exporter::tests::tracing_handle_exposes_filter_accessors
Shared target policy rejects third-party telemetry while allowing control-plane bypasses target::tests::formats_allowed_targets_as_list, target::tests::parses_allowed_target_path, target::tests::rejects_unknown_target_path, filter::tests::dynamic_filter_rejects_third_party_targets, filter::tests::control_plane_target_bypasses_dynamic_filter

Additional coverage:

Requirement Tests
Successful instrumented calls leave span status unset span::tests::instrument_macro_leaves_success_status_unset
OTel fields and objects can be injected into error tracing span::tests::span_records_fields_with_default_and_override_keys, span::tests::span_records_objects_with_default_and_override_prefixes, span::tests::span_records_user_fields_with_prefixed_keys
Active span selection ignores third-party current spans and handles re-entered spans internal::tests::active_span_selection_ignores_third_party_current_span, internal::tests::active_span_layer_keeps_outer_enter_active_when_same_span_is_reentered
Async and explicit span tracking keep active-span state correct internal::tests::active_span_future_tracks_span_only_during_poll, internal::tests::active_span_layer_tracks_public_entered_span, internal::tests::explicit_active_span_guard_does_not_pop_layer_tracked_span
Span filters still apply under the Miden target gate and control-plane wrapper filter::tests::application_target_gate_still_applies_inside_span_filters, filter::tests::control_plane_filter_wrapper_preserves_span_filters
Target taxonomy rejects component targets and string targets target::tests::rejects_component_target, target::tests::rejects_target_string

@huitseeker huitseeker added the no changelog This PR does not require an entry in the `CHANGELOG.md` file label May 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no changelog This PR does not require an entry in the `CHANGELOG.md` file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant