opentelemetry-js/packages/opentelemetry-plugin-xml-ht...
Daniel Dyla 9a3fd7b560
Rename scope to context (#853)
2020-03-13 15:01:07 -04:00
..
images XMLHttpRequest (#595) 2019-12-19 15:34:09 -08:00
src Rename formatter to propagator (#851) 2020-03-13 09:22:59 -07:00
test Rename scope to context (#853) 2020-03-13 15:01:07 -04:00
.npmignore XMLHttpRequest (#595) 2019-12-19 15:34:09 -08:00
LICENSE XMLHttpRequest (#595) 2019-12-19 15:34:09 -08:00
README.md Rename scope to context (#853) 2020-03-13 15:01:07 -04:00
karma.conf.js XMLHttpRequest (#595) 2019-12-19 15:34:09 -08:00
package.json Rename scope to context (#853) 2020-03-13 15:01:07 -04:00
tsconfig.json XMLHttpRequest (#595) 2019-12-19 15:34:09 -08:00
tslint.json XMLHttpRequest (#595) 2019-12-19 15:34:09 -08:00

README.md

OpenTelemetry XMLHttpRequest Instrumentation for web

Gitter chat NPM Published Version dependencies devDependencies Apache License

This module provides auto instrumentation for web using XMLHttpRequest .

Installation

npm install --save @opentelemetry/plugin-xml-http-request

Usage

import { ConsoleSpanExporter, SimpleSpanProcessor } from '@opentelemetry/tracing';
import { WebTracer } from '@opentelemetry/web';
import { XMLHttpRequestPlugin } from '@opentelemetry/plugin-xml-http-request';
import { ZoneContextManager } from '@opentelemetry/context-zone';

const webTracerWithZone = new WebTracer({
  contextManager: new ZoneContextManager(),
  plugins: [
    new XMLHttpRequestPlugin({
      propagateTraceHeaderCorsUrls: ['http://localhost:8090']
    })
  ]
});
webTracerWithZone.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));

// and some test
const req = new XMLHttpRequest();
req.open('GET', 'http://localhost:8090/xml-http-request.js', true);
req.send();

Example Screenshots

Screenshot of the running example Screenshot of the running example Screenshot of the running example

See examples/tracer-web for a short example.

License

Apache 2.0 - See LICENSE for more information.