dartastic_opentelemetry_api 1.0.0-beta.6
dartastic_opentelemetry_api: ^1.0.0-beta.6 copied to clipboard
Dartastic.io's OpenTelemetry API for Dart following the OpenTelemetry specification. Supports all platforms including web.
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
1.0.0-beta.6 - 2026-05-11 #
Added #
-
OTelAPI.attributesOf<E extends OTelSemantic>(Map<E, Object>)— a shorthand-friendly counterpart toattributesFromSemanticMap. Parameterized on a single concrete semconv enum [E], so Dart 3.10 static dot-shorthand can drop the prefix at the call site:// Today and forever: OTelAPI.attributesOf<Http>({ Http.requestMethod: 'GET', Http.responseStatusCode: 200, }); // With Dart 3.10+ static dot-shorthand enabled: OTelAPI.attributesOf<Http>({ .requestMethod: 'GET', .responseStatusCode: 200, });attributesFromSemanticMapstays the right call site when you need to mix multiple semconv enums or your ownOTelSemantic-implementing enums in one map. -
New top-level
Userenum insemantics.dartcovering the OTel-specuser.*keys:userId,userEmail,userFullName,userName,userRoles,userSession. Replaces the previousUserSemanticsenum inui_semantics.dart. -
New top-level
Sessionenum insemantics.dartcovering the OTel-specsession.*keys:sessionId,sessionPreviousId. Spec-only subset of the previousSessionViewSemantics. -
Spec-derived metric-name enums in new
semantic_metrics.dart. Covers every metric in the OTel attribute registry except the language-runtime namespaces (jvm.*,go.*,nodejs.*,cpython.*,v8js.*,kestrel.*,aspnetcore.*,signalr.*,openshift.*,nfs.*— Dart apps don't emit those). Generated by parsing the OTelmodel/*/metrics.yamlfiles, so name / instrument kind / unit string travel together:final metric = HttpMetric.serverRequestDuration; metric.name; // 'http.server.request.duration' metric.instrument; // SemanticInstrument.histogram metric.unit; // 's'Enums (15):
CicdMetric,ContainerMetric,DbMetric,DnsMetric,FaasMetric,GenAiMetric,HttpMetric,K8sMetric,McpMetric,MessagingMetric,OtelMetric,ProcessMetric,RpcMetric,SystemMetric,VcsMetric. NewOTelMetricinterface unifies them; newSemanticInstrumentenum names the four OTel instrument kinds. -
Spec event-name enum in new
semantic_events.dart— all 16 spec-defined event names (exception,feature_flag.evaluation,browser.web_vital,gen_ai.client.inference.operation.details, the per-protocol*.exceptionevents for HTTP/RPC/messaging/FaaS, plusazure.resource.log).SemanticEventexposes anamegetter;OTelEventinterface for switching.
Changed #
-
Breaking: Dropped the
Resourcesuffix from semconv-enum names where it didn't conflict with a built-in Dart / Flutter / common-package type.HttpResource.requestMethodis nowHttp.requestMethod,UrlResource.urlFullis nowUrl.urlFull, etc. — a straight find-and- replace migration for ~60 enums. Migration: replaceXResource→Xfor every enum below.Kept the
Resourcesuffix on five enums to avoid name clashes with common types:Enum Conflicts with ErrorResourcedart:coreErrorExceptionResourcedart:coreExceptionFileResourcedart:ioFileProcessResourcedart:ioProcessServerResourcepackage:grpcServerEventResourcepackage:webEventAll other 60+ enums dropped the suffix:
Client,Cloud,ComputeUnit,ComputeInstance,Database,Deployment,Device,Environment,FeatureFlag,GenAI,General,GraphQL,Host,Http,Kubernetes,Messaging,Network,OperatingSystem,RPC,Url,Service,SourceCode,TelemetryDistro,TelemetrySDK,UserAgent,Version, plus all 33 new enums in this release (Android,Artifact,Aws,Azure,Browser,Cassandra,Cicd,CloudEvents,Cloudfoundry,Code,Destination,Dns,Elasticsearch,Enduser,Faas,Gcp,Geo,Hardware,Heroku,Ios,Log,Oci,Opentracing,Otel,Peer,Profile,Source,System,Test,Thread,Tls,Vcs,Webengine). -
Breaking — file restructure.
lib/src/api/semantics/resource_semantics.dart→lib/src/api/semantics/semantics.dart(the new consolidated home for theOTelSemanticinterface and every attribute-key enum);lib/src/api/semantics/resource_values.dart→lib/src/api/semantics/semantic_values.dart. The previous standalonesemantics.dart(interface only) is deleted; its content moved to the top of the renamed file. Consumers using the package barrel (package:dartastic_opentelemetry_api/dartastic_opentelemetry_api.dart) are unaffected. Directsrc/api/semantics/...imports need the new paths. -
Breaking —
UserSemanticsremoved. Use the newUserenum insemantics.dartinstead. Migration:UserSemantics.userId→User.userId, etc. -
Breaking —
SessionViewSemanticssplit. OTel-spec keys (session.id,session.previous_id) →Sessioninsemantics.dart. Datadog/Dynatrace-style non-spec RUM keys (session_idunderscored,session.start,session.duration,view.*,action.count,user_satisfaction_score) → newRumSessionViewenum inui_semantics.dart.ui_semantics.dartis now strictly the home for Flutter / RUM non-spec conventions.
Added #
-
Typed value-set enums — a new
semantic_values.dartfile exposes enums for the 35+ OTel attributes whose spec entry defines a closed set of valid string values. Each value enum exposes its on-wire string via a.valuegetter and implementsOTelSemanticValuefor future polymorphic helpers. Highlights:CloudProvider,CloudPlatform,FaasInvokedProvider,FaasTriggerHostArch,OsTypeHttpRequestMethod,HttpConnectionStateNetworkType,NetworkTransport,NetworkConnectionType,NetworkIoDirectionDbSystem,DbClientConnectionState,CassandraConsistencyLevel,AzureCosmosdbConnectionMode,AzureCosmosdbConsistencyLevelMessagingSystem,MessagingOperationRpcSystem,RpcMessageType,GraphqlOperationTypeOpentracingRefType,OtelStatusCode,OtelSpanSamplingResult,TelemetrySdkLanguageSystemCpuState,SystemMemoryState,SystemFilesystemState,SystemFilesystemType,SystemPagingDirection,SystemPagingState,SystemPagingType,SystemProcessStatus,DiskIoDirection,LogIostreamIosAppState,AndroidAppStateAwsEcsLaunchTypeCicdPipelineRunState,CicdPipelineTaskType,CicdWorkerStateHardwareType,TlsProtocolNameVcsChangeState,VcsLineChangeType,VcsRefTypeTestCaseResultStatus,TestSuiteRunStatusProfileFrameTypeGenAiOperationName,GenAiSystem,GenAiTokenTypeContainerCpuState,ProcessContextSwitchType,ProcessPagingFaultType
Usage:
OTelAPI.attributesFromSemanticMap({ Database.dbSystemName: DbSystem.postgresql.value, Cloud.cloudProvider: CloudProvider.gcp.value, Network.networkTransport: NetworkTransport.quic.value, }); -
Comprehensive semconv-enum coverage of the OTel attribute registry. Every top-level registry namespace that wasn't already represented now has a typed enum. Consumers can keep using raw strings for app-specific keys, but for spec-defined attributes there is now a typed-enum entry, making typos at the call site a compile error.
New enums (33):
AndroidResource—android.os.api_level,android.app.state,android.stateArtifactResource— software-artifact / supply-chain (artifact.attestation.*,artifact.hash,artifact.purl,artifact.version, etc.)AwsResource— ECS / EKS / Lambda / S3 / CloudWatch Logs / DynamoDB attributes (aws.ecs.*,aws.eks.cluster.arn,aws.lambda.invoked_arn,aws.s3.*,aws.dynamodb.*,aws.log.*,aws.request_id)AzureResource—azure.client.id,azure.cosmosdb.*, plus the legacyaz.namespace/az.service_request_idkeys still emitted by some SDKsBrowserResource—browser.brands,browser.language,browser.mobile,browser.platform(matches what the SDK web detector emits)CassandraResource—cassandra.consistency.level,cassandra.coordinator.dc, etc.CicdResource— pipeline / task / worker attributes (cicd.pipeline.*,cicd.worker.*,cicd.system.component)CloudEventsResource—cloudevents.event_id,cloudevents.event_source,cloudevents.event_spec_version,cloudevents.event_subject,cloudevents.event_typeCloudfoundryResource— Cloud Foundry platform attrs (cloudfoundry.app.*,cloudfoundry.org.*,cloudfoundry.process.*,cloudfoundry.space.*,cloudfoundry.system.*)CodeResource— source-link attrs (code.function.name,code.file.path,code.line.number,code.column.number,code.namespace,code.stacktrace)DestinationResource—destination.address,destination.port(mirror ofServerResourcefor outbound non-HTTP)DnsResource—dns.question.name,dns.answersElasticsearchResource—elasticsearch.cluster.name,elasticsearch.node.name,elasticsearch.node.versionEnduserResource—enduser.id,enduser.role,enduser.scope(separate fromuser.*;enduser.*is what services set about the end user they're serving)EventResource—event.name(used by the logs signal)FaasResource— Function-as-a-Service attrs (faas.coldstart,faas.invoked_*,faas.trigger, etc.)GcpResource—gcp.client.service,gcp.cloud_run.job.*,gcp.gce.instance.*GeoResource—geo.continent.code,geo.country.iso_code,geo.locality.name,geo.location.lat,geo.location.lon,geo.postal_code,geo.region.iso_codeHardwareResource—hardware.id,hardware.name,hardware.parent,hardware.type,hardware.serial_number,hardware.vendor,hardware.modelHerokuResource—heroku.app.id,heroku.release.commit,heroku.release.creation_timestampIosResource—ios.app.state,ios.stateLogResource—log.iostream,log.file.*,log.record.original,log.record.uidNetworkResource— addednetworkProtocolName(network.protocol.name),networkProtocolVersion(network.protocol.version), andnetworkTransport(network.transport) — current OTel semconv keys for the wire protocol an HTTP client / server is speaking overOciResource—oci.manifest.digestOpentracingResource—opentracing.ref_typeOtelResource—otel.scope.name,otel.scope.version,otel.status_code,otel.status_description,otel.span.sampling_result, plus the deprecated-but-still-emittedotel.library.name/otel.library.versionPeerResource—peer.serviceProfileResource—profile.frame.type(experimental profiling signal)SourceResource—source.address,source.port(mirror ofClientResourcefor inbound non-HTTP)SystemResource— system-level metric attrs for CPU / memory / disk / network / filesystem / paging / process (used by the SDK's auto-collected runtime metrics)TestResource—test.case.name,test.case.result.status,test.suite.name,test.suite.run.statusThreadResource—thread.id,thread.nameTlsResource— full TLS connection attribute set (tls.cipher,tls.protocol.*,tls.client.*,tls.server.*)UserAgentResource—user_agent.original,user_agent.name,user_agent.version— the OTel semconv user-agent attributes set by HTTP-client instrumentation (e.g.dartastic_dio_otel) on each outbound requestVcsResource— version-control attrs (vcs.repository.url.full,vcs.ref.head.*,vcs.change.*,vcs.owner.name,vcs.provider.name, etc.)WebengineResource—webengine.description,webengine.name,webengine.version
-
Backfilled current-spec keys on
DatabaseResource— the olderdb.system/db.name/db.statement/db.operationentries are retained for back-compat, with the newer formalized keys added alongside them:dbSystemName(db.system.name),dbNamespace(db.namespace),dbOperationName(db.operation.name),dbOperationBatchSize(db.operation.batch.size),dbQueryText(db.query.text),dbQuerySummary(db.query.summary),dbResponseStatusCode(db.response.status_code),dbStoredProcedureName(db.stored_procedure.name),dbClientConnectionState(db.client.connection.state),dbClientConnectionPoolName(db.client.connection.pool.name),dbClientConnectionUsedState(db.client.connection.used.state). -
Backfilled current-spec keys on
ComputeUnitResource(which holds thecontainer.*registry):containerImageTags(container.image.tags, the pluralized form that replaces the legacycontainer.image.tag),containerImageId(container.image.id),containerImageRepoDigests(container.image.repo_digests),containerCommand(container.command),containerCommandArgs(container.command_args),containerCommandLine(container.command_line),containerCsiPluginName(container.csi.plugin.name),containerCsiVolumeId(container.csi.volume.id),containerLabels(container.labels).
1.0.0-beta.5 - 2026-05-10 #
Added #
-
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.
1.0.0-beta.4 - 2026-05-10 #
Added #
OTelAPI.loggerProviders()— returns the global defaultAPILoggerProviderplus any named providers added viaOTelAPI.addLoggerProvider(name). Parallel to the existingtracerProviders()andmeterProviders(). Backed by a newOTelFactory.getLoggerProviders()so SDK implementations get the same enumeration. LetsOTel.shutdown()in the SDK iterate over named LoggerProviders the way it already does for tracer / meter providers — without this,OTel.addLoggerProvider(name)consumers had to remember to shut each one down manually.
1.0.0-beta.3 - 2026-05-10 #
Fixed #
- Breaking:
ServiceResource.serviceResourcepace(keyservice.Resourcepace) was a mangled find/replace artifact (Name→Resourceaccidentally hitserviceNamespace). Restored the correct OTel semconv entry:ServiceResource.serviceNamespacewith keyservice.namespace. Migration: replaceServiceResource.serviceResourcepacewithServiceResource.serviceNamespace.
1.0.0-beta.2 - 2026-05-08 #
Added #
DatabaseResource.dbCollectionName(db.collection.name) — current OTel semconv key, replaces the deprecateddb.sql.table.DatabaseResource.dbResponseReturnedRows(db.response.returned_rows) — current OTel semconv key for the row count returned by a database operation.UserSemantics.userRoles(user.roles) — current OTel semconv key, an array of roles assigned to a user.
Changed #
- README and example renamed the placeholder
AppAttributeenum toExampleAttribute(so readers can't blindly copy the name) and dropped the redundantapp.prefix from invented demo keys. Where current OTel semconv keys exist, the example now uses the API's typed enums (e.g.DatabaseResource.dbCollectionName,UserSemantics.userRoles) instead of an app-defined fallback.
Removed #
- Breaking:
UserSemantics.userRole(singularuser.role). The singular form is an anti-pattern — users typically have multiple roles. UseUserSemantics.userRoles(user.roles) and pass aList<String>instead.
1.0.0-beta.1 - 2026-05-07 #
Fixed #
Context.runIsolate()now marks the deserializedSpanContextasisRemote = trueon the receiving side. Previously the parent isolate's local SpanContext (withisRemote = false) was restored verbatim, sotracer.startSpanin the new isolate fell into the "no parent" branch and produced a fresh root span instead of a child of the parent. This now matches the W3C trace-context-from-HTTP semantic — a SpanContext that crossed a process or isolate boundary is treated as remote and parented correctly.
1.0.0-beta - 2026-05-07 #
Added #
- (Thank you to Kevin Moore @kevmoo)
Context.run()andContext.runSync()— Zone-based implicit context propagation. These are the spec-aligned way to attach a context for a scope of execution and ensure it propagates correctly acrossawaits and async callbacks. - (Thank you to Kevin Moore @kevmoo)
isTransferableflag onContextKey(defaultfalse) to opt custom keys into cross-isolate transfer viaContext.runIsolate(). ServerResourceandUrlResourcesemantic resource enums.
Changed #
- Breaking:
tracer.startSpan()no longer automatically activates the span in the current context, aligning with the OpenTelemetry specification. Usetracer.withSpan/withSpanAsync(orContext.runSync/Context.run) to make a span active for a scope. - Breaking:
Context.currentWithBaggage()is now pure — it returns a Context with Baggage but no longer mutatesContext.current. Pair the returned Context withrunSync/runif you need it active. - Breaking: Custom values stored via
ContextKeyare no longer transferred across isolate boundaries by default. PassisTransferable: truewhen creating the key to opt in. Built-inBaggageandSpanContextcontinue to transfer unconditionally. APITracer.withSpan()andwithSpanAsync()now use Zone-based context propagation (Context.runSync/Context.run) for correct behavior across async boundaries (no-op implementation only).- README and example updated to demonstrate Zone-based context management.
Deprecated #
- The static
Context.currentsetter. Setting it does not propagate acrossZones, which produces incorrect context inside async callbacks. UseContext.run()orContext.runSync()instead.
Fixed #
APITracer.createSpan()now correctly inherits parent spans from the providedcontextparameter orContext.current. Previously these were ignored.Context.runIsolate()now serializes the specific Context instance it was called on, not the globalContext.current.Context.runIsolate()no longer mutates the parent isolate's_currentContexton return — eliminates a case where Zone-bound context could leak into the parent's static field.nowAsNanos()no longer loses precision on JS. The 64-bit wrap now happens before the multiplication by 1000.
1.0.0-alpha - 2025-12-22 #
Changed #
Documentation, updated to 1.0.0-alpha release candidate, matching dartastic_opentelemetry
0.9.0 - 2025-12-14 #
Added #
Logs signal, kudos to https://github.com/yuzurihaaa
0.8.3 - 2025-06-06 #
0.8.2 - 2025-06-05 #
Changed #
- Added instrumentationScope() to API
- Removed _getAndCacheOtelFactory() check from getTracerProviders/getMeterProviders
0.8.0 - 2025-05-01 #
Added #
- Initial public release of the OpenTelemetry API for Dart
- Core abstractions for traces, metrics and common (baggage, context)
- Context propagation mechanisms
- Implementation of the OpenTelemetry specification
- No-op implementations of all interfaces
- Comprehensive test suite
- Basic examples
Compliance #
- Implements OpenTelemetry API specification v1.42