test(otelSpan) {
    let result

    // eslint-disable-next-line sonarjs/no-labels, no-labels
    detector: switch (otelSpan.kind) {
      case SpanKind.SERVER: {
        for (const rule of this.#serverRules.values()) {
          if (rule.matches(otelSpan) === true) {
            result = rule
            // eslint-disable-next-line no-labels
            break detector
          }
        }
        for (const rule of this.#fallbackServerRules.values()) {
          if (rule.matches(otelSpan) === true) {
            result = rule
            break
          }
        }
        break
      }

      case SpanKind.CONSUMER: {
        for (const rule of this.#consumerRules.values()) {
          if (rule.matches(otelSpan) === true) {
            result = rule
            // eslint-disable-next-line no-labels
            break detector
          }
        }
        for (const rule of this.#fallbackConsumerRules.values()) {
          if (rule.matches(otelSpan) === true) {
            result = rule
            break
          }
        }
        break
      }

      case SpanKind.CLIENT: {
        for (const rule of this.#clientRules.values()) {
          if (rule.matches(otelSpan) === true) {
            result = rule
            // eslint-disable-next-line no-labels
            break detector
          }
        }
        for (const rule of this.#fallbackClientRules.values()) {
          if (rule.matches(otelSpan) === true) {
            result = rule
            break
          }
        }
        break
      }

      // there currently are no producer rules, just fallback
      // if we add new rules they will have to be wired up
      case SpanKind.PRODUCER: {
        for (const rule of this.#producerRules.values()) {
          if (rule.matches(otelSpan) === true) {
            result = rule
            // eslint-disable-next-line no-labels
            break detector
          }
        }
        for (const rule of this.#fallbackProducerRules.values()) {
          if (rule.matches(otelSpan) === true) {
            result = rule
            break
          }
        }
        break
      }

      // there currently are no internal rules, just fallback
      // if we add new rules they will have to be wired up
      case SpanKind.INTERNAL: {
        for (const rule of this.#fallbackInternalRules.values()) {
          if (rule.matches(otelSpan) === true) {
            result = rule
            break
          }
        }
        break
      }
    }

    return result
  }
Determines if the span matches any known rules. If the span matches, then
the matching rule will be returned.

@param {object} otelSpan The span to test.

@returns {Rule|undefined} The matching rule, or `undefined` if no rules match.