Socket
Book a DemoInstallSign in
Socket

@bondsports/telemetry

Package Overview
Dependencies
Maintainers
7
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bondsports/telemetry

Package for everything opentelemetry related in bond sports

latest
Source
npmnpm
Version
1.1.6
Version published
Weekly downloads
1.1K
67.99%
Maintainers
7
Weekly downloads
 
Created
Source

Telemetry

Motive

This package goal is to make the experience of configuring and working with OpenTelemetry easier.

example

Below are short examples for tracing and metrics. More examples are available at the examples folder, and the various opentelemetry repos.

Tracing

The following code shows a simple example of how to work with tracing. please notice that you need to manually install any auto-instrumentation library that you require.

import { Tracing } from '@bondsports/telemetry';
import { trace } from '@opentelemetry/api';

const tracing = new Tracing();

tracing.start();

const tracer = trace.getTracer('tracing-name')

const span = tracer.startSpan('some-action');

span.setAttribute('some-attribute');

// DO STUFF

span.end();

tracing.stop().then(() => console.log('done'));

Another way for initialize tracing with custom resource:

import { Tracing } from '@bondsports/telemetry';
import { Resource } from '@opentelemetry/resources';

const resource = new Resource({ 'service.version': number, 'service.name': 'my-service-name' });

const tracing = new Tracing([], resource);
...

Metrics

The following code shows a simple example of how to work with metrics.

import { Metrics } from '@bondsports/telemetry';

const metrics = new Metrics('sample-meter');

const meter = metrics.start();

const counter = meter.createCounter('sample_counter');

counter.add(1);

metrics.stop().then(() => console.log('done'));

Configuration

Common configuration

nameallowed valuedefault valuedescription
TELEMETRY_SERVICE_NAMEstringfrom package.jsonThe service name
TELEMETRY_SERVICE_VERSIONstringfrom package.jsonThe service version
TELEMETRY_HOST_NAMEstringos.hostname()The host name

Tracing configuration

nameallowed valuedefault valuedescription
TELEMETRY_TRACING_ENABLED'true', 'false''false'Should Tracing be enabled
TELEMETRY_TRACING_URL*stringhttp://localhost:55681/v1/traceThe URL to the OpenTelemetry Collector
TELEMETRY_TRACING_RATIOfloat1The amount of traces to sample

* required (only when tracing is enabled).

Metric configuration

nameallowed valuedefault valuedescription
TELEMETRY_METRICS_ENABLED'true', 'false''false'Should Metrics be enabled
TELEMETRY_METRICS_URL*stringhttp://localhost:55681/v1/metricsThe URL to the OpenTelemetry Collector
TELEMETRY_METRICS_INTERVALnumber15000The interval in miliseconds between sending data to the collector

* required (only when tracing is enabled).

FAQs

Package last updated on 04 Dec 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