{"record":{"id":"eb8d6f51506cdb32","repo":"lancedb/lancedb","slug":"could-not-install-the-lancedb-metrics-recorder-an-eb8d6f","errorCode":null,"errorMessage":"Could not install the LanceDB metrics recorder: another `metrics` recorder is already installed in this process. LanceDB metrics will not be exported via OpenTelemetry.","messagePattern":"Could not install the LanceDB metrics recorder: another `metrics` recorder is already installed in this process\\. LanceDB metrics will not be exported via OpenTelemetry\\.","errorType":"console","errorClass":"UserWarning","httpStatus":null,"severity":"warning","filePath":"python/python/lancedb/otel.py","lineNumber":81,"sourceCode":"    -----\n    Requires the OpenTelemetry API (``pip install lancedb[otel]``) and, to\n    actually export, an OpenTelemetry SDK (``pip install opentelemetry-sdk``)\n    configured by the application. Calling this more than once is safe;\n    instruments are created only on the first successful call.\n    \"\"\"\n    global _INSTRUMENTED\n\n    try:\n        from opentelemetry.metrics import Observation, get_meter_provider\n    except ImportError as exc:\n        raise ImportError(\n            \"instrument_lancedb_metrics requires the OpenTelemetry API/SDK. \"\n            \"Install it with `pip install lancedb[otel]` or \"\n            \"`pip install opentelemetry-sdk`.\"\n        ) from exc\n\n    if not register_lancedb_metrics_recorder():\n        warnings.warn(\n            \"Could not install the LanceDB metrics recorder: another `metrics` \"\n            \"recorder is already installed in this process. LanceDB metrics will \"\n            \"not be exported via OpenTelemetry.\",\n            stacklevel=2,\n        )\n        return False\n\n    if _INSTRUMENTED:\n        return True\n\n    provider = meter_provider or get_meter_provider()\n    meter = provider.get_meter(\"lancedb\")\n\n    def scalar_callback(metric_name: str):\n        def callback(_options):\n            return [\n                Observation(point.value, point.attributes)\n                for point in snapshot_lancedb_metrics()","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/lancedb/lancedb/blob/c7b051aff7039333a3f61b79217246c27676806a/python/python/lancedb/otel.py#L63-L99","documentation":"`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.","triggerScenarios":"Calling `instrument_lancedb_metrics()` after another library (or a prior call) has already set a global metrics reader/recorder via OTel API.","commonSituations":"Apps where Prometheus, Datadog, or the app itself already installed an OTel metrics view; importing/instrumenting in multiple modules; test processes reusing one MeterProvider.","solutions":["Integrate LanceDB metrics into the existing recorder instead of installing a second one (set up OTel manually and export LanceDB's meters)","Call instrument_lancedb_metrics() once, before any other OTel metrics setup","Check the return value and skip LanceDB instrumentation if False","Remove duplicate OTel SDK initialization from other libraries"],"exampleFix":"// before\ninstrument_lancedb_metrics()  # warns: recorder already installed\n// after\nok = instrument_lancedb_metrics()\nif not ok:\n    # export lancedb metrics via the already-installed OTel recorder\n    configure_existing_meter_provider()","handlingStrategy":"try-catch","validationCode":"from opentelemetry.metrics import get_meter_provider, _internal\nok = instrument_lancedb_metrics()  # check return value before assuming export\nif not ok:\n    print(\"LanceDB metrics not registered; another recorder is active\")","typeGuard":null,"tryCatchPattern":"import warnings\nwith warnings.catch_warnings(record=True) as caught:\n    warnings.simplefilter(\"always\")\n    ok = instrument_lancedb_metrics()\nif not ok:\n    attach_lancedb_meters_to_existing_provider()","preventionTips":["Initialize OTel metrics once per process, early","Check the boolean return of instrument_lancedb_metrics()","Coordinate with libraries (Prometheus/Datadog) that install their own metrics readers","In tests, isolate or reset the global MeterProvider"],"tags":["python","opentelemetry","metrics","conflict"],"backgroundTag":"conflicting-config-options","analyzedSha":"c7b051aff7039333a3f61b79217246c27676806a","analyzedAt":"2026-09-08T23:42:37.579Z","contentChangedAt":"2026-09-08T23:42:37.579Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}