{
  "id": "task_libraries:metrics/python",
  "path": "/exapedia/python-metrics-libraries",
  "template": {
    "id": "task_libraries",
    "version": 4
  },
  "title": "Python metrics libraries",
  "answer": [
    {
      "t": "text",
      "text": "Python metrics libraries record numeric measurements from a running application, such as request counts, latencies, and queue lengths. An instrument such as a counter or histogram records each value with labels before an exporter sends the totals to a monitoring backend. These libraries let developers and on-call engineers see how production services behave over time."
    }
  ],
  "breadcrumb": [
    {
      "label": "Tools"
    },
    {
      "label": "Python metrics libraries"
    }
  ],
  "sections": [
    {
      "id": "libraries_popularity",
      "anchor": "popularity",
      "heading": "Popularity",
      "blocks": [
        {
          "b": "table",
          "columns": [
            "Library",
            "Monthly downloads",
            "Stars",
            "Last release",
            "License"
          ],
          "rows": [
            [
              [
                {
                  "t": "link",
                  "href": "#opentelemetry-api",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F129"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F130"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F136"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F133"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F131"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#prometheus-client",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F144"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F145"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F151"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F148"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F146"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#sentry-sdk",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F159"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F160"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F168"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F163"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F161"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#datadog",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F176"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F177"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F183"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F180"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F178"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#logfire",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F187"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F188"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F196"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F191"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F189"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#aws-lambda-powertools",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F205"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F206"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F214"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F209"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F207"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#statsd",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F222"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F223"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F229"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F226"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F224"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#aws-embedded-metrics",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F233"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F234"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F242"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F237"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F235"
                }
              ]
            ]
          ],
          "variant": "pop",
          "caption": [
            {
              "t": "text",
              "text": "Downloads: "
            },
            {
              "t": "text",
              "text": "PyPI"
            },
            {
              "t": "text",
              "text": ", last thirty days. Stars and releases: GitHub. Amber: no release in over a year."
            }
          ]
        }
      ],
      "note": [
        {
          "t": "link",
          "href": "#opentelemetry-api",
          "label": [
            {
              "t": "fact",
              "fact": "F129"
            }
          ]
        },
        {
          "t": "text",
          "text": " has the most monthly downloads in this comparison, at "
        },
        {
          "t": "fact",
          "fact": "F130"
        },
        {
          "t": "text",
          "text": "."
        }
      ]
    },
    {
      "id": "libraries_capabilities",
      "anchor": "capabilities",
      "heading": "Capabilities",
      "blocks": [
        {
          "b": "table",
          "columns": [
            "Library",
            "Prometheus scrape output",
            "Per-call metric sample rate"
          ],
          "rows": [
            [
              [
                {
                  "t": "link",
                  "href": "#opentelemetry-api",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F129"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F137"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F138"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#prometheus-client",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F144"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F152"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F153"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#sentry-sdk",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F159"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F169"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F170"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#datadog",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F176"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F184"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F185"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#logfire",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F187"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F197"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F198"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#aws-lambda-powertools",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F205"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F215"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F216"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#statsd",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F222"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F230"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F231"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#aws-embedded-metrics",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F233"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F243"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F244"
                }
              ]
            ]
          ],
          "variant": "cap"
        }
      ]
    },
    {
      "id": "libraries_entries",
      "anchor": "libraries",
      "heading": "Libraries",
      "blocks": [
        {
          "b": "entry",
          "anchor": "opentelemetry-api",
          "name": [
            {
              "t": "fact",
              "fact": "F129"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/open-telemetry/opentelemetry-python"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/opentelemetry-api"
            },
            {
              "label": "Docs",
              "href": "https://opentelemetry-python.readthedocs.io/en/latest/api/metrics.html"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F12"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F130"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F136"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F132"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F131"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://opentelemetry-python.readthedocs.io/en/latest/api/metrics.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F129"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F13"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F14"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F15"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F16"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F17"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F18"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F19"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F20"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F142"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F143"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/vectorize-io/hindsight",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F142"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def record_operation_result(\n    self,\n    operation: str,\n    bank_id: str,\n    outcome: OperationOutcome,\n    duration: float,\n    source: str = \"api\",\n    budget: str | None = None,\n    max_tokens: int | None = None,\n    memories_backend: str | None = None,\n):\n    \"\"\"Record a single completed operation (duration + count) with its outcome.\n\n    Direct (non-context-manager) recording for code paths that need explicit\n    outcome control rather than the exception-based ``record_operation`` — e.g.\n    the async worker, where deferrals/retries are not terminal outcomes and must\n    not be counted as completions.\n    \"\"\"\n    attributes = {\n        \"operation\": operation,\n        \"source\": source,\n        **self._tenant_attrs(),\n        **_backend_attrs(memories_backend_for(bank_id) if memories_backend is None else memories_backend),\n    }\n    if self._include_bank_id:\n        attributes[\"bank_id\"] = bank_id\n    if budget:\n        attributes[\"budget\"] = budget\n    if max_tokens:\n        attributes[\"max_tokens\"] = str(max_tokens)\n    attributes[\"success\"] = outcome.value\n\n    # Record duration\n    self.operation_duration.record(duration, attributes)\n\n    # Record operation count\n    self.operation_total.add(1, attributes)\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/vectorize-io/hindsight/blob/72e3454659bb94a345a27a2ad84f1c4b39b52572/hindsight-api-slim/hindsight_api/metrics.py#L772-L808",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F141"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20opentelemetry-api%20native%20metrics%20counters%20histograms%20instrumentation&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F129"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from opentelemetry import metrics\nfrom opentelemetry.sdk.metrics import MeterProvider\nfrom opentelemetry.sdk.metrics.export import InMemoryMetricReader\nreader = InMemoryMetricReader()\nmetrics.set_meter_provider(MeterProvider(metric_readers=[reader]))\ncounter = metrics.get_meter(\"demo\").create_counter(\"requests\")\ncounter.add(1)\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://opentelemetry-python.readthedocs.io/en/latest/api/metrics.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "example.py"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F134"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "prometheus-client",
          "name": [
            {
              "t": "fact",
              "fact": "F144"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/prometheus/client_python"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/prometheus-client"
            },
            {
              "label": "Docs",
              "href": "https://prometheus.github.io/client_python/instrumenting/counter/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F38"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F145"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F151"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F147"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F146"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://prometheus.github.io/client_python/instrumenting/counter/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F144"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F39"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F40"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F41"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F42"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F43"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F44"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F45"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F46"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F157"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F158"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/rycus86/prometheus_flask_exporter",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F157"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def after_request(response):\n    if hasattr(request, 'prom_do_not_track') or hasattr(request, 'prom_exclude_all'):\n        return response\n\n    if self.excluded_paths:\n        if any(pattern.match(request.path) for pattern in self.excluded_paths):\n            return response\n\n    if hasattr(request, 'prom_start_time') and self._not_yet_handled('duration_reported'):\n        total_time = max(default_timer() - request.prom_start_time, 0)\n\n        if callable(duration_group):\n            group = duration_group(request)\n        else:\n            group = getattr(request, duration_group)\n\n        request_duration_labels = {\n            'method': request.method,\n            'status': _to_status_code(response.status_code),\n            duration_group_name: group\n        }\n        request_duration_labels.update(labels.values_for(response))\n\n        request_duration_metric.labels(**request_duration_labels).observe(total_time)\n\n    if self._not_yet_handled('total_reported'):\n        request_total_metric.labels(\n            method=request.method, status=_to_status_code(response.status_code),\n            **labels.values_for(response)\n        ).inc()\n\n    return response\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/rycus86/prometheus_flask_exporter/blob/f2ba7ceb090647c6b6330ffe6c5b769139b2e10c/prometheus_flask_exporter/__init__.py#L464-L495",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F156"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20prometheus-client%20native%20metrics%20counters%20histograms%20instrumentation&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F144"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from prometheus_client import Counter\nrequests = Counter(\"demo_requests_total\", \"Processed requests\")\nrequests.inc()\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://github.com/prometheus/client_python/blob/master/prometheus_client/metrics.py",
                  "label": [
                    {
                      "t": "text",
                      "text": "_index.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F149"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "sentry-sdk",
          "name": [
            {
              "t": "fact",
              "fact": "F159"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/getsentry/sentry-python"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/sentry-sdk"
            },
            {
              "label": "Docs",
              "href": "https://docs.sentry.io/platforms/python/metrics/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F166"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F160"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F168"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F162"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F161"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://docs.sentry.io/platforms/python/metrics/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F159"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F174"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F175"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/Vocab-Apps/anki-hyper-tts",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F174"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def get_tts_audio_instrumented(self, source_text, voice: voice_module.TtsVoice_v3, options, audio_request_context):\n    with sentry_sdk.new_scope() as sentry_scope:\n        # inside this scope, we can set tags and context which will get unwound when this scope closes\n        sentry_scope.set_context(\"audio_voice\", {\n            'name': voice.name,\n            'voice_key': voice.voice_key,\n            'service': voice.service\n        })\n        sentry_scope.set_context(\"audio_options\", options)\n        sentry_scope.set_context('audio_request', {\n            'text': source_text\n        })\n        sentry_scope.set_context(\"audio_request_context\", {\n            'reason': audio_request_context.get_audio_request_reason_tag(),\n            'batch_uuid': audio_request_context.get_batch_uuid_str(),\n            'retry_count': audio_request_context.retry_count,\n            'retry_max': audio_request_context.retry_max,\n        })\n        use_clt = self.use_cloud_language_tools(voice)\n        sentry_scope.set_tags({\n            'hypertts_pro': use_clt,\n            'audio_service': voice.service,\n            'audio_request_reason': audio_request_context.audio_request_reason.name,\n            'final_attempt': audio_request_context.is_final_attempt()\n        })\n\n        metrics_attributes = {\n            \"service\": voice.service,\n            'hypertts_pro': use_clt,\n            'reason': audio_request_context.get_audio_request_reason_tag()\n        }\n\n        transaction_name = f'{voice.service}'\n        if use_clt:\n            transaction_name = f'cloudlanguagetools_{voice.service}'\n        current_txn = sentry_sdk.get_current_scope().transaction\n        if current_txn is not None:\n            cm = sentry_sdk.start_span(op=\"audio\", name=transaction_name)\n        else:\n            cm = sentry_sdk.start_transaction(op=\"audio\", name=transaction_name)\n        with cm as transaction:\n            try:\n                # audio request metrics\n                sentry_sdk.metrics.count(\n                    \"audio_request\",\n                    1,\n                    attributes=metrics_attributes,\n                )\n\n                tts_start = time.time()\n                result_audio = self.get_tts_audio_implementation(source_text, voice, options, audio_request_context)\n                tts_duration_ms = (time.time() - tts_start) * 1000\n\n                # success metrics\n                sentry_sdk.metrics.count(\n                    \"audio_request_success\",\n                    1,\n                    attributes=metrics_attributes,\n                )\n\n                sentry_sdk.metrics.distribution(\n                    \"audio_request_duration\",\n                    tts_duration_ms,\n                    unit=\"millisecond\",\n                    attributes=metrics_attributes,\n                )\n\n                return result_audio\n            except Exception as e:\n                sentry_scope.set_tags({\n                    'exception_type': type(e).__name__,\n                    'error_retryable': getattr(e, 'retryable', None),\n                    'is_audio_request_exception': True\n                })\n                sentry_scope.set_context(\"exception_type\", {\n                    'exception_type': type(e).__name__,\n                    'error_retryable': getattr(e, 'retryable', None)\n                })\n                # group by default fingerprint + service so that the same\n                # exception type from different services creates separate issues\n                sentry_scope.fingerprint = ['{{ default }}', voice.service]\n                # this the only place we capture audio request exceptions\n                sentry_sdk.capture_exception(e)\n\n                sentry_sdk.metrics.count(\n                    \"audio_request_failure\",\n                    1,\n                    attributes={**metrics_attributes, 'exception_type': type(e).__name__},\n                )\n\n                # let the caller handle the exception as well (e.g. for retry logic)\n                raise\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/Vocab-Apps/anki-hyper-tts/blob/e5f48ec691b92bfe8d55e70814ddab44a1a34f97/hypertts_addon/servicemanager.py#L299-L390",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F173"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=sentry-sdk%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F159"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import os\nimport sentry_sdk\nsentry_sdk.init(dsn=os.environ[\"SENTRY_DSN\"])\nsentry_sdk.metrics.count(\"demo.requests\", 1)\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://github.com/getsentry/sentry-python/blob/79eec68cc1f5ed082774320ebd6a51b08c243fe6/sentry_sdk/metrics.py",
                  "label": [
                    {
                      "t": "text",
                      "text": "metrics.py"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F164"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "datadog",
          "name": [
            {
              "t": "fact",
              "fact": "F176"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/DataDog/datadogpy"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/datadog"
            },
            {
              "label": "Docs",
              "href": "https://datadogpy.readthedocs.io/en/latest/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F63"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F177"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F183"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F179"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F178"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://datadogpy.readthedocs.io/en/latest/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F176"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F64"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F65"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F66"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F67"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F68"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F69"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F70"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F71"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from datadog import DogStatsd\nclient = DogStatsd(host=\"127.0.0.1\", port=8125)\nclient.increment(\"demo.requests\")\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://datadogpy.readthedocs.io/en/latest/",
                  "label": [
                    {
                      "t": "text",
                      "text": "index.rst"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20datadog%20native%20metrics%20counters%20histograms%20instrumentation&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "Find projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F176"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F181"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "logfire",
          "name": [
            {
              "t": "fact",
              "fact": "F187"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/pydantic/logfire"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/logfire"
            },
            {
              "label": "Docs",
              "href": "https://logfire.pydantic.dev/docs/reference/api/logfire/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F194"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F188"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F196"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F190"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F189"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://logfire.pydantic.dev/docs/reference/api/logfire/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F187"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F203"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F204"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/Haidra-Org/AI-Horde",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F203"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def record_request_assignment_pressure(\n    *,\n    gentype: str,\n    evidence: str,\n    might_stall: bool,\n    dispatch_opportunities: int,\n    lost_opportunities: int,\n    returned_capacity: int,\n    active_preceding_dispatches: int,\n    arriving_preceding_work: float,\n    returned_work: float,\n) -> None:\n    \"\"\"Record bounded diagnostics for one assignment-pressure calculation.\"\"\"\n\n    counts = (\n        dispatch_opportunities,\n        lost_opportunities,\n        returned_capacity,\n        active_preceding_dispatches,\n        arriving_preceding_work,\n        returned_work,\n    )\n    if any(count < 0 for count in counts):\n        raise ValueError(\"Assignment-pressure values must be non-negative\")\n    if lost_opportunities > dispatch_opportunities:\n        raise ValueError(\"Lost opportunities cannot exceed compatible dispatch opportunities\")\n    if evidence not in REQUEST_ASSIGNMENT_PRESSURE_EVIDENCE:\n        raise ValueError(f\"Unknown assignment-pressure evidence state: {evidence}\")\n\n    histogram_attributes: dict[str, str | bool] = {\n        \"horde.gentype\": gentype,\n        \"horde.might_stall\": might_stall,\n    }\n    request_assignment_pressure_dispatch_opportunities.record(dispatch_opportunities, histogram_attributes)\n    request_assignment_pressure_lost_opportunities.record(lost_opportunities, histogram_attributes)\n    request_assignment_pressure_returned_capacity.record(returned_capacity, histogram_attributes)\n    request_assignment_pressure_active_preceding.record(active_preceding_dispatches, histogram_attributes)\n    request_assignment_pressure_arriving_work.record(arriving_preceding_work, histogram_attributes)\n    request_assignment_pressure_returned_work.record(returned_work, histogram_attributes)\n    if dispatch_opportunities > 0:\n        request_assignment_pressure_lost_share.record(\n            lost_opportunities / dispatch_opportunities,\n            histogram_attributes,\n        )\n    request_assignment_pressure_samples.add(\n        1,\n        {\n            **histogram_attributes,\n            \"horde.evidence\": evidence,\n        },\n    )\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/Haidra-Org/AI-Horde/blob/80f649d59e4a5aaf7e94127889932cf74d5abd89/horde/metrics.py#L510-L560",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F202"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=logfire%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F187"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import os\nimport logfire\nlogfire.configure(token=os.environ[\"LOGFIRE_TOKEN\"])\ncounter = logfire.metric_counter(\"demo.requests\")\ncounter.add(1)\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://logfire.pydantic.dev/docs/reference/api/logfire/",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F192"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "aws-lambda-powertools",
          "name": [
            {
              "t": "fact",
              "fact": "F205"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/aws-powertools/powertools-lambda-python"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/aws-lambda-powertools"
            },
            {
              "label": "Docs",
              "href": "https://docs.powertools.aws.dev/lambda/python/latest/core/metrics/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F212"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F206"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F214"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F208"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F207"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://docs.powertools.aws.dev/lambda/python/latest/core/metrics/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F205"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F220"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F221"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/aws-samples/aws-serverless-ecommerce-platform",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F220"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "@metrics.log_metrics(raise_on_empty_metrics=False)\n@logger.inject_lambda_context\n@tracer.capture_lambda_handler\ndef handler(event, _):\n    \"\"\"\n    Lambda handler\n    \"\"\"\n\n    order_id = event[\"detail\"][\"orderId\"]\n\n    logger.info({\n        \"message\": \"Received failed order {}\".format(order_id),\n        \"orderId\": order_id\n    })\n\n    payment_token = get_payment_token(order_id)\n    cancel_payment(payment_token)\n    delete_payment_token(order_id)\n\n    # Add custom metrics\n    amount_lost = event[\"detail\"][\"total\"]\n\n    metrics.add_dimension(name=\"environment\", value=ENVIRONMENT)\n    metrics.add_metric(name=\"paymentCancelled\", unit=MetricUnit.Count, value=1)\n    metrics.add_metric(name=\"amountLost\", unit=MetricUnit.Count, value=amount_lost)\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/aws-samples/aws-serverless-ecommerce-platform/blob/3b9ef36dd3e338c8ab697c2bcb1b672e064e303c/payment/src/on_failed/main.py#L64-L88",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F219"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=aws-lambda-powertools%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F205"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from aws_lambda_powertools import Metrics\nfrom aws_lambda_powertools.metrics import MetricUnit\nmetrics = Metrics(namespace=\"Demo\")\nmetrics.add_metric(name=\"Requests\", unit=MetricUnit.Count, value=1)\nmetrics.flush_metrics()\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://docs.powertools.aws.dev/lambda/python/latest/api/metrics/metrics.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "metrics.html"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F210"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "statsd",
          "name": [
            {
              "t": "fact",
              "fact": "F222"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/jsocol/pystatsd"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/statsd"
            },
            {
              "label": "Docs",
              "href": "https://statsd.readthedocs.io/en/stable/reference.html"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F87"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F223"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F229"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F225"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F224"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://statsd.readthedocs.io/en/stable/reference.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F222"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F88"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F89"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F90"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F91"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F92"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F93"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F94"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F95"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from statsd import StatsClient\nclient = StatsClient(host=\"127.0.0.1\", port=8125)\nclient.incr(\"demo.requests\")\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://statsd.readthedocs.io/en/stable/reference.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.rst"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20statsd%20native%20metrics%20counters%20histograms%20instrumentation&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "Find projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F222"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F227"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "aws-embedded-metrics",
          "name": [
            {
              "t": "fact",
              "fact": "F233"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/awslabs/aws-embedded-metrics-python"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/aws-embedded-metrics"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F240"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F234"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F242"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F236"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F235"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://github.com/awslabs/aws-embedded-metrics-python",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F233"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F248"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F249"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/aws-samples/serverless-samples",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F248"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "@metric_scope\ndef lambda_handler(event, context, metrics):\n    route_key = event['routeKey']\n\n    response_body = {'Message': 'Unsupported route'}\n    status_code = 400\n    headers = {'Content-Type': 'application/json'}\n\n    # Put common business metrics using EMF\n    metric_payload = {}\n    metrics.put_dimensions({'Service': 'Locations'})\n    metrics.put_metric('ProcessedLocations', 1, 'Count')\n    metrics.set_property('requestId', event['requestContext']['requestId'])\n    metrics.set_property('routeKey', event['routeKey'])\n\n    try:\n        # Get all locations\n        if route_key == 'GET /locations':\n            metric_payload['operation'] = 'GET'\n            ddb_response = ddbTable.scan(Select='ALL_ATTRIBUTES')\n            response_body = ddb_response['Items']\n            status_code = 200\n        # Location CRUD operations\n        if route_key == 'GET /locations/{locationid}':\n            metric_payload['operation'] = 'GET'\n            metric_payload['locationid'] = event['pathParameters']['locationid']\n            ddb_response = ddbTable.get_item(\n                Key={'locationid': event['pathParameters']['locationid']}\n            )\n            if 'Item' in ddb_response:\n                response_body = ddb_response['Item']\n            else:\n                response_body = {}\n            status_code = 200\n        if route_key == 'DELETE /locations/{locationid}':\n            metric_payload['operation'] = 'DELETE'\n            metric_payload['locationid'] = event['pathParameters']['locationid']\n            ddbTable.delete_item(\n                Key={'locationid': event['pathParameters']['locationid']}\n            )\n            response_body = {}\n            status_code = 200\n        if route_key == 'PUT /locations':\n            request_json = json.loads(event['body'])\n            request_json['timestamp'] = datetime.now().isoformat()\n            if 'locationid' not in request_json:\n                request_json['locationid'] = str(uuid.uuid1())\n            metric_payload['operation'] = 'PUT'\n            metric_payload['locationid'] = request_json['locationid']\n            ddbTable.put_item(\n                Item=request_json\n            )\n            response_body = request_json\n            status_code = 200\n    except Exception as err:\n        status_code = 400\n        response_body = {'Error:': str(err)}\n        print(str(err))\n    metrics.set_property(\"Payload\", metric_payload)\n    return {\n        'statusCode': status_code,\n        'body': json.dumps(response_body),\n        'headers': headers\n    }\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/aws-samples/serverless-samples/blob/d8b80a19a88dbc596d2e2ead2c466fc2780f1eb0/serverless-rest-api/python-http-cdk/src/api/locations.py#L19-L82",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F247"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=aws-embedded-metrics%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F233"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from aws_embedded_metrics import metric_scope\n@metric_scope\ndef record_request(metrics):\n    metrics.put_metric(\"Requests\", 1, \"Count\")\nrecord_request()\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://github.com/awslabs/aws-embedded-metrics-python",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F238"
            }
          ]
        }
      ]
    }
  ],
  "questions": [
    {
      "q": "Which Python metrics library should I use?",
      "a": [
        {
          "t": "link",
          "href": "#opentelemetry-api",
          "label": [
            {
              "t": "fact",
              "fact": "F129"
            }
          ]
        },
        {
          "t": "text",
          "text": " suits applications that want vendor-neutral instruments and a choice of backend. "
        },
        {
          "t": "link",
          "href": "#prometheus-client",
          "label": [
            {
              "t": "fact",
              "fact": "F144"
            }
          ]
        },
        {
          "t": "text",
          "text": " suits services that Prometheus scrapes over HTTP. "
        },
        {
          "t": "link",
          "href": "#aws-lambda-powertools",
          "label": [
            {
              "t": "text",
              "text": "Powertools for AWS Lambda"
            }
          ]
        },
        {
          "t": "text",
          "text": " suits Lambda functions that publish to CloudWatch."
        }
      ]
    },
    {
      "q": "OpenTelemetry vs Prometheus: which should I use?",
      "a": [
        {
          "t": "link",
          "href": "#opentelemetry-api",
          "label": [
            {
              "t": "fact",
              "fact": "F129"
            }
          ]
        },
        {
          "t": "text",
          "text": " defines vendor-neutral instruments and leaves collection and export to a configured SDK. "
        },
        {
          "t": "link",
          "href": "#prometheus-client",
          "label": [
            {
              "t": "fact",
              "fact": "F144"
            }
          ]
        },
        {
          "t": "text",
          "text": " records labeled instruments in process and serves them in the Prometheus format over HTTP."
        }
      ]
    },
    {
      "q": "What is Logfire?",
      "a": [
        {
          "t": "link",
          "href": "#logfire",
          "label": [
            {
              "t": "text",
              "text": "Logfire"
            }
          ]
        },
        {
          "t": "text",
          "text": " is the Python SDK and command-line interface for Pydantic Logfire. It provides instruments and readers compatible with OpenTelemetry."
        }
      ]
    },
    {
      "q": "How do I add Prometheus metrics to a Python app?",
      "a": [
        {
          "t": "link",
          "href": "#prometheus-client",
          "label": [
            {
              "t": "fact",
              "fact": "F144"
            }
          ]
        },
        {
          "t": "text",
          "text": " creates labeled counters, histograms, and summaries in the application process. It then serves their values over HTTP for Prometheus to scrape."
        }
      ]
    },
    {
      "q": "What is Powertools for AWS Lambda?",
      "a": [
        {
          "t": "link",
          "href": "#aws-lambda-powertools",
          "label": [
            {
              "t": "text",
              "text": "Powertools for AWS Lambda"
            }
          ]
        },
        {
          "t": "text",
          "text": " is a toolkit for Lambda functions with a metrics facade that writes the CloudWatch Embedded Metric Format by default."
        }
      ]
    }
  ],
  "facts": {
    "F1": {
      "label": "Library name, opentelemetry-api",
      "display": "OpenTelemetry API",
      "asOf": "2026-11-17"
    },
    "F2": {
      "label": "Monthly downloads, opentelemetry-api",
      "display": "700.9M",
      "asOf": "2026-11-17"
    },
    "F3": {
      "label": "License, opentelemetry-api",
      "display": "Apache-2.0",
      "asOf": "2026-11-17"
    },
    "F4": {
      "label": "Package release, opentelemetry-api",
      "display": "1.45.2, Oct 2026",
      "asOf": "2026-10-29"
    },
    "F5": {
      "label": "Package release date, opentelemetry-api",
      "display": "Oct 2026",
      "asOf": "2026-10-29"
    },
    "F6": {
      "label": "Repository stars, opentelemetry-api",
      "display": "2.7K",
      "asOf": "2026-11-17"
    },
    "F7": {
      "label": "Counters, opentelemetry-api",
      "display": "Via plugin",
      "asOf": "2026-11-17"
    },
    "F8": {
      "label": "Latency measurements, opentelemetry-api",
      "display": "Via plugin",
      "asOf": "2026-11-17"
    },
    "F9": {
      "label": "Metric dimensions, opentelemetry-api",
      "display": "Via plugin",
      "asOf": "2026-11-17"
    },
    "F10": {
      "label": "Pull endpoint, opentelemetry-api",
      "display": "Via plugin",
      "asOf": "2026-11-17"
    },
    "F11": {
      "label": "Install, opentelemetry-api",
      "display": "pip install opentelemetry-api opentelemetry-sdk opentelemetry-exporter-otlp-proto-grpc",
      "asOf": "2026-11-17"
    },
    "F12": {
      "label": "What it does, opentelemetry-api",
      "display": "Defines metric instruments and provider interfaces; an SDK supplies collection and exporters supply delivery.",
      "asOf": "2026-11-17"
    },
    "F13": {
      "label": "strengths lead, opentelemetry-api",
      "display": "Separates instrumentation from collection",
      "asOf": "2026-11-17"
    },
    "F14": {
      "label": "strengths, opentelemetry-api",
      "display": "Instrument library code without selecting its application’s metrics backend.",
      "asOf": "2026-11-17"
    },
    "F15": {
      "label": "strengths lead, opentelemetry-api",
      "display": "Associates attributes with measurements",
      "asOf": "2026-11-17"
    },
    "F16": {
      "label": "strengths, opentelemetry-api",
      "display": "Attach dimensions to measurements through the metrics API and an installed SDK.",
      "asOf": "2026-11-17"
    },
    "F17": {
      "label": "limitations lead, opentelemetry-api",
      "display": "API alone records nothing",
      "asOf": "2026-11-17"
    },
    "F18": {
      "label": "limitations, opentelemetry-api",
      "display": "Install and configure an SDK provider to collect measurements.",
      "asOf": "2026-11-17"
    },
    "F19": {
      "label": "limitations lead, opentelemetry-api",
      "display": "Global provider binds once",
      "asOf": "2026-11-17"
    },
    "F20": {
      "label": "limitations, opentelemetry-api",
      "display": "Configure the provider once during application startup.",
      "asOf": "2026-11-17"
    },
    "F21": {
      "label": "Quickstart, opentelemetry-api",
      "display": "# Copyright The OpenTelemetry Authors\n# SPDX-License-Identifier: Apache-2.0\n\nfrom collections.abc import Iterable\n\nfrom opentelemetry.exporter.otlp.proto.grpc.metric_exporter import (\n    OTLPMetricExporter,\n)\nfrom opentelemetry.metrics import (\n    CallbackOptions,\n    Observation,\n    get_meter_provider,\n    set_meter_provider,\n)\nfrom opentelemetry.sdk.metrics import MeterProvider\nfrom opentelemetry.sdk.metrics.export import PeriodicExportingMetricReader\n\nexporter = OTLPMetricExporter(insecure=True)\nreader = PeriodicExportingMetricReader(exporter)\nprovider = MeterProvider(metric_readers=[reader])\nset_meter_provider(provider)\n\n\ndef observable_counter_func(options: CallbackOptions) -> Iterable[Observation]:\n    yield Observation(1, {})\n\n\ndef observable_up_down_counter_func(\n    options: CallbackOptions,\n) -> Iterable[Observation]:\n    yield Observation(-10, {})\n\n\ndef observable_gauge_func(options: CallbackOptions) -> Iterable[Observation]:\n    yield Observation(9, {})\n\n\nmeter = get_meter_provider().get_meter(\"getting-started\", \"0.1.2\")\n\n# Counter\ncounter = meter.create_counter(\"counter\")\ncounter.add(1)\n\n# Async Counter\nobservable_counter = meter.create_observable_counter(\n    \"observable_counter\",\n    [observable_counter_func],\n)\n\n# UpDownCounter\nupdown_counter = meter.create_up_down_counter(\"updown_counter\")\nupdown_counter.add(1)\nupdown_counter.add(-5)\n\n# Async UpDownCounter\nobservable_updown_counter = meter.create_observable_up_down_counter(\n    \"observable_updown_counter\", [observable_up_down_counter_func]\n)\n\n# Histogram\nhistogram = meter.create_histogram(\"histogram\")\nhistogram.record(99.9)\n\n\n# Histogram with explicit bucket boundaries advisory\nhistogram = meter.create_histogram(\n    \"histogram_with_advisory\",\n    explicit_bucket_boundaries_advisory=[0.0, 1.0, 2.0],\n)\nhistogram.record(99.9)\n\n# Async Gauge\ngauge = meter.create_observable_gauge(\"gauge\", [observable_gauge_func])\n",
      "asOf": "2026-11-17"
    },
    "F22": {
      "label": "Project function, opentelemetry-api",
      "display": "def initialize_metrics(service_name: str = \"hindsight-api\", service_version: str = \"1.0.0\"):\n    \"\"\"\n    Initialize OpenTelemetry metrics with Prometheus exporter.\n\n    This should be called once during application startup.\n\n    Args:\n        service_name: Name of the service for resource attributes\n        service_version: Version of the service\n\n    Returns:\n        PrometheusMetricReader instance (for accessing metrics endpoint)\n    \"\"\"\n    global _meter\n\n    # Create resource with service information\n    resource = Resource.create(\n        {\n            \"service.name\": service_name,\n            \"service.version\": service_version,\n        }\n    )\n\n    # Create Prometheus metric reader\n    prometheus_reader = PrometheusMetricReader()\n\n    # Create view with custom bucket boundaries for duration histogram\n    duration_view = View(\n        instrument_name=\"hindsight.operation.duration\",\n        aggregation=ExplicitBucketHistogramAggregation(boundaries=DURATION_BUCKETS),\n    )\n\n    # Create view with custom bucket boundaries for LLM duration histogram\n    llm_duration_view = View(\n        instrument_name=\"hindsight.llm.duration\",\n        aggregation=ExplicitBucketHistogramAggregation(boundaries=LLM_DURATION_BUCKETS),\n    )\n\n    # Create view with custom bucket boundaries for HTTP request duration histogram\n    http_duration_view = View(\n        instrument_name=\"hindsight.http.duration\",\n        aggregation=ExplicitBucketHistogramAggregation(boundaries=HTTP_DURATION_BUCKETS),\n    )\n\n    # Create meter provider with Prometheus exporter and custom views\n    provider = MeterProvider(\n        resource=resource,\n        metric_readers=[prometheus_reader],\n        views=[\n            duration_view,\n            llm_duration_view,\n            http_duration_view,\n            View(\n                instrument_name=\"hindsight.event_loop.lag\",\n                aggregation=ExplicitBucketHistogramAggregation(boundaries=LOOP_LAG_BUCKETS),\n            ),\n        ],\n    )\n\n    # Set the global meter provider\n    metrics.set_meter_provider(provider)\n\n    # Get meter for this application\n    _meter = metrics.get_meter(__name__)\n\n    return prometheus_reader\n",
      "asOf": "2026-11-17"
    },
    "F23": {
      "label": "Project function reference, opentelemetry-api",
      "display": "metrics.py · initialize_metrics()",
      "asOf": "2026-11-17"
    },
    "F24": {
      "label": "Project repository, opentelemetry-api",
      "display": "vectorize-io/hindsight",
      "asOf": "2026-11-17"
    },
    "F25": {
      "label": "Project stars, vectorize-io/hindsight",
      "display": "61.5K",
      "asOf": "2026-11-17"
    },
    "F26": {
      "label": "Project push date, vectorize-io/hindsight",
      "display": "Nov 2026",
      "asOf": "2026-11-17"
    },
    "F27": {
      "label": "Library name, prometheus-client",
      "display": "Prometheus client",
      "asOf": "2026-11-17"
    },
    "F28": {
      "label": "Monthly downloads, prometheus-client",
      "display": "170.3M",
      "asOf": "2026-11-17"
    },
    "F29": {
      "label": "License, prometheus-client",
      "display": "Apache-2.0 AND BSD-2-Clause",
      "asOf": "2026-11-17"
    },
    "F30": {
      "label": "Package release, prometheus-client",
      "display": "0.26.0, Jul 2026",
      "asOf": "2026-07-24"
    },
    "F31": {
      "label": "Package release date, prometheus-client",
      "display": "Jul 2026",
      "asOf": "2026-07-24"
    },
    "F32": {
      "label": "Repository stars, prometheus-client",
      "display": "4.4K",
      "asOf": "2026-11-17"
    },
    "F33": {
      "label": "Counters, prometheus-client",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F34": {
      "label": "Latency measurements, prometheus-client",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F35": {
      "label": "Metric dimensions, prometheus-client",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F36": {
      "label": "Pull endpoint, prometheus-client",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F37": {
      "label": "Install, prometheus-client",
      "display": "pip install prometheus-client",
      "asOf": "2026-11-17"
    },
    "F38": {
      "label": "What it does, prometheus-client",
      "display": "Records application metrics and exposes an HTTP endpoint for Prometheus to scrape.",
      "asOf": "2026-11-17"
    },
    "F39": {
      "label": "strengths lead, prometheus-client",
      "display": "Serves a scrape endpoint",
      "asOf": "2026-11-17"
    },
    "F40": {
      "label": "strengths, prometheus-client",
      "display": "Expose metrics over HTTP with the built-in server.",
      "asOf": "2026-11-17"
    },
    "F41": {
      "label": "strengths lead, prometheus-client",
      "display": "Groups observations with labels",
      "asOf": "2026-11-17"
    },
    "F42": {
      "label": "strengths, prometheus-client",
      "display": "Separate related time series by method, endpoint, or other declared dimensions.",
      "asOf": "2026-11-17"
    },
    "F43": {
      "label": "limitations lead, prometheus-client",
      "display": "Summaries omit local quantiles",
      "asOf": "2026-11-17"
    },
    "F44": {
      "label": "limitations, prometheus-client",
      "display": "Choose a histogram when queries need latency percentiles.",
      "asOf": "2026-11-17"
    },
    "F45": {
      "label": "limitations lead, prometheus-client",
      "display": "Multiprocess mode restricts features",
      "asOf": "2026-11-17"
    },
    "F46": {
      "label": "limitations, prometheus-client",
      "display": "Custom collectors and label removal are unavailable in multiprocess deployments.",
      "asOf": "2026-11-17"
    },
    "F47": {
      "label": "Quickstart, prometheus-client",
      "display": "from prometheus_client import start_http_server, Summary\nimport random\nimport time\n\n# Create a metric to track time spent and requests made.\nREQUEST_TIME = Summary('request_processing_seconds', 'Time spent processing request')\n\n# Decorate function with metric.\n@REQUEST_TIME.time()\ndef process_request(t):\n    \"\"\"A dummy function that takes some time.\"\"\"\n    time.sleep(t)\n\nif __name__ == '__main__':\n    # Start up the server to expose the metrics.\n    start_http_server(8000)\n    # Generate some requests.\n    while True:\n        process_request(random.random())\n",
      "asOf": "2026-11-17"
    },
    "F48": {
      "label": "Project function, prometheus-client",
      "display": "def after_request(response):\n    if hasattr(request, 'prom_do_not_track') or hasattr(request, 'prom_exclude_all'):\n        return response\n\n    if self.excluded_paths:\n        if any(pattern.match(request.path) for pattern in self.excluded_paths):\n            return response\n\n    if hasattr(request, 'prom_start_time') and self._not_yet_handled('duration_reported'):\n        total_time = max(default_timer() - request.prom_start_time, 0)\n\n        if callable(duration_group):\n            group = duration_group(request)\n        else:\n            group = getattr(request, duration_group)\n\n        request_duration_labels = {\n            'method': request.method,\n            'status': _to_status_code(response.status_code),\n            duration_group_name: group\n        }\n        request_duration_labels.update(labels.values_for(response))\n\n        request_duration_metric.labels(**request_duration_labels).observe(total_time)\n\n    if self._not_yet_handled('total_reported'):\n        request_total_metric.labels(\n            method=request.method, status=_to_status_code(response.status_code),\n            **labels.values_for(response)\n        ).inc()\n\n    return response\n",
      "asOf": "2026-11-17"
    },
    "F49": {
      "label": "Project function reference, prometheus-client",
      "display": "__init__.py · after_request()",
      "asOf": "2026-11-17"
    },
    "F50": {
      "label": "Project repository, prometheus-client",
      "display": "rycus86/prometheus_flask_exporter",
      "asOf": "2026-11-17"
    },
    "F51": {
      "label": "Project stars, rycus86/prometheus_flask_exporter",
      "display": "686",
      "asOf": "2026-11-17"
    },
    "F52": {
      "label": "Project push date, rycus86/prometheus_flask_exporter",
      "display": "Mar 2025",
      "asOf": "2025-03-25"
    },
    "F53": {
      "label": "Library name, datadog",
      "display": "Datadog",
      "asOf": "2026-11-17"
    },
    "F54": {
      "label": "Monthly downloads, datadog",
      "display": "56.2M",
      "asOf": "2026-11-17"
    },
    "F55": {
      "label": "License, datadog",
      "display": "BSD-3-Clause",
      "asOf": "2026-11-17"
    },
    "F56": {
      "label": "Package release, datadog",
      "display": "0.56.0, Nov 2026",
      "asOf": "2026-11-04"
    },
    "F57": {
      "label": "Package release date, datadog",
      "display": "Nov 2026",
      "asOf": "2026-11-04"
    },
    "F58": {
      "label": "Repository stars, datadog",
      "display": "674",
      "asOf": "2026-11-17"
    },
    "F59": {
      "label": "Counters, datadog",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F60": {
      "label": "Latency measurements, datadog",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F61": {
      "label": "Metric dimensions, datadog",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F62": {
      "label": "Install, datadog",
      "display": "pip install datadog",
      "asOf": "2026-11-17"
    },
    "F63": {
      "label": "What it does, datadog",
      "display": "Submits application metrics to the Datadog Agent through its DogStatsD client.",
      "asOf": "2026-11-17"
    },
    "F64": {
      "label": "strengths lead, datadog",
      "display": "Tags individual measurements",
      "asOf": "2026-11-17"
    },
    "F65": {
      "label": "strengths, datadog",
      "display": "Attach tags and a sample rate when incrementing counters.",
      "asOf": "2026-11-17"
    },
    "F66": {
      "label": "strengths lead, datadog",
      "display": "Supports UDP and Unix sockets",
      "asOf": "2026-11-17"
    },
    "F67": {
      "label": "strengths, datadog",
      "display": "Choose the transport that fits the Agent deployment.",
      "asOf": "2026-11-17"
    },
    "F68": {
      "label": "limitations lead, datadog",
      "display": "Requires a running Agent",
      "asOf": "2026-11-17"
    },
    "F69": {
      "label": "limitations, datadog",
      "display": "Provide a reachable Datadog Agent for DogStatsD metrics.",
      "asOf": "2026-11-17"
    },
    "F70": {
      "label": "limitations lead, datadog",
      "display": "Buffered metrics need draining",
      "asOf": "2026-11-17"
    },
    "F71": {
      "label": "limitations, datadog",
      "display": "Wait for pending payloads before shutting down a buffered sender.",
      "asOf": "2026-11-17"
    },
    "F72": {
      "label": "Quickstart, datadog",
      "display": "from datadog.dogstatsd import DogStatsd\n\nclient = DogStatsd()\nclient.increment(\"home.page.hits\")\n",
      "asOf": "2026-11-17"
    },
    "F73": {
      "label": "Project function, datadog",
      "display": "def gauge(self, metric: str, value: float, labels: Optional[Dict] = None) -> None:\n    self.client.gauge(\n        metric,\n        value=value,\n        tags=self._encode_labels(labels),\n        sample_rate=self.rate,\n    )\n",
      "asOf": "2026-11-17"
    },
    "F74": {
      "label": "Project function reference, datadog",
      "display": "datadog.py · gauge()",
      "asOf": "2026-11-17"
    },
    "F75": {
      "label": "Project repository, datadog",
      "display": "faust-streaming/faust",
      "asOf": "2026-11-17"
    },
    "F76": {
      "label": "Project stars, faust-streaming/faust",
      "display": "1.9K",
      "asOf": "2026-11-17"
    },
    "F77": {
      "label": "Project push date, faust-streaming/faust",
      "display": "Oct 2026",
      "asOf": "2026-10-28"
    },
    "F78": {
      "label": "Library name, statsd",
      "display": "statsd",
      "asOf": "2026-11-17"
    },
    "F79": {
      "label": "Monthly downloads, statsd",
      "display": "9.7M",
      "asOf": "2026-11-17"
    },
    "F80": {
      "label": "License, statsd",
      "display": "MIT",
      "asOf": "2026-11-17"
    },
    "F81": {
      "label": "Package release, statsd",
      "display": "4.0.1, Nov 2022",
      "asOf": "2022-11-06"
    },
    "F82": {
      "label": "Package release date, statsd",
      "display": "Nov 2022",
      "asOf": "2022-11-06"
    },
    "F83": {
      "label": "Repository stars, statsd",
      "display": "553",
      "asOf": "2026-11-17"
    },
    "F84": {
      "label": "Counters, statsd",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F85": {
      "label": "Latency measurements, statsd",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F86": {
      "label": "Install, statsd",
      "display": "pip install statsd",
      "asOf": "2026-11-17"
    },
    "F87": {
      "label": "What it does, statsd",
      "display": "Sends counters and timings from Python applications to a StatsD daemon.",
      "asOf": "2026-11-17"
    },
    "F88": {
      "label": "strengths lead, statsd",
      "display": "Batches measurements into packets",
      "asOf": "2026-11-17"
    },
    "F89": {
      "label": "strengths, statsd",
      "display": "Use a pipeline to send several measurements together.",
      "asOf": "2026-11-17"
    },
    "F90": {
      "label": "strengths lead, statsd",
      "display": "Prefixes metric names",
      "asOf": "2026-11-17"
    },
    "F91": {
      "label": "strengths, statsd",
      "display": "Apply a shared prefix when constructing the client.",
      "asOf": "2026-11-17"
    },
    "F92": {
      "label": "limitations lead, statsd",
      "display": "Pipelines need thread isolation",
      "asOf": "2026-11-17"
    },
    "F93": {
      "label": "limitations, statsd",
      "display": "Create a separate pipeline for each thread.",
      "asOf": "2026-11-17"
    },
    "F94": {
      "label": "limitations lead, statsd",
      "display": "Timings use milliseconds",
      "asOf": "2026-11-17"
    },
    "F95": {
      "label": "limitations, statsd",
      "display": "Convert durations before passing them to timing.",
      "asOf": "2026-11-17"
    },
    "F96": {
      "label": "Quickstart, statsd",
      "display": "import statsd\nc = statsd.StatsClient('localhost', 8125)\nc.incr('foo')  # Increment the 'foo' counter.\nc.timing('stats.timed', 320)  # Record a 320ms 'stats.timed'.\n",
      "asOf": "2026-11-17"
    },
    "F97": {
      "label": "Project function, statsd",
      "display": "def on_message_in(self, tp: TP, offset: int, message: Message) -> None:\n    \"\"\"Call before message is delegated to streams.\"\"\"\n    super().on_message_in(tp, offset, message)\n\n    self.client.incr(\"messages_received\", rate=self.rate)\n    self.client.incr(\"messages_active\", rate=self.rate)\n    self.client.incr(f\"topic.{tp.topic}.messages_received\", rate=self.rate)\n    self.client.gauge(f\"read_offset.{tp.topic}.{tp.partition}\", offset)\n",
      "asOf": "2026-11-17"
    },
    "F98": {
      "label": "Project function reference, statsd",
      "display": "statsd.py · on_message_in()",
      "asOf": "2026-11-17"
    },
    "F99": {
      "label": "Project repository, statsd",
      "display": "faust-streaming/faust",
      "asOf": "2026-11-17"
    },
    "F100": {
      "label": "Project stars, faust-streaming/faust",
      "display": "1.9K",
      "asOf": "2026-11-17"
    },
    "F101": {
      "label": "Project push date, faust-streaming/faust",
      "display": "Oct 2026",
      "asOf": "2026-10-28"
    },
    "F102": {
      "label": "Developer need",
      "display": "Exposing a Prometheus scrape endpoint",
      "asOf": "2026-11-17"
    },
    "F103": {
      "label": "Why choose prometheus-client",
      "display": "a built-in HTTP metrics endpoint",
      "asOf": "2026-11-17"
    },
    "F104": {
      "label": "Developer need in introduction",
      "display": "exposing a Prometheus scrape endpoint",
      "asOf": "2026-11-17"
    },
    "F105": {
      "label": "Developer need",
      "display": "Keeping instrumentation independent of collection",
      "asOf": "2026-11-17"
    },
    "F106": {
      "label": "Why choose opentelemetry-api",
      "display": "API contracts separated from SDK collection",
      "asOf": "2026-11-17"
    },
    "F107": {
      "label": "Developer need in introduction",
      "display": "keeping instrumentation independent of collection",
      "asOf": "2026-11-17"
    },
    "F108": {
      "label": "Developer need",
      "display": "Batching StatsD measurements",
      "asOf": "2026-11-17"
    },
    "F109": {
      "label": "Why choose statsd",
      "display": "pipeline-based metric batches",
      "asOf": "2026-11-17"
    },
    "F110": {
      "label": "Developer need in introduction",
      "display": "batching StatsD measurements",
      "asOf": "2026-11-17"
    },
    "F111": {
      "label": "When to consider datadog",
      "display": "per-measurement tags for a Datadog Agent are needed",
      "asOf": "2026-11-17"
    },
    "F112": {
      "label": "Developer need",
      "display": "Tagging Datadog Agent measurements",
      "asOf": "2026-11-17"
    },
    "F113": {
      "label": "Why choose datadog",
      "display": "per-measurement tags and sampling",
      "asOf": "2026-11-17"
    },
    "F114": {
      "label": "Developer need in introduction",
      "display": "tagging Datadog Agent measurements",
      "asOf": "2026-11-17"
    },
    "F115": {
      "label": "Page introduction",
      "display": "Python metrics libraries let backend developers instrument application events and measurements.",
      "asOf": "2026-11-17"
    },
    "F116": {
      "label": "FAQ: Which package exposes metrics for Prometheus scraping?",
      "display": "The Prometheus client includes an HTTP server that exposes its metrics for scraping.",
      "asOf": "2026-11-17"
    },
    "F117": {
      "label": "FAQ: Can Prometheus metrics carry dimensions?",
      "display": "Declare label names and call labels to select a related time series.",
      "asOf": "2026-11-17"
    },
    "F118": {
      "label": "FAQ: Should Prometheus summaries calculate latency percentiles?",
      "display": "The Python client does not calculate summary quantiles locally; use a histogram instead.",
      "asOf": "2026-11-17"
    },
    "F119": {
      "label": "FAQ: Why are newly declared labeled metrics absent?",
      "display": "Labeled metrics are not initialized until label values are supplied; initialize expected values explicitly.",
      "asOf": "2026-11-17"
    },
    "F120": {
      "label": "FAQ: Does OpenTelemetry API export metrics by itself?",
      "display": "The API supplies a no-op implementation when an application does not install a supporting implementation.",
      "asOf": "2026-11-17"
    },
    "F121": {
      "label": "FAQ: Can an application replace its global OpenTelemetry provider repeatedly?",
      "display": "The global provider can be set only once; later attempts log a warning.",
      "asOf": "2026-11-17"
    },
    "F122": {
      "label": "FAQ: What else does the OpenTelemetry starter need?",
      "display": "The original example installs an SDK provider and periodic reader with a separate OTLP gRPC exporter.",
      "asOf": "2026-11-17"
    },
    "F123": {
      "label": "FAQ: Can statsd batch measurements?",
      "display": "Pipelines collect measurements until send, then pack them into UDP packets.",
      "asOf": "2026-11-17"
    },
    "F124": {
      "label": "FAQ: Can threads share a statsd pipeline?",
      "display": "Use a separate pipeline per thread because pipeline instances are not thread-safe.",
      "asOf": "2026-11-17"
    },
    "F125": {
      "label": "FAQ: Which duration unit does statsd expect?",
      "display": "Convert durations to milliseconds before recording timer values.",
      "asOf": "2026-11-17"
    },
    "F126": {
      "label": "FAQ: Does DogStatsD require a running service?",
      "display": "The Datadog Agent must be running and available for DogStatsD metrics.",
      "asOf": "2026-11-17"
    },
    "F127": {
      "label": "FAQ: Does using only DogStatsD require HTTP API keys?",
      "display": "API and app keys are not required when using only the DogStatsd client.",
      "asOf": "2026-11-17"
    },
    "F128": {
      "label": "FAQ: Which transports does the Datadog metrics client support?",
      "display": "The DogStatsD client supports UDP and Unix domain sockets.",
      "asOf": "2026-11-17"
    },
    "F129": {
      "label": "Library name, opentelemetry-api",
      "display": "opentelemetry-api",
      "asOf": "2026-11-20"
    },
    "F130": {
      "label": "Monthly downloads, opentelemetry-api",
      "display": "721.7M",
      "asOf": "2026-11-20"
    },
    "F131": {
      "label": "License, opentelemetry-api",
      "display": "Apache-2.0",
      "asOf": "2026-11-20"
    },
    "F132": {
      "label": "Package release, opentelemetry-api",
      "display": "1.45.2",
      "asOf": "2026-11-20"
    },
    "F133": {
      "label": "Package release date, opentelemetry-api",
      "display": "Oct 2026",
      "asOf": "2026-11-20"
    },
    "F134": {
      "label": "Install, opentelemetry-api",
      "display": "pip install opentelemetry-api opentelemetry-sdk",
      "asOf": "2026-11-20"
    },
    "F135": {
      "label": "Quickstart, opentelemetry-api",
      "display": "from opentelemetry import metrics\nfrom opentelemetry.sdk.metrics import MeterProvider\nfrom opentelemetry.sdk.metrics.export import InMemoryMetricReader\nreader = InMemoryMetricReader()\nmetrics.set_meter_provider(MeterProvider(metric_readers=[reader]))\ncounter = metrics.get_meter(\"demo\").create_counter(\"requests\")\ncounter.add(1)\n",
      "asOf": "2026-11-20"
    },
    "F136": {
      "label": "Repository stars, opentelemetry-api",
      "display": "2.7K",
      "asOf": "2026-11-20"
    },
    "F137": {
      "label": "Prometheus scrape output, opentelemetry-api",
      "display": "Via plugin",
      "asOf": "2026-11-20"
    },
    "F138": {
      "label": "Per-call metric sample rate, opentelemetry-api",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F139": {
      "label": "Collection and backend role, opentelemetry-api",
      "display": "Vendor-neutral instrument API; configured SDK/provider/readers implement collection and export.",
      "asOf": "2026-11-20"
    },
    "F140": {
      "label": "Project function, opentelemetry-api",
      "display": "def record_operation_result(\n    self,\n    operation: str,\n    bank_id: str,\n    outcome: OperationOutcome,\n    duration: float,\n    source: str = \"api\",\n    budget: str | None = None,\n    max_tokens: int | None = None,\n    memories_backend: str | None = None,\n):\n    \"\"\"Record a single completed operation (duration + count) with its outcome.\n\n    Direct (non-context-manager) recording for code paths that need explicit\n    outcome control rather than the exception-based ``record_operation`` — e.g.\n    the async worker, where deferrals/retries are not terminal outcomes and must\n    not be counted as completions.\n    \"\"\"\n    attributes = {\n        \"operation\": operation,\n        \"source\": source,\n        **self._tenant_attrs(),\n        **_backend_attrs(memories_backend_for(bank_id) if memories_backend is None else memories_backend),\n    }\n    if self._include_bank_id:\n        attributes[\"bank_id\"] = bank_id\n    if budget:\n        attributes[\"budget\"] = budget\n    if max_tokens:\n        attributes[\"max_tokens\"] = str(max_tokens)\n    attributes[\"success\"] = outcome.value\n\n    # Record duration\n    self.operation_duration.record(duration, attributes)\n\n    # Record operation count\n    self.operation_total.add(1, attributes)\n",
      "asOf": "2026-11-20"
    },
    "F141": {
      "label": "Project source file, opentelemetry-api",
      "display": "hindsight-api-slim/hindsight_api/metrics.py",
      "asOf": "2026-11-20"
    },
    "F142": {
      "label": "Project full_name, opentelemetry-api",
      "display": "vectorize-io/hindsight",
      "asOf": "2026-11-20"
    },
    "F143": {
      "label": "Project stargazers_count, opentelemetry-api",
      "display": "61.7K",
      "asOf": "2026-11-20"
    },
    "F144": {
      "label": "Library name, prometheus-client",
      "display": "prometheus-client",
      "asOf": "2026-11-20"
    },
    "F145": {
      "label": "Monthly downloads, prometheus-client",
      "display": "175.4M",
      "asOf": "2026-11-20"
    },
    "F146": {
      "label": "License, prometheus-client",
      "display": "Apache-2.0 AND BSD-2-Clause",
      "asOf": "2026-11-20"
    },
    "F147": {
      "label": "Package release, prometheus-client",
      "display": "0.26.0",
      "asOf": "2026-11-20"
    },
    "F148": {
      "label": "Package release date, prometheus-client",
      "display": "Jul 2026",
      "asOf": "2026-11-20"
    },
    "F149": {
      "label": "Install, prometheus-client",
      "display": "pip install prometheus-client",
      "asOf": "2026-11-20"
    },
    "F150": {
      "label": "Quickstart, prometheus-client",
      "display": "from prometheus_client import Counter\nrequests = Counter(\"demo_requests_total\", \"Processed requests\")\nrequests.inc()\n",
      "asOf": "2026-11-20"
    },
    "F151": {
      "label": "Repository stars, prometheus-client",
      "display": "4.4K",
      "asOf": "2026-11-20"
    },
    "F152": {
      "label": "Prometheus scrape output, prometheus-client",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F153": {
      "label": "Per-call metric sample rate, prometheus-client",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F154": {
      "label": "Collection and backend role, prometheus-client",
      "display": "In-process labeled instruments and native Prometheus HTTP exposition.",
      "asOf": "2026-11-20"
    },
    "F155": {
      "label": "Project function, prometheus-client",
      "display": "def after_request(response):\n    if hasattr(request, 'prom_do_not_track') or hasattr(request, 'prom_exclude_all'):\n        return response\n\n    if self.excluded_paths:\n        if any(pattern.match(request.path) for pattern in self.excluded_paths):\n            return response\n\n    if hasattr(request, 'prom_start_time') and self._not_yet_handled('duration_reported'):\n        total_time = max(default_timer() - request.prom_start_time, 0)\n\n        if callable(duration_group):\n            group = duration_group(request)\n        else:\n            group = getattr(request, duration_group)\n\n        request_duration_labels = {\n            'method': request.method,\n            'status': _to_status_code(response.status_code),\n            duration_group_name: group\n        }\n        request_duration_labels.update(labels.values_for(response))\n\n        request_duration_metric.labels(**request_duration_labels).observe(total_time)\n\n    if self._not_yet_handled('total_reported'):\n        request_total_metric.labels(\n            method=request.method, status=_to_status_code(response.status_code),\n            **labels.values_for(response)\n        ).inc()\n\n    return response\n",
      "asOf": "2026-11-20"
    },
    "F156": {
      "label": "Project source file, prometheus-client",
      "display": "prometheus_flask_exporter/__init__.py",
      "asOf": "2026-11-20"
    },
    "F157": {
      "label": "Project full_name, prometheus-client",
      "display": "rycus86/prometheus_flask_exporter",
      "asOf": "2026-11-20"
    },
    "F158": {
      "label": "Project stargazers_count, prometheus-client",
      "display": "686",
      "asOf": "2026-11-20"
    },
    "F159": {
      "label": "Library name, sentry-sdk",
      "display": "Sentry SDK",
      "asOf": "2026-11-20"
    },
    "F160": {
      "label": "Monthly downloads, sentry-sdk",
      "display": "157.9M",
      "asOf": "2026-11-20"
    },
    "F161": {
      "label": "License, sentry-sdk",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F162": {
      "label": "Package release, sentry-sdk",
      "display": "2.75.0",
      "asOf": "2026-11-20"
    },
    "F163": {
      "label": "Package release date, sentry-sdk",
      "display": "Nov 2026",
      "asOf": "2026-11-20"
    },
    "F164": {
      "label": "Install, sentry-sdk",
      "display": "pip install sentry-sdk",
      "asOf": "2026-11-20"
    },
    "F165": {
      "label": "Quickstart, sentry-sdk",
      "display": "import os\nimport sentry_sdk\nsentry_sdk.init(dsn=os.environ[\"SENTRY_DSN\"])\nsentry_sdk.metrics.count(\"demo.requests\", 1)\n",
      "asOf": "2026-11-20"
    },
    "F166": {
      "label": "Official description, sentry-sdk",
      "display": "Connects Python applications to Sentry.",
      "asOf": "2026-11-20"
    },
    "F167": {
      "label": "Quickstart source file, sentry-sdk",
      "display": "sentry_sdk/metrics.py",
      "asOf": "2026-11-20"
    },
    "F168": {
      "label": "Repository stars, sentry-sdk",
      "display": "2.2K",
      "asOf": "2026-11-20"
    },
    "F169": {
      "label": "Prometheus scrape output, sentry-sdk",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F170": {
      "label": "Per-call metric sample rate, sentry-sdk",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F171": {
      "label": "Collection and backend role, sentry-sdk",
      "display": "Hosted Sentry count/gauge/distribution metrics correlated with its error and trace context.",
      "asOf": "2026-11-20"
    },
    "F172": {
      "label": "Project function, sentry-sdk",
      "display": "def get_tts_audio_instrumented(self, source_text, voice: voice_module.TtsVoice_v3, options, audio_request_context):\n    with sentry_sdk.new_scope() as sentry_scope:\n        # inside this scope, we can set tags and context which will get unwound when this scope closes\n        sentry_scope.set_context(\"audio_voice\", {\n            'name': voice.name,\n            'voice_key': voice.voice_key,\n            'service': voice.service\n        })\n        sentry_scope.set_context(\"audio_options\", options)\n        sentry_scope.set_context('audio_request', {\n            'text': source_text\n        })\n        sentry_scope.set_context(\"audio_request_context\", {\n            'reason': audio_request_context.get_audio_request_reason_tag(),\n            'batch_uuid': audio_request_context.get_batch_uuid_str(),\n            'retry_count': audio_request_context.retry_count,\n            'retry_max': audio_request_context.retry_max,\n        })\n        use_clt = self.use_cloud_language_tools(voice)\n        sentry_scope.set_tags({\n            'hypertts_pro': use_clt,\n            'audio_service': voice.service,\n            'audio_request_reason': audio_request_context.audio_request_reason.name,\n            'final_attempt': audio_request_context.is_final_attempt()\n        })\n\n        metrics_attributes = {\n            \"service\": voice.service,\n            'hypertts_pro': use_clt,\n            'reason': audio_request_context.get_audio_request_reason_tag()\n        }\n\n        transaction_name = f'{voice.service}'\n        if use_clt:\n            transaction_name = f'cloudlanguagetools_{voice.service}'\n        current_txn = sentry_sdk.get_current_scope().transaction\n        if current_txn is not None:\n            cm = sentry_sdk.start_span(op=\"audio\", name=transaction_name)\n        else:\n            cm = sentry_sdk.start_transaction(op=\"audio\", name=transaction_name)\n        with cm as transaction:\n            try:\n                # audio request metrics\n                sentry_sdk.metrics.count(\n                    \"audio_request\",\n                    1,\n                    attributes=metrics_attributes,\n                )\n\n                tts_start = time.time()\n                result_audio = self.get_tts_audio_implementation(source_text, voice, options, audio_request_context)\n                tts_duration_ms = (time.time() - tts_start) * 1000\n\n                # success metrics\n                sentry_sdk.metrics.count(\n                    \"audio_request_success\",\n                    1,\n                    attributes=metrics_attributes,\n                )\n\n                sentry_sdk.metrics.distribution(\n                    \"audio_request_duration\",\n                    tts_duration_ms,\n                    unit=\"millisecond\",\n                    attributes=metrics_attributes,\n                )\n\n                return result_audio\n            except Exception as e:\n                sentry_scope.set_tags({\n                    'exception_type': type(e).__name__,\n                    'error_retryable': getattr(e, 'retryable', None),\n                    'is_audio_request_exception': True\n                })\n                sentry_scope.set_context(\"exception_type\", {\n                    'exception_type': type(e).__name__,\n                    'error_retryable': getattr(e, 'retryable', None)\n                })\n                # group by default fingerprint + service so that the same\n                # exception type from different services creates separate issues\n                sentry_scope.fingerprint = ['{{ default }}', voice.service]\n                # this the only place we capture audio request exceptions\n                sentry_sdk.capture_exception(e)\n\n                sentry_sdk.metrics.count(\n                    \"audio_request_failure\",\n                    1,\n                    attributes={**metrics_attributes, 'exception_type': type(e).__name__},\n                )\n\n                # let the caller handle the exception as well (e.g. for retry logic)\n                raise\n",
      "asOf": "2026-11-20"
    },
    "F173": {
      "label": "Project source file, sentry-sdk",
      "display": "hypertts_addon/servicemanager.py",
      "asOf": "2026-11-20"
    },
    "F174": {
      "label": "Project full_name, sentry-sdk",
      "display": "Vocab-Apps/anki-hyper-tts",
      "asOf": "2026-11-20"
    },
    "F175": {
      "label": "Project stargazers_count, sentry-sdk",
      "display": "292",
      "asOf": "2026-11-20"
    },
    "F176": {
      "label": "Library name, datadog",
      "display": "Datadog",
      "asOf": "2026-11-20"
    },
    "F177": {
      "label": "Monthly downloads, datadog",
      "display": "58.1M",
      "asOf": "2026-11-20"
    },
    "F178": {
      "label": "License, datadog",
      "display": "BSD-3-Clause",
      "asOf": "2026-11-20"
    },
    "F179": {
      "label": "Package release, datadog",
      "display": "0.56.0",
      "asOf": "2026-11-20"
    },
    "F180": {
      "label": "Package release date, datadog",
      "display": "Nov 2026",
      "asOf": "2026-11-20"
    },
    "F181": {
      "label": "Install, datadog",
      "display": "pip install datadog",
      "asOf": "2026-11-20"
    },
    "F182": {
      "label": "Quickstart, datadog",
      "display": "from datadog import DogStatsd\nclient = DogStatsd(host=\"127.0.0.1\", port=8125)\nclient.increment(\"demo.requests\")\n",
      "asOf": "2026-11-20"
    },
    "F183": {
      "label": "Repository stars, datadog",
      "display": "674",
      "asOf": "2026-11-20"
    },
    "F184": {
      "label": "Prometheus scrape output, datadog",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F185": {
      "label": "Per-call metric sample rate, datadog",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F186": {
      "label": "Collection and backend role, datadog",
      "display": "DogStatsD dialect client with per-observation tags and sample rates; requires an Agent/backend.",
      "asOf": "2026-11-20"
    },
    "F187": {
      "label": "Library name, logfire",
      "display": "Logfire",
      "asOf": "2026-11-20"
    },
    "F188": {
      "label": "Monthly downloads, logfire",
      "display": "19.2M",
      "asOf": "2026-11-20"
    },
    "F189": {
      "label": "License, logfire",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F190": {
      "label": "Package release, logfire",
      "display": "6.0.0",
      "asOf": "2026-11-20"
    },
    "F191": {
      "label": "Package release date, logfire",
      "display": "Nov 2026",
      "asOf": "2026-11-20"
    },
    "F192": {
      "label": "Install, logfire",
      "display": "pip install logfire",
      "asOf": "2026-11-20"
    },
    "F193": {
      "label": "Quickstart, logfire",
      "display": "import os\nimport logfire\nlogfire.configure(token=os.environ[\"LOGFIRE_TOKEN\"])\ncounter = logfire.metric_counter(\"demo.requests\")\ncounter.add(1)\n",
      "asOf": "2026-11-20"
    },
    "F194": {
      "label": "Official description, logfire",
      "display": "Provides the Pydantic Logfire SDK and command-line interface.",
      "asOf": "2026-11-20"
    },
    "F195": {
      "label": "Quickstart source file, logfire",
      "display": "reference/api/logfire/",
      "asOf": "2026-11-20"
    },
    "F196": {
      "label": "Repository stars, logfire",
      "display": "4.6K",
      "asOf": "2026-11-20"
    },
    "F197": {
      "label": "Prometheus scrape output, logfire",
      "display": "Via plugin",
      "asOf": "2026-11-20"
    },
    "F198": {
      "label": "Per-call metric sample rate, logfire",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F199": {
      "label": "Collection and backend role, logfire",
      "display": "Logfire installation entry point, delegated exact-version SDK, and OpenTelemetry-compatible instruments/readers.",
      "asOf": "2026-11-20"
    },
    "F200": {
      "label": "Installation components, logfire",
      "display": "{\"install_distribution\": \"logfire\", \"implementation_dependency\": \"logfire-sdk==6.0.0\", \"component_counters\": {\"logfire\": 19185102, \"logfire-sdk\": 4415649, \"logfire-api\": 37482809}}",
      "asOf": "2026-11-20"
    },
    "F201": {
      "label": "Project function, logfire",
      "display": "def record_request_assignment_pressure(\n    *,\n    gentype: str,\n    evidence: str,\n    might_stall: bool,\n    dispatch_opportunities: int,\n    lost_opportunities: int,\n    returned_capacity: int,\n    active_preceding_dispatches: int,\n    arriving_preceding_work: float,\n    returned_work: float,\n) -> None:\n    \"\"\"Record bounded diagnostics for one assignment-pressure calculation.\"\"\"\n\n    counts = (\n        dispatch_opportunities,\n        lost_opportunities,\n        returned_capacity,\n        active_preceding_dispatches,\n        arriving_preceding_work,\n        returned_work,\n    )\n    if any(count < 0 for count in counts):\n        raise ValueError(\"Assignment-pressure values must be non-negative\")\n    if lost_opportunities > dispatch_opportunities:\n        raise ValueError(\"Lost opportunities cannot exceed compatible dispatch opportunities\")\n    if evidence not in REQUEST_ASSIGNMENT_PRESSURE_EVIDENCE:\n        raise ValueError(f\"Unknown assignment-pressure evidence state: {evidence}\")\n\n    histogram_attributes: dict[str, str | bool] = {\n        \"horde.gentype\": gentype,\n        \"horde.might_stall\": might_stall,\n    }\n    request_assignment_pressure_dispatch_opportunities.record(dispatch_opportunities, histogram_attributes)\n    request_assignment_pressure_lost_opportunities.record(lost_opportunities, histogram_attributes)\n    request_assignment_pressure_returned_capacity.record(returned_capacity, histogram_attributes)\n    request_assignment_pressure_active_preceding.record(active_preceding_dispatches, histogram_attributes)\n    request_assignment_pressure_arriving_work.record(arriving_preceding_work, histogram_attributes)\n    request_assignment_pressure_returned_work.record(returned_work, histogram_attributes)\n    if dispatch_opportunities > 0:\n        request_assignment_pressure_lost_share.record(\n            lost_opportunities / dispatch_opportunities,\n            histogram_attributes,\n        )\n    request_assignment_pressure_samples.add(\n        1,\n        {\n            **histogram_attributes,\n            \"horde.evidence\": evidence,\n        },\n    )\n",
      "asOf": "2026-11-20"
    },
    "F202": {
      "label": "Project source file, logfire",
      "display": "horde/metrics.py",
      "asOf": "2026-11-20"
    },
    "F203": {
      "label": "Project full_name, logfire",
      "display": "Haidra-Org/AI-Horde",
      "asOf": "2026-11-20"
    },
    "F204": {
      "label": "Project stargazers_count, logfire",
      "display": "1.7K",
      "asOf": "2026-11-20"
    },
    "F205": {
      "label": "Library name, aws-lambda-powertools",
      "display": "Powertools for AWS Lambda",
      "asOf": "2026-11-20"
    },
    "F206": {
      "label": "Monthly downloads, aws-lambda-powertools",
      "display": "15.6M",
      "asOf": "2026-11-20"
    },
    "F207": {
      "label": "License, aws-lambda-powertools",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F208": {
      "label": "Package release, aws-lambda-powertools",
      "display": "3.41.0",
      "asOf": "2026-11-20"
    },
    "F209": {
      "label": "Package release date, aws-lambda-powertools",
      "display": "Nov 2026",
      "asOf": "2026-11-20"
    },
    "F210": {
      "label": "Install, aws-lambda-powertools",
      "display": "pip install aws-lambda-powertools",
      "asOf": "2026-11-20"
    },
    "F211": {
      "label": "Quickstart, aws-lambda-powertools",
      "display": "from aws_lambda_powertools import Metrics\nfrom aws_lambda_powertools.metrics import MetricUnit\nmetrics = Metrics(namespace=\"Demo\")\nmetrics.add_metric(name=\"Requests\", unit=MetricUnit.Count, value=1)\nmetrics.flush_metrics()\n",
      "asOf": "2026-11-20"
    },
    "F212": {
      "label": "Official description, aws-lambda-powertools",
      "display": "Implements serverless best practices in AWS Lambda functions.",
      "asOf": "2026-11-20"
    },
    "F213": {
      "label": "Quickstart source file, aws-lambda-powertools",
      "display": "api/metrics/metrics.html",
      "asOf": "2026-11-20"
    },
    "F214": {
      "label": "Repository stars, aws-lambda-powertools",
      "display": "3.3K",
      "asOf": "2026-11-20"
    },
    "F215": {
      "label": "Prometheus scrape output, aws-lambda-powertools",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F216": {
      "label": "Per-call metric sample rate, aws-lambda-powertools",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F217": {
      "label": "Collection and backend role, aws-lambda-powertools",
      "display": "Lambda observability toolkit with a native Metrics facade and default CloudWatch EMF provider.",
      "asOf": "2026-11-20"
    },
    "F218": {
      "label": "Project function, aws-lambda-powertools",
      "display": "@metrics.log_metrics(raise_on_empty_metrics=False)\n@logger.inject_lambda_context\n@tracer.capture_lambda_handler\ndef handler(event, _):\n    \"\"\"\n    Lambda handler\n    \"\"\"\n\n    order_id = event[\"detail\"][\"orderId\"]\n\n    logger.info({\n        \"message\": \"Received failed order {}\".format(order_id),\n        \"orderId\": order_id\n    })\n\n    payment_token = get_payment_token(order_id)\n    cancel_payment(payment_token)\n    delete_payment_token(order_id)\n\n    # Add custom metrics\n    amount_lost = event[\"detail\"][\"total\"]\n\n    metrics.add_dimension(name=\"environment\", value=ENVIRONMENT)\n    metrics.add_metric(name=\"paymentCancelled\", unit=MetricUnit.Count, value=1)\n    metrics.add_metric(name=\"amountLost\", unit=MetricUnit.Count, value=amount_lost)\n",
      "asOf": "2026-11-20"
    },
    "F219": {
      "label": "Project source file, aws-lambda-powertools",
      "display": "payment/src/on_failed/main.py",
      "asOf": "2026-11-20"
    },
    "F220": {
      "label": "Project full_name, aws-lambda-powertools",
      "display": "aws-samples/aws-serverless-ecommerce-platform",
      "asOf": "2026-11-20"
    },
    "F221": {
      "label": "Project stargazers_count, aws-lambda-powertools",
      "display": "1.1K",
      "asOf": "2026-11-20"
    },
    "F222": {
      "label": "Library name, statsd",
      "display": "statsd",
      "asOf": "2026-11-20"
    },
    "F223": {
      "label": "Monthly downloads, statsd",
      "display": "9.9M",
      "asOf": "2026-11-20"
    },
    "F224": {
      "label": "License, statsd",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F225": {
      "label": "Package release, statsd",
      "display": "4.0.1",
      "asOf": "2026-11-20"
    },
    "F226": {
      "label": "Package release date, statsd",
      "display": "Nov 2022",
      "asOf": "2026-11-20"
    },
    "F227": {
      "label": "Install, statsd",
      "display": "pip install statsd",
      "asOf": "2026-11-20"
    },
    "F228": {
      "label": "Quickstart, statsd",
      "display": "from statsd import StatsClient\nclient = StatsClient(host=\"127.0.0.1\", port=8125)\nclient.incr(\"demo.requests\")\n",
      "asOf": "2026-11-20"
    },
    "F229": {
      "label": "Repository stars, statsd",
      "display": "553",
      "asOf": "2026-11-20"
    },
    "F230": {
      "label": "Prometheus scrape output, statsd",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F231": {
      "label": "Per-call metric sample rate, statsd",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F232": {
      "label": "Collection and backend role, statsd",
      "display": "Core StatsD daemon client; metric names/prefixes and sample-rate arguments, separate from DogStatsD tag extensions.",
      "asOf": "2026-11-20"
    },
    "F233": {
      "label": "Library name, aws-embedded-metrics",
      "display": "AWS Embedded Metrics",
      "asOf": "2026-11-20"
    },
    "F234": {
      "label": "Monthly downloads, aws-embedded-metrics",
      "display": "2.3M",
      "asOf": "2026-11-20"
    },
    "F235": {
      "label": "License, aws-embedded-metrics",
      "display": "Apache-2.0",
      "asOf": "2026-11-20"
    },
    "F236": {
      "label": "Package release, aws-embedded-metrics",
      "display": "3.5.0",
      "asOf": "2026-11-20"
    },
    "F237": {
      "label": "Package release date, aws-embedded-metrics",
      "display": "Mar 2026",
      "asOf": "2026-11-20"
    },
    "F238": {
      "label": "Install, aws-embedded-metrics",
      "display": "pip install aws-embedded-metrics",
      "asOf": "2026-11-20"
    },
    "F239": {
      "label": "Quickstart, aws-embedded-metrics",
      "display": "from aws_embedded_metrics import metric_scope\n@metric_scope\ndef record_request(metrics):\n    metrics.put_metric(\"Requests\", 1, \"Count\")\nrecord_request()\n",
      "asOf": "2026-11-20"
    },
    "F240": {
      "label": "Official description, aws-embedded-metrics",
      "display": "Provides the AWS Embedded Metrics package for Python.",
      "asOf": "2026-11-20"
    },
    "F241": {
      "label": "Quickstart source file, aws-embedded-metrics",
      "display": "README.md",
      "asOf": "2026-11-20"
    },
    "F242": {
      "label": "Repository stars, aws-embedded-metrics",
      "display": "232",
      "asOf": "2026-11-20"
    },
    "F243": {
      "label": "Prometheus scrape output, aws-embedded-metrics",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F244": {
      "label": "Per-call metric sample rate, aws-embedded-metrics",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F245": {
      "label": "Collection and backend role, aws-embedded-metrics",
      "display": "Direct CloudWatch EMF logger, metric_scope lifecycle, dimensions, and contextual log properties.",
      "asOf": "2026-11-20"
    },
    "F246": {
      "label": "Project function, aws-embedded-metrics",
      "display": "@metric_scope\ndef lambda_handler(event, context, metrics):\n    route_key = event['routeKey']\n\n    response_body = {'Message': 'Unsupported route'}\n    status_code = 400\n    headers = {'Content-Type': 'application/json'}\n\n    # Put common business metrics using EMF\n    metric_payload = {}\n    metrics.put_dimensions({'Service': 'Locations'})\n    metrics.put_metric('ProcessedLocations', 1, 'Count')\n    metrics.set_property('requestId', event['requestContext']['requestId'])\n    metrics.set_property('routeKey', event['routeKey'])\n\n    try:\n        # Get all locations\n        if route_key == 'GET /locations':\n            metric_payload['operation'] = 'GET'\n            ddb_response = ddbTable.scan(Select='ALL_ATTRIBUTES')\n            response_body = ddb_response['Items']\n            status_code = 200\n        # Location CRUD operations\n        if route_key == 'GET /locations/{locationid}':\n            metric_payload['operation'] = 'GET'\n            metric_payload['locationid'] = event['pathParameters']['locationid']\n            ddb_response = ddbTable.get_item(\n                Key={'locationid': event['pathParameters']['locationid']}\n            )\n            if 'Item' in ddb_response:\n                response_body = ddb_response['Item']\n            else:\n                response_body = {}\n            status_code = 200\n        if route_key == 'DELETE /locations/{locationid}':\n            metric_payload['operation'] = 'DELETE'\n            metric_payload['locationid'] = event['pathParameters']['locationid']\n            ddbTable.delete_item(\n                Key={'locationid': event['pathParameters']['locationid']}\n            )\n            response_body = {}\n            status_code = 200\n        if route_key == 'PUT /locations':\n            request_json = json.loads(event['body'])\n            request_json['timestamp'] = datetime.now().isoformat()\n            if 'locationid' not in request_json:\n                request_json['locationid'] = str(uuid.uuid1())\n            metric_payload['operation'] = 'PUT'\n            metric_payload['locationid'] = request_json['locationid']\n            ddbTable.put_item(\n                Item=request_json\n            )\n            response_body = request_json\n            status_code = 200\n    except Exception as err:\n        status_code = 400\n        response_body = {'Error:': str(err)}\n        print(str(err))\n    metrics.set_property(\"Payload\", metric_payload)\n    return {\n        'statusCode': status_code,\n        'body': json.dumps(response_body),\n        'headers': headers\n    }\n",
      "asOf": "2026-11-20"
    },
    "F247": {
      "label": "Project source file, aws-embedded-metrics",
      "display": "serverless-rest-api/python-http-cdk/src/api/locations.py",
      "asOf": "2026-11-20"
    },
    "F248": {
      "label": "Project full_name, aws-embedded-metrics",
      "display": "aws-samples/serverless-samples",
      "asOf": "2026-11-20"
    },
    "F249": {
      "label": "Project stargazers_count, aws-embedded-metrics",
      "display": "351",
      "asOf": "2026-11-20"
    }
  },
  "dataCheckedAt": "2026-11-20",
  "agent": {
    "exaCall": {
      "endpoint": "/search",
      "body": {
        "query": "Best Python metrics libraries prometheus-client opentelemetry-api statsd datadog code examples counters latency instrumentation",
        "numResults": 5
      },
      "docsUrl": "https://exa.ai/docs/reference/search"
    },
    "calls": []
  }
}
