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

0.55.0 • Public • Published

OpenTelemetry XMLHttpRequest Instrumentation for web

NPM Published Version Apache License

Note: This is an experimental package under active development. New releases may include breaking changes.

This module provides auto instrumentation for web using XMLHttpRequest .

Installation

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

Usage

import {
  ConsoleSpanExporter,
  SimpleSpanProcessor,
  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({
  spanProcessors: [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();

XHR Instrumentation options

XHR instrumentation plugin has few options available to choose from. You can set the following:

Options Type Description
applyCustomAttributesOnSpan XHRCustomAttributeFunction Function for adding custom attributes
ignoreNetworkEvents boolean Disable network events being added as span events (network events are added by default)
measureRequestSize boolean Measure outgoing request length (outgoing request length is not measured by default)

Semantic Conventions

This package uses @opentelemetry/semantic-conventions version 1.22+, which implements Semantic Convention Version 1.7.0

Attributes collected:

Attribute Short Description
http.status_code HTTP response status code
http.host The value of the HTTP host header
http.user_agent Value of the HTTP User-Agent header sent by the client
http.scheme The URI scheme identifying the used protocol
http.url Full HTTP request URL
http.method HTTP request method
http.request_content_length_uncompressed Uncompressed size of the request body, if any body exists

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.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.25.1-alpha.230canary
0.55.0
3,837latest
0.34.0497next

Version History

VersionDownloads (Last 7 Days)Published
0.55.0
3,837
0.54.2
7,072
0.54.1
7,273
0.54.0
7,212
0.53.0100,092
0.52.166,828
0.52.05,778
0.51.127,577
0.51.0583
0.50.06,432
0.49.13,473
0.49.00
0.48.014,445
0.47.0210
0.46.04,779
0.45.13,691
0.45.00
0.44.09,482
0.43.03,811
0.42.01
0.41.23,913
0.41.1256
0.41.08,081
0.40.02,413
0.39.1476
0.39.00
0.38.06,072
0.37.01,297
0.36.1444
0.36.06
0.35.13,835
0.35.016
0.34.0497
0.33.0215
0.32.0652
0.31.018
0.30.0250
0.29.2236
0.29.10
0.29.00
0.28.0652
0.27.01,639
0.26.05
0.25.1-alpha.230
0.25.1-alpha.220
0.25.1-alpha.160
0.25.1-alpha.130
0.25.1-alpha.120
0.25.1-alpha.70
0.25.1-alpha.40
0.25.1-alpha.20
0.25.044
0.25.1-alpha.210
0.24.1-alpha.200
0.24.1-alpha.190
0.24.1-alpha.180
0.24.1-alpha.140
0.24.1-alpha.93
0.24.1-alpha.80
0.24.1-alpha.70
0.24.1-alpha.60
0.24.1-alpha.50
0.24.1-alpha.40
0.24.1-alpha.10
0.24.034
0.24.1-alpha.310
0.23.1-alpha.280
0.23.1-alpha.240
0.23.1-alpha.230
0.23.1-alpha.160
0.23.1-alpha.150
0.23.1-alpha.130
0.23.1-alpha.120
0.23.1-alpha.30
0.23.1-alpha.180
0.23.031
0.23.1-alpha.170
0.22.1-alpha.160
0.22.1-alpha.150
0.22.1-alpha.140
0.22.1-alpha.130
0.22.1-alpha.90
0.22.1-alpha.30
0.22.1-alpha.20
0.22.075
0.22.1-alpha.50
0.21.1-alpha.30
0.21.1-alpha.20
0.21.1-alpha.10
0.21.02
0.21.1-alpha.70
0.20.1-alpha.50
0.20.1-alpha.40
0.20.1-alpha.30
0.20.0152
0.20.1-alpha.490
0.19.1-alpha.440
0.19.1-alpha.430
0.19.1-alpha.330
0.19.1-alpha.310
0.19.1-alpha.290
0.19.1-alpha.280
0.19.1-alpha.270
0.19.1-alpha.266
0.19.1-alpha.250
0.19.1-alpha.230
0.19.1-alpha.210
0.19.1-alpha.190
0.19.1-alpha.140
0.19.1-alpha.130
0.19.1-alpha.120
0.19.1-alpha.110
0.19.1-alpha.90
0.19.1-alpha.70
0.19.1-alpha.420
0.19.1-alpha.410
0.19.1-alpha.400
0.19.1-alpha.390
0.19.1-alpha.370
0.19.00
0.19.1-alpha.360
0.18.3-alpha.350
0.18.3-alpha.330
0.18.3-alpha.310
0.18.3-alpha.300
0.18.3-alpha.290
0.18.3-alpha.280
0.18.3-alpha.270
0.18.3-alpha.250
0.18.3-alpha.230
0.18.3-alpha.200
0.18.3-alpha.180
0.18.3-alpha.170
0.18.3-alpha.160
0.18.3-alpha.140
0.18.3-alpha.133
0.18.3-alpha.110
0.18.3-alpha.100
0.18.3-alpha.90
0.18.3-alpha.70
0.18.3-alpha.50
0.18.3-alpha.40
0.18.3-alpha.30
0.18.3-alpha.10
0.18.24
0.18.3-alpha.20
0.18.2-alpha.13
0.18.10
0.18.2-alpha.810
0.18.1-alpha.260
0.18.1-alpha.240
0.18.1-alpha.230
0.18.1-alpha.210
0.18.1-alpha.200
0.18.1-alpha.180
0.18.1-alpha.160
0.18.1-alpha.130
0.18.1-alpha.113
0.18.1-alpha.30
0.18.00
0.18.1-alpha.120
0.17.1-alpha.110
0.17.1-alpha.100
0.17.1-alpha.80
0.17.1-alpha.50
0.17.1-alpha.20
0.17.1-alpha.211
0.17.01
0.16.1-alpha.200
0.16.1-alpha.180
0.16.1-alpha.150
0.16.1-alpha.141
0.16.1-alpha.120
0.16.1-alpha.110
0.16.1-alpha.100
0.16.1-alpha.60
0.16.00
0.15.00
0.14.017
0.13.01

Package Sidebar

Install

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

Weekly Downloads

303,930

Version

0.55.0

License

Apache-2.0

Unpacked Size

229 kB

Total Files

66

Last publish

Collaborators

  • pichlermarc
  • bogdandrutu
  • dyladan