Skip to content

v0.12.0

Latest

Choose a tag to compare

@michaelbushe michaelbushe released this 08 Oct 14:51
· 4 commits to main since this release

Stable-channel republication of 1.0.0-rc.4. The code is the rc's code with a
stable version stamp, so users who have not opted into prereleases get the
fixes. See the 1.0.0-rc.4 entry for detail. The changes listed below are the
delta against 0.11.0, the previous stable release, not against the previous
prerelease.

Added

  • TraceState.toHeaderString() returns the W3C tracestate header value and
    applies the §3.3.1.5 truncation procedure when the joined value exceeds the
    512-character budget: whole entries are removed, entries over 128 characters
    first, then entries from the end, and every removal is reported through
    OTelErrorHandling. toString() continues to return all entries
    (#128).
  • APIMeter.registerBatchCallback(callback, instruments) registers one callback
    that observes several instruments at once and returns an
    APIBatchCallbackRegistration with unregister(). Instruments must belong
    to the same meter, per metrics/api.md (#113).
  • InstrumentAdvisory on all seven APIMeter.create* methods, carrying
    explicitBucketBoundaries and attributeKeys hints to the SDK
    (#113).
  • APIObservableInstrument, implemented by the three observable instruments,
    so batch callbacks and registerBatchCallback take a real type
    (#113).
  • createObservableCounter, createObservableUpDownCounter and
    createObservableGauge accept a callbacks list, and the instruments gain
    addCallback, which returns a registration handle, and removeCallback
    (#113).
  • APITracer.startSpan and APITracer.createSpan now accept a root: true
    parameter to force the creation of a root span, even when a parent span is
    active in the context
    (#118).
  • APITracer.startSpan now accepts an optional startTime parameter
    (#118).
  • TraceFlags.RANDOM_FLAG, TraceFlags.isRandom and TraceFlags.withRandom
    expose the random-trace-id bit (0x02), which W3C Trace Context Level 2
    makes a MUST to propagate unchanged across a continued trace. The byte
    already propagated, but the bit could not be read or set
    (#142).

Changed

  • BREAKING: TraceFlags.fromString is now a static method that returns
    null unless given two lowercase hex digits. Propagators must reject
    invalid headers (context/api-propagators.md, MUST)
    (#114).
  • BREAKING: parentSpan and spanContext parameters have been removed from
    APITracer.startSpan and APITracer.createSpan. Span creation now always
    uses the parent span or remote context stored in the provided Context (or
    Context.current if omitted). parentSpan: parent becomes
    context: Context.current.withSpan(parent). spanContext: sc has no direct
    replacement: it assigned sc to the new span verbatim, span ID included,
    which the specification's Span Creation section does not provide for. Putting
    sc on the Context instead makes the new span a child of it — a new span
    ID, with parentSpanId set to sc.spanId. Callers who actually wanted a span
    carrying sc unchanged should use OTelAPI.nonRecordingSpan(sc).
    The full parent precedence is root > remote SpanContext > local Span >
    valid non-remote SpanContext > new root, applied identically with and
    without an SDK installed. A candidate whose SpanContext is invalid is
    skipped, so a Context carrying only an invalid span or span context yields
    a root span rather than an error. When a remote SpanContext identifies a
    Span in the same Context, that Span is kept as the new span's
    parentSpan
    (#118).
  • BREAKING: Baggage.getAllValues() now returns
    Map<String, BaggageEntry> instead of List<String>, the name/value pairs
    the specification's "Get All Values" operation requires. To get the old
    List<String> back, write
    getAllValues().values.map((e) => e.value).toList().
    Baggage.getAllEntries() is now @Deprecated and delegates to
    getAllValues(); it will be removed in a future release
    (#127).
  • BREAKING: APIMeterProvider holds no configuration or operational
    state, per metrics/noop.md. The endpoint, serviceName, serviceVersion,
    enabled and isShutdown getters and setters are removed, getMeter
    returns a fresh no-op meter each call, and shutdown and forceFlush
    always return true (#113).

Deprecated

  • The boundaries parameter on createHistogram. Use
    advisory: InstrumentAdvisory(explicitBucketBoundaries: ...). When both are
    given, boundaries wins so existing callers keep their buckets, and the rest
    of the advisory is kept (#113).
  • The callback parameter on the three createObservable* methods. Use the
    callbacks list; a callback is prepended to it (#113).

Removed

  • BREAKING: APISpan no longer exposes attributes, spanEvents, spanLinks,
    status or statusDescription. trace/api.md says implementations SHOULD NOT
    provide access to a span's data besides its SpanContext. An SDK reads them
    through getReadableSpan, which is not exported from the package barrel.
    Setting attributes is unchanged. SDK users are unaffected in practice: the SDK
    span already gates every mutator on its own recording state, so this reaches
    API-direct users and custom SDKs
    (#140).
  • BREAKING: the parentSpan and spanContext parameters of
    APITracer.startSpan and APITracer.createSpan. The parent now comes from
    the Context, so parentSpan: parent becomes
    context: Context.current.withSpan(parent). spanContext: sc has no
    equivalent, because it gave the new span sc verbatim, span ID included.
    Put sc on the Context to parent a new span to it, or use
    OTelAPI.nonRecordingSpan(sc) to wrap it unchanged. The startSpan dartdoc
    documents the full parent precedence
    (#118).
  • BREAKING: Context.copyWithValue. It generated a key the caller could never
    get back, so a value stored through it was unreachable. Create the key with
    OTelAPI.contextKey<T>(name) and use Context.copyWith(key, value)
    (#130).

Fixed

  • The metrics API now documents that APIMeterProvider, APIMeter and the seven
    instruments need to be safe for concurrent use, that an instrument name must
    conform to the instrument name syntax, and that Histogram.record expects a
    non-negative value. metrics/api.md makes the first a MUST and the other two a
    SHOULD. Comments only, no behavior change
    (#141).

  • IdGenerator no longer draws every ID byte from a fresh
    Random.secure().nextInt(256) call (one OS entropy syscall per byte), which
    made generating a span ID cost ~330 µs and a trace ID ~665 µs on macOS arm64 —
    roughly 1 ms to start a root span. It now seeds a xorshift128 generator once
    from the OS CSPRNG and expands it locally (~18,000–21,000× faster), keeping
    the same 8/16-byte, non-zero, unique-ID contract, with 32-bit-masked
    arithmetic so VM and web builds produce identical sequences. Note that a
    locally generated trace ID exposes the full generator state, so subsequent
    IDs from the same isolate are predictable — generated IDs must not be used
    as secrets or security tokens
    (#144).

  • Integer trace flags retain only the low byte, including during
    SpanContext.fromJson, so they always render as two hex digits as required
    by the W3C Trace Context trace-flags grammar
    (#114).

  • TraceState construction (fromMap, OTelAPI/OTelFactory traceState(...))
    now validates keys and values against the W3C tracestate grammar, dropping
    invalid entries instead of silently accepting them
    (#119).

  • BREAKING: IdGenerator.hexToBytes, and so OTelAPI.traceIdFrom and
    OTelAPI.spanIdFrom, no longer accept anything outside lowercase hex
    (#112).

  • OTelAPI.traceIdFrom and OTelAPI.spanIdFrom no longer throw a
    FormatException on malformed or wrong-length input: the error is reported
    through OTelErrorHandling and an invalid (all-zero) id is returned, since
    error-handling.md says API methods MUST NOT throw on incorrect use
    (#137).

  • APISpan.addLink and APISpan.addSpanLink now document that a link given at
    span creation is preferred to a later call. The trace/api.md spec makes this
    a MUST, because head sampling can only use the information present at span
    creation. Comments only, no behavior change
    (#133).

  • The trace API now documents that APITracerProvider, APITracer and
    APISpan implementations need to be safe for concurrent use, which
    trace/api.md makes a MUST. Comments only, no behavior change
    (#120).

  • The logs API now documents that APILoggerProvider and APILogger
    implementations need to be safe for concurrent use, which logs/api.md makes
    a MUST. Comments only, no behavior change
    (#121).

  • Span events with an empty name are dropped and reported to OTelErrorHandler.
    OTelAPI.spanEvent(''), addEvent, addEventNow and addEvents no longer
    throw an ArgumentError, per error-handling.md
    (#117).

  • Empty string and empty array attribute values no longer throw ArgumentError
    (#103).

  • Typed Attributes getters return null on a type mismatch instead of throwing
    StateError, and report it through the error handler
    (#106).

  • APISpan honors the isRecording value given at creation, so mutating
    operations on a non-recording span are no-ops
    (#124).

  • APITracer.isEnabled() no longer always returns false. It reports whether
    a real SDK factory is installed, so honoring isRecording no longer makes
    every span non-recording
    (#124).

  • TraceState.put now moves a new or updated key to the front of the
    entries, per the W3C Trace Context rules for mutating tracestate. This
    also fixes overflow trimming, which evicted the newest entry instead of
    the oldest.
    (#115)

  • TraceState.fromString keeps only the first entry when a key repeats, which
    W3C Trace Context allows one of. A list member with an invalid key or value is
    now reported to the error handler instead of being dropped silently. An empty
    list member and a whitespace-only list member are dropped without a report,
    because the W3C grammar allows them
    (#116).

  • Without an SDK, createSpan returns the parent span directly when it is already
    non-recording instead of wrapping it again, per trace/api.md
    (#129).

  • APITracer builds its InstrumentationScope once, from the tracer's own name,
    version, schema URL and attributes. Span attributes no longer leak into the
    scope, and no version is invented (#129).