{"id":27150,"library":"mongo-tooling-metrics","title":"Mongo Tooling Metrics","description":"A slim library which leverages Pydantic to reliably collect type-enforced metrics and store them to MongoDB. Version 1.0.8 supports Python >=3.7,<4.0. Low release cadence.","status":"active","version":"1.0.8","language":"python","source_language":"en","source_url":"https://github.com/your-org/mongo-tooling-metrics","tags":["mongodb","metrics","pydantic","telemetry"],"install":[{"cmd":"pip install mongo-tooling-metrics","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"Hyphen in package name not allowed in Python imports; use underscore.","wrong":"from mongo-tooling-metrics import MetricCollector","symbol":"MetricCollector","correct":"from mongo_tooling_metrics import MetricCollector"},{"note":"MetricsConfig is exposed at package level; importing from submodule may break.","wrong":"from mongo_tooling_metrics.config import MetricsConfig","symbol":"MetricsConfig","correct":"from mongo_tooling_metrics import MetricsConfig"}],"quickstart":{"code":"from mongo_tooling_metrics import MetricCollector, MetricsConfig\nimport os\n\nconfig = MetricsConfig(\n    mongo_uri=os.environ.get('MONGO_URI', 'mongodb://localhost:27017'),\n    database_name='metrics',\n    collection_name='my_metrics'\n)\ncollector = MetricCollector(config)\ncollector.send_gauge('my_gauge', 42)\nprint('Metric sent successfully.')","lang":"python","description":"Initialize MetricsConfig with MongoDB URI and collection details, then create a MetricCollector and send a gauge metric."},"warnings":[{"fix":"Ensure metric values are numeric (int or float).","message":"MetricCollector.send_gauge() and send_counter() accept only int or float values; passing a string will raise a ValidationError silently if using Pydantic v1?","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Enable logging or check the return value of send methods if available.","message":"If MongoDB connection fails, metrics are silently dropped; no exception is raised by default.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use the correct import: from mongo_tooling_metrics import MetricCollector","cause":"Attempted to import using the package name with hyphens.","error":"ImportError: cannot import name 'MetricCollector' from 'mongo-tooling-metrics'"},{"fix":"Ensure mongo_uri is a string, e.g., os.environ.get('MONGO_URI', 'mongodb://localhost:27017')","cause":"Passed a non-string value (e.g., None) for mongo_uri.","error":"pydantic.error_wrappers.ValidationError: 1 validation error for MetricsConfig\nmongo_uri\n  str type expected (type=type_error.str)"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}