{"id":21388,"library":"glean-sdk","title":"Glean SDK","description":"Glean is a modern telemetry system by Mozilla for collecting, storing, and sending application metrics and pings. It provides a type-safe, cross-platform SDK with a metric API, automatic batching, and built-in pings. Current version is 67.2.0, with a regular release cadence aligned with Mozilla's release cycle.","status":"active","version":"67.2.0","language":"python","source_language":"en","source_url":"https://github.com/mozilla/glean","tags":["telemetry","metrics","mozilla","glean"],"install":[{"cmd":"pip install glean-sdk","lang":"bash","label":"install"}],"dependencies":[{"reason":"Required for datetime parsing","package":"python-dateutil","optional":false}],"imports":[{"note":"Import directly from 'glean' for the main API","wrong":"from glean_sdk import Glean","symbol":"Glean","correct":"from glean import Glean"},{"wrong":"from glean.metrics import MetricsPing","symbol":"MetricsPing","correct":"from glean import MetricsPing"},{"wrong":null,"symbol":"BooleanMetricType","correct":"from glean.metrics import BooleanMetricType"}],"quickstart":{"code":"import os\nimport glean\nfrom glean import Glean, Configuration, MetricsPing\nfrom glean.metrics import BooleanMetricType\n\n# Initialize Glean with a custom server endpoint\nserver_endpoint = os.environ.get('GLEAN_SERVER_ENDPOINT', 'https://example.com')\napp_id = 'my-app'\nGlean.initialize(\n    application_id=app_id,\n    application_version='1.0.0',\n    upload_enabled=True,\n    configuration=Configuration(\n        server_endpoint=server_endpoint\n    )\n)\n# Define a boolean metric\nmy_metric = BooleanMetricType(1, 'test.bool')\nprint('Glean initialized successfully')","lang":"python","description":"Minimal example initializing Glean with a configurable server endpoint and a boolean metric."},"warnings":[{"fix":"Replace all `from glean_sdk import ...` with `from glean import ...`.","message":"Starting from version 50.0.0, the import path changed from `glean_sdk` to `glean`. Old code using `import glean_sdk` will break. Update imports to `from glean import ...`.","severity":"breaking","affected_versions":">=50.0.0"},{"fix":"Remove MetricsPing usage; pings are now scheduled automatically. Use `Glean.initialize(...)` without explicitly scheduling pings.","message":"The `MetricsPing` class was removed in version 60.0.0 in favor of automatic ping scheduling. Code importing `MetricsPing` will break.","severity":"breaking","affected_versions":">=60.0.0"},{"fix":"Pass `data_dir` inside `Configuration` object.","message":"The `Glean.initialize()` parameter `data_dir` is deprecated since version 55.0.0. Use `Configuration.data_dir` instead.","severity":"deprecated","affected_versions":">=55.0.0"},{"fix":"Initialize Glean at application startup, guarded by a flag or on first launch.","message":"Glean must be initialized only once. Calling `Glean.initialize()` multiple times raises an error or does nothing silently. Ensure initialization happens early and only once.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure metric strings follow the '[a-z][a-z0-9-]{0,}[.][a-z][a-z0-9-]{0,}' pattern.","message":"Metric identifiers must be kebab-case (e.g., 'category.name'). Using underscores or invalid characters will cause errors during metric registration.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'67.2.0':44 'align':50 'api':33 'applic':16 'automat':34 'batch':35 'built':38 'built-in':37 'cadenc':49 'collect':12 'cross':27 'cross-platform':26 'current':41 'cycl':55 'glean':1,3,59 'metric':17,32,57 'modern':6 'mozilla':10,52,58 'ping':19,40 'platform':28 'provid':21 'regular':47 'releas':48,54 'safe':25 'sdk':2,29 'send':15 'store':13 'system':8 'telemetri':7,56 'type':24 'type-saf':23 'version':42","created_at":"2026-04-27T16:59:38.734139+00:00","updated_at":"2026-04-27T16:59:38.734139+00:00","problems":[{"fix":"Use 'from glean import ...' instead of 'from glean_sdk import ...'.","cause":"Old import path using glean_sdk instead of glean.","error":"glean_sdk is not defined"},{"fix":"Guard initialization with a flag or ensure single call at startup.","cause":"Calling Glean.initialize() more than once in the same process.","error":"Glean has already been initialized"},{"fix":"Use valid identifier format like 'test.bool'.","cause":"Metric identifier must be in kebab-case (e.g., 'my.metric').","error":"Invalid metric identifier: 'my_metric'"},{"fix":"Remove MetricsPing; ping scheduling is automatic.","cause":"MetricsPing was removed in version 60+.","error":"ImportError: cannot import name 'MetricsPing' from 'glean'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"67.5.0","cli_name":"","cli_version":null,"type":"library","homepage":"https://mozilla.github.io/glean/","github":"https://github.com/mozilla/glean","docs":null,"changelog":"https://mozilla.github.io/glean/book/appendix/changelog/sdk.html","pypi":"https://pypi.org/project/glean-sdk/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["observability","data","aws"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":null}}