搜尋套件、儲存庫與 APP 分類

GitHub 儲存庫Workiva/opentelemetry-dart

opentelemetry-dart

Workiva/opentelemetry-dart open-source repository details.

opentelemetry-dart 專案封面
星標
87
分支
55
最近推送(UTC)
2026年8月26日
專案狀態
未封存

原始 README

以下為英文專案原文快照,最新內容請造訪 GitHub。

OpenTelemetry for Dart

This repository is the Dart implementation of the OpenTelemetry project. All contributions and designs should follow the OpenTelemetry specification.

Project Status

Signal Status
Traces Beta
Metrics Alpha
Logs Unimplemented

Getting Started

This section will show you how to initialize the OpenTelemetry SDK, capture a span, and propagate context.

Initialize the OpenTelemetry SDK
import 'package:opentelemetry/sdk.dart'
    show
        BatchSpanProcessor,
        CollectorExporter,
        ConsoleExporter,
        SimpleSpanProcessor,
        TracerProviderBase;
import 'package:opentelemetry/api.dart'
    show registerGlobalTracerProvider, globalTracerProvider;

void main(List<String> args) {
  final tracerProvider = TracerProviderBase(processors: [
    BatchSpanProcessor(
        CollectorExporter(Uri.parse('https://my-collector.com/v1/traces'))),
    SimpleSpanProcessor(ConsoleExporter())
  ]);

  registerGlobalTracerProvider(tracerProvider);
  final tracer = globalTracerProvider.getTracer('instrumentation-name');
}
Capture a Span
import 'package:opentelemetry/api.dart' show StatusCode, globalTracerProvider;

void main(List<String> args) {
  final tracer = globalTracerProvider.getTracer('instrumentation-name');

  final span = tracer.startSpan('main');
  try {
    // do some work
    span.addEvent('some work');
  } catch (e, s) {
    span
      ..setStatus(StatusCode.error, e.toString())
      ..recordException(e, stackTrace: s);
    rethrow;
  } finally {
    span.end();
  }
}
Propagate Context
Intra-process

In order to parent spans, context must be propagated. Propagation can be achieved by manually passing an instance of Context or by using Dart Zones.

See the attach detach context examplefor more information.

Inter-process

In order to parent spans between processes, context can be serialized and deserialized using a TextMapPropagator, TextMapSetter, and TextMapGetter.

See the W3C context propagation example for more information.

High Resolution Timestamps

A tracer provider can register a web-specific time provider that uses the browser's performance API instead of DateTime when recording timestamps for a span's start timestamp, end timestamp, and span events.

import 'package:opentelemetry/web_sdk.dart' as web_sdk;

final tracerProvider =
    web_sdk.WebTracerProvider(timeProvider: web_sdk.WebTimeProvider());

Important Note: Span timestamps may be inaccurate if the executing system is suspended for sleep. See https://github.com/open-telemetry/opentelemetry-js/issues/852 for more information.

Contributing

In order to generate protobuf definitions, you must have protoc installed and available in your path.

Publishing New Versions

Only Workiva maintainers can publish new versions of opentelemetry-dart. See Publishing opentelemetry-dart

Workiva GitHub avatar
GitHub 作者

Workiva ↗

語言DartMakefileShell

此儲存庫發佈的套件

使用的依賴

依賴清單 16 項

如何選擇適合專案的儲存庫?

先依使用情境篩選,再比較專案活躍情況,最後到原始儲存庫確認使用要求。

  1. 透過儲存庫名稱、作者或描述搜尋,再依技術分類縮小範圍。
  2. 綜合星標、分支與最近推送比較專案;星標反映社群關注,不保證品質。
  3. 使用前在 GitHub 確認 README、授權條款與 Issues。

來源與維護

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗