diff --git a/contrib/opencensus-ext-azure/README.rst b/contrib/opencensus-ext-azure/README.rst index c6dcf7bca..0c6b69197 100644 --- a/contrib/opencensus-ext-azure/README.rst +++ b/contrib/opencensus-ext-azure/README.rst @@ -16,6 +16,54 @@ Installation Usage ----- +Trace +~~~~~ + +The **Azure Monitor Trace Exporter** allows you to export `OpenCensus`_ traces to `Azure Monitor`_. + +.. _Azure Monitor: https://docs.microsoft.com/azure/azure-monitor/ +.. _OpenCensus: https://github.com/census-instrumentation/opencensus-python/ + +This example shows how to send a span "hello" to Azure Monitor. + +* Create an Azure Monitor resource and get the instrumentation key, more information can be found `here `_. +* Put the instrumentation key in ``APPINSIGHTS_INSTRUMENTATIONKEY`` environment variable. + + +.. code:: python + + from opencensus.ext.azure.trace_exporter import AzureExporter + from opencensus.trace import tracer as tracer_module + + tracer = tracer_module.Tracer(exporter=AzureExporter()) + + with tracer.span(name='hello'): + print('Hello, World!') + +You can also specify the instrumentation key explicitly in the code. + .. code:: python - # TBD + import requests + + from opencensus.ext.azure.common import Options + from opencensus.ext.azure.trace_exporter import AzureExporter + from opencensus.trace import config_integration + from opencensus.trace.tracer import Tracer + + if __name__ == '__main__': + config_integration.trace_integrations(['requests']) + tracer = Tracer(exporter=AzureExporter(Options( + # TODO: replace this with your own instrumentation key. + instrumentation_key='00000000-0000-0000-0000-000000000000', + timeout=29.9, + ))) + with tracer.span(name='parent'): + response = requests.get(url='https://www.wikipedia.org/wiki/Rabbit') + +References +---------- + +* `Azure Monitor `_ +* `Examples `_ +* `OpenCensus Project `_ diff --git a/contrib/opencensus-ext-azure/examples/client.py b/contrib/opencensus-ext-azure/examples/client.py index 695f568e2..be04607c2 100644 --- a/contrib/opencensus-ext-azure/examples/client.py +++ b/contrib/opencensus-ext-azure/examples/client.py @@ -20,6 +20,8 @@ if __name__ == '__main__': config_integration.trace_integrations(['requests']) + # TODO: you need to specify the instrumentation key in the + # APPINSIGHTS_INSTRUMENTATIONKEY environment variable. tracer = Tracer(exporter=AzureExporter()) with tracer.span(name='parent'): with tracer.span(name='child'): diff --git a/contrib/opencensus-ext-azure/examples/config.py b/contrib/opencensus-ext-azure/examples/config.py new file mode 100644 index 000000000..572ffbef6 --- /dev/null +++ b/contrib/opencensus-ext-azure/examples/config.py @@ -0,0 +1,25 @@ +# Copyright 2019, OpenCensus Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from opencensus.ext.azure.common import Options +from opencensus.ext.azure.trace_exporter import AzureExporter +from opencensus.trace import tracer as tracer_module + +tracer = tracer_module.Tracer(exporter=AzureExporter(Options( + # TODO: replace the all-zero GUID with your instrumentation key. + instrumentation_key='00000000-0000-0000-0000-000000000000', +))) + +with tracer.span(name='foo'): + print('Hello, World!') diff --git a/contrib/opencensus-ext-azure/examples/custom.py b/contrib/opencensus-ext-azure/examples/custom.py index 718376cb7..4e26ebf66 100644 --- a/contrib/opencensus-ext-azure/examples/custom.py +++ b/contrib/opencensus-ext-azure/examples/custom.py @@ -16,15 +16,13 @@ from opencensus.ext.flask.flask_middleware import FlaskMiddleware app = Flask(__name__) -# TODO: -# Replace 00000000-0000-0000-0000-000000000000 with your Instrumentation Key -# https://docs.microsoft.com/en-us/azure/azure-monitor/app/create-new-resource +# TODO: replace the all-zero GUID with your instrumentation key. app.config['OPENCENSUS'] = { 'TRACE': { 'SAMPLER': 'opencensus.trace.samplers.ProbabilitySampler(rate=1)', 'EXPORTER': '''opencensus.ext.azure.trace_exporter.AzureExporter( opencensus.ext.azure.common.Options( - instrumentation_key="00000000-0000-0000-0000-000000000000", + instrumentation_key='00000000-0000-0000-0000-000000000000', timeout=29.9, ))''', }, diff --git a/contrib/opencensus-ext-azure/examples/server.py b/contrib/opencensus-ext-azure/examples/server.py index 23d475fce..7aef38c57 100644 --- a/contrib/opencensus-ext-azure/examples/server.py +++ b/contrib/opencensus-ext-azure/examples/server.py @@ -19,6 +19,8 @@ from opencensus.ext.azure.trace_exporter import AzureExporter from opencensus.ext.flask.flask_middleware import FlaskMiddleware +# TODO: you need to specify the instrumentation key in the +# APPINSIGHTS_INSTRUMENTATIONKEY environment variable. app = Flask(__name__) middleware = FlaskMiddleware(app, exporter=AzureExporter()) diff --git a/contrib/opencensus-ext-azure/examples/simple.py b/contrib/opencensus-ext-azure/examples/simple.py index 040dc669d..650fe72b9 100644 --- a/contrib/opencensus-ext-azure/examples/simple.py +++ b/contrib/opencensus-ext-azure/examples/simple.py @@ -15,9 +15,9 @@ from opencensus.ext.azure.trace_exporter import AzureExporter from opencensus.trace import tracer as tracer_module +# TODO: you need to specify the instrumentation key in the +# APPINSIGHTS_INSTRUMENTATIONKEY environment variable. tracer = tracer_module.Tracer(exporter=AzureExporter()) -if __name__ == '__main__': - with tracer.span(name='foo') as foo: - with foo.span(name='bar'): - print('Hello, World!') +with tracer.span(name='foo'): + print('Hello, World!') diff --git a/contrib/opencensus-ext-dbapi/README.rst b/contrib/opencensus-ext-dbapi/README.rst index e57046ecf..c993de665 100644 --- a/contrib/opencensus-ext-dbapi/README.rst +++ b/contrib/opencensus-ext-dbapi/README.rst @@ -16,6 +16,14 @@ Installation Usage ----- -.. code:: python +The OpenCensus Database API Integration library provides the database +integration infrastructure for extensions `opencensus-ext-mysql`_ +and `opencensus-ext-pymysql`_. - # TBD +.. _opencensus-ext-mysql: https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-mysql +.. _opencensus-ext-pymysql: https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-pymysql + +References +---------- + +* `OpenCensus Project `_ diff --git a/contrib/opencensus-ext-django/README.rst b/contrib/opencensus-ext-django/README.rst index 42eb6058a..9fe978fc6 100644 --- a/contrib/opencensus-ext-django/README.rst +++ b/contrib/opencensus-ext-django/README.rst @@ -49,3 +49,8 @@ for a complete reference. )''', } } + +References +---------- + +* `OpenCensus Project `_ diff --git a/contrib/opencensus-ext-flask/README.rst b/contrib/opencensus-ext-flask/README.rst index db1046816..797e2bbbc 100644 --- a/contrib/opencensus-ext-flask/README.rst +++ b/contrib/opencensus-ext-flask/README.rst @@ -48,3 +48,8 @@ for a complete reference. )''', } } + +References +---------- + +* `OpenCensus Project `_ diff --git a/contrib/opencensus-ext-google-cloud-clientlibs/README.rst b/contrib/opencensus-ext-google-cloud-clientlibs/README.rst index 8a8789b07..93a34388a 100644 --- a/contrib/opencensus-ext-google-cloud-clientlibs/README.rst +++ b/contrib/opencensus-ext-google-cloud-clientlibs/README.rst @@ -25,4 +25,11 @@ Usage .. code:: python - # TBD + from opencensus.trace import config_integration + + config_integration.trace_integrations(['google_cloud_clientlibs']) + +References +---------- + +* `OpenCensus Project `_ diff --git a/contrib/opencensus-ext-grpc/README.rst b/contrib/opencensus-ext-grpc/README.rst index 105b23b9d..29ebc4007 100644 --- a/contrib/opencensus-ext-grpc/README.rst +++ b/contrib/opencensus-ext-grpc/README.rst @@ -33,4 +33,12 @@ Usage .. code:: python - # TBD + from opencensus.trace import config_integration + + config_integration.trace_integrations(['grpc']) + +References +---------- + +* `gRPC `_ +* `OpenCensus Project `_ diff --git a/contrib/opencensus-ext-httplib/README.rst b/contrib/opencensus-ext-httplib/README.rst index 26f6670c3..6029dad93 100644 --- a/contrib/opencensus-ext-httplib/README.rst +++ b/contrib/opencensus-ext-httplib/README.rst @@ -26,4 +26,17 @@ Usage .. code:: python - # TBD + import requests + from opencensus.trace import config_integration + from opencensus.trace.tracer import Tracer + + config_integration.trace_integrations(['httplib']) + tracer = Tracer() + + with tracer.span(name='parent'): + response = requests.get('https://www.wikipedia.org/wiki/Rabbit') + +References +---------- + +* `OpenCensus Project `_ diff --git a/contrib/opencensus-ext-jaeger/README.rst b/contrib/opencensus-ext-jaeger/README.rst index 54adf881b..7d6368d97 100644 --- a/contrib/opencensus-ext-jaeger/README.rst +++ b/contrib/opencensus-ext-jaeger/README.rst @@ -16,6 +16,27 @@ Installation Usage ----- +The **OpenCensus Jaeger Exporter** allows you to export `OpenCensus`_ traces to `Jaeger`_. + +.. _Jaeger: https://www.jaegertracing.io/ +.. _OpenCensus: https://github.com/census-instrumentation/opencensus-python/ + .. code:: python - # TBD + from opencensus.ext.jaeger.trace_exporter import JaegerExporter + from opencensus.trace import tracer as tracer_module + + tracer = tracer_module.Tracer(exporter=JaegerExporter( + service_name='my service', + agent_host_name='localhost', + agent_port=6831, + )) + + with tracer.span(name='hello'): + print('Hello, World!') + +References +---------- + +* `Jaeger `_ +* `OpenCensus Project `_ diff --git a/contrib/opencensus-ext-mysql/README.rst b/contrib/opencensus-ext-mysql/README.rst index f99f5a45f..ef8a0f74c 100644 --- a/contrib/opencensus-ext-mysql/README.rst +++ b/contrib/opencensus-ext-mysql/README.rst @@ -23,4 +23,11 @@ Usage .. code:: python - # TBD + from opencensus.trace import config_integration + + config_integration.trace_integrations(['mysql']) + +References +---------- + +* `OpenCensus Project `_ diff --git a/contrib/opencensus-ext-ocagent/README.rst b/contrib/opencensus-ext-ocagent/README.rst index c2cd222b3..97898b40a 100644 --- a/contrib/opencensus-ext-ocagent/README.rst +++ b/contrib/opencensus-ext-ocagent/README.rst @@ -26,3 +26,9 @@ Stats ocagent_stats_exporter.new_stats_exporter( service_name='service_name', endpoint='localhost:55678') + +References +---------- + +* `OpenCensus Project `_ +* `OpenCensus Services `_ diff --git a/contrib/opencensus-ext-postgresql/README.rst b/contrib/opencensus-ext-postgresql/README.rst index 54bd91bfb..51eedeb44 100644 --- a/contrib/opencensus-ext-postgresql/README.rst +++ b/contrib/opencensus-ext-postgresql/README.rst @@ -23,4 +23,11 @@ Usage .. code:: python - # TBD + from opencensus.trace import config_integration + + config_integration.trace_integrations(['postgresql']) + +References +---------- + +* `OpenCensus Project `_ diff --git a/contrib/opencensus-ext-prometheus/README.rst b/contrib/opencensus-ext-prometheus/README.rst index 5e36d506c..c469b44d9 100644 --- a/contrib/opencensus-ext-prometheus/README.rst +++ b/contrib/opencensus-ext-prometheus/README.rst @@ -69,3 +69,7 @@ For further details for the Prometheus implementation, see the folder *prometheu | contrib/opencensus-ext-prometheus/opencensus/ext/prometheus/stats_exporter/ | Stats implementation for Prometheus | +-------------------------------------------------------------------------------+-------------------------------------+ +References +---------- + +* `OpenCensus Project `_ diff --git a/contrib/opencensus-ext-pymongo/README.rst b/contrib/opencensus-ext-pymongo/README.rst index bf28c7c1b..4f45447bc 100644 --- a/contrib/opencensus-ext-pymongo/README.rst +++ b/contrib/opencensus-ext-pymongo/README.rst @@ -23,4 +23,11 @@ Usage .. code:: python - # TBD + from opencensus.trace import config_integration + + config_integration.trace_integrations(['pymongo']) + +References +---------- + +* `OpenCensus Project `_ diff --git a/contrib/opencensus-ext-pymysql/README.rst b/contrib/opencensus-ext-pymysql/README.rst index e8a2eca43..663f6cb82 100644 --- a/contrib/opencensus-ext-pymysql/README.rst +++ b/contrib/opencensus-ext-pymysql/README.rst @@ -18,4 +18,12 @@ Usage .. code:: python - # TBD + from opencensus.trace import config_integration + + config_integration.trace_integrations(['pymysql']) + +References +---------- + +* `OpenCensus Project `_ + diff --git a/contrib/opencensus-ext-pyramid/README.rst b/contrib/opencensus-ext-pyramid/README.rst index 9d44a448f..abbf610fc 100644 --- a/contrib/opencensus-ext-pyramid/README.rst +++ b/contrib/opencensus-ext-pyramid/README.rst @@ -46,3 +46,8 @@ for a complete reference. } config = Configurator(settings=settings) + +References +---------- + +* `OpenCensus Project `_ diff --git a/contrib/opencensus-ext-requests/README.rst b/contrib/opencensus-ext-requests/README.rst index 6fc6269c4..54762d7c0 100644 --- a/contrib/opencensus-ext-requests/README.rst +++ b/contrib/opencensus-ext-requests/README.rst @@ -31,5 +31,17 @@ Usage .. code:: python - execution_context.set_opencensus_attr('blacklist_hostnames',['hostname:port']) + import requests + from opencensus.trace import config_integration + from opencensus.trace.tracer import Tracer + if __name__ == '__main__': + config_integration.trace_integrations(['requests']) + tracer = Tracer() + with tracer.span(name='parent'): + response = requests.get(url='https://www.wikipedia.org/wiki/Rabbit') + +References +---------- + +* `OpenCensus Project `_ diff --git a/contrib/opencensus-ext-sqlalchemy/README.rst b/contrib/opencensus-ext-sqlalchemy/README.rst index 7356819dc..5534c9090 100644 --- a/contrib/opencensus-ext-sqlalchemy/README.rst +++ b/contrib/opencensus-ext-sqlalchemy/README.rst @@ -26,4 +26,11 @@ Usage .. code:: python - # TBD + from opencensus.trace import config_integration + + config_integration.trace_integrations(['sqlalchemy']) + +References +---------- + +* `OpenCensus Project `_ diff --git a/contrib/opencensus-ext-stackdriver/README.rst b/contrib/opencensus-ext-stackdriver/README.rst index 9702c3bbc..07361eec3 100644 --- a/contrib/opencensus-ext-stackdriver/README.rst +++ b/contrib/opencensus-ext-stackdriver/README.rst @@ -112,3 +112,7 @@ For further details for the Stackdriver implementation, see the folder *stackdri | contrib/opencensus-ext-stackdriver/opencensus/ext/stackdriver/stats_exporter/ | Stats implementation for Stackdriver| +---------------------------------------------------------------------------------+-------------------------------------+ +References +---------- + +* `OpenCensus Project `_ diff --git a/contrib/opencensus-ext-threading/README.rst b/contrib/opencensus-ext-threading/README.rst index faa8f8c8c..3b8021704 100644 --- a/contrib/opencensus-ext-threading/README.rst +++ b/contrib/opencensus-ext-threading/README.rst @@ -22,4 +22,11 @@ Usage .. code:: python - # TBD + from opencensus.trace import config_integration + + config_integration.trace_integrations(['threading']) + +References +---------- + +* `OpenCensus Project `_ diff --git a/contrib/opencensus-ext-zipkin/README.rst b/contrib/opencensus-ext-zipkin/README.rst index e9663a979..fafbefeb7 100644 --- a/contrib/opencensus-ext-zipkin/README.rst +++ b/contrib/opencensus-ext-zipkin/README.rst @@ -16,6 +16,27 @@ Installation Usage ----- +The **OpenCensus Zipkin Exporter** allows you to export `OpenCensus`_ traces to `Zipkin`_. + +.. _OpenCensus: https://github.com/census-instrumentation/opencensus-python/ +.. _Zipkin: https://zipkin.io/ + .. code:: python - # TBD + from opencensus.ext.zipkin.trace_exporter import ZipkinExporter + from opencensus.trace import tracer as tracer_module + + tracer = tracer_module.Tracer(exporter=ZipkinExporter( + service_name='my service', + host_name='localhost', + port=9411, + )) + + with tracer.span(name='hello'): + print('Hello, World!') + +References +---------- + +* `OpenCensus Project `_ +* `Zipkin `_