Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@honeycombio/opentelemetry-web

Package Overview
Dependencies
Maintainers
15
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@honeycombio/opentelemetry-web

Honeycomb OpenTelemetry Wrapper for Browser Applications

  • 0.0.1
  • npm
  • Socket score

Version published
Weekly downloads
23K
increased by5.07%
Maintainers
15
Weekly downloads
 
Created
Source

Honeycomb OpenTelemetry Web

OSS Lifecycle CircleCI npm

Honeycomb wrapper for OpenTelemetry in the browser.

STATUS: this library is ALPHA.

Latest release:

This package sets up OpenTelemetry for tracing, using our recommended practices, including:

  • Useful extra attributes, or fields, related to the browser
  • Easy configuration to send to Honeycomb
  • Basic sampler to control event volume (coming soon)
  • Multi span attributes (coming soon)
  • Convenient packaging
  • An informative debug mode
  • Links to traces in Honeycomb (coming soon)

Why use this?

This wrapper is a little ahead of OpenTelemetry, so that you can get the recommended fields in before they're completely standardized.

This wrapper is at least as stable as OpenTelemetry, because it is backwards-compatible as we update it to the latest OpenTelemetry versions, semantic conventions, and recommended practices.

We test this library, with its combination of OpenTelemetry dependencies, so that you can be confident that upgrades will work.

This project provides a convenient distribution of all the code required to get traces from the browser.

Getting started

Install this library:

npm install @honeycombio/opentelemetry-web @opentelemetry/auto-instrumentations-web

Get a Honeycomb API key.

Initialize tracing at the start of your application:

import { HoneycombWebSDK } from '@honeycombio/opentelemetry-web';
import { getWebAutoInstrumentations } from '@opentelemetry/auto-instrumentations-web';

const sdk = new HoneycombWebSDK({
  apiKey: 'api-key-goes-here',
  serviceName: 'your-great-browser-application',
  instrumentations: [getWebAutoInstrumentations()], // add automatic instrumentation
});
sdk.start();

Build and run your application, and then look for data in Honeycomb. On the Home screen, choose your application by looking for the service name in the Dataset dropdown at the top. Data should populate.

Honeycomb screen, with "Home" circled on the left, and the dropdown circled at the top.

SDK Configuration

Pass these options to the HoneycombWebSDK:

namerequired?typedefault valuedescription
apiKeyrequired*stringHoneycomb API Key for sending traces directly to Honeycomb.
serviceNameoptionalstringunknown_serviceThe name of this browser application. Your telemetry will go to a Honeycomb dataset with this name.
localVisualizations**optionalbooleanfalseFor each trace created, print a link to the console so that you can find it in Honeycomb. Super useful in development! Do not use in production.
sampleRate**optionalnumber1If you want to send a random fraction of traces, then make this a whole number greater than 1. Only 1 in sampleRate traces will be sent, and the rest never be created.
tracesEndpointoptionalstring${endpoint}/v1/tracesPopulate this to send traces to a route other than /v1/traces.
debugoptionalbooleanfalseEnable additional logging.
datasetoptionalstringPopulate this only if your Honeycomb environment is still Classic.
skipOptionsValidation**optionalbooleanfalseDo not require any fields.* Use with OpenTelemetry Collector.

* Note: the apiKey field is required because this SDK really wants to help you send data directly to Honeycomb.

** Note: these config options are planned but not implemented yet, they will be available as part of the beta release.

Send to an OpenTelemetry Collector

In production, we recommend running an OpenTelemetry Collector, so that your browser app can send traces to it for you to have control over your Honeycomb API key as well any data transformation. Your OpenTelemetry Collector can send the traces on to Honeycomb, and your API key will be in the Collector's configuration. Here is a configuration of the Honeycomb Web SDK that sends to your Collector:

{
  endpoint: "http(s)://<your-collector-url>",
  serviceName: "your-spiffy-browser-application",
  skipOptionsValidation: true // because we are not including apiKey
}

Fields emitted

The SDK adds these fields to all telemetry:

namestatusstatic?descriptionexample
user_agent.originalstablestaticwindow.user_agentMozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36
browser.heightplannedper-spanwindow.innerHeight, the height of the layout viewport in pixels287
browser.widthplannedper-spanwindow.innerWidth, the height of the layout viewport in pixels1720
browser.brandsstablestaticNavigatorUAData: brands["Not_A Brand 8", "Chromium 120", "Google Chrome 120"]
browser.platformstablestaticNavigatorUAData: platform"Windows"
browser.mobilestablestaticNavigatorUAData: mobiletrue
browser.languagestablestaticNavigator: language"fr-FR"
browser.touch_screen_enabledstablestaticNavigator: maxTouchPointstrue
page.urlcustomper-spanhttps://docs.honeycomb.io/getting-data-in/data-best-practices/#datasets-group-data-together?page=2
page.routecustomper-span/getting-data-in/data-best-practices/
page.searchcustomper-span?page=2
page.hashcustomper-span#datasets-group-data-together
page.hostnamecustomper-spandocs.honeycomb.io
screen.widthcustomstaticTotal available screen width in pixels.780
screen.heightcustomstaticTotal available screen height in pixels1000
honeycomb.distro.versionstablestaticpackage version"1.2.3"
honeycomb.distro.runtime_versionstablestatic"browser"
entry_page.urlcustomstatichttps://docs.honeycomb.io/getting-data-in/data-best-practices/#datasets-group-data-together?page=2
entry_page.pathcustomstatic/getting-data-in/data-best-practices/
entry_page.searchcustomstatic?page=2
entry_page.hashcustomstatic#datasets-group-data-together
entry_page.hostnamecustomstaticdocs.honeycomb.io
entry_page.referrercustomstaticDocument: referrerhttps://honeycomb.io

Static fields are added to the Resource, so they are same for every span emitted for the loaded page.

Fields that can change during the lifetime of the page are instead added to each span in a SpanProcessor.

Migration Practices

This wrapper can change faster than OpenTelemetry, and yet be more stable. This section describes how we do that.

Versioning

Our version numbers are independent of the OpenTelemetry version numbers. Check the badge at the top of this README for the OpenTelemetry version this is based on.

When OpenTelemetry releases a new version of the packages this project depends on, we update this project to use them within a week, unless our tests indicate a problem.

When the OpenTelemetry API or SDK has a major version bump, this package will, too. We also have major version bumps of our own.

Code

If there is something we want to get into OpenTelemetry, or a PR that we wish were merged already, we can incorporate that code here in parallel to working to get it published upstream.

When that code is in place upstream, we remove it here, and release a new version. When there is no change to the inputs and outputs, nothing else is required.

Fields

This project adds fields to the outgoing spans. We follow semantic convention when they exist.

For fields that aren't yet part of the semantic conventions, we give them a name. If those field names become stable with a different name, then:

  1. We add the new name, and emit both for 6 months.
  2. We mark the old name as deprecated in this documentation
  3. We offer a configuration option to NOT emit both.
  4. After that period, we add a configuration parameter to allow you to say, keep emitting that old field name.
  5. A year after the semantic convention has been in place, we stop emitting the old field name at all. (at the next major version bump)

Configuration

The configuration accepted by this wrapper is based on the options available in the OpenTelemetry libraries.

When an option is not available upstream, we give it a name. If that option becomes available upstream under a different name, we migrate to that.

  1. We add the new name, and accept both for 6 months.
  2. We mark the old name as deprecated in this documentation, and issue a warning in debug mode.
  3. After this period, the old name will be ignored (at the next major version bump).

Development

See DEVELOPING.md

Contributing

See CONTRIBUTING.md

Support

See SUPPORT.md

Code of Conduct

See CODE_OF_CONDUCT.md

FAQs

Package last updated on 31 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc