DVOpenTelemetryConfig class final

OpenTelemetry export as a project declares it, and as a deployment's environment overrides it.

dartvel:
  openTelemetry:
    enabled: true
    endpoint: https://collector.internal:4318   # OTLP/HTTP base URL
    protocol: http/protobuf                     # or http/json
    secretHeaders:                              # header: DV.Secrets name
      x-honeycomb-team: HONEYCOMB_API_KEY
    serviceName: shop                           # default: the package name
    resource:
      deployment.environment.name: production
    traces: true
    metrics: true
    logs: true
    sampler: parentbased_traceidratio
    ratio: 0.1

The pubspec is read strictly, for the reason every dartvel.* section is: each setting has a default, so a misspelt key or a string where a number belongs would be replaced by it and look exactly like a setting that was honoured. The standard OTEL_* variables are read leniently by withEnvironment, and win.

Constructors

DVOpenTelemetryConfig({bool enabled = false, String? endpoint, String? tracesEndpoint, String? metricsEndpoint, String? logsEndpoint, DVOtlpProtocol protocol = DVOtlpProtocol.httpProtobuf, Map<String, String> headers = const <String, String>{}, Map<String, String> secretHeaders = const <String, String>{}, String? serviceName, String? serviceVersion, Map<String, String> resourceAttributes = const <String, String>{}, bool traces = true, bool metrics = true, bool logs = true, DVOtelSampler sampler = DVOtelSampler.parentBasedAlwaysOn, double ratio = 1, int maxQueueSize = 2048, int maxExportBatchSize = 512, Duration scheduleDelay = const Duration(seconds: 5), Duration exportTimeout = const Duration(seconds: 10), Duration metricInterval = const Duration(seconds: 60), DVLogLevel logLevel = DVLogLevel.info})
const
DVOpenTelemetryConfig.parse(Object? section)
Reads the dartvel.openTelemetry section, or the defaults when there is none. Throws ArgumentError naming the key for anything it cannot honour.
factory

Properties

enabled → bool
Whether anything is exported at all. Off unless the project says so or the deployment names an OTLP endpoint.
final
endpoint → String?
The collector's OTLP/HTTP base URL; each signal is sent to <endpoint>/v1/<signal>. Null means http://localhost:4318.
final
exports → bool
Whether this configuration sends anything anywhere.
no setter
exportTimeout → Duration
How long one export request may take.
final
hashCode → int
The hash code for this object.
no setterinherited
headers → Map<String, String>
Headers sent with every export, with their values. Only the environment sets these (OTEL_EXPORTER_OTLP_HEADERS), because a header usually carries a key and a key in pubspec.yaml is published with the repository.
final
logLevel → DVLogLevel
The lowest log level exported.
final
logs → bool
final
logsEndpoint → String?
final
maxExportBatchSize → int
The most spans or records in one export request.
final
maxQueueSize → int
Spans or log records held for export; past it new ones are dropped and counted, never queued without bound.
final
metricInterval → Duration
How often metrics are collected and sent.
final
metrics → bool
final
metricsEndpoint → String?
final
protocol → DVOtlpProtocol
final
ratio → double
The share of traces a ratio sampler keeps, 0 to 1.
final
resourceAttributes → Map<String, String>
More resource attributes, as OTEL_RESOURCE_ATTRIBUTES gives them.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
sampler → DVOtelSampler
final
scheduleDelay → Duration
How long a part-full batch waits before it is sent anyway.
final
secretHeaders → Map<String, String>
Headers whose values are DV.Secrets names, resolved when export starts.
final
serviceName → String?
service.name. Null means the application's package name.
final
serviceVersion → String?
service.version. Null means the application's pubspec version.
final
traces → bool
Whether each signal is exported.
final
tracesEndpoint → String?
A signal's own URL, used exactly as given, as OTEL_EXPORTER_OTLP_<SIGNAL>_ENDPOINT is.
final

Methods

endpointFor(DVOtelSignal signal) → Uri?
Where signal is sent, or null when it is not exported.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDeclaration() → Map<String, Object?>
The section as parse reads it: what the build embeds in the generated runtime, and what a DartvelConfig class serialises to. Literal headers are never part of it.
toString() → String
A string representation of this object.
inherited
withEnvironment(Map<String, String> environment, {List<String>? warnings}) → DVOpenTelemetryConfig
This configuration with the standard OpenTelemetry environment variables applied over it.
withServiceDefaults({String? name, String? version}) → DVOpenTelemetryConfig
The same configuration with serviceName and serviceVersion filled in where nothing set them: the build passes the package's own.

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Constants

settings → const List<String>
The settings the pubspec section takes.