Skip to content

Commit

Permalink
Add Cloud Trace Exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Xue committed May 29, 2020
1 parent e91041f commit 002279b
Show file tree
Hide file tree
Showing 22 changed files with 681 additions and 556 deletions.
5 changes: 5 additions & 0 deletions docs-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@ redis>=2.6
sqlalchemy>=1.0
thrift>=0.10.0
wrapt >=1.0.0,<2.0.0
google-cloud-core >=1.3.0
google-api-core >=1.17.0
google-cloud-trace >=0.23.0
google-cloud-monitoring >=0.36.0
grpcio >=1.28.1
34 changes: 34 additions & 0 deletions docs/examples/cloud_trace_exporter/README.rst
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>`_
14 changes: 14 additions & 0 deletions docs/examples/cloud_trace_exporter/basic_trace.py
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!")
7 changes: 7 additions & 0 deletions docs/ext/cloud_trace/cloud_trace.rst
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:
43 changes: 43 additions & 0 deletions ext/opentelemetry-exporter-cloud-trace/README.rst
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/>`_
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019, OpenTelemetry Authors
# Copyright OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -13,17 +13,17 @@
# limitations under the License.
#
[metadata]
name = opentelemetry-ext-stackdriver
description = Stackdriver integration for OpenTelemetry
name = opentelemetry-exporter-cloud-trace
description = Cloud Trace integration for OpenTelemetry
long_description = file: README.rst
long_description_content_type = text/x-rst
author = OpenTelemetry Authors
author_email = cncf-opentelemetry-contributors@lists.cncf.io
url = https://github.com/open-telemetry/opentelemetry-python/ext/opentelemetry-ext-stackdriver
url = https://github.com/open-telemetry/opentelemetry-python/ext/opentelemetry-exporter-cloud-trace
platforms = any
license = Apache-2.0
classifiers =
Development Status :: 3 - Alpha
Development Status :: 4 - Beta
Intended Audience :: Developers
License :: OSI Approved :: Apache Software License
Programming Language :: Python
Expand All @@ -41,7 +41,6 @@ packages=find_namespace:
install_requires =
opentelemetry-api
opentelemetry-sdk
google-cloud-monitoring
google-cloud-trace

[options.packages.find]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019, OpenTelemetry Authors
# Copyright OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -17,7 +17,7 @@

BASE_DIR = os.path.dirname(__file__)
VERSION_FILENAME = os.path.join(
BASE_DIR, "src", "opentelemetry", "ext", "stackdriver", "version.py"
BASE_DIR, "src", "opentelemetry", "exporter", "cloud_trace", "version.py"
)
PACKAGE_INFO = {}
with open(VERSION_FILENAME) as f:
Expand Down
Loading

0 comments on commit 002279b

Please sign in to comment.