Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Commit d685f98

Browse files
authored
Update docs (#625)
Added docs/samples to ext packages.
1 parent f0064d8 commit d685f98

File tree

25 files changed

+260
-23
lines changed

25 files changed

+260
-23
lines changed

contrib/opencensus-ext-azure/README.rst

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,54 @@ Installation
1616
Usage
1717
-----
1818

19+
Trace
20+
~~~~~
21+
22+
The **Azure Monitor Trace Exporter** allows you to export `OpenCensus`_ traces to `Azure Monitor`_.
23+
24+
.. _Azure Monitor: https://docs.microsoft.com/azure/azure-monitor/
25+
.. _OpenCensus: https://github.com/census-instrumentation/opencensus-python/
26+
27+
This example shows how to send a span "hello" to Azure Monitor.
28+
29+
* Create an Azure Monitor resource and get the instrumentation key, more information can be found `here <https://docs.microsoft.com/azure/azure-monitor/app/create-new-resource>`_.
30+
* Put the instrumentation key in ``APPINSIGHTS_INSTRUMENTATIONKEY`` environment variable.
31+
32+
33+
.. code:: python
34+
35+
from opencensus.ext.azure.trace_exporter import AzureExporter
36+
from opencensus.trace import tracer as tracer_module
37+
38+
tracer = tracer_module.Tracer(exporter=AzureExporter())
39+
40+
with tracer.span(name='hello'):
41+
print('Hello, World!')
42+
43+
You can also specify the instrumentation key explicitly in the code.
44+
1945
.. code:: python
2046
21-
# TBD
47+
import requests
48+
49+
from opencensus.ext.azure.common import Options
50+
from opencensus.ext.azure.trace_exporter import AzureExporter
51+
from opencensus.trace import config_integration
52+
from opencensus.trace.tracer import Tracer
53+
54+
if __name__ == '__main__':
55+
config_integration.trace_integrations(['requests'])
56+
tracer = Tracer(exporter=AzureExporter(Options(
57+
# TODO: replace this with your own instrumentation key.
58+
instrumentation_key='00000000-0000-0000-0000-000000000000',
59+
timeout=29.9,
60+
)))
61+
with tracer.span(name='parent'):
62+
response = requests.get(url='https://www.wikipedia.org/wiki/Rabbit')
63+
64+
References
65+
----------
66+
67+
* `Azure Monitor <https://docs.microsoft.com/azure/azure-monitor/>`_
68+
* `Examples <https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-azure/examples>`_
69+
* `OpenCensus Project <https://opencensus.io/>`_

contrib/opencensus-ext-azure/examples/client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
if __name__ == '__main__':
2222
config_integration.trace_integrations(['requests'])
23+
# TODO: you need to specify the instrumentation key in the
24+
# APPINSIGHTS_INSTRUMENTATIONKEY environment variable.
2325
tracer = Tracer(exporter=AzureExporter())
2426
with tracer.span(name='parent'):
2527
with tracer.span(name='child'):
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2019, OpenCensus Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from opencensus.ext.azure.common import Options
16+
from opencensus.ext.azure.trace_exporter import AzureExporter
17+
from opencensus.trace import tracer as tracer_module
18+
19+
tracer = tracer_module.Tracer(exporter=AzureExporter(Options(
20+
# TODO: replace the all-zero GUID with your instrumentation key.
21+
instrumentation_key='00000000-0000-0000-0000-000000000000',
22+
)))
23+
24+
with tracer.span(name='foo'):
25+
print('Hello, World!')

contrib/opencensus-ext-azure/examples/custom.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@
1616
from opencensus.ext.flask.flask_middleware import FlaskMiddleware
1717

1818
app = Flask(__name__)
19-
# TODO:
20-
# Replace 00000000-0000-0000-0000-000000000000 with your Instrumentation Key
21-
# https://docs.microsoft.com/en-us/azure/azure-monitor/app/create-new-resource
19+
# TODO: replace the all-zero GUID with your instrumentation key.
2220
app.config['OPENCENSUS'] = {
2321
'TRACE': {
2422
'SAMPLER': 'opencensus.trace.samplers.ProbabilitySampler(rate=1)',
2523
'EXPORTER': '''opencensus.ext.azure.trace_exporter.AzureExporter(
2624
opencensus.ext.azure.common.Options(
27-
instrumentation_key="00000000-0000-0000-0000-000000000000",
25+
instrumentation_key='00000000-0000-0000-0000-000000000000',
2826
timeout=29.9,
2927
))''',
3028
},

contrib/opencensus-ext-azure/examples/server.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
from opencensus.ext.azure.trace_exporter import AzureExporter
2020
from opencensus.ext.flask.flask_middleware import FlaskMiddleware
2121

22+
# TODO: you need to specify the instrumentation key in the
23+
# APPINSIGHTS_INSTRUMENTATIONKEY environment variable.
2224
app = Flask(__name__)
2325
middleware = FlaskMiddleware(app, exporter=AzureExporter())
2426

contrib/opencensus-ext-azure/examples/simple.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
from opencensus.ext.azure.trace_exporter import AzureExporter
1616
from opencensus.trace import tracer as tracer_module
1717

18+
# TODO: you need to specify the instrumentation key in the
19+
# APPINSIGHTS_INSTRUMENTATIONKEY environment variable.
1820
tracer = tracer_module.Tracer(exporter=AzureExporter())
1921

20-
if __name__ == '__main__':
21-
with tracer.span(name='foo') as foo:
22-
with foo.span(name='bar'):
23-
print('Hello, World!')
22+
with tracer.span(name='foo'):
23+
print('Hello, World!')

contrib/opencensus-ext-dbapi/README.rst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ Installation
1616
Usage
1717
-----
1818

19-
.. code:: python
19+
The OpenCensus Database API Integration library provides the database
20+
integration infrastructure for extensions `opencensus-ext-mysql`_
21+
and `opencensus-ext-pymysql`_.
2022

21-
# TBD
23+
.. _opencensus-ext-mysql: https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-mysql
24+
.. _opencensus-ext-pymysql: https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-pymysql
25+
26+
References
27+
----------
28+
29+
* `OpenCensus Project <https://opencensus.io/>`_

contrib/opencensus-ext-django/README.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,8 @@ for a complete reference.
4949
)''',
5050
}
5151
}
52+
53+
References
54+
----------
55+
56+
* `OpenCensus Project <https://opencensus.io/>`_

contrib/opencensus-ext-flask/README.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,8 @@ for a complete reference.
4848
)''',
4949
}
5050
}
51+
52+
References
53+
----------
54+
55+
* `OpenCensus Project <https://opencensus.io/>`_

contrib/opencensus-ext-google-cloud-clientlibs/README.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,11 @@ Usage
2525

2626
.. code:: python
2727
28-
# TBD
28+
from opencensus.trace import config_integration
29+
30+
config_integration.trace_integrations(['google_cloud_clientlibs'])
31+
32+
References
33+
----------
34+
35+
* `OpenCensus Project <https://opencensus.io/>`_

0 commit comments

Comments
 (0)