Skip to content

fix(sdk-node): pass OTLP HTTP metric config#6666

Open
cyphercodes wants to merge 2 commits into
open-telemetry:mainfrom
cyphercodes:fix/sdk-node-otlp-http-metric-config
Open

fix(sdk-node): pass OTLP HTTP metric config#6666
cyphercodes wants to merge 2 commits into
open-telemetry:mainfrom
cyphercodes:fix/sdk-node-otlp-http-metric-config

Conversation

@cyphercodes
Copy link
Copy Markdown

Which problem is this PR solving?

Fixes #6665.

startNodeSDK was creating OTLP HTTP metric exporters from declarative config with only compression wired through, so settings such as endpoint, headers, timeout, TLS, temporality, and histogram aggregation were ignored.

Short description of the changes

  • Map OTLP HTTP metric exporter declarative config into the exporter constructor options.
  • Support both headers_list and structured headers, with structured headers taking precedence.
  • Add regression coverage for connection and aggregation exporter options.
  • Add an experimental changelog entry.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • cd experimental/packages/opentelemetry-sdk-node && npm run lint
  • cd experimental/packages/opentelemetry-sdk-node && npm run compile
  • cd experimental/packages/opentelemetry-sdk-node && npm test -- --grep "passes OTLP HTTP metric exporter"
  • cd experimental/packages/opentelemetry-sdk-node && npm test (190 passing, 3 pending)
  • npx markdownlint-cli2 experimental/CHANGELOG.md
  • git diff --check

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added
  • Documentation has been updated

Signed-off-by: cyphercodes <cyphercodes@users.noreply.github.com>
@cyphercodes cyphercodes requested a review from a team as a code owner May 2, 2026 16:51
@codecov
Copy link
Copy Markdown

codecov Bot commented May 4, 2026

Codecov Report

❌ Patch coverage is 93.93939% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.86%. Comparing base (c990aff) to head (2ab245d).

Files with missing lines Patch % Lines
...ental/packages/opentelemetry-sdk-node/src/utils.ts 93.93% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6666   +/-   ##
=======================================
  Coverage   94.85%   94.86%           
=======================================
  Files         377      377           
  Lines       12751    12770   +19     
  Branches     2887     2890    +3     
=======================================
+ Hits        12095    12114   +19     
  Misses        656      656           
Files with missing lines Coverage Δ
...ental/packages/opentelemetry-sdk-node/src/utils.ts 97.28% <93.93%> (+0.09%) ⬆️
🚀 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.

Copy link
Copy Markdown
Contributor

@trentm trentm left a comment

Choose a reason for hiding this comment

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

Nice. Thanks for taking this. I just have some minor nits.

Heads up that there will be conflicts with #6679 but I can help with merge conflicts.


type OtlpHttpMetricExporterConfigModel = NonNullable<
PeriodicMetricReaderConfigModel['exporter']['otlp_http']
>;
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.

nit: This type could be exported from the configuration package and used directly.

}

function getMetricExporterTemporalityPreference(
temporalityPreference: OtlpHttpMetricExporterConfigModel['temporality_preference']
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.

nit: Likewise, we could add an ExporterTemporalityPreferenceConfigModel export from the configuration package.

);
});

it('passes OTLP HTTP metric exporter connection options from configuration', async function () {
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.

nit: Move this it(...) case to a new describe('getPeriodicMetricReaderFromConfiguration', ... section. If I read this correctly, this is currently in the getBatchLogRecordProcessorConfigFromEnv describe block.

});

assert.ok(reader);
const exporter = getMetricExporterInternals(reader);
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.

Could the same thing be accomplished with a type assertion to any? E.g.:

Suggested change
const exporter = getMetricExporterInternals(reader);
const exporter = (reader as any)._exporter;

I guess I'm expressing a personal preference to avoid defining interface FooInterals types that give the veneer of type safety for spelunking into internal object details.

Copy link
Copy Markdown
Member

@MikeGoldsmith MikeGoldsmith left a comment

Choose a reason for hiding this comment

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

This looks good to me, thanks @cyphercodes.

A gap I still see, that I tried to resolve in my accidental duplicate PR (#6707), is the gRPC metric exporter only passes compression. It's missing endpoint, timeout, credentials (TLS), and metadata (headers) — same properties you're now passing for HTTP. This matches the pattern in the trace exporter gRPC path (#6705).

I'd be happy to do a follow-up for the gRPC parameters if you'd prefer to keep this PR scoped to HTTP.

@maryliag
Copy link
Copy Markdown
Contributor

Hey @cyphercodes do you still plan on working on this PR?

@cyphercodes
Copy link
Copy Markdown
Author

Updated this PR to resolve the merge conflict with current main.

What changed:

  • Merged upstream main into the PR branch.
  • Resolved the conflict in experimental/packages/opentelemetry-sdk-node/test/utils.test.ts by keeping the upstream LoggerProviderOptions rename and preserving the metric exporter aggregation typings added by this PR.

Local verification:

  • npm ci
  • npm run version:update
  • npm --prefix experimental/packages/otlp-transformer run protos
  • npm --prefix experimental/packages/opentelemetry-sdk-node run compile
  • npm --prefix experimental/packages/opentelemetry-sdk-node run lint -- --quiet
  • (cd experimental/packages/opentelemetry-sdk-node && npx mocha test/utils.test.ts)
  • git diff --check

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.

[sdk-node] startNodeSDK is not handling all OtlpHttpMetricExporterConfigModel properties

4 participants