lancedb/lancedb · warning · UserWarning

Could not install the LanceDB metrics recorder: another…

Error message

Could not install the LanceDB metrics recorder: another `metrics` recorder is already installed in this process. LanceDB metrics will not be exported via OpenTelemetry.

What it means

`instrument_lancedb_metrics()` could not register its OpenTelemetry metrics recorder because another `opentelemetry-metrics` recorder is already set on the global MeterProvider for this process. LanceDB metrics will not be exported; the function warns and returns False instead of raising.

Solutions

  1. Integrate LanceDB metrics into the existing recorder instead of installing a second one (set up OTel manually and export LanceDB's meters)
  2. Call instrument_lancedb_metrics() once, before any other OTel metrics setup
  3. Check the return value and skip LanceDB instrumentation if False
  4. Remove duplicate OTel SDK initialization from other libraries

Example fix

// before
instrument_lancedb_metrics()  # warns: recorder already installed
// after
ok = instrument_lancedb_metrics()
if not ok:
    # export lancedb metrics via the already-installed OTel recorder
    configure_existing_meter_provider()
Defensive patterns

Strategy: try-catch

Validate before calling

from opentelemetry.metrics import get_meter_provider, _internal
ok = instrument_lancedb_metrics()  # check return value before assuming export
if not ok:
    print("LanceDB metrics not registered; another recorder is active")

Try / catch

import warnings
with warnings.catch_warnings(record=True) as caught:
    warnings.simplefilter("always")
    ok = instrument_lancedb_metrics()
if not ok:
    attach_lancedb_meters_to_existing_provider()

Prevention

When it happens

Trigger: Calling `instrument_lancedb_metrics()` after another library (or a prior call) has already set a global metrics reader/recorder via OTel API.

Common situations: Apps where Prometheus, Datadog, or the app itself already installed an OTel metrics view; importing/instrumenting in multiple modules; test processes reusing one MeterProvider.

Understand the failure class

Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.

Related errors


AI-assisted analysis of lancedb/lancedb@c7b051aff7 (2026-09-08). Data as JSON: /api/errors/eb8d6f51506cdb32. Report an issue: GitHub.

Appendix: source

Thrown at python/python/lancedb/otel.py:81

    -----
    Requires the OpenTelemetry API (``pip install lancedb[otel]``) and, to
    actually export, an OpenTelemetry SDK (``pip install opentelemetry-sdk``)
    configured by the application. Calling this more than once is safe;
    instruments are created only on the first successful call.
    """
    global _INSTRUMENTED

    try:
        from opentelemetry.metrics import Observation, get_meter_provider
    except ImportError as exc:
        raise ImportError(
            "instrument_lancedb_metrics requires the OpenTelemetry API/SDK. "
            "Install it with `pip install lancedb[otel]` or "
            "`pip install opentelemetry-sdk`."
        ) from exc

    if not register_lancedb_metrics_recorder():
        warnings.warn(
            "Could not install the LanceDB metrics recorder: another `metrics` "
            "recorder is already installed in this process. LanceDB metrics will "
            "not be exported via OpenTelemetry.",
            stacklevel=2,
        )
        return False

    if _INSTRUMENTED:
        return True

    provider = meter_provider or get_meter_provider()
    meter = provider.get_meter("lancedb")

    def scalar_callback(metric_name: str):
        def callback(_options):
            return [
                Observation(point.value, point.attributes)
                for point in snapshot_lancedb_metrics()

View on GitHub (pinned to c7b051aff7)