-
Notifications
You must be signed in to change notification settings - Fork 819
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: Make ID generator configurable #1331
Conversation
packages/opentelemetry-core/src/platform/node/RandomIdGenerator.ts
Outdated
Show resolved
Hide resolved
packages/opentelemetry-core/src/platform/node/AWSXrayIdGenerator.ts
Outdated
Show resolved
Hide resolved
packages/opentelemetry-core/test/platform/AWSXrayIdGenerator.test.ts
Outdated
Show resolved
Hide resolved
const IdGenerator = new RandomIdGenerator(); | ||
const IdGeneratorWithParameters = new RandomIdGenerator(8, 16); | ||
|
||
describe('IdGeneratorConstructor', () => { |
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.
Once you remove the length parameters, make sure this is mostly just copy-paste from previous tests
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.
I actually added beforeEach() keyword to separate obtaining value part and testing value part. Is that good or not?
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.
Hello and thanks for your first contribution.
I can see from the PR here that you are a little confused about what is meant by platform
. In our case, AWS is not a platform, but node and web are. The platform folders allow us to compile the project for node and web in cases where the implementation must differ (for instance, Buffer is not supported in web so other mechanisms must be used). The ID Generator interface would not go into a platform-specific folder because the interface is platform agnostic. If the implementation differs between web and node, as our current id generation does, then the concrete implementations would go into platform folders.
I would suggest you move the interface into some location that is outside of the platform
folder, and the concrete generator implementation should have a node
and web
version.
In addition, we typically keep vendor-specific code out of our repositories. For instance, you can see the google cloud trace and cloud monitoring exporters are kept in google-controlled repositories.
There are also some small stylistic issues which @anuraaga alluded to WRT method name casing and things like that.
I am happy to carve out some time if you would like to discuss these issues.
packages/opentelemetry-core/test/platform/AWSXrayIdGenerator.test.ts
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,46 @@ | |||
/* |
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.
This definitely does not belong in core. I'm not sure it belongs in contrib either though. We have been keeping proprietary vendor code out of our repositories across all of otel AFAIK. Dis something change?
Codecov Report
@@ Coverage Diff @@
## master #1331 +/- ##
==========================================
- Coverage 93.73% 93.61% -0.12%
==========================================
Files 144 149 +5
Lines 3991 4261 +270
Branches 808 870 +62
==========================================
+ Hits 3741 3989 +248
- Misses 250 272 +22
|
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.
Few things.
- Move all interfaces to types.ts
- You should mimic the same behaviour for browser and for node
- When bundle is being compiled the compiler checks for "browser" field in package.json if you check it you will see that file
./src/platform/index.ts
is replaced with file./src/platform/browser/index.ts
- When you write tests you should write a test that is not platform dependent, it means you add this in folder
test
. When the tests will be run in node it will pickup theid
from node and run tests using this implementation. When tests will be run in karma it will use thebrowser
from package.json replace the appropriate files and will run the test in browser environment. It means you write one test that should pass in both environments. - You are lacking here the whole implementation for browser
Besides all I have open questions
- Is this required by spec ?
- What are you trying to achieve ? Is this to be able to inject your own id generators ?
Concerns:
- The AWSXrayIdGenerator should not be a part of api, this can be either in core package (it might make sense) or in contrib repo
Thank you for your comment! I have already added web version of IdGenerator
|
packages/opentelemetry-core/src/platform/browser/RandomIdGenerator.ts
Outdated
Show resolved
Hide resolved
packages/opentelemetry-core/src/platform/browser/RandomIdGenerator.ts
Outdated
Show resolved
Hide resolved
packages/opentelemetry-core/src/platform/browser/RandomIdGenerator.ts
Outdated
Show resolved
Hide resolved
packages/opentelemetry-core/src/platform/node/RandomIdGenerator.ts
Outdated
Show resolved
Hide resolved
This looks a lot better after the changes, thanks |
packages/opentelemetry-core/src/platform/browser/RandomIdGenerator.ts
Outdated
Show resolved
Hide resolved
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.
LGTM. Thanks for you patience with the review process.
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.
lgtm
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.
Thanks!
It seems we still need 2 more maintainer's review to get this PR merged, what should we do now? @dyladan |
@EdZou you don't need maintainers, any approvers will do. @open-telemetry/javascript-approvers please take a look at this |
@EdZou I already pinged that group 3 hours ago. Please be patient as many of those people are contributing in their own free time, or have limited time their work allows them to dedicate to open source efforts. |
OMG, really sorry, I wrongly comprehend to let me take a look at the member of JS approver lists. Really sorry for that. |
Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com>
Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com>
* feat: graceful shutdown for tracing and metrics * fix: wording in test case * fix: typo * fix meterprovider config to use bracket notation Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com> * fix meterprovider config to use bracket notation Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com> * fix: add callbacks to shutdown methods * fix: merge conflict * simplify meter shutdown code Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com> * fix: fix one-liner * private function name style fix Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com> * fix: naming of private member variables * fix: graceful shutdown now works in browser * fix: window event listener will trigger once * fix: modify global shutdown helper functions * fix: remove callback from remove listener args * fix: change global shutdown function names and simplify functionality * fix: add rest of function refactoring and simplification * fix: remove unintended code snippet * fix: refactor naming of listener cleanup function and fix sandbox issue * fix: make global shutdown cleanup local * fix: change interval of MeterProvider collection to ensure it does not trigger through clock * chore: removing _cleanupGlobalShutdownListeners * fix: remove unnecesary trace provider member function * Removing default span attributes (#1342) * refactor(opentelemetry-tracing): removing default span attributes Signed-off-by: Aravin Sivakumar <aravinarjunn@gmail.com> * refactor(opentelemetry-tracing): removing default span attributed from tracer object Signed-off-by: Aravin Sivakumar <aravinarjunn@gmail.com> * refactor(opentelemetry-tracing): removing accidental add to package.json Signed-off-by: Aravin Sivakumar <aravinarjunn@gmail.com> * refactor(opentelemetry-tracing): removing redundant test and fixing suggestions by Shawn and Daniel Signed-off-by: Aravin Sivakumar <aravinarjunn@gmail.com> * feat: add baggage support to the opentracing shim (#918) Co-authored-by: Mayur Kale <mayurkale@google.com> * Add nodejs sdk package (#1187) Co-authored-by: Naseem <naseemkullah@gmail.com> Co-authored-by: legendecas <legendecas@gmail.com> Co-authored-by: Mark Wolff <mrw00010@gmail.com> Co-authored-by: Matthew Wear <matthew.wear@gmail.com> * feat: add OTEL_LOG_LEVEL env var (#974) * Proto update to latest to support arrays and maps (#1339) * chore: 0.10.0 release proposal (#1345) * fix: add missing grpc-js index (#1358) * chore: 0.10.1 release proposal (#1359) * feat(api/context-base): change compile target to es5 (#1368) * Feat: Make ID generator configurable (#1331) Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com> * fix: require grpc-js instead of grpc in grpc-js example (#1364) Co-authored-by: Bartlomiej Obecny <bobecny@gmail.com> * chore(deps): update all non-major dependencies (#1371) * chore: bump metapackage dependencies (#1383) * chore: 0.10.2 proposal (#1382) * fix: remove unnecesary trace provider member function * refactor(metrics): distinguish different aggregator types (#1325) Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com> * Propagate b3 parentspanid and debug flag (#1346) * feat: Export MinMaxLastSumCountAggregator metrics to the collector as Summary (#1320) Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com> * feat: Collector Metric Exporter for the Web (#1308) Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com> * Fix issues in TypeScript getting started example code (#1374) Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com> * chore: deploy canary releases (#1384) * fix: protos pull * fix: address marius' feedback * chore: deleting removeAllListeners from prometheus, fixing tests, cleanu of events when using shutdown notifier * fix: add documentation and cleanup code * fix: remove async label from shutdown and cleanup test case * fix: update controller collect to return promise * fix: make downsides of disabling graceful shutdown more apparent Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com> Co-authored-by: Bartlomiej Obecny <bobecny@gmail.com> Co-authored-by: Aravin <34178459+aravinsiva@users.noreply.github.com> Co-authored-by: Ruben Vargas Palma <ruben.vp8510@gmail.com> Co-authored-by: Mayur Kale <mayurkale@google.com> Co-authored-by: Naseem <naseemkullah@gmail.com> Co-authored-by: legendecas <legendecas@gmail.com> Co-authored-by: Mark Wolff <mrw00010@gmail.com> Co-authored-by: Matthew Wear <matthew.wear@gmail.com> Co-authored-by: Naseem <naseem@transit.app> Co-authored-by: Mark Wolff <mark.wolff@microsoft.com> Co-authored-by: Cong Zou <32532612+EdZou@users.noreply.github.com> Co-authored-by: Reginald McDonald <40721169+reggiemcdonald@users.noreply.github.com> Co-authored-by: WhiteSource Renovate <bot@renovateapp.com> Co-authored-by: srjames90 <srjames@lightstep.com> Co-authored-by: David W <dwitt12345@gmail.com> Co-authored-by: Mick Dekkers <mickdekkersnl@gmail.com>
Which problem is this PR solving?
The existing implementation of id generating only contains two functions while in the Java and Go repository, we provide an interface and default IdGenerator implementation.
Short description of the changes