-
Notifications
You must be signed in to change notification settings - Fork 810
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)!: collapse base classes into one #5031
feat(exporters)!: collapse base classes into one #5031
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5031 +/- ##
==========================================
+ Coverage 93.19% 94.56% +1.37%
==========================================
Files 314 314
Lines 8077 7961 -116
Branches 1622 1600 -22
==========================================
+ Hits 7527 7528 +1
+ Misses 550 433 -117
|
abff0e1
to
dbb413b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR looks good :) but I wonder about convertLegacyOtlpGrpcOptions
and other functions with legacy in its name. If the PR is already breaking why not refactor the interfaces so we do not need any transformation function from legacy options?
experimental/packages/otlp-exporter-base/src/configuration/legacy-node-configuration.ts
Show resolved
Hide resolved
* TODO: Replace export * with named exports before next major version | ||
*/ | ||
export * from './node'; | ||
export { OTLPMetricExporter } from './node'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why exporting only the class from ./node
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep that's somewhat confusing but it's how all our platform-specific exports work, see here. 🙂
The way I understand it, when bundled for the the browser, webpack overrides all usages of this file with the one from platform/browser/index.js
- so the user will end up with the correct implementation.
AFAIK we can't override the other way around so that's what ended up becoming the default.
Yes, good point - the PR is already breaking but I'm trying to make it so that anyone using the exporter in a "normal" way (i.e. not extending it, just using the constructor and then passing it to a I'm then planning to introduce a new factory function for each exporter that will eventually replace the constructors, so that we don't have to export a class directly anymore, but we can have the factory function return a |
Which problem is this PR solving?
Through recent changes I've been working on reducing code-duplication across the exporters and separating config-code, transport code and base exporter code. I'm doing this for three reasons:
In the changes I made previously, we have seen a convergence of the
OTLPExporterNodeBase
,OTLPExporterBrowserBase
, andOTLPGRPCExporterBase
classes. This PR removes all of these classes, and replaces them with an implementation of a new interface:IOTLPExportDelegate
Collapsing these into a single implementation with a single name has the benefit of fixing #4794, which was caused by differently named platform exports for Node.js and the Browser - a design-level bug that needed resolving before we can consider an OTLP Exporter GA release. I'm fixing the problem of having different public interfaces for different transports by introducing new entrypoints:
node-http
andbrowser-http
which are only imported by their respective platform-specific implementations.This export delegate contains all the behavior that is present in the OTLP exporter specification and shared across all signals. It can be created via a factory function to avoid exposing the internal API as public. Specific exporters are expected to use this delegate to eventually compose an exporter though different transports and serializers. Composition is used over inheritance as polymorphism is not of relevance when using an OTLP exporter: It is either a
PushMetricExporter
, aSpanExporter
, or aLogRecordExporter
- having anOTLPExporterBase
does not add any value to the end-user as the public interface ends up being the same. On top of that it was only used internally as it was the easy way of getting base functionality to the individual exporters. In doing so it also exposed a lot of internals as part of the public API.OTLPExporterBase
still exists but now only takes anIOTLPExportDelegate
and will eventually be removed. I've decided to keep it around to have a base for the individual exporters, which can be instantiated withnew
. In a future revision, I plan to introduce factory functions for each exporter which returns aPushMetricExporter
, aSpanExporter
, or aLogRecordExporter
instead of a specific exporter class. The factory functions will also do away with some duplicate ways of configuring transports.As a way to transition to these factory functions, this PR introduces "translation" helpers for the "old" configuration to the "new" one which is already used internally (these legacy conversions can be identified by the word
legacy
in their names).Fixes #4794
Updates #4186
Breaking changes
OTLPExporterNodeBase
has been removed in favor of a platform-agnostic implementation (OTLPExporterBase
)OTLPExporterBrowserBase
has been removed in favor of a platform-agnostic implementation (OTLPExporterBase
)ExportServiceError
was intended for internal use and has been dropped from exportsvalidateAndNormalizeHeaders
was intended for internal use and has been dropped from exportsOTLPExporterBase
all properties are now private, the constructor now takes anIOTLPExportDelegate
, the type parameter for config type has been dropped.SpanExporter
,PushMetricExporter
orLogRecordExporter
, based on their respective type.OTLPGRPCExporterNodeBase
has been removed in favor of a platform-agnostic implementation (OTLPExporterBase
from@opentelemetry/otlp-exporter-base
)Type of change
Please delete options that are not relevant.
How Has This Been Tested?