{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/comments/75785419","id":75785419,"diff_hunk":"@@ -278,3 +278,92 @@ follows::\n \n .. _Time Series:\n     https://cloud.google.com/monitoring/api/ref_v3/rest/v3/TimeSeries\n+\n+\n+Writing Custom Metrics\n+---------------------------\n+\n+The Stackdriver Monitoring API can be used to write data points to custom metrics. Please refer to\n+the documentation on `Custom Metrics`_ for more information.\n+\n+To write a data point to a custom metric, you must provide an instance of\n+:class:`~gcloud.monitoring.metric.Metric` specifying the metric type as well as the values for\n+the metric labels. You will need to have either created the metric descriptor earlier (see the\n+`Metric Descriptors`_ section ) or rely on metric type auto-creation (see `Auto-creation of","path":"docs/monitoring-usage.rst","position":33,"original_position":33,"commit_id":"ebf168bd2a104b2a55e695acff357a28b194a0bb","original_commit_id":"ebf168bd2a104b2a55e695acff357a28b194a0bb","user":{"login":"rimey","id":360806,"avatar_url":"https://avatars.githubusercontent.com/u/360806?v=3","gravatar_id":"","url":"https://api.github.com/users/rimey","html_url":"https://github.com/rimey","followers_url":"https://api.github.com/users/rimey/followers","following_url":"https://api.github.com/users/rimey/following{/other_user}","gists_url":"https://api.github.com/users/rimey/gists{/gist_id}","starred_url":"https://api.github.com/users/rimey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rimey/subscriptions","organizations_url":"https://api.github.com/users/rimey/orgs","repos_url":"https://api.github.com/users/rimey/repos","events_url":"https://api.github.com/users/rimey/events{/privacy}","received_events_url":"https://api.github.com/users/rimey/received_events","type":"User","site_admin":false},"body":"Remove space before parenthesis.","created_at":"2016-08-23T00:36:24Z","updated_at":"2016-08-23T00:36:24Z","html_url":"https://github.com/GoogleCloudPlatform/gcloud-python/pull/2057#discussion_r75785419","pull_request_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/2057","_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/comments/75785419"},"html":{"href":"https://github.com/GoogleCloudPlatform/gcloud-python/pull/2057#discussion_r75785419"},"pull_request":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/2057"}}},"pull_request":{"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/2057","id":80155289,"html_url":"https://github.com/GoogleCloudPlatform/gcloud-python/pull/2057","diff_url":"https://github.com/GoogleCloudPlatform/gcloud-python/pull/2057.diff","patch_url":"https://github.com/GoogleCloudPlatform/gcloud-python/pull/2057.patch","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/issues/2057","number":2057,"state":"open","locked":false,"title":"Monitoring Custom Metrics","user":{"login":"waprin","id":1075173,"avatar_url":"https://avatars.githubusercontent.com/u/1075173?v=3","gravatar_id":"","url":"https://api.github.com/users/waprin","html_url":"https://github.com/waprin","followers_url":"https://api.github.com/users/waprin/followers","following_url":"https://api.github.com/users/waprin/following{/other_user}","gists_url":"https://api.github.com/users/waprin/gists{/gist_id}","starred_url":"https://api.github.com/users/waprin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/waprin/subscriptions","organizations_url":"https://api.github.com/users/waprin/orgs","repos_url":"https://api.github.com/users/waprin/repos","events_url":"https://api.github.com/users/waprin/events{/privacy}","received_events_url":"https://api.github.com/users/waprin/received_events","type":"User","site_admin":false},"body":"This kicks off the PR for #1867 with the usage docs. Implementation is started and will follow this soon.\r\n\r\n@rimey is primary reviewer here, largely just took most of his suggestions but some followup comments here:\r\n\r\n1) Keyword arguments sounds like a good idea and not too tricky, we can do that now.\r\n\r\n2) re: a way to write multiple TimeSeries in one go. I did add the suggested method.\r\n\r\nCurrently, there is no way to write more than one point in a TimeSeries. The only way we could batch writes is doing something like this: \r\n\r\nhttps://developers.google.com/api-client-library/python/guide/batch\r\n\r\nThis might involve some changes to the core client library here, how important do we think this is?\r\n\r\nIn general, what are the main use cases for writing multiple TimeSeries at once? Is it just batching to reduce network requests? I think the method would currently just be a wrapper around\r\n\r\n```\r\nfor ts in timeseries_list:\r\n     ts.create()\r\n```\r\n\r\nwhich may be a good wrapper to have, even though users could trivially write that out.\r\n\r\n3) I think you want the most common use case to be as simple as possible, which is why I think we want a `write` method that just takes a single value without forcing to pass the metric and resource every time. Since the `timeseries.create()` API call requires a Metric and Resource, we have to have a class that contains that Metric and Resource. We can of course just use the TimeSeries itself, but since you can only write a single point to that TimeSeries, it's not something that makes sense to re-use if we want the local object to map well to the API object. So I instead propose to add a TimeseriesWriter class that can take a Metric and Resource and be re-used to create new TimeSeries with those Metric and Resource. \r\n\r\n```\r\ntimeseries_writer = client.get_timeseries_writer(metric, resource)\r\ntimeseries_writer.write_point(value) # API call\r\n````\r\n\r\ncc @sharbison3 @supriyagarg \r\n","created_at":"2016-08-04T21:46:25Z","updated_at":"2016-08-23T00:36:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1b2a938e5c9e62815362a8855a2a743f48cf36a6","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/2057/commits","review_comments_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/2057/comments","review_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/issues/2057/comments","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/statuses/ebf168bd2a104b2a55e695acff357a28b194a0bb","head":{"label":"waprin:justdoc2","ref":"justdoc2","sha":"ebf168bd2a104b2a55e695acff357a28b194a0bb","user":{"login":"waprin","id":1075173,"avatar_url":"https://avatars.githubusercontent.com/u/1075173?v=3","gravatar_id":"","url":"https://api.github.com/users/waprin","html_url":"https://github.com/waprin","followers_url":"https://api.github.com/users/waprin/followers","following_url":"https://api.github.com/users/waprin/following{/other_user}","gists_url":"https://api.github.com/users/waprin/gists{/gist_id}","starred_url":"https://api.github.com/users/waprin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/waprin/subscriptions","organizations_url":"https://api.github.com/users/waprin/orgs","repos_url":"https://api.github.com/users/waprin/repos","events_url":"https://api.github.com/users/waprin/events{/privacy}","received_events_url":"https://api.github.com/users/waprin/received_events","type":"User","site_admin":false},"repo":{"id":60732333,"name":"gcloud-python","full_name":"waprin/gcloud-python","owner":{"login":"waprin","id":1075173,"avatar_url":"https://avatars.githubusercontent.com/u/1075173?v=3","gravatar_id":"","url":"https://api.github.com/users/waprin","html_url":"https://github.com/waprin","followers_url":"https://api.github.com/users/waprin/followers","following_url":"https://api.github.com/users/waprin/following{/other_user}","gists_url":"https://api.github.com/users/waprin/gists{/gist_id}","starred_url":"https://api.github.com/users/waprin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/waprin/subscriptions","organizations_url":"https://api.github.com/users/waprin/orgs","repos_url":"https://api.github.com/users/waprin/repos","events_url":"https://api.github.com/users/waprin/events{/privacy}","received_events_url":"https://api.github.com/users/waprin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/waprin/gcloud-python","description":"Google Cloud Client Library for Python","fork":true,"url":"https://api.github.com/repos/waprin/gcloud-python","forks_url":"https://api.github.com/repos/waprin/gcloud-python/forks","keys_url":"https://api.github.com/repos/waprin/gcloud-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/waprin/gcloud-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/waprin/gcloud-python/teams","hooks_url":"https://api.github.com/repos/waprin/gcloud-python/hooks","issue_events_url":"https://api.github.com/repos/waprin/gcloud-python/issues/events{/number}","events_url":"https://api.github.com/repos/waprin/gcloud-python/events","assignees_url":"https://api.github.com/repos/waprin/gcloud-python/assignees{/user}","branches_url":"https://api.github.com/repos/waprin/gcloud-python/branches{/branch}","tags_url":"https://api.github.com/repos/waprin/gcloud-python/tags","blobs_url":"https://api.github.com/repos/waprin/gcloud-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/waprin/gcloud-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/waprin/gcloud-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/waprin/gcloud-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/waprin/gcloud-python/statuses/{sha}","languages_url":"https://api.github.com/repos/waprin/gcloud-python/languages","stargazers_url":"https://api.github.com/repos/waprin/gcloud-python/stargazers","contributors_url":"https://api.github.com/repos/waprin/gcloud-python/contributors","subscribers_url":"https://api.github.com/repos/waprin/gcloud-python/subscribers","subscription_url":"https://api.github.com/repos/waprin/gcloud-python/subscription","commits_url":"https://api.github.com/repos/waprin/gcloud-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/waprin/gcloud-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/waprin/gcloud-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/waprin/gcloud-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/waprin/gcloud-python/contents/{+path}","compare_url":"https://api.github.com/repos/waprin/gcloud-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/waprin/gcloud-python/merges","archive_url":"https://api.github.com/repos/waprin/gcloud-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/waprin/gcloud-python/downloads","issues_url":"https://api.github.com/repos/waprin/gcloud-python/issues{/number}","pulls_url":"https://api.github.com/repos/waprin/gcloud-python/pulls{/number}","milestones_url":"https://api.github.com/repos/waprin/gcloud-python/milestones{/number}","notifications_url":"https://api.github.com/repos/waprin/gcloud-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/waprin/gcloud-python/labels{/name}","releases_url":"https://api.github.com/repos/waprin/gcloud-python/releases{/id}","deployments_url":"https://api.github.com/repos/waprin/gcloud-python/deployments","created_at":"2016-06-08T21:34:51Z","updated_at":"2016-06-08T21:34:55Z","pushed_at":"2016-08-23T00:31:45Z","git_url":"git://github.com/waprin/gcloud-python.git","ssh_url":"git@github.com:waprin/gcloud-python.git","clone_url":"https://github.com/waprin/gcloud-python.git","svn_url":"https://github.com/waprin/gcloud-python","homepage":"https://googlecloudplatform.github.io/gcloud-python/","size":58128,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"GoogleCloudPlatform:master","ref":"master","sha":"0bf3b686764ba7758dc47a7e783d11839e068f3b","user":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"repo":{"id":16316451,"name":"gcloud-python","full_name":"GoogleCloudPlatform/gcloud-python","owner":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleCloudPlatform/gcloud-python","description":"Google Cloud Client Library for Python","fork":false,"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python","forks_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/forks","keys_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/teams","hooks_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/hooks","issue_events_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/events","assignees_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/tags","blobs_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/languages","stargazers_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/stargazers","contributors_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/contributors","subscribers_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/subscribers","subscription_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/subscription","commits_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/merges","archive_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/downloads","issues_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/labels{/name}","releases_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/releases{/id}","deployments_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/deployments","created_at":"2014-01-28T15:51:47Z","updated_at":"2016-08-21T13:43:45Z","pushed_at":"2016-08-23T00:31:45Z","git_url":"git://github.com/GoogleCloudPlatform/gcloud-python.git","ssh_url":"git@github.com:GoogleCloudPlatform/gcloud-python.git","clone_url":"https://github.com/GoogleCloudPlatform/gcloud-python.git","svn_url":"https://github.com/GoogleCloudPlatform/gcloud-python","homepage":"https://googlecloudplatform.github.io/gcloud-python/","size":72006,"stargazers_count":373,"watchers_count":373,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":191,"mirror_url":null,"open_issues_count":184,"forks":191,"open_issues":184,"watchers":373,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/2057"},"html":{"href":"https://github.com/GoogleCloudPlatform/gcloud-python/pull/2057"},"issue":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/issues/2057"},"comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/issues/2057/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/2057/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/2057/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/statuses/ebf168bd2a104b2a55e695acff357a28b194a0bb"}}}}
{"actor":{"display_login":"rimey"}}