Stackdriver Trace is a distributed tracing system that collects latency data from your applications and displays it in the Google Cloud Platform Console.
You can track how requests propagate through your application and receive detailed near real-time performance insights. Stackdriver Trace automatically analyzes all of your application’s traces to generate in-depth latency reports to surface performance degradations, and can capture traces from all of your VMs, containers, or Google App Engine projects.
Stackdriver Monitoring provides visibility into the performance, uptime, and overall health of cloud-powered applications. Stackdriver collects metrics, events, and metadata from Google Cloud Platform, Amazon Web Services, hosted uptime probes, application instrumentation, and a variety of common application components including Cassandra, Nginx, Apache Web Server, Elasticsearch, and many others.
Stackdriver ingests that data and generates insights via dashboards, charts, and alerts. Stackdriver alerting helps you collaborate by integrating with Slack, PagerDuty, HipChat, Campfire, and more.
OpenCensus Python has support for this exporter available through package: * Trace opencensus.trace.exporters.stackdriver_exporter
For assistance setting up Stackdriver, Click here for a guided codelab.
Creating the exporters
To create the exporters, you’ll need to:
- Have a GCP Project ID
- Have already enabled Stackdriver Tracing and Metrics, if not, please visit the Code lab
- Create the exporters in code
Instrument your code with the following snippet:
#!/usr/bin/env python import os from opencensus.trace.tracer import Tracer from opencensus.trace.exporters import stackdriver_exporter from opencensus.trace.exporters.transports.background_thread import BackgroundThreadTransport def main(): sde = stackdriver_exporter.StackdriverExporter( project_id=os.environ.get("GCP_PROJECT_ID"), transport=BackgroundThreadTransport) tracer = Tracer(exporter=sde) with tracer.span(name='doingWork') as span: for i in range(10): continue if __name__ == "__main__": main()
Viewing your metrics
Please visit https://console.cloud.google.com/monitoring
Viewing your traces
Please visit https://console.cloud.google.com/traces/traces