Skip to content

v1.0.0-beta.5

Pre-release
Pre-release

Choose a tag to compare

@michaelbushe michaelbushe released this 10 May 19:19
· 61 commits to main since this release

Added

  • Pluggable TimeProvider for span timestamps. New abstraction with three pieces:

    • TimeProvider (interface) and SystemTimeProvider (default, DateTime.now) — lib/src/util/time_provider.dart.
    • WebTimeProviderwindow.performance.now() + timeOrigin for sub-millisecond span timestamps on web. Lives in lib/src/util/web_time_provider.dart as a conditional facade (web_time_provider_web.dart on Dart-on-JS / Wasm; web_time_provider_stub.dart throws on native).
    • defaultTimeProvider — platform-aware constant exported from lib/src/util/default_time_provider.dart. Native targets resolve to SystemTimeProvider; web targets to WebTimeProvider. Selected at compile time via dart.library.js_interop, the modern Wasm-compatible check.

    Plumbed through APITracerProvider.timeProviderAPITracer.timeProviderAPISpan._timeProvider so span starts, ends, and events all source their timestamps from the same clock. APISpan.addEventNow and addEvents(Map) now route through the span's _timeProvider rather than the static OTelFactory.spanEventNow shortcut, which was hardcoded to DateTime.now and silently dropped sub-millisecond precision when the provider was a WebTimeProvider.

    Why this matters on web. DateTime.now() on Dart-on-JS is millisecond-precision — the underlying source is JS Date.now(), and microsecondsSinceEpoch returns millisecondsSinceEpoch × 1000 (the lower three digits are always zero, regardless of the Int64 storage type used by OTLP). WebTimeProvider routes through the browser performance API: ~5µs nominal precision, browser-coarsened to ~100µs as a Spectre mitigation, still 10–200× better than Date.now(). Native targets are unaffected and stay at DateTime.now's 1µs floor.

    Auto-default on web. Web users do not have to opt in — constructing an APITracerProvider on a web target automatically gets WebTimeProvider via defaultTimeProvider. To override (e.g., a fake clock in tests), assign tracerProvider.timeProvider = customProvider.

Changed

  • README and the API example now use OTelAPI.attributesFromSemanticMap({Enum.value: ...}) for typed-enum-keyed attribute maps in place of OTelAPI.attributesFromMap({Enum.value.key: ...}) / Attributes.of({Enum.value.key: ...}) / <String, Object>{...}.toAttributes(). The shorter form drops the .key accessor on every entry while keeping the typed-enum-key principle. Mixing different semconv enum types in one map is fine — the param is Map<OTelSemantic, Object> and every semconv enum implements OTelSemantic. No API surface change; attributesFromSemanticMap has existed since beta-era.