Skip to content

Add setOutputStreamMapper to OtlpStdout exporter builders - #9051

Open
HimanshuJha-2005 wants to merge 1 commit into
open-telemetry:mainfrom
HimanshuJha-2005:feat/stdout-exporter-output-stream-mapper
Open

HimanshuJha-2005 wants to merge 1 commit into
open-telemetry:mainfrom
HimanshuJha-2005:feat/stdout-exporter-output-stream-mapper

Conversation

@HimanshuJha-2005

@HimanshuJha-2005 HimanshuJha-2005 commented Nov 22, 2026 •

Copy link
Copy Markdown

Fixes #8976.

Description

Adds setOutputStreamMapper(Function<OutputStream, OutputStream> outputStreamMapper) to OtlpStdoutSpanExporterBuilder, OtlpStdoutMetricExporterBuilder, and OtlpStdoutLogRecordExporterBuilder as suggested in #8976.

This allows callers to programmatically customize the destination stream, such as wrapping it in a GZIPOutputStream or a custom line-framing stream, without requiring non-standard environment variables.

Key Changes

  • Added setOutputStreamMapper(Function<OutputStream, OutputStream> outputStreamMapper) on OtlpStdoutSpanExporterBuilder, OtlpStdoutMetricExporterBuilder, and OtlpStdoutLogRecordExporterBuilder.
  • Updated build() to apply the mapping function to outputStream before passing it to StreamJsonWriter.
  • Preserved ordering independence between setOutput(...) and setOutputStreamMapper(...).
  • Added null validation for outputStreamMapper and the mapped OutputStream.
  • Added unit tests in AbstractOtlpStdoutExporterTest covering custom stream mapping, end-to-end GZIP compression and decompression, call ordering, and null safety across traces, metrics, and logs.

Validation

  • ./gradlew :exporters:logging-otlp:spotlessCheck passed.
  • ./gradlew :exporters:logging-otlp:check passed (including Checkstyle, AnimalSniffer Java 8 compatibility, jApiCmp, and JUnit 5 tests).

…etry#8976)

Allows callers to customize the underlying output stream (e.g. for gzip compression, buffering, or framing) on OtlpStdoutSpanExporterBuilder, OtlpStdoutMetricExporterBuilder, and OtlpStdoutLogRecordExporterBuilder.

Signed-off-by: Himanshu Jha <[email protected]>
@HimanshuJha-2005
HimanshuJha-2005 requested a review from a team as a code owner November 22, 2026 19:39
@linux-foundation-easycla

linux-foundation-easycla Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: HimanshuJha-2005 / name: Himanshu Jha (9ac4a5a)

@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-11-22 20:09 UTC

Review the latest changes.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

@codecov

codecov Bot commented Nov 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.46%. Comparing base (f0549eb) to head (9ac4a5a).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #9051      +/-   ##
============================================
+ Coverage     90.45%   90.46%   +0.01%     
- Complexity    11182    11189       +7     
============================================
  Files          1032     1032              
  Lines         30508    30541      +33     
  Branches       3992     3995       +3     
============================================
+ Hits          27596    27630      +34     
  Misses         1935     1935              
+ Partials        977      976       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
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.

Feature: opt-in line-encoding options (marker prefix, base64, gzip, max line bytes) for the OTLP stdout exporter

1 participant