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

[Plugin] - WebTracer - add "document-load" plugin #405

Closed
obecny opened this issue Oct 4, 2019 · 7 comments · Fixed by #433
Closed

[Plugin] - WebTracer - add "document-load" plugin #405

obecny opened this issue Oct 4, 2019 · 7 comments · Fixed by #433
Assignees
Milestone

Comments

@obecny
Copy link
Member

obecny commented Oct 4, 2019

I want to start adding auto instrumentation for WebTracer and as first thing would be simply the document load. But together with this I'm thinking of the architecture and how to structure things.
NodeTracer (TracerSDK) does this by creating a PluginLoader which is kind of cool and I thought that maybe thats the way to go. Then the first plugin for web tracer would be something like document-load. But then I was also thinking where it should be located. Probably some of the plugins can be shared between node and browser but not all of them. Now we have just opentelemetry-plugin-* and I wonder if that will be appropriate place or we should rather have a separate namespace and then even if some plugins can be shared we can simply reference them. I think that would be a cleaner solution so it will look like:
opentelemetry-plugin-web-* ?
and for the first plugin it would be something like :
opentelemetry-plugin-web-document-load

Any thoughts , objections, suggestions :) ?

@obecny
Copy link
Member Author

obecny commented Oct 4, 2019

The plugins then would be lazy loaded so they won't be bundled together with WebTracer. The Plugin Loader would be responsible for that

@dyladan
Copy link
Member

dyladan commented Oct 4, 2019

Would we then have opentelemetry-plugin-node-* for things that are specific to node?

@mayurkale22
Copy link
Member

As it is possible to have some of the plugins shared between node and browser, I would suggest to follow opentelemetry-plugin-* pattern.

@obecny
Copy link
Member Author

obecny commented Oct 4, 2019

We will have more and more plugins in a future and it might be misleading which one is supported in browser only and which one in node only or both. Just looking at repo now we already have 3 plugins for http, are they going be all supported in browser too ?

@dyladan
Copy link
Member

dyladan commented Oct 4, 2019

The 3 that exist are for the Nodejs standard library modules and afaik browser support for them is N/A

@markwolff
Copy link
Member

Maybe the plugins could be folder organized based on their supported environments: nodejs/opentelemetry-plugin-mongodb, web/opentelemetry-plugin-document-load, js/opentelemetry-plugin-purejslibrary

@draffensperger
Copy link
Contributor

My main suggestion here is that we don't rely on plugins as runtime objects or any kind of require function usage, since I think that could put limits on how people bundle their code. E.g. webpack, Rollup, Closure, etc. all support ES6 modules but may collapse them down into a flattened code bundle rather than having them as runtime objects.

What if the plugin model looked something like this:

const opentelemetry = require('@opentelemetry/core');
const { WebTracer } = require('@opentelemetry/web');
const { DocumentLoadPlugin } = require('@opentelemetry/web-document-load');
const { UserInteractionPlugin } = require('@opentelemetry/web-interaction');
const { XhrPlugin } = require('@opentelemetry/web-xhr');
const { ReactPlugin } = require('@opentelemetry/web-react');

const tracer = new WebTracer({
  plugins: [
     new DocumentLoadPlugin(),
     new UserInteractionPlugin,
     new XhrPlugin({ hostRegex: '.*' })
  ]
});

opentelemetry.initGlobalTracer(tracer);

This way we are just using the normal import system and passing the plugins to the tracer as objects rather than trying to hook into the module system, which I think is good for Node, but feels hacky in the browser to me.

@obecny obecny changed the title WebTracer - auto instrumentation - plugins [Plugin] - WebTracer - add "document-load plugin" Oct 14, 2019
@obecny obecny changed the title [Plugin] - WebTracer - add "document-load plugin" [Plugin] - WebTracer - add "document-load" plugin Oct 14, 2019
@mayurkale22 mayurkale22 added this to the Alpha v0.2 milestone Oct 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants