feat(exporters)!: rewrite exporter config logic #4971
+2,709
−2,759
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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:
getDefaultUrl
was intended for internal use has been removed from all exportersgetUrlFromConfig
was intended for internal use and has been removed from all exportershostname
was intended for internal use and has been removed from all exportersurl
was intended for internal use and has been removed from all exporterstimeoutMillis
was intended for internal use and has been removed from all exportersonInit
was intended for internal use and has been removed from all exportersparseHeaders
is now not exported anymoreappendResourcePathToUrl
is now not exported anymoreappendResourcePathToUrlIfNeeded
is now not exported anymoreconfigureExporterTimeout
is now not exported anymoreinvalidTimeout
is now not exported anymoreFollow-up steps:
OTEL_EXPORTER_OTLP_TEMPORALITY_PREFERENCE
, this will be done in a follow-up.OTLPExporterNodeBase
,OTLPExporterBrowserBase
,OTLPGrpcExporterNodeBase
into one shared base, that favors composition over inheritance. This can be done by:OTLPExporterDelegate
(draft) based on the "new" config, this replaces theOTLPExporterNodeBase
,OTLPExporterBrowserBase
,OTLPGrpcExporterNodeBase
classes which right now do essentially the same, except for the constructor which will be replaced by the factory function.@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?