{"action":"created","issue":{"url":"https://api.github.com/repos/prometheus/client_python/issues/100","repository_url":"https://api.github.com/repos/prometheus/client_python","labels_url":"https://api.github.com/repos/prometheus/client_python/issues/100/labels{/name}","comments_url":"https://api.github.com/repos/prometheus/client_python/issues/100/comments","events_url":"https://api.github.com/repos/prometheus/client_python/issues/100/events","html_url":"https://github.com/prometheus/client_python/issues/100","id":177579664,"number":100,"title":"Problem with labels method on metrics objects","user":{"login":"claws","id":1298001,"avatar_url":"https://avatars.githubusercontent.com/u/1298001?v=3","gravatar_id":"","url":"https://api.github.com/users/claws","html_url":"https://github.com/claws","followers_url":"https://api.github.com/users/claws/followers","following_url":"https://api.github.com/users/claws/following{/other_user}","gists_url":"https://api.github.com/users/claws/gists{/gist_id}","starred_url":"https://api.github.com/users/claws/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/claws/subscriptions","organizations_url":"https://api.github.com/users/claws/orgs","repos_url":"https://api.github.com/users/claws/repos","events_url":"https://api.github.com/users/claws/events{/privacy}","received_events_url":"https://api.github.com/users/claws/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-09-17T14:21:43Z","updated_at":"2016-09-17T14:37:34Z","closed_at":null,"body":"I am expecting to be able to set labels on a Counter like in the examples:\r\n\r\n``` python\r\nfrom prometheus_client import Counter\r\nc = Counter('my_requests_total', 'HTTP Failures', ['method', 'endpoint'])\r\nc.labels(method='get', endpoint='/').inc()\r\n```\r\n\r\nI am using prometheus-client (0.0.14) from PyPI.\r\n\r\n``` console\r\n$ python\r\nPython 2.7.12 (v2.7.12:d33e0cf91556, Jun 26 2016, 12:10:39) \r\n[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin\r\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\r\n>>> from prometheus_client import Counter, CollectorRegistry\r\n>>> reg = CollectorRegistry()\r\n>>> c = Counter('items_total', 'number of items total', registry=reg)\r\n>>> c.labels(first=1, another=2).inc()\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\nAttributeError: 'Counter' object has no attribute 'labels'\r\n>>>\r\n>>> type(c)\r\n<class 'prometheus_client.core.Counter'>\r\n>>> dir(c)\r\n['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_reserved_labelnames', '_samples', '_type', '_value', 'collect', 'count_exceptions', 'inc']\r\n```\r\n\r\nThe Counter object does not seem to have a labels method attached to it. Perhaps some recent changes has affected the application of the decorator that applies it to the metrics?\r\n\r\n#99 kind of indicates this same problem but has words relating it to pushgateway.\r\n"},"comment":{"url":"https://api.github.com/repos/prometheus/client_python/issues/comments/247776492","html_url":"https://github.com/prometheus/client_python/issues/100#issuecomment-247776492","issue_url":"https://api.github.com/repos/prometheus/client_python/issues/100","id":247776492,"user":{"login":"claws","id":1298001,"avatar_url":"https://avatars.githubusercontent.com/u/1298001?v=3","gravatar_id":"","url":"https://api.github.com/users/claws","html_url":"https://github.com/claws","followers_url":"https://api.github.com/users/claws/followers","following_url":"https://api.github.com/users/claws/following{/other_user}","gists_url":"https://api.github.com/users/claws/gists{/gist_id}","starred_url":"https://api.github.com/users/claws/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/claws/subscriptions","organizations_url":"https://api.github.com/users/claws/orgs","repos_url":"https://api.github.com/users/claws/repos","events_url":"https://api.github.com/users/claws/events{/privacy}","received_events_url":"https://api.github.com/users/claws/received_events","type":"User","site_admin":false},"created_at":"2016-09-17T14:37:34Z","updated_at":"2016-09-17T14:37:34Z","body":"I thought it might have something to do with the needing to declare the label names up front (which the docs seem to use) but this does seem to affect it.\r\n\r\n``` console\r\n$ python\r\nPython 2.7.12 (v2.7.12:d33e0cf91556, Jun 26 2016, 12:10:39) \r\n[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin\r\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\r\n>>> from prometheus_client import CollectorRegistry, Counter\r\n>>> reg = CollectorRegistry()\r\n>>> c = Counter('my_requests_total', 'HTTP Failures', ['method', 'endpoint'], registry=reg)\r\n>>> c.labels(method='get', endpoint='/').inc()\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\nTypeError: labels() got an unexpected keyword argument 'method'\r\n>>> \r\n>>> c.labels({'method':'get', 'endpoint':'/'}).inc()\r\n>>> \r\n```\r\n\r\nIf I pass the labels as a dict it seems to work."}}
{"actor":{"display_login":"claws"}}