Skip to content

Add structured tracing and diagnostics surface for observability - #60

Merged
P3az3 merged 2 commits into
MillestoneX:mainfrom
Spaully:fix/issue-31-structured-tracing
Jul 22, 2026
Merged

Add structured tracing and diagnostics surface for observability#60
P3az3 merged 2 commits into
MillestoneX:mainfrom
Spaully:fix/issue-31-structured-tracing

Conversation

@Spaully

@Spaully Spaully commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Introduce a feature-gated diagnostics system for the campaign contract, enabling structured tracing and runtime counters.

Changes

  • Adds diag feature flag (default off) to campaign/Cargo.toml
  • Adds CampaignMetrics struct and DataKey::DiagnosticMetrics storage variant
  • Adds metrics_view read-only entrypoint (always available, returns zeros when diag off)
  • Adds emit_diagnostics contract entrypoint (publishes diagnostics event when diag on)
  • 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 and JSON schema
  • Adds diagnostics test coverage

Closes #31

@Spaully
Spaully force-pushed the fix/issue-31-structured-tracing branch from fbfeb34 to 16c8a7f Compare July 22, 2026 15:29
Spaully and others added 2 commits July 22, 2026 16:22
…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
Spaully force-pushed the fix/issue-31-structured-tracing branch from 21f0cb6 to 5aaa960 Compare July 22, 2026 16:23

@P3az3 P3az3 left a comment

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.

LGTM

@P3az3
P3az3 merged commit 8541a72 into MillestoneX:main Jul 22, 2026
4 checks passed
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.

Introduce structured tracing / metrics surface for observability

2 participants