LCOV - code coverage report
Current view: top level - src/trace/sampling - always_off_sampler.dart (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 3 3
Test Date: 2025-11-15 13:23:01 Functions: - 0 0

            Line data    Source code
       1              : // Licensed under the Apache License, Version 2.0
       2              : // Copyright 2025, Michael Bushe, All rights reserved.
       3              : 
       4              : import 'package:dartastic_opentelemetry_api/dartastic_opentelemetry_api.dart';
       5              : import 'sampler.dart';
       6              : 
       7              : /// A sampler that never samples any traces.
       8              : ///
       9              : /// This sampler implements the "always off" sampling strategy, which means
      10              : /// it will never record or sample any span regardless of any other factors.
      11              : /// This is useful for testing or production environments where you want to
      12              : /// temporarily disable sampling without changing the code.
      13              : ///
      14              : /// More information:
      15              : /// https://opentelemetry.io/docs/specs/otel/trace/sdk/#alwaysoff
      16              : class AlwaysOffSampler implements Sampler {
      17              :   /// Gets a description of this sampler.
      18              :   ///
      19              :   /// @return The string "AlwaysOffSampler"
      20            1 :   @override
      21              :   String get description => 'AlwaysOffSampler';
      22              : 
      23              :   /// Creates a new AlwaysOffSampler.
      24           81 :   const AlwaysOffSampler();
      25              : 
      26              :   /// Always returns a decision to drop the span.
      27              :   ///
      28              :   /// This method ignores all parameters and always returns a decision
      29              :   /// to drop the span (not record or sample it).
      30              :   ///
      31              :   /// @param parentContext Ignored
      32              :   /// @param traceId Ignored
      33              :   /// @param name Ignored
      34              :   /// @param spanKind Ignored
      35              :   /// @param attributes Ignored
      36              :   /// @param links Ignored
      37              :   /// @return A sampling result with decision set to drop
      38            5 :   @override
      39              :   SamplingResult shouldSample({
      40              :     required Context parentContext,
      41              :     required String traceId,
      42              :     required String name,
      43              :     required SpanKind spanKind,
      44              :     required Attributes? attributes,
      45              :     required List<SpanLink>? links,
      46              :   }) {
      47              :     return const SamplingResult(
      48              :       decision: SamplingDecision.drop,
      49              :       source: SamplingDecisionSource.tracerConfig,
      50              :     );
      51              :   }
      52              : }
        

Generated by: LCOV version 2.0-1