dvTracedDatabaseCall<T> function
Runs body, one statement against a database of kind system
(sqlite, postgresql, mysql, other_sql), as a client span under the
current one and as a db.client.operation.duration observation.
Only inside a trace. A query outside any span is a queue poll or a cache
sweep, and a root span per poll every second is not a trace anybody
wants. And never with the values: sql is recorded with its literals
replaced by ?, and bound parameters are not recorded at all -- the
statement says what was asked, the values are whose data it was.
Implementation
Future<T> dvTracedDatabaseCall<T>(
String system,
String sql,
Future<T> Function() body, {
String? namespace,
}) {
final bool semantic = DVObservability.semanticMetrics;
final DVSpan? parent =
DVObservability.requestTracing ? dvCurrentSpan : null;
if (parent == null && !semantic) return body();
return _traced(system, sql, body, parent, semantic, namespace);
}