These examples show how to use OpenTelemetry to send tracing data to Cloud Trace.
- To use this exporter you first need to:
- A Google Cloud project. You can create one here.
- Enable Cloud Trace API (listed in the Cloud Console as Stackdriver Trace API) in the project here. * If the page says "API Enabled" then you're done! No need to do anything.
- Enable Default Application Credentials by creating setting GOOGLE_APPLICATION_CREDENTIALS or by installing gcloud sdk and calling
gcloud auth application-default login
.
- Installation
pip install opentelemetry-api
pip install opentelemetry-sdk
pip install opentelemetry-exporter-cloud-trace
- Run an example locally
.. literalinclude:: basic_trace.py :language: python :lines: 1-
After running any of these examples, you can go to Cloud Trace overview to see the results.
- Make sure you've setup Application Default Credentials. Either run
gcloud auth application-default login
or set theGOOGLE_APPLICATION_CREDENTIALS
environment variable to be a path to a service account token file.
- Check that you've enabled the Cloud Trace (Stackdriver Trace) API
- Install pip
- If your machine uses python2 by default, pip will also be the python2 version. Try using
pip3
instead ofpip
.
Try upgrading pip
pip install --upgrade pip
pip install grcpio
has been known to hang when you aren't using an upgraded version.
Make sure you are using python3. If
python --version
returns Python 2.X.X
try calling
python3 basic_trace.py