Nightly Patch Machine

    @opentelemetry/instrumentation-xml-http-request
    TypeScript icon, indicating that this package has built-in type declarations

    0.29.2 • Public • Published

    OpenTelemetry XMLHttpRequest Instrumentation for web

    NPM Published Version Apache License

    This module provides auto instrumentation for web using XMLHttpRequest .

    Installation

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

    Usage

    import { ConsoleSpanExporter, SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base';
    import { WebTracerProvider } from '@opentelemetry/sdk-trace-web';
    import { XMLHttpRequestInstrumentation } from '@opentelemetry/instrumentation-xml-http-request';
    import { ZoneContextManager } from '@opentelemetry/context-zone';
    import { registerInstrumentations } from '@opentelemetry/instrumentation';
    
    const providerWithZone = new WebTracerProvider();
    providerWithZone.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
    
    providerWithZone.register({
      contextManager: new ZoneContextManager(),
    });
    
    registerInstrumentations({
      instrumentations: [
        new XMLHttpRequestInstrumentation({
          propagateTraceHeaderCorsUrls: ['http://localhost:8090']
        }),
      ],
    });
    
    
    const webTracerWithZone = providerWithZone.getTracer('default');
    
    /////////////////////////////////////////
    
    // or plugin can be also initialised separately and then set the tracer provider or meter provider
    const xmlHttpRequestInstrumentation = new XMLHttpRequestInstrumentation({
      propagateTraceHeaderCorsUrls: ['http://localhost:8090']
    });
    const providerWithZone = new WebTracerProvider();
    providerWithZone.register({
      contextManager: new ZoneContextManager(),
    });
    xmlHttpRequestInstrumentation.setTracerProvider(providerWithZone);
    /////////////////////////////////////////
    
    
    // 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.

    Useful links

    License

    Apache 2.0 - See LICENSE for more information.

    Install

    npm i @opentelemetry/instrumentation-xml-http-request

    DownloadsWeekly Downloads

    18,559

    Version

    0.29.2

    License

    Apache-2.0

    Unpacked Size

    198 kB

    Total Files

    57

    Last publish

    Collaborators

    • bogdandrutu
    • dyladan