@kimitsu/otel-sdk-web v1.7.50
OpenTelemetry SDK for Browser JS
NOTE: This package depends on experimental packages. There's no guarantee to work correctly.
This package provides OpenTelemetry SDK for Browser JS including tracing, metrics and logs.
Quick Start
Installation
npm
npm install @kimitsu/otel-sdk-web
yarn
yarn add @kimitsu/otel-sdk-web
pnpm
pnpm install @kimitsu/otel-sdk-web
Instrumentation
Create Tracer
, Meter
and Logger
const { tracer, meter, logger } = start({
serviceName: "client",
tracerName: "app",
meterName: "app",
loggerName: "app",
});
Emit Span
s
const span = tracer.startSpan("client manual span");
span.end();
Emit Instrument
s
const counter = meter.createCounter("client_counter");
counter.add(1);
Emit LogRecord
s
logger.info("client log");
Configuration
Common Attributes
Option Name | Required | Description | Type | Default Value |
---|---|---|---|---|
serviceName | ❌ | Your service name. | string | |
otelcolOrigin | ❌ | The origin of OpenTelemetry Collector. | string | "http://localhost:4318" |
debug | ❌ | The flag to enable debug output to console.log . | boolean | false |
Traces Attributes
Option Name | Required | Description | Type | Default Value |
---|---|---|---|---|
tracerName | ✅ | The Tracer name. | string | |
otelcolTracesPath | ❌ | The path of the traces endpoint of OpenTelemetry Collector. | string | "/v1/traces" |
Metrics Attributes
Option Name | Required | Description | Type | Default Value |
---|---|---|---|---|
meterName | ✅ | The Meter name. | string | |
otelcolMetricsPath | ❌ | The path of the metrics endpoint of OpenTelemetry Collector. | string | "/v1/metrics" |
metricsExportIntervalMillis | ❌ | The interval in milliseconds for exporting metrics. | number | 60_000 |
Logs Attributes
Option Name | Required | Description | Type | Default Value |
---|---|---|---|---|
loggerName | ✅ | The Logger name. | string | |
otelcolLogsPath | ❌ | The path of the logs endpoint of OpenTelemetry Collector. | string | "/v1/logs" |
logLevel | ❌ | The log level. | SeverityNumber | SeverityNumber.INFO |
Examples
Next.js
See under /examples/nextjs
.
7 days ago
7 days ago
11 days ago
10 days ago
11 days ago
13 days ago
13 days ago
16 days ago
17 days ago
17 days ago
18 days ago
18 days ago
19 days ago
19 days ago
20 days ago
25 days ago
25 days ago
28 days ago
1 month ago
30 days ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago