v1.0.0-beta.5
Pre-releaseAdded
-
Pluggable
TimeProviderfor span timestamps. New abstraction with three pieces:TimeProvider(interface) andSystemTimeProvider(default,DateTime.now) —lib/src/util/time_provider.dart.WebTimeProvider—window.performance.now()+timeOriginfor sub-millisecond span timestamps on web. Lives inlib/src/util/web_time_provider.dartas a conditional facade (web_time_provider_web.darton Dart-on-JS / Wasm;web_time_provider_stub.dartthrows on native).defaultTimeProvider— platform-aware constant exported fromlib/src/util/default_time_provider.dart. Native targets resolve toSystemTimeProvider; web targets toWebTimeProvider. Selected at compile time viadart.library.js_interop, the modern Wasm-compatible check.
Plumbed through
APITracerProvider.timeProvider→APITracer.timeProvider→APISpan._timeProviderso span starts, ends, and events all source their timestamps from the same clock.APISpan.addEventNowandaddEvents(Map)now route through the span's_timeProviderrather than the staticOTelFactory.spanEventNowshortcut, which was hardcoded toDateTime.nowand silently dropped sub-millisecond precision when the provider was aWebTimeProvider.Why this matters on web.
DateTime.now()on Dart-on-JS is millisecond-precision — the underlying source is JSDate.now(), andmicrosecondsSinceEpochreturnsmillisecondsSinceEpoch × 1000(the lower three digits are always zero, regardless of the Int64 storage type used by OTLP).WebTimeProviderroutes through the browser performance API: ~5µs nominal precision, browser-coarsened to ~100µs as a Spectre mitigation, still 10–200× better thanDate.now(). Native targets are unaffected and stay atDateTime.now's 1µs floor.Auto-default on web. Web users do not have to opt in — constructing an
APITracerProvideron a web target automatically getsWebTimeProviderviadefaultTimeProvider. To override (e.g., a fake clock in tests), assigntracerProvider.timeProvider = customProvider.
Changed
- README and the API example now use
OTelAPI.attributesFromSemanticMap({Enum.value: ...})for typed-enum-keyed attribute maps in place ofOTelAPI.attributesFromMap({Enum.value.key: ...})/Attributes.of({Enum.value.key: ...})/<String, Object>{...}.toAttributes(). The shorter form drops the.keyaccessor on every entry while keeping the typed-enum-key principle. Mixing different semconv enum types in one map is fine — the param isMap<OTelSemantic, Object>and every semconv enum implementsOTelSemantic. No API surface change;attributesFromSemanticMaphas existed since beta-era.