let i, s, h;
function R(r) {
  i = r;
}
function N() {
  return i;
}
function w(r, e) {
  if (!i)
    throw new Error("MetricReporterFactory not configured. Call setMetricReporterFactory() first.");
  return i.createMetricReporter(r, e);
}
function y(r) {
  s = r;
}
function F() {
  return s;
}
function W(r) {
  h = r;
}
function D() {
  return h;
}
function O(r) {
  h?.reportUsage(r);
}
class m {
  /** @inheritdoc */
  reportHistogramMetrics() {
  }
  /** @inheritdoc */
  reportCountMetrics() {
  }
  /** @inheritdoc */
  wrapMetrics(e, t) {
    return t;
  }
  /** @inheritdoc */
  callWithMetrics(e, t) {
    return t();
  }
  /** @inheritdoc */
  wrapTrace(e, t, o) {
    return t;
  }
  /** @inheritdoc */
  callWithTrace(e, t) {
    return t();
  }
  /** @inheritdoc */
  Metric(e) {
    return (t, o, n) => n;
  }
  /** @inheritdoc */
  Trace(e, t) {
    return (o, n, a) => a;
  }
}
const M = new m();
class d {
  constructor(e, t) {
    this.namespace = e, this.scope = t;
  }
  delegate;
  resolve() {
    return this.delegate || (this.delegate = i ? i.createMetricReporter(this.namespace, this.scope) : void 0), this.delegate ?? M;
  }
  reportHistogramMetrics(e, t) {
    this.resolve().reportHistogramMetrics(e, t);
  }
  reportCountMetrics(e, t) {
    this.resolve().reportCountMetrics(e, t);
  }
  wrapMetrics(e, t) {
    return (...o) => this.resolve().callWithMetrics(e, () => t(...o));
  }
  callWithMetrics(e, t) {
    return this.resolve().callWithMetrics(e, t);
  }
  wrapTrace(e, t, o) {
    return (...n) => this.resolve().callWithTrace(e, () => t(...n));
  }
  callWithTrace(e, t) {
    return this.resolve().callWithTrace(e, t);
  }
  Metric(e) {
    const t = this.resolve.bind(this);
    return function(o, n, a) {
      const c = a.value, l = typeof n == "string" ? n : String(n), u = e || l, p = function(...g) {
        return t().callWithMetrics(u, () => c.apply(this, g));
      };
      a.value = p;
    };
  }
  Trace(e, t) {
    const o = this.resolve.bind(this);
    return function(n, a, c) {
      const l = c.value, u = typeof a == "string" ? a : String(a), p = e || u, g = function(...f) {
        return o().wrapTrace(
          p,
          l.bind(this),
          t
        )(...f);
      };
      c.value = g;
    };
  }
}
function b(r, e) {
  return new d(r, e);
}
function _(r) {
  return (e, t, o) => o;
}
const C = {
  /**
   * Decorator for tracing method execution.
   * No-op if telemetry decorators are not configured.
   */
  Trace(r) {
    return s ? s.Trace(r) : _();
  }
};
export {
  m as N,
  C as T,
  N as a,
  b,
  w as c,
  F as d,
  R as e,
  y as f,
  D as g,
  O as r,
  W as s
};
//# sourceMappingURL=telemetry-Bf0GI6nJ.js.map
