Add structured tracing and diagnostics surface for observability - #60
Merged
Merged
Conversation
Spaully
force-pushed
the
fix/issue-31-structured-tracing
branch
from
July 22, 2026 15:29
fbfeb34 to
16c8a7f
Compare
…servability Implement issue MillestoneX#31 with a feature-gated diagnostics system: - Adds diag feature flag (default off) to campaign/Cargo.toml - Adds CampaignMetrics struct and DataKey::DiagnosticMetrics variant - Adds metrics_view read-only entrypoint (always available) - Adds emit_diagnostics contract entrypoint (no-op when diag off) - Adds diagnostics_emit event function gated behind #[cfg(feature = diag)] - Tracks counters for donations, milestone releases, and refunds - Creates docs/observability.md with user-facing documentation - Adds diagnostics test coverage
All CampaignMetrics imports in files that only use it within to prevent unused-import errors when the feature is off (default): - campaign/src/event.rs: gate CampaignMetrics import - campaign/src/multi_asset_release.rs: gate CampaignMetrics import - campaign/src/release_milestone.rs: gate CampaignMetrics import - campaign/src/storage.rs: gate CampaignMetrics import The env parameter in emit_diagnostics and metrics_view is only consumed inside #[cfg(feature = "diag")] branches; add a #[cfg(not(feature = "diag"))] let _ = env binding to silence the unused-variable warning under the default (diag-off) compilation.
Spaully
force-pushed
the
fix/issue-31-structured-tracing
branch
from
July 22, 2026 16:23
21f0cb6 to
5aaa960
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Introduce a feature-gated diagnostics system for the campaign contract, enabling structured tracing and runtime counters.
Changes
diagfeature flag (default off) tocampaign/Cargo.tomlCampaignMetricsstruct andDataKey::DiagnosticMetricsstorage variantmetrics_viewread-only entrypoint (always available, returns zeros when diag off)emit_diagnosticscontract entrypoint (publishesdiagnosticsevent when diag on)diagnostics_emitevent function gated behind#[cfg(feature = diag)]docs/observability.mdwith user-facing documentation and JSON schemaCloses #31