opentelemetry-js/packages/opentelemetry-plugin-docume...
Daniel Dyla 18c6aa4f19 Named Tracers / Tracer Registry (#582)
* feat: spike of named tracer registry

* chore: mysql/mongo tracer registry support

* fix: lint

* chore: add getTracer back

* chore: change default tracer name to empty string

* fix: lint

* chore: update examples for registry

* chore(tracer-registry): make name required

* chore: lint

* chore: update examples for required tracer name

* chore: remove unused tracer delegate

* chore: remove references to basic tracer

* chore: remove references to NodeTracer

* chore: update xhr for tracer registry

* chore: update tracer names to match package names

* chore: add version script to all packages

* chore: update plugins to use version script

* chore: add jsdoc to noop tracer registry

* chore: update ioredis for tracer registry

* chore: update pg pool for tracer registry

* fix: lint

* chore: fix tests

* chore: lint

* chore: lint

Co-authored-by: Mayur Kale <mayurkale@google.com>
2020-01-09 08:29:38 -08:00
..
src Named Tracers / Tracer Registry (#582) 2020-01-09 08:29:38 -08:00
test Named Tracers / Tracer Registry (#582) 2020-01-09 08:29:38 -08:00
LICENSE feat(plugin-document-load): new plugin for document load for web tracer (#433) 2019-10-23 10:32:22 -07:00
README.md chore: update plugin readme with example links (#647) 2019-12-27 08:58:24 -05:00
karma.conf.js chore: fixing coverage for karma using istanbul (#466) 2019-11-01 13:11:25 -07:00
package.json chore: 0.3.2 (patch) release proposal (#659) 2020-01-03 12:27:10 -08:00
tsconfig.json feat(plugin-document-load): new plugin for document load for web tracer (#433) 2019-10-23 10:32:22 -07:00
tslint.json feat(plugin-document-load): new plugin for document load for web tracer (#433) 2019-10-23 10:32:22 -07:00

README.md

OpenTelemetry Plugin Document Load

Gitter chat NPM Published Version dependencies devDependencies Apache License

This module provides automated instrumentation for document load for Web applications.

Installation

npm install --save @opentelemetry/plugin-document-load

Usage

import { ConsoleSpanExporter, SimpleSpanProcessor } from '@opentelemetry/tracing';
import { WebTracer } from '@opentelemetry/web';
import { DocumentLoad } from '@opentelemetry/plugin-document-load';

const webTracer = new WebTracer({
  plugins: [
    new DocumentLoad()
  ]
});

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

Optional: Send a trace parent from your server

This plugin supports connecting the server side spans for the initial HTML load with the client side span for the load from the browser's timing API. This works by having the server send its parent trace context (trace ID, span ID and trace sampling decision) to the client.

Because the browser does not send a trace context header for the initial page navigation, the server needs to fake a trace context header in a middleware and then send that trace context header back to the client as a meta tag traceparent . The traceparent meta tag should be in the trace context W3C draft format . For example:

  ...
<head>
  <!--
    https://www.w3.org/TR/trace-context/
    Set the `traceparent` in the server's HTML template code. It should be
    dynamically generated server side to have the server's request trace Id,
    a parent span Id that was set on the server's request span, and the trace
    flags to indicate the server's sampling decision
    (01 = sampled, 00 = notsampled).
    '{version}-{traceId}-{spanId}-{sampleDecision}'
  -->
  <meta name="traceparent" content="00-ab42124a3c573678d4d8b21ba52df3bf-d21f7bc17caa5aba-01">
</head>
<body>
  ...
  <script>
    // and then initialise the WebTracer
    // var webTracer = new WebTracer({ .......
  </script>
</body>

See examples/tracer-web for a short example.

License

Apache 2.0 - See LICENSE for more information.