Skip to content

feat(otlp-transformer): add custom logs protobuf serializer#6390

Open
pichlermarc wants to merge 5 commits intoopen-telemetry:mainfrom
dynatrace-oss-contrib:feat/custom-logs-proto-serializer
Open

feat(otlp-transformer): add custom logs protobuf serializer#6390
pichlermarc wants to merge 5 commits intoopen-telemetry:mainfrom
dynatrace-oss-contrib:feat/custom-logs-proto-serializer

Conversation

@pichlermarc
Copy link
Member

@pichlermarc pichlermarc commented Feb 10, 2026

Which problem is this PR solving?

Currently we run into warnings that CSPs are being violated by protobuf.js (#4987). Also, to convert to protobuf.js' format, we do have to go through an intermediate representation, which is costly in terms of allocations.

This PR moves toward fixing this by introducing a custom protobuf serializer that can be used instead.

Note: my previous PR #6228 had a simple dynamic growing approach. However, since there is a risk that memory behavior will change for the worse from the current protobuf.js-based implementation, which does a double-pass to determine the size of the final message, I opted to also implement a double-pass approach. The first pass determines the buffer size and the second pass actually writes to said buffer. This makes the approach slightly slower than what I proposed in #6228 (also slower than JSON serialization, but faster than the protobuf.js-based approach), but more predictable than the doubling the buffer size or always allocating 64KB, which may not be needed.

Towards fixing:

Part of:

Supersedes #6228

Relevant benchmark results:

Old:

transform 512 logs (protobuf) x 502 ops/sec ±0.14% (96 runs sampled)
transform 512 logs (json) x 732 ops/sec ±0.19% (96 runs sampled)

New:

transform 512 logs (protobuf) x 650 ops/sec ±0.13% (97 runs sampled)
transform 512 logs (json) x 744 ops/sec ±0.17% (99 runs sampled)

Disclosure of AI use: I generated the initial prototype of this with GitHub Copilot and Claude Sonnet 4.5, but then applied a whole bunch of optimizations and changes to it to make it fit what we're trying to do here.

Short description of the changes

Type of change

  • New feature

How Has This Been Tested?

  • Added unit tests
  • Existing unit tests
  • Existing E2E tests
  • Existing benchmarks

@codecov
Copy link

codecov bot commented Feb 10, 2026

Codecov Report

❌ Patch coverage is 98.96907% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.61%. Comparing base (fcafab5) to head (67fc0c5).

Files with missing lines Patch % Lines
...ansformer/src/common/protobuf/common-serializer.ts 97.53% 2 Missing ⚠️
...p-transformer/src/logs/protobuf/logs-serializer.ts 98.19% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6390      +/-   ##
==========================================
+ Coverage   95.50%   95.61%   +0.11%     
==========================================
  Files         365      370       +5     
  Lines       11609    11992     +383     
  Branches     2677     2740      +63     
==========================================
+ Hits        11087    11466     +379     
- Misses        522      526       +4     
Files with missing lines Coverage Δ
...mer/src/common/protobuf/protobuf-size-estimator.ts 100.00% <100.00%> (ø)
...transformer/src/common/protobuf/protobuf-writer.ts 100.00% <100.00%> (ø)
...ages/otlp-transformer/src/common/protobuf/utils.ts 100.00% <100.00%> (ø)
...ackages/otlp-transformer/src/logs/protobuf/logs.ts 100.00% <100.00%> (ø)
...ansformer/src/common/protobuf/common-serializer.ts 97.53% <97.53%> (ø)
...p-transformer/src/logs/protobuf/logs-serializer.ts 98.19% <98.19%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pichlermarc pichlermarc force-pushed the feat/custom-logs-proto-serializer branch from 3a90e81 to bef2eb7 Compare February 10, 2026 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments