lightstep / lightstep-tracer-javascript

Lightstep distributed tracing library for Node.js and the browser
https://lightstep.com
MIT License
77 stars 66 forks source link

don't try to call the DOM if we're in a webworker #140

Closed austinlparker closed 5 years ago

austinlparker commented 5 years ago

Previously, in the event the tracer was loaded into a browser it would always check to see if it had been called from an HTML element (mostly so the tracer could be configured via that element). However, you can run in a browser but not have DOM access if you're in a service/webworker. This fixes the problem via early return if the tracer is running inside a worker (see https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope for details)