Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(exporters)!: rewrite exporter config logic #4971

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pichlermarc
Copy link
Member

@pichlermarc pichlermarc commented Sep 2, 2024

Which problem is this PR solving?

Config code for exporters (user-provided, defaults, and env config) is currently hard to test individually and is spread/duplicated all over the different signal exporters.

This PR moves the configuration as much as possible into separate files/functions and splits them up into:

  • defaults
  • fallback merging (user-provided merging with env var config and defaults)
    • fallback merging is intentionally held modular in an effort to possibly allow a file-config fallback in the future
  • parsing the config from the environment

Since most config is now moved to base-packages we can remove the in-depth tests from the specific packages. This reduces duplication and makes further changes easier, as they will touch "fewer" files. Since now the configuration-code is not part of the individual exporter-implementations, collapsing the base exporters into one class becomes simpler as we have to worry less about the inheritance structure (abstract methods were removed in this PR as they were config-related).

In addition to these improvements, this PR also fixes #3748, #3747 which was a side-effect of the previous way of implementing env var config.

Breaking changes:

  • All exporters:
    • (user-facing) getDefaultUrl was intended for internal use has been removed from all exporters
    • (user-facing) getUrlFromConfig was intended for internal use and has been removed from all exporters
    • (user-facing) hostname was intended for internal use and has been removed from all exporters
    • (user-facing) url was intended for internal use and has been removed from all exporters
    • (user-facing) timeoutMillis was intended for internal use and has been removed from all exporters
    • (user-facing) onInit was intended for internal use and has been removed from all exporters
  • Exporter base package:
    • (internal) parseHeaders is now not exported anymore
    • (internal) appendResourcePathToUrl is now not exported anymore
    • (internal) appendResourcePathToUrlIfNeeded is now not exported anymore
    • (internal) configureExporterTimeout is now not exported anymore
    • (internal) invalidTimeout is now not exported anymore

Follow-up steps:

  • this PR did not apply the same to the metrics-specific enviornment variables like OTEL_EXPORTER_OTLP_TEMPORALITY_PREFERENCE, this will be done in a follow-up.
  • consolidate all base-classes OTLPExporterNodeBase, OTLPExporterBrowserBase, OTLPGrpcExporterNodeBase into one shared base, that favors composition over inheritance. This can be done by:
    • introducing a function that converts the "legacy" (i.e. current) configuration to the new configuration model (introduced in this PR)
    • creating a factory function that creates an OTLPExporterDelegate (draft) based on the "new" config, this replaces the OTLPExporterNodeBase, OTLPExporterBrowserBase, OTLPGrpcExporterNodeBase classes which right now do essentially the same, except for the constructor which will be replaced by the factory function.
    • final exporters don't inherit from any of these anymore, but they simply implement all functions by calling the the delegate's functions.
  • clean up existing tests to avoid testing export-output in-depth (this is tested in @opentelemetry/otlp-transformer, testing that the output is the correct format should suffice)

Fixes #3748
Fixes #3747

Type of change

How Has This Been Tested?

  • Remaining unit tests
  • New unit tests

@pichlermarc pichlermarc force-pushed the feat/node-exporter-config-rewrite branch 2 times, most recently from 2b185dc to af05548 Compare September 10, 2024 15:30
Copy link

codecov bot commented Sep 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.04%. Comparing base (f8ab559) to head (5843f7a).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4971      +/-   ##
==========================================
- Coverage   93.39%   91.04%   -2.36%     
==========================================
  Files          46       88      +42     
  Lines         712     1954    +1242     
  Branches      120      416     +296     
==========================================
+ Hits          665     1779    +1114     
- Misses         47      175     +128     

see 42 files with indirect coverage changes

@pichlermarc pichlermarc force-pushed the feat/node-exporter-config-rewrite branch 2 times, most recently from 9bfaad5 to b93d9db Compare September 16, 2024 14:44
@pichlermarc pichlermarc force-pushed the feat/node-exporter-config-rewrite branch from 11b5f20 to 3c1756f Compare September 16, 2024 15:31
@pichlermarc pichlermarc changed the title feat(exporters)!: rewrite exporter config logic for testability feat(exporters)!: rewrite exporter config logic Sep 16, 2024
@pichlermarc pichlermarc marked this pull request as ready for review September 16, 2024 15:40
@pichlermarc pichlermarc requested review from a team September 16, 2024 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant