Skip to content

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

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

fix(sdk-node): pass OTLP HTTP metric config#6666
cyphercodes wants to merge 5 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

codecov Bot commented May 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.87179% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.93%. Comparing base (c0bfea7) to head (7191c49).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
...ental/packages/opentelemetry-sdk-node/src/utils.ts 94.87% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6666   +/-   ##
=======================================
  Coverage   94.92%   94.93%           
=======================================
  Files         377      377           
  Lines       12817    12840   +23     
  Branches     2924     2929    +5     
=======================================
+ Hits        12167    12190   +23     
  Misses        650      650           
Files with missing lines Coverage Δ
...ental/packages/opentelemetry-sdk-node/src/utils.ts 97.23% <94.87%> (+0.11%) ⬆️
🚀 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.

@trentm trentm left a comment

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.

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.

@MikeGoldsmith MikeGoldsmith left a comment

Copy link
Copy Markdown
Member

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
Member

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

@MikeGoldsmith

Copy link
Copy Markdown
Member

@cyphercodes did you see my message regarding the other paramters to the grpc exporter constructor? Please confirm you don't intend to add them here, and I can do them in a follow-up PR.

@cyphercodes

Copy link
Copy Markdown
Author

Updated this PR against current main and resolved the merge conflict in experimental/packages/opentelemetry-sdk-node/src/utils.ts.

Also confirming the gRPC metric exporter constructor params are intentionally left out of this PR to keep this focused on the OTLP HTTP metric config path. Happy for those to be handled in a follow-up 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

@MikeGoldsmith MikeGoldsmith left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me. We can do the follow-up work for additional constructor params in a new PR.H

@trentm

trentm commented May 29, 2026

Copy link
Copy Markdown
Contributor

[I'd had a number of nits in my review from 3w ago. Did you intended to look into those?

Comment thread experimental/CHANGELOG.md Outdated

### :bug: Bug Fixes

* fix(sdk-node): pass OTLP HTTP metric exporter configuration from declarative config [#6665](https://github.com/open-telemetry/opentelemetry-js/issues/6665) @cyphercodes

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.

This now needs to move up to the unreleased section.

Signed-off-by: cyphercodes <cyphercodes@users.noreply.github.com>
@cyphercodes

Copy link
Copy Markdown
Author

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

What changed:

  • Merged upstream main into fix/sdk-node-otlp-http-metric-config.
  • Resolved the conflict in experimental/packages/opentelemetry-sdk-node/src/utils.ts by keeping the OTLP HTTP metric exporter config mapping and upstream's metric producer support.
  • Preserved upstream exporter timeout validation for metric HTTP exporter config.

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
  • (cd experimental/packages/opentelemetry-sdk-node && npx mocha test/utils.test.ts) — 56 passing
  • npm --prefix experimental/packages/opentelemetry-sdk-node run lint -- --quiet
  • git diff --check

@maryliag

maryliag commented Jun 8, 2026

Copy link
Copy Markdown
Member

Hi @cyphercodes, there were several comments added by Trent and Mike that you still need to address, your latest commit is merging with master but not addressing any of them.

I also want to take this opportunity for a reminder of OpenTelemetry Generative AI Contribution Policy. The policy allows AI-assisted contributions, but contributors remain responsible for understanding, validating, and meaningfully owning the work they submit. That includes replying on PRs, we would like to hear directly from you, specially replying to other humans that are taking the time to review your contribution, so please avoid just copying AI generated output that don't add value to the conversation.

Thank you!

@maryliag

Copy link
Copy Markdown
Member

There has been no activity in this PR, so I will go ahead and close without merging.

@MikeGoldsmith do you want to take over? Let me know if so, and if you want to make changes on top of this PR (in this case I will leave it open) or just create a new one

…ttp-metric-config

# Conflicts:
#	experimental/packages/opentelemetry-sdk-node/test/utils.test.ts
@cyphercodes

Copy link
Copy Markdown
Author

Updated this PR against current main and addressed the outstanding review nits.\n\nWhat changed:\n- Resolved the current merge conflict in experimental/packages/opentelemetry-sdk-node/test/utils.test.ts.\n- Exported/used the generated configuration types for OTLP HTTP metric exporter temporality/config.\n- Moved the periodic metric reader tests into their own describe block.\n- Simplified the metric reader test internals cast per review.\n- Moved the changelog entry back to the Unreleased bug fixes section.\n\nVerification run locally:\n- npm ci\n- npm run version:update\n- npm --prefix experimental/packages/otlp-transformer run protos\n- npm --prefix experimental/packages/opentelemetry-sdk-node run compile\n- (cd experimental/packages/opentelemetry-sdk-node && npx mocha test/utils.test.ts) — 54 passing\n- npm --prefix experimental/packages/opentelemetry-sdk-node run lint -- --quiet\n- git diff --check

@MikeGoldsmith

Copy link
Copy Markdown
Member

Sorry @cyphercodes, #6814 superseded this and has merged. The linked issue is now closed so I think we should close this PR too.

@maryliag

Copy link
Copy Markdown
Member

Closing this issue, per @MikeGoldsmith latest comment

@maryliag maryliag closed this Jun 24, 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.

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

4 participants