Created
May 31, 2017 14:13
-
-
Save mainroach/36340d54b13500b7ae9065ec3ad83e75 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from googleapiclient import discovery | |
from oauth2client.client import GoogleCredentials | |
class TraceContext(object): | |
def write(self): | |
# Build our JSON blob | |
# …... | |
# Authentication is provided by the 'gcloud' tool when running locally | |
# and by built-in service accounts when running on GAE, GCE, or GKE. | |
# See https://developers.google.com/identity/protocols/application-default-credentials for more information. | |
credentials = GoogleCredentials.get_application_default() | |
# Construct the cloudtrace service object (version v1) for interacting | |
# with the API. You can browse other available API services and versions at | |
# https://developers.google.com/api-client-library/python/apis/ | |
service = discovery.build('cloudtrace', 'v1', credentials=credentials) | |
# Actually submit the patched tracing data. | |
request = service.projects().patchTraces(projectId=projectId, body=body) | |
request.execute() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment