Skip to content

docs(mofa-monitoring): Add English doc comments and usage examples#1271

Open
magic-peach wants to merge 2 commits intomofa-org:mainfrom
magic-peach:fix/mofa-monitoring-docs
Open

docs(mofa-monitoring): Add English doc comments and usage examples#1271
magic-peach wants to merge 2 commits intomofa-org:mainfrom
magic-peach:fix/mofa-monitoring-docs

Conversation

@magic-peach
Copy link
Copy Markdown
Contributor

@magic-peach magic-peach commented Mar 15, 2026

Summary

Addresses #1319. The mofa-monitoring tracing module had many public types with only brief bilingual inline comments and no Rust /// doc-comments with examples or usage guidance. This PR adds the missing documentation.

Changes

src/tracing/tracer.rs

  • SamplingStrategy: full when-to-use table and code example for each variant
  • TracerConfig: # Examples block showing the builder pattern
  • SimpleSpanProcessor: document the latency trade-off vs BatchSpanProcessor
  • BatchSpanProcessor: document buffering behaviour, config knobs, and the importance of force_flush before shutdown
  • TracerProvider: full usage example (exporter → processor → provider → tracer)
  • GlobalTracer: document the process-wide singleton pattern

src/tracing/instrumentation.rs

  • AgentTracer: add usage example with start_operation/end_span
  • TracedAgent: explain the wrapper pattern and when to use it
  • trace_agent_operation: add complete example with closure

src/tracing/exporter.rs

  • OtlpConfig: document all fields; add OTEL_EXPORTER_OTLP_* environment variable reference table
  • OtlpExporter: list compatible backends; note that Jaeger ≥ 1.35 OTLP port (4317/4318) should be used instead of the deprecated Thrift UDP agent

src/tracing/span.rs

  • SpanKind: replace terse bilingual comments with a semantic table explaining how tracing backends use each variant for service dependency maps

Test plan

  • cargo doc -p mofa-monitoring --no-deps — no warnings
  • No functional code changes; docs only

Part of the GSoC work tracked in #1318.

🤖 Generated with Claude Code

- Expand SamplingStrategy variants with usage guidance and when-to-use table
- Add # Example block to TracerConfig showing builder pattern
- Add Quick Start section to README with working code example
- Document OTLP environment variables in a reference table
@magic-peach magic-peach marked this pull request as ready for review March 15, 2026 19:10
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a76a26d74d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…ion, exporters

Building on mofa-org#1319 follow-up to a76a26d:

tracer.rs
- SimpleSpanProcessor: document latency trade-off vs BatchSpanProcessor
- BatchSpanProcessor: document buffering behaviour and config knobs
- TracerProvider: add full usage example (exporter → processor → provider)
- GlobalTracer: document singleton pattern

instrumentation.rs
- AgentTracer: add usage example with start_operation/end_span
- TracedAgent: explain the wrapper pattern
- trace_agent_operation: add full example with closure

exporter.rs
- OtlpConfig: document all fields; add OTEL_EXPORTER_OTLP_* env-var reference
- OtlpExporter: list compatible backends; note Jaeger OTLP vs legacy Thrift

span.rs
- SpanKind: replace terse bilingual comments with a semantic table
  explaining how backends use each variant for service maps

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@magic-peach
Copy link
Copy Markdown
Contributor Author

@lijingrs @BH3GEI please review my pr

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