Skip to content

Implement OTLP protobuf encoder#63

Merged
brickfrog merged 1 commit into
mainfrom
main.cg9-7-4-otlp-protobuf-1780328971932-22209-0
Jun 1, 2026
Merged

Implement OTLP protobuf encoder#63
brickfrog merged 1 commit into
mainfrom
main.cg9-7-4-otlp-protobuf-1780328971932-22209-0

Conversation

@brickfrog

Copy link
Copy Markdown
Owner

Summary

  • spike-gated moonbitlang/protobuf viability and resolved latest moonbitlang/protobuf@0.1.1
  • implement ProtobufEncoder for OTLP traces/logs using official protobuf Writer primitives and hand-rolled OTLP field mappings
  • add structural protobuf decode tests plus a Python-protobuf-derived golden trace request fixture
  • update docs/otlp-protobuf-design.md with the implemented approach and runtime version

TDD

  • intent: Encode OTLP ExportTraceServiceRequest/ExportLogsServiceRequest to protobuf bytes behind the ProtobufEncoder seam, with bytes ids, fixed64 timestamps, fixed32 flags, and round-trip/golden verification
  • red: temporarily stubbed ProtobufEncoder.encode_spans to return an empty protobuf body; moon test --target native failed with the protobuf encoder tests
  • green/done: restored implementation; moon test --target native passed (279 tests)

Wire-format audit note

  • moonbitlang/protobuf resolved to 0.1.1, the latest version available in the local mooncakes registry index
  • wire-format correctness is verified by structural round-trip decode tests and a GOLDEN byte fixture for a representative ExportTraceServiceRequest produced by a Python google.protobuf 7.34.1 dynamic descriptor for the same OTLP subset

Verification

  • moon fmt --check
  • moon test --target native
  • moon build --target native --release
  • moon check --target all src/otlp/transport
  • moon info; moon fmt left no extra changes

No dependency on ryota0624/opentelemetry_proto_mbt or protoc-gen-mbt.

Verification

Generated by Choir from commands executed in the leaf workspace.

  • moon fmt --check
    • exit: 0
    • head: 7786caa
    • output tail:
Finished. moon: no work to do
  • moon test --target native
    • exit: 0
    • head: 7786caa
    • output tail:
Total tests: 279, passed: 279, failed: 0.
  • moon build --target native --release
    • exit: 0
    • head: 7786caa
    • output tail:
Finished. moon: no work to do

@brickfrog

Copy link
Copy Markdown
Owner Author

Choir: GitHub Actions rollup reports all checks successful on the latest head — re-check review/merge policy on GitHub (not an approval or merge signal by itself).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds OTLP protobuf encoding support to the src/otlp/transport layer by implementing a ProtobufEncoder that emits ExportTraceServiceRequest / ExportLogsServiceRequest protobuf bytes using moonbitlang/protobuf, along with round-trip structural decoder tests and a golden-byte fixture to validate wire-format correctness.

Changes:

  • Add moonbitlang/protobuf@0.1.1 as a dependency and import it in the OTLP transport package.
  • Implement OTLP trace/log protobuf encoding (field mappings + primitive writer helpers) and introduce EncodingError::ProtobufEncodeFailed for structured failures.
  • Add extensive protobuf decode-based tests plus a golden bytes assertion for a representative trace request; update protobuf design documentation accordingly.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/otlp/transport/encoding.mbt Implements OTLP protobuf writer helpers, trace/log request encoders, and a new structured encoding error.
src/otlp/transport/encoding_test.mbt Adds structural protobuf decoders + assertions for traces/logs, a golden bytes test, and error-path validation.
src/otlp/transport/moon.pkg Imports moonbitlang/protobuf so transport code/tests can use protobuf writer/reader APIs.
moon.mod Adds moonbitlang/protobuf@0.1.1 dependency.
src/otlp/transport/pkg.generated.mbti Updates the public interface to include the new ProtobufEncodeFailed error variant.
docs/otlp-protobuf-design.md Updates the design doc to reflect the implemented hand-rolled OTLP subset approach and runtime version.

@brickfrog

Copy link
Copy Markdown
Owner Author

Choir: GitHub Copilot issue-thread comment observed on PR — parent notified with updated gate snapshot (not merge approval).

@brickfrog brickfrog merged commit a61cff4 into main Jun 1, 2026
2 checks passed
@brickfrog brickfrog deleted the main.cg9-7-4-otlp-protobuf-1780328971932-22209-0 branch June 1, 2026 16:19
@brickfrog brickfrog mentioned this pull request Jun 1, 2026
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.

2 participants