0.14.0 • Published 4 years ago

@opentelemetry/plugin-fetch v0.14.0

Weekly downloads
3,936
License
Apache-2.0
Repository
github
Last release
4 years ago

OpenTelemetry Fetch Instrumentation for web

Gitter chat NPM Published Version dependencies devDependencies Apache License

This module provides auto instrumentation for web using fetch.

Installation

npm install --save @opentelemetry/plugin-fetch

Usage

'use strict';
import { ConsoleSpanExporter, SimpleSpanProcessor } from '@opentelemetry/tracing';
import { WebTracerProvider } from '@opentelemetry/web';
import { FetchPlugin } from '@opentelemetry/plugin-fetch';
import { ZoneContextManager } from '@opentelemetry/context-zone';

const provider = new WebTracerProvider({
  plugins: [
    new FetchPlugin(),
  ],
});

provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));

provider.register({
  contextManager: new ZoneContextManager(),
});

// and some test

fetch('http://localhost:8090/fetch.js');

Example Screenshots

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

See examples/tracer-web/fetch for a short example.

Useful links

License

Apache 2.0 - See LICENSE for more information.