• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

open-telemetry/opentelemetry-js: OpenTelemetry JavaScript Client

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

open-telemetry/opentelemetry-js

开源软件地址:

https://github.com/open-telemetry/opentelemetry-js

开源编程语言:

TypeScript 96.8%

开源软件介绍:


Getting Started   •   API Reference   •   SDK Reference

GitHub release (latest by date including pre-releases) Codecov Status license
Build Status Beta

Contributing   •   Development Guide   •   Examples


About this project

This is the JavaScript version of OpenTelemetry, a framework for collecting traces and metrics from applications.

Compatibility Matrix

API Version Core version Experimental Packages
1.1.x 1.1.x 0.28.x
1.0.x 1.0.x 0.26.x, 0.27.x
1.0.x 0.26.x -----
1.0.x 0.25.x -----
1.0.x 0.24.x -----
1.0.x 0.23.x -----
1.0.x 0.22.x -----
0.21.x 0.21.x -----
0.20.x 0.20.x -----
v1.0.0-rc.3 0.19.x -----
0.18.x 0.18.x -----
0.17.x -----
0.16.x -----
0.15.x -----
0.14.x -----
0.13.x -----
0.12.x -----
0.11.x -----

Versioning

The current version for each package can be found in the respective package.json file for that module. For additional details see the versioning and stability document in the specification.

Quick start

Application Owner

Install Dependencies

npm install --save @opentelemetry/api
npm install --save @opentelemetry/sdk-node
npm install --save @opentelemetry/auto-instrumentations-node

Note: auto-instrumentations-node is a meta package from opentelemetry-js-contrib that provides a simple way to initialize multiple Node.js instrumentations.

Instantiate Tracing

// tracing.js

'use strict'

const process = require('process');
const opentelemetry = require('@opentelemetry/sdk-node');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
const { ConsoleSpanExporter } = require('@opentelemetry/sdk-trace-base');
const { Resource } = require('@opentelemetry/resources');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');

// configure the SDK to export telemetry data to the console
// enable all auto-instrumentations from the meta package
const traceExporter = new ConsoleSpanExporter();
const sdk = new opentelemetry.NodeSDK({
  resource: new Resource({
    [SemanticResourceAttributes.SERVICE_NAME]: 'my-service',
  }),
  traceExporter,
  instrumentations: [getNodeAutoInstrumentations()]
});

// initialize the SDK and register with the OpenTelemetry API
// this enables the API to record telemetry
sdk.start()
  .then(() => console.log('Tracing initialized'))
  .catch((error) => console.log('Error initializing tracing', error));

// gracefully shut down the SDK on process exit
process.on('SIGTERM', () => {
  sdk.shutdown()
    .then(() => console.log('Tracing terminated'))
    .catch((error) => console.log('Error terminating tracing', error))
    .finally(() => process.exit(0));
});

Run Your Application

node -r ./tracing.js app.js

The above example will emit auto-instrumented telemetry about your Node.js application to the console. For a more in-depth example, see the Getting Started Guide. For more information about automatic instrumentation see @opentelemetry/sdk-trace-node, which provides auto-instrumentation for Node.js applications. If the automatic instrumentation does not suit your needs, or you would like to create manual traces, see @opentelemetry/sdk-trace-base

Library Author

If you are a library author looking to build OpenTelemetry into your library, please see the documentation. As a library author, it is important that you only depend on properties and methods published on the public API. If you use any properties or methods from the SDK that are not officially a part of the public API, your library may break if an Application Owner uses a different SDK implementation.

Supported Runtimes

Platform Version Supported
Node.JS v18
Node.JS v16
Node.JS v14
Older Node Versions See Node Support
Web Browsers See Browser Support below

Node Support

Only Node.js Active or Maintenance LTS versions are supported. Previous versions of node may work, but they are not tested by OpenTelemetry and they are not guaranteed to work. Please note that versions of Node.JS v8 prior to v8.12.0 will NOT work, because OpenTelemetry Node depends on the perf_hooks module introduced in v8.5.0 and performance.timeOrigin that is set correctly starting in v8.12.0.

Browser Support

Automated browser tests are run in the latest version of Headless Chrome. There is currently no list of officially supported browsers, but OpenTelemetry is developed using standard web technologies with wide support and should work in currently supported versions of major browsers.

Feature Status

Signal API Status SDK Status
Tracing Stable Release Candidate
Metrics Development Development
Logs Roadmap Roadmap

For a more detailed breakdown of feature support see the specification compliance matrix.

Contributing

We'd love your help!. Use tags up-for-grabs and good first issue to get started with the project. For instructions to build and make changes to this project, see the CONTRIBUTING guide.

We have a weekly SIG meeting! See the community page for meeting details and notes.

Approvers (@open-telemetry/js-approvers):

Find more about the approver role in community repository.

Maintainers (@open-telemetry/js-maintainers):

Find more about the maintainer role in community repository.

Thanks to all the people who already contributed

Thanks to all previous approvers and maintainers

Packages

API

Package Description
@opentelemetry/api This package provides TypeScript interfaces, enums and no-op implementations for the OpenTelemetry core trace and metrics model. It is intended for use both on the server and in the browser.
@opentelemetry/core This package provides default and no-op implementations of the OpenTelemetry api for trace and metrics. It's intended for use both on the server and in the browser.

Implementation / SDKs

Package Description
@opentelemetry/sdk-trace-base This module provides a full control over instrumentation and span creation. It doesn't load async_hooks or any instrumentation by default. It is intended for use both on the server and in the browser.
@opentelemetry/sdk-metrics-base This module provides instruments and meters for reporting of time series data.
@opentelemetry/sdk-trace-node This module provides automatic tracing for Node.js applications. It is intended for use on the server only.
@opentelemetry/sdk-trace-web This module provides automated instrumentation and tracing for Web applications. It is intended for use in the browser only.

Compatible Exporters

OpenTelemetry is vendor-agnostic and can upload data to any backend with various exporter implementations. Even though, OpenTelemetry provides support for many backends, vendors/users can also implement their own exporters for proprietary and unofficially supported backends.

See the OpenTelemetry registry for a list of exporters available.

Instrumentations

OpenTelemetry can collect tracing data automatically using instrumentations.

To request automatic tracing support for a module not on this list, please file an issue. Alternatively, Vendor/Users can write an instrumentation yourself.

Currently, OpenTelemetry supports automatic tracing for:

Node Instrumentations

Core
Contrib

These instrumentations are hosted at https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/node

Web Instrumentations

Core
Contrib

These instrumentations are hosted at https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/web

Shims

Package Description
@opentelemetry/shim-opentracing OpenTracing shim allows existing OpenTracing instrumentation to report to OpenTelemetry

Upgrade guidelines

0.28.x to 0.29.x

  • @opentelemetry/exporter-trace-otlp-http is now exporting scopeSpans instead of instrumentationLibrarySpans
    • this exporter now requires collector version 0.48 and up.
  • @opentelemetry/exporter-metrics-otlp-http is now exporting scopeMetrics instead of instrumentationLibraryMetrics
    • this exporter now requires collector version 0.48 and up.

0.27.x to 0.28.x

  • In @opentelemetry/exporter-trace-otlp-http, OTLPExporterBase._isShutdown is replaced with _shutdownOnce.

0.26.x to 0.27.x

Metric and trace exporters are split into separate packages:

  • @opentelemetry/exporter-otlp-http => @opentelemetry/exporter-trace-otlp-http and @opentelemetry/exporter-metrics-otlp-http
  • @opentelemetry/exporter-otlp-grpc => @opentelemetry/exporter-trace-otlp-grpc and @opentelemetry/exporter-metrics-otlp-grpc
  • @opentelemetry/exporter-otlp-proto => @opentelemetry/exporter-trace-otlp-proto and @opentelemetry/exporter-metrics-otlp-proto

Metric types are renamed:

  • @openetelemetry/api-metrics
    • Meter
      • createValueRecorder => createHistogram
      • createValueObserver => createObservableGauge
      • createSumObserver => createObservableCounter
      • createUpDownSumObserver => createObservableUpDownCounter
    • ValueRecorder => Histogram
    • ValueObserver => ObservableGauge
    • SumObserver => ObservableCounter
    • UpDownSumObserver => ObservableUpDownCounter
    • ObserverResult => ObservableResult
    • Observation.observer => Observation.observable
  • @opentelemetry/sdk-metrics-base
    • MetricKind
      • VALUE_RECORDER => HISTOGRAM
      • SUM_OBSERVER => OBSERVABLE_COUNTER
      • UP_DOWN_SUM_OBSERVER => OBSERVABLE_UP_DOWN_COUNTER
      • VALUE_OBSERVER => OBSERVABLE_GAUGE

0.25.x to 1.x.y

Collector exporter packages and types are renamed:

  • @opentelemetry/exporter-collector => @opentelemetry/exporter-otlp-http
    • CollectorExporterBase => OTLPExporterBase
    • CollectorTraceExporter => OTLPTraceExporter
    • CollectorMetricExporter => OTLPMetricExporter
    • CollectorExporterBrowserBase => OTLPExporterBrowserBase
    • CollectorExporterNodeBase => OTLPExporterNodeBase
    • CollectorExporterConfigBase => OTLPExporterConfigBase
    • CollectorExporterError => OTLPExporterError
    • COLLECTOR_SPAN_KIND_MAPPING => OTLP_SPAN_KIND_MAPPING
    • collectorTypes => otlpTypes
  • @opentelemetry/exporter-collector-grpc => @opentelemetry/exporter-otlp-grpc
    • CollectorTraceExporter => OTLPTraceExporter
    • CollectorMetricExporter => OTLPMetricExporter
    • CollectorExporterConfigNode => OTLPExporterConfigNode
  • @opentelemetry/exporter-collector-proto => @opentelemetry/exporter-otlp-proto
    • CollectorExporterNodeBase => OTLPExporterNodeBase
    • CollectorMetricExporter => OTLPMetricExporter
    • CollectorTraceExporter => OTLPTraceExporter
  • W3C propagators in @opentelemetry/core were renamed
    • HttpTraceContextPropagator -> W3CTraceContextPropagator
    • HttpBaggagePropagator -> W3CBaggagePropagator

热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap