feat: add @opentelemetry/browser package#224
feat: add @opentelemetry/browser package#224david-luna wants to merge 26 commits intoopen-telemetry:mainfrom
Conversation
|
A couple of initial comments -
There are a few reasons
|
|
Thanks for the early feedback :) Agree on avoiding the builer pattern. I can refactor it to a previous draft I had which uses function composition. The current Implementation merges the configuration types so the user has a single place to add the configuration. I could keep it in the refactor. What's your opinion? Should we have separe config objects (one per signal) or a single one? |
We want to keep it simple AND flexible (classic trade off) 😅 For users who want to minimize their bundle size, it should be possible to only include the log SDK. This is tricky because an instrumentation could generate both events and spans. I think this is something we need to explore. |
|
I've changed to functions and removed the metrics. Still I have implemented a function to let the user combine logs & traces SDKs into one function. We can discuss all together the design in the next SIG |
Co-authored-by: Jared Freeze <overbalance@users.noreply.github.com>
Co-authored-by: Jared Freeze <overbalance@users.noreply.github.com>
Co-authored-by: Jared Freeze <overbalance@users.noreply.github.com>
Co-authored-by: Jared Freeze <overbalance@users.noreply.github.com>
Co-authored-by: Jared Freeze <overbalance@users.noreply.github.com>
Co-authored-by: Jared Freeze <overbalance@users.noreply.github.com>
…owser into otel-browser
| // Resource & Entities related | ||
| resource?: Resource; | ||
| // Processor | ||
| blrpScheduleDelay?: number; |
There was a problem hiding this comment.
Would it make sense to have an object grouping these options? Something like
...
batchLogRecordProcessorConfig: {
scheduleDelay?: number;
..etc,
}
Same with traces config
There was a problem hiding this comment.
I think it does. Even we can do the same with the export config
exportConfig: {
endpoint?: string;
headers?: Record<string, string>;
}
but maybe there is no need to use such a long name. If used directly with the logs SDK the name of the method already gives the context
startLogsSdk({
// other config...
processorConfig: {
scheduleDelay: 5000,
}
});and if used with the compose API is nested in the the logs key
// Combine the functions into one
const startMySdk = combineSdks({
logs: startLogsSdk,
traces: startTracesSdk
});
startMySdk({
// other config...
logs: {
processorConfig: {
scheduleDelay: 5000,
}
}
});
Which problem is this PR solving?
Add a new package named
@opentelemetry/browserwhich hold the setup of the different signals separately and a bulder to compose them together into an SDK interface with start and stop methods.This approach has taken into consideration that configuring all signals into a single SDK class presents challenges when it comes to tree shaking and bundlers cannot anticipate which modules are going to be used. So the configuration has been split by signal and needs to be imported explicitly by the consumer making easier for bundlers to analyse the code and remove unused modules.
You could start an SDK in isolation:
O combine more than one SDK
Some bundlers are smart enough to tree shake even if the SDKs are exported from a barrel file but explicit export paths has been added to be in sync with the approach done for instrumentations.
Refs #131
Short description of the changes
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Checklist: