-
Notifications
You must be signed in to change notification settings - Fork 610
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andrew Xue
committed
May 29, 2020
1 parent
e91041f
commit 002279b
Showing
22 changed files
with
681 additions
and
556 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
Cloud Trace Exporter Example | ||
============================ | ||
|
||
These examples show how to use OpenTelemetry to send tracing data to Cloud Trace. | ||
|
||
|
||
Basic Example | ||
------------- | ||
|
||
To use this exporter you first need to: | ||
* A Google Cloud project. You can `create one here. <https://console.cloud.google.com/projectcreate>`_ | ||
* Enable Cloud Trace API (aka StackDriver Trace API) in the project `here. <https://console.cloud.google.com/apis/library?q=cloud_trace>`_ | ||
* Enable `Default Application Credentials. <https://developers.google.com/identity/protocols/application-default-credentials>`_ | ||
|
||
* Installation | ||
|
||
.. code-block:: sh | ||
pip install opentelemetry-api | ||
pip install opentelemetry-sdk | ||
pip install opentelemetry-exporter-cloud-trace | ||
* Run example | ||
|
||
.. code-block:: sh | ||
python basic_trace.py | ||
Checking Output | ||
-------------------------- | ||
|
||
After running any of these examples, you can go to `Cloud Trace overview <https://console.cloud.google.com/traces/list>`_ to see the results. | ||
|
||
* `More information about exporters in general <https://opentelemetry-python.readthedocs.io/en/stable/getting-started.html#configure-exporters-to-emit-spans-elsewhere>`_ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from opentelemetry import trace | ||
from opentelemetry.exporter.cloud_trace import CloudTraceSpanExporter | ||
from opentelemetry.sdk.trace import TracerProvider | ||
from opentelemetry.sdk.trace.export import SimpleExportSpanProcessor | ||
|
||
trace.set_tracer_provider(TracerProvider()) | ||
|
||
cloud_trace_exporter = CloudTraceSpanExporter() | ||
trace.get_tracer_provider().add_span_processor( | ||
SimpleExportSpanProcessor(cloud_trace_exporter) | ||
) | ||
tracer = trace.get_tracer(__name__) | ||
with tracer.start_as_current_span("foo"): | ||
print("Hello world!") |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
OpenTelemetry Cloud Trace Exporter | ||
================================== | ||
|
||
.. automodule:: opentelemetry.exporter.cloud_trace | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
OpenTelemetry Cloud Trace Exporters | ||
=================================== | ||
|
||
This library provides classes for exporting trace data to Google Cloud Trace. | ||
|
||
Installation | ||
------------ | ||
|
||
:: | ||
|
||
pip install opentelemetry-exporter-cloud-trace | ||
|
||
Usage | ||
----- | ||
|
||
.. code:: python | ||
from opentelemetry import trace | ||
from opentelemetry.exporter.cloud_trace import CloudTraceSpanExporter | ||
from opentelemetry.sdk.trace import TracerProvider | ||
from opentelemetry.sdk.trace.export import ( | ||
SimpleExportSpanProcessor, | ||
) | ||
trace.set_tracer_provider(TracerProvider()) | ||
cloud_trace_exporter = CloudTraceSpanExporter( | ||
project_id='my-gcloud-project', | ||
) | ||
trace.get_tracer_provider().add_span_processor( | ||
SimpleExportSpanProcessor(cloud_trace_exporter) | ||
) | ||
tracer = trace.get_tracer(__name__) | ||
with tracer.start_as_current_span('foo'): | ||
print('Hello world!') | ||
References | ||
---------- | ||
|
||
* `Cloud Trace <https://cloud.google.com/trace/>`_ | ||
* `OpenTelemetry Project <https://opentelemetry.io/>`_ |
This file contains 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
This file contains 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
Oops, something went wrong.