open-telemetry / opentelemetry-js

OpenTelemetry JavaScript Client
https://opentelemetry.io
Apache License 2.0
2.76k stars 810 forks source link

feat(otlp-exporter-base): internally accept a http header provider function only #5179

Closed pichlermarc closed 2 days ago

pichlermarc commented 3 days ago

Which problem is this PR solving?

Changes internal code to always expect a header provider function, instead of a direct object. This enables us to implement #2903 later.

This does not fully implement #2903 as I want to migrate the current way of constructing an OTLP exporter to a factory function. That factory function will have a slightly different options to the existing OTLP exporters. Goal of introducing the factory function with a different interface is to:

The changes in this PR are currently non-breaking as it's not part of the public API in any released version. So it's just internally breaking if we merge it before we release the changes from #5031.

Enables #2903

Short description of the changes

Type of change

How Has This Been Tested?

codecov[bot] commented 3 days ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 94.56%. Comparing base (91b9abd) to head (909666f). Report is 2 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #5179 +/- ## ========================================== - Coverage 94.57% 94.56% -0.01% ========================================== Files 314 314 Lines 7956 7966 +10 Branches 1600 1601 +1 ========================================== + Hits 7524 7533 +9 - Misses 432 433 +1 ``` | [Files with missing lines](https://app.codecov.io/gh/open-telemetry/opentelemetry-js/pull/5179?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry) | Coverage Δ | | |---|---|---| | [.../configuration/convert-legacy-node-http-options.ts](https://app.codecov.io/gh/open-telemetry/opentelemetry-js/pull/5179?src=pr&el=tree&filepath=experimental%2Fpackages%2Fotlp-exporter-base%2Fsrc%2Fconfiguration%2Fconvert-legacy-node-http-options.ts&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry#diff-ZXhwZXJpbWVudGFsL3BhY2thZ2VzL290bHAtZXhwb3J0ZXItYmFzZS9zcmMvY29uZmlndXJhdGlvbi9jb252ZXJ0LWxlZ2FjeS1ub2RlLWh0dHAtb3B0aW9ucy50cw==) | `100.00% <100.00%> (ø)` | | | [...-base/src/configuration/otlp-http-configuration.ts](https://app.codecov.io/gh/open-telemetry/opentelemetry-js/pull/5179?src=pr&el=tree&filepath=experimental%2Fpackages%2Fotlp-exporter-base%2Fsrc%2Fconfiguration%2Fotlp-http-configuration.ts&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry#diff-ZXhwZXJpbWVudGFsL3BhY2thZ2VzL290bHAtZXhwb3J0ZXItYmFzZS9zcmMvY29uZmlndXJhdGlvbi9vdGxwLWh0dHAtY29uZmlndXJhdGlvbi50cw==) | `100.00% <100.00%> (ø)` | | | [...e/src/configuration/otlp-http-env-configuration.ts](https://app.codecov.io/gh/open-telemetry/opentelemetry-js/pull/5179?src=pr&el=tree&filepath=experimental%2Fpackages%2Fotlp-exporter-base%2Fsrc%2Fconfiguration%2Fotlp-http-env-configuration.ts&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry#diff-ZXhwZXJpbWVudGFsL3BhY2thZ2VzL290bHAtZXhwb3J0ZXItYmFzZS9zcmMvY29uZmlndXJhdGlvbi9vdGxwLWh0dHAtZW52LWNvbmZpZ3VyYXRpb24udHM=) | `95.83% <100.00%> (+0.08%)` | :arrow_up: | | [...ter-base/src/configuration/shared-configuration.ts](https://app.codecov.io/gh/open-telemetry/opentelemetry-js/pull/5179?src=pr&el=tree&filepath=experimental%2Fpackages%2Fotlp-exporter-base%2Fsrc%2Fconfiguration%2Fshared-configuration.ts&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry#diff-ZXhwZXJpbWVudGFsL3BhY2thZ2VzL290bHAtZXhwb3J0ZXItYmFzZS9zcmMvY29uZmlndXJhdGlvbi9zaGFyZWQtY29uZmlndXJhdGlvbi50cw==) | `100.00% <100.00%> (ø)` | | | [...xporter-base/src/transport/http-transport-utils.ts](https://app.codecov.io/gh/open-telemetry/opentelemetry-js/pull/5179?src=pr&el=tree&filepath=experimental%2Fpackages%2Fotlp-exporter-base%2Fsrc%2Ftransport%2Fhttp-transport-utils.ts&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry#diff-ZXhwZXJpbWVudGFsL3BhY2thZ2VzL290bHAtZXhwb3J0ZXItYmFzZS9zcmMvdHJhbnNwb3J0L2h0dHAtdHJhbnNwb3J0LXV0aWxzLnRz) | `100.00% <ø> (ø)` | | | [...perimental/packages/otlp-exporter-base/src/util.ts](https://app.codecov.io/gh/open-telemetry/opentelemetry-js/pull/5179?src=pr&el=tree&filepath=experimental%2Fpackages%2Fotlp-exporter-base%2Fsrc%2Futil.ts&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry#diff-ZXhwZXJpbWVudGFsL3BhY2thZ2VzL290bHAtZXhwb3J0ZXItYmFzZS9zcmMvdXRpbC50cw==) | `100.00% <100.00%> (ø)` | | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/open-telemetry/opentelemetry-js/pull/5179/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry)

🚨 Try these New Features: