Skip to content

Instantly share code, notes, and snippets.

@mainroach
Created May 31, 2017 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mainroach/36340d54b13500b7ae9065ec3ad83e75 to your computer and use it in GitHub Desktop.
Save mainroach/36340d54b13500b7ae9065ec3ad83e75 to your computer and use it in GitHub Desktop.
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