├── .coveragerc ├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md └── workflows │ ├── build.yml │ └── codeql-analysis.yml ├── .gitignore ├── .isort.cfg ├── .pylintrc ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── MANIFEST.in ├── Makefile ├── README.rst ├── RELEASING.md ├── context └── opencensus-context │ ├── CHANGELOG.md │ ├── README.rst │ ├── examples │ ├── async_span.py │ ├── explicit_threading.py │ ├── py27.py │ ├── py37.py │ ├── span.py │ └── thread_pool.py │ ├── opencensus │ ├── __init__.py │ └── common │ │ ├── __init__.py │ │ └── runtime_context │ │ ├── __init__.py │ │ └── version.py │ ├── setup.cfg │ ├── setup.py │ └── tests │ └── test_runtime_context.py ├── contrib ├── opencensus-correlation │ ├── CHANGELOG.md │ ├── README.rst │ ├── opencensus │ │ ├── __init__.py │ │ └── common │ │ │ ├── __init__.py │ │ │ └── correlationcontext │ │ │ ├── __init__.py │ │ │ └── correlationcontext.py │ ├── setup.cfg │ ├── setup.py │ ├── tests │ │ ├── __init__.py │ │ └── test_correlation_context.py │ └── version.py ├── opencensus-ext-azure │ ├── CHANGELOG.md │ ├── README.rst │ ├── examples │ │ ├── logs │ │ │ ├── correlated.py │ │ │ ├── error.py │ │ │ ├── event.py │ │ │ ├── properties.py │ │ │ └── simple.py │ │ ├── metrics │ │ │ ├── simple.py │ │ │ └── sum.py │ │ └── traces │ │ │ ├── client.py │ │ │ ├── credential.py │ │ │ ├── custom.py │ │ │ ├── django │ │ │ ├── logfile │ │ │ └── mysite │ │ │ │ ├── db.sqlite3 │ │ │ │ ├── manage.py │ │ │ │ ├── mysite │ │ │ │ ├── __init__.py │ │ │ │ ├── asgi.py │ │ │ │ ├── settings.py │ │ │ │ ├── urls.py │ │ │ │ └── wsgi.py │ │ │ │ └── polls │ │ │ │ ├── __init__.py │ │ │ │ ├── admin.py │ │ │ │ ├── apps.py │ │ │ │ ├── migrations │ │ │ │ └── __init__.py │ │ │ │ ├── models.py │ │ │ │ ├── tests.py │ │ │ │ ├── urls.py │ │ │ │ └── views.py │ │ │ ├── server.py │ │ │ └── simple.py │ ├── opencensus │ │ ├── __init__.py │ │ └── ext │ │ │ ├── __init__.py │ │ │ └── azure │ │ │ ├── __init__.py │ │ │ ├── common │ │ │ ├── __init__.py │ │ │ ├── exporter.py │ │ │ ├── processor.py │ │ │ ├── protocol.py │ │ │ ├── storage.py │ │ │ ├── transport.py │ │ │ ├── utils.py │ │ │ └── version.py │ │ │ ├── log_exporter │ │ │ └── __init__.py │ │ │ ├── metrics_exporter │ │ │ ├── __init__.py │ │ │ └── standard_metrics │ │ │ │ ├── __init__.py │ │ │ │ ├── cpu.py │ │ │ │ ├── http_requests.py │ │ │ │ ├── memory.py │ │ │ │ └── process.py │ │ │ ├── statsbeat │ │ │ ├── __init__.py │ │ │ ├── state.py │ │ │ ├── statsbeat.py │ │ │ └── statsbeat_metrics.py │ │ │ └── trace_exporter │ │ │ └── __init__.py │ ├── setup.cfg │ ├── setup.py │ └── tests │ │ ├── test_azure_log_exporter.py │ │ ├── test_azure_metrics_exporter.py │ │ ├── test_azure_standard_metrics.py │ │ ├── test_azure_statsbeat_metrics.py │ │ ├── test_azure_trace_exporter.py │ │ ├── test_azure_utils.py │ │ ├── test_options.py │ │ ├── test_processor_mixin.py │ │ ├── test_protocol.py │ │ ├── test_storage.py │ │ └── test_transport_mixin.py ├── opencensus-ext-datadog │ ├── CHANGELOG.md │ ├── README.rst │ ├── examples │ │ └── datadog.py │ ├── opencensus │ │ ├── __init__.py │ │ └── ext │ │ │ ├── __init__.py │ │ │ └── datadog │ │ │ ├── __init__.py │ │ │ ├── traces.py │ │ │ └── transport.py │ ├── setup.cfg │ ├── setup.py │ ├── tests │ │ ├── traces_test.py │ │ └── transport_test.py │ └── version.py ├── opencensus-ext-dbapi │ ├── CHANGELOG.md │ ├── README.rst │ ├── opencensus │ │ ├── __init__.py │ │ └── ext │ │ │ ├── __init__.py │ │ │ └── dbapi │ │ │ ├── __init__.py │ │ │ └── trace.py │ ├── setup.cfg │ ├── setup.py │ ├── tests │ │ └── test_dbapi_trace.py │ └── version.py ├── opencensus-ext-django │ ├── CHANGELOG.md │ ├── README.rst │ ├── examples │ │ ├── app │ │ │ ├── __init__.py │ │ │ ├── forms.py │ │ │ ├── settings.py │ │ │ ├── templates │ │ │ │ └── home.html │ │ │ ├── urls.py │ │ │ └── views.py │ │ └── manage.py │ ├── opencensus │ │ ├── __init__.py │ │ └── ext │ │ │ ├── __init__.py │ │ │ └── django │ │ │ ├── __init__.py │ │ │ └── middleware.py │ ├── setup.cfg │ ├── setup.py │ ├── tests │ │ ├── test_django_db_middleware.py │ │ └── test_django_middleware.py │ └── version.py ├── opencensus-ext-fastapi │ ├── CHANGELOG.md │ ├── README.rst │ ├── opencensus │ │ ├── __init__.py │ │ └── ext │ │ │ ├── __init__.py │ │ │ └── fastapi │ │ │ ├── __init__.py │ │ │ └── fastapi_middleware.py │ ├── setup.cfg │ ├── setup.py │ ├── tests │ │ └── test_fastapi_middleware.py │ └── version.py ├── opencensus-ext-flask │ ├── CHANGELOG.md │ ├── README.rst │ ├── examples │ │ ├── custom.py │ │ └── simple.py │ ├── opencensus │ │ ├── __init__.py │ │ └── ext │ │ │ ├── __init__.py │ │ │ └── flask │ │ │ ├── __init__.py │ │ │ ├── common │ │ │ ├── __init__.py │ │ │ └── version.py │ │ │ └── flask_middleware.py │ ├── setup.cfg │ ├── setup.py │ └── tests │ │ └── test_flask_middleware.py ├── opencensus-ext-gevent │ ├── CHANGELOG.md │ ├── README.rst │ ├── opencensus │ │ ├── __init__.py │ │ └── ext │ │ │ ├── __init__.py │ │ │ └── gevent │ │ │ ├── __init__.py │ │ │ └── geventcompatibility.py │ ├── setup.cfg │ ├── setup.py │ ├── tests │ │ └── test_patching.py │ └── version.py ├── opencensus-ext-google-cloud-clientlibs │ ├── CHANGELOG.md │ ├── README.rst │ ├── opencensus │ │ ├── __init__.py │ │ └── ext │ │ │ ├── __init__.py │ │ │ └── google_cloud_clientlibs │ │ │ ├── __init__.py │ │ │ └── trace.py │ ├── setup.cfg │ ├── setup.py │ ├── tests │ │ └── test_google_cloud_clientlibs_trace.py │ └── version.py ├── opencensus-ext-grpc │ ├── CHANGELOG.md │ ├── README.rst │ ├── examples │ │ ├── hello_world.proto │ │ ├── hello_world_client.py │ │ ├── hello_world_pb2.py │ │ ├── hello_world_pb2_grpc.py │ │ └── hello_world_server.py │ ├── opencensus │ │ ├── __init__.py │ │ └── ext │ │ │ ├── __init__.py │ │ │ └── grpc │ │ │ ├── __init__.py │ │ │ ├── client_interceptor.py │ │ │ ├── server_interceptor.py │ │ │ └── utils.py │ ├── setup.cfg │ ├── setup.py │ ├── tests │ │ ├── test_client_interceptor.py │ │ └── test_server_interceptor.py │ └── version.py ├── opencensus-ext-httplib │ ├── CHANGELOG.md │ ├── README.rst │ ├── opencensus │ │ ├── __init__.py │ │ └── ext │ │ │ ├── __init__.py │ │ │ └── httplib │ │ │ ├── __init__.py │ │ │ └── trace.py │ ├── setup.cfg │ ├── setup.py │ ├── tests │ │ └── test_httplib_trace.py │ └── version.py ├── opencensus-ext-httpx │ ├── CHANGELOG.md │ ├── README.rst │ ├── opencensus │ │ ├── __init__.py │ │ └── ext │ │ │ ├── __init__.py │ │ │ └── httpx │ │ │ ├── __init__.py │ │ │ └── trace.py │ ├── setup.cfg │ ├── setup.py │ ├── tests │ │ └── test_httpx_trace.py │ └── version.py ├── opencensus-ext-jaeger │ ├── CHANGELOG.md │ ├── README.rst │ ├── opencensus │ │ ├── __init__.py │ │ └── ext │ │ │ ├── __init__.py │ │ │ └── jaeger │ │ │ ├── __init__.py │ │ │ └── trace_exporter │ │ │ ├── __init__.py │ │ │ └── gen │ │ │ ├── __init__.py │ │ │ └── jaeger │ │ │ ├── __init__.py │ │ │ ├── agent.py │ │ │ └── jaeger.py │ ├── setup.cfg │ ├── setup.py │ ├── tests │ │ └── test_jaeger_exporter.py │ └── version.py ├── opencensus-ext-logging │ ├── CHANGELOG.md │ ├── README.rst │ ├── opencensus │ │ ├── __init__.py │ │ └── ext │ │ │ ├── __init__.py │ │ │ └── logging │ │ │ ├── __init__.py │ │ │ └── trace.py │ ├── setup.cfg │ ├── setup.py │ ├── tests │ │ └── test_logging_integration.py │ └── version.py ├── opencensus-ext-mysql │ ├── CHANGELOG.md │ ├── README.rst │ ├── opencensus │ │ ├── __init__.py │ │ └── ext │ │ │ ├── __init__.py │ │ │ └── mysql │ │ │ ├── __init__.py │ │ │ └── trace.py │ ├── setup.cfg │ ├── setup.py │ ├── tests │ │ └── test_mysql_trace.py │ └── version.py ├── opencensus-ext-ocagent │ ├── CHANGELOG.md │ ├── README.rst │ ├── opencensus │ │ ├── __init__.py │ │ └── ext │ │ │ ├── __init__.py │ │ │ └── ocagent │ │ │ ├── __init__.py │ │ │ ├── stats_exporter │ │ │ └── __init__.py │ │ │ ├── trace_exporter │ │ │ ├── __init__.py │ │ │ └── utils.py │ │ │ └── utils │ │ │ └── __init__.py │ ├── setup.cfg │ ├── setup.py │ ├── tests │ │ ├── test_ocagent_utils.py │ │ ├── test_stats_exporter.py │ │ ├── test_trace_exporter.py │ │ └── test_trace_exporter_utils.py │ └── version.py ├── opencensus-ext-postgresql │ ├── CHANGELOG.md │ ├── README.rst │ ├── opencensus │ │ ├── __init__.py │ │ └── ext │ │ │ ├── __init__.py │ │ │ └── postgresql │ │ │ ├── __init__.py │ │ │ └── trace.py │ ├── setup.cfg │ ├── setup.py │ ├── tests │ │ └── test_postgresql_trace.py │ └── version.py ├── opencensus-ext-prometheus │ ├── CHANGELOG.md │ ├── README.rst │ ├── examples │ │ └── prometheus.py │ ├── opencensus │ │ ├── __init__.py │ │ └── ext │ │ │ ├── __init__.py │ │ │ └── prometheus │ │ │ ├── __init__.py │ │ │ └── stats_exporter │ │ │ └── __init__.py │ ├── setup.cfg │ ├── setup.py │ ├── tests │ │ └── test_prometheus_stats.py │ └── version.py ├── opencensus-ext-pymongo │ ├── CHANGELOG.md │ ├── README.rst │ ├── opencensus │ │ ├── __init__.py │ │ └── ext │ │ │ ├── __init__.py │ │ │ └── pymongo │ │ │ ├── __init__.py │ │ │ └── trace.py │ ├── setup.cfg │ ├── setup.py │ ├── tests │ │ └── test_pymongo_trace.py │ └── version.py ├── opencensus-ext-pymysql │ ├── CHANGELOG.md │ ├── README.rst │ ├── opencensus │ │ ├── __init__.py │ │ └── ext │ │ │ ├── __init__.py │ │ │ └── pymysql │ │ │ ├── __init__.py │ │ │ └── trace.py │ ├── setup.cfg │ ├── setup.py │ ├── tests │ │ └── test_pymysql_trace.py │ └── version.py ├── opencensus-ext-pyramid │ ├── CHANGELOG.md │ ├── README.rst │ ├── examples │ │ ├── app │ │ │ └── __init__.py │ │ └── simple.py │ ├── opencensus │ │ ├── __init__.py │ │ └── ext │ │ │ ├── __init__.py │ │ │ └── pyramid │ │ │ ├── __init__.py │ │ │ ├── config.py │ │ │ └── pyramid_middleware.py │ ├── setup.cfg │ ├── setup.py │ ├── tests │ │ ├── test_pyramid_config.py │ │ └── test_pyramid_middleware.py │ └── version.py ├── opencensus-ext-requests │ ├── CHANGELOG.md │ ├── README.rst │ ├── opencensus │ │ ├── __init__.py │ │ └── ext │ │ │ ├── __init__.py │ │ │ └── requests │ │ │ ├── __init__.py │ │ │ ├── common │ │ │ ├── __init__.py │ │ │ └── version.py │ │ │ └── trace.py │ ├── setup.cfg │ ├── setup.py │ └── tests │ │ └── test_requests_trace.py ├── opencensus-ext-sqlalchemy │ ├── CHANGELOG.md │ ├── README.rst │ ├── opencensus │ │ ├── __init__.py │ │ └── ext │ │ │ ├── __init__.py │ │ │ └── sqlalchemy │ │ │ ├── __init__.py │ │ │ └── trace.py │ ├── setup.cfg │ ├── setup.py │ ├── tests │ │ └── test_sqlalchemy_trace.py │ └── version.py ├── opencensus-ext-stackdriver │ ├── CHANGELOG.md │ ├── README.rst │ ├── examples │ │ └── stackdriver.py │ ├── opencensus │ │ ├── __init__.py │ │ └── ext │ │ │ ├── __init__.py │ │ │ └── stackdriver │ │ │ ├── __init__.py │ │ │ ├── stats_exporter │ │ │ └── __init__.py │ │ │ └── trace_exporter │ │ │ └── __init__.py │ ├── setup.cfg │ ├── setup.py │ ├── tests │ │ ├── test_stackdriver_exporter.py │ │ └── test_stackdriver_stats.py │ └── version.py ├── opencensus-ext-threading │ ├── CHANGELOG.md │ ├── README.rst │ ├── opencensus │ │ ├── __init__.py │ │ └── ext │ │ │ ├── __init__.py │ │ │ └── threading │ │ │ ├── __init__.py │ │ │ └── trace.py │ ├── setup.cfg │ ├── setup.py │ ├── tests │ │ └── test_threading_trace.py │ └── version.py └── opencensus-ext-zipkin │ ├── CHANGELOG.md │ ├── README.rst │ ├── opencensus │ ├── __init__.py │ └── ext │ │ ├── __init__.py │ │ └── zipkin │ │ ├── __init__.py │ │ └── trace_exporter │ │ └── __init__.py │ ├── setup.cfg │ ├── setup.py │ ├── tests │ └── test_zipkin_exporter.py │ └── version.py ├── docs ├── .nojekyll ├── conf.py ├── index.rst ├── requirements.txt └── trace │ ├── api │ ├── binary_format_propagation.rst │ ├── context_tracer.rst │ ├── execution_context.rst │ ├── file_exporter.rst │ ├── google_cloud_format_propagation.rst │ ├── index.rst │ ├── logging_exporter.rst │ ├── noop_tracer.rst │ ├── print_exporter.rst │ ├── samplers.rst │ ├── span.rst │ ├── span_context.rst │ ├── stackdriver_exporter.rst │ ├── text_format_propagation.rst │ ├── trace_context_http_header_format_propagation.rst │ ├── trace_options.rst │ ├── tracer.rst │ └── zipkin_exporter.rst │ ├── index.rst │ └── usage.rst ├── examples ├── stats │ └── helloworld │ │ └── main.py └── trace │ └── helloworld │ └── main.py ├── noxfile.py ├── opencensus ├── __init__.py ├── common │ ├── __init__.py │ ├── backports │ │ └── __init__.py │ ├── configuration │ │ └── __init__.py │ ├── http_handler │ │ └── __init__.py │ ├── monitored_resource │ │ ├── __init__.py │ │ ├── aws_identity_doc_utils.py │ │ ├── gcp_metadata_config.py │ │ ├── k8s_utils.py │ │ └── monitored_resource.py │ ├── resource │ │ └── __init__.py │ ├── schedule │ │ └── __init__.py │ ├── transports │ │ ├── __init__.py │ │ ├── async_.py │ │ ├── base.py │ │ └── sync.py │ ├── utils │ │ └── __init__.py │ └── version │ │ └── __init__.py ├── log │ └── __init__.py ├── metrics │ ├── __init__.py │ ├── export │ │ ├── __init__.py │ │ ├── cumulative.py │ │ ├── gauge.py │ │ ├── metric.py │ │ ├── metric_descriptor.py │ │ ├── metric_producer.py │ │ ├── point.py │ │ ├── summary.py │ │ ├── time_series.py │ │ └── value.py │ ├── label_key.py │ ├── label_value.py │ └── transport.py ├── stats │ ├── __init__.py │ ├── aggregation.py │ ├── aggregation_data.py │ ├── base_exporter.py │ ├── bucket_boundaries.py │ ├── execution_context.py │ ├── measure.py │ ├── measure_to_view_map.py │ ├── measurement.py │ ├── measurement_map.py │ ├── metric_utils.py │ ├── stats.py │ ├── stats_recorder.py │ ├── view.py │ ├── view_data.py │ └── view_manager.py ├── tags │ ├── __init__.py │ ├── propagation │ │ ├── __init__.py │ │ └── binary_serializer.py │ ├── tag.py │ ├── tag_key.py │ ├── tag_map.py │ ├── tag_value.py │ └── validation.py └── trace │ ├── __init__.py │ ├── attributes.py │ ├── attributes_helper.py │ ├── base_exporter.py │ ├── base_span.py │ ├── blank_span.py │ ├── config_integration.py │ ├── exceptions_status.py │ ├── execution_context.py │ ├── file_exporter.py │ ├── integrations.py │ ├── link.py │ ├── logging_exporter.py │ ├── print_exporter.py │ ├── propagation │ ├── __init__.py │ ├── b3_format.py │ ├── binary_format.py │ ├── google_cloud_format.py │ ├── text_format.py │ ├── trace_context_http_header_format.py │ └── tracestate_string_format.py │ ├── samplers │ └── __init__.py │ ├── span.py │ ├── span_context.py │ ├── span_data.py │ ├── stack_trace.py │ ├── status.py │ ├── time_event.py │ ├── trace_options.py │ ├── tracer.py │ ├── tracers │ ├── __init__.py │ ├── base.py │ ├── context_tracer.py │ └── noop_tracer.py │ ├── tracestate.py │ └── utils.py ├── scripts ├── pylint.sh ├── twine_upload.sh └── update_docs.sh ├── setup.cfg ├── setup.py ├── tests ├── __init__.py ├── system │ ├── credentials.json.enc │ ├── set_credential.sh │ ├── stats │ │ ├── prometheus │ │ │ └── prometheus_stats_test.py │ │ └── stackdriver │ │ │ └── stackdriver_stats_test.py │ └── trace │ │ ├── basic_trace │ │ └── basic_trace_system_test.py │ │ ├── django │ │ ├── app │ │ │ ├── __init__.py │ │ │ ├── forms.py │ │ │ ├── settings.py │ │ │ ├── templates │ │ │ │ └── home.html │ │ │ ├── urls.py │ │ │ └── views.py │ │ ├── django_system_test.py │ │ └── manage.py │ │ └── flask │ │ ├── .dockerignore │ │ ├── flask_system_test.py │ │ └── main.py └── unit │ ├── common │ ├── monitored_resource_util │ │ ├── test_aws_identity_doc_utils.py │ │ ├── test_gcp_metadata_config.py │ │ ├── test_k8s_utils.py │ │ └── test_monitored_resource.py │ ├── test_configuration.py │ ├── test_http_handler.py │ ├── test_resource.py │ ├── test_schedule.py │ ├── test_utils.py │ └── transports │ │ ├── test_async.py │ │ ├── test_common_base_transport.py │ │ └── test_sync.py │ ├── log │ └── test_log.py │ ├── metrics │ ├── export │ │ ├── test_cumulative.py │ │ ├── test_gauge.py │ │ ├── test_metric.py │ │ ├── test_metric_descriptor.py │ │ ├── test_metric_producer.py │ │ ├── test_point.py │ │ ├── test_summary.py │ │ ├── test_time_series.py │ │ └── test_value.py │ ├── test_label_key.py │ ├── test_label_value.py │ └── test_transport.py │ ├── stats │ ├── test_aggregation.py │ ├── test_aggregation_data.py │ ├── test_base_stats.py │ ├── test_bucket_boundaries.py │ ├── test_measure.py │ ├── test_measure_to_view_map.py │ ├── test_measurement.py │ ├── test_measurement_map.py │ ├── test_metric_utils.py │ ├── test_stats.py │ ├── test_stats_execution_context.py │ ├── test_stats_recorder.py │ ├── test_view.py │ ├── test_view_data.py │ └── test_view_manager.py │ ├── tags │ ├── propagation │ │ └── test_binary_serializer.py │ ├── test_tag.py │ ├── test_tag_key.py │ ├── test_tag_map.py │ └── test_tag_value.py │ └── trace │ ├── exporters │ ├── test_base_exporter.py │ ├── test_file_exporter.py │ ├── test_logging_exporter.py │ └── test_print_exporter.py │ ├── propagation │ ├── test_b3_format.py │ ├── test_binary_format.py │ ├── test_google_cloud_format.py │ ├── test_text_format.py │ └── test_trace_context_http_header_format.py │ ├── samplers │ ├── test_always_off.py │ ├── test_always_on.py │ ├── test_base_sampler.py │ └── test_probability.py │ ├── test_attributes.py │ ├── test_base_span.py │ ├── test_blank_span.py │ ├── test_config_integration.py │ ├── test_exceptions_status.py │ ├── test_execution_context.py │ ├── test_ext_utils.py │ ├── test_link.py │ ├── test_span.py │ ├── test_span_context.py │ ├── test_span_data.py │ ├── test_stack_trace.py │ ├── test_status.py │ ├── test_time_event.py │ ├── test_trace_options.py │ ├── test_tracer.py │ ├── test_tracestate.py │ └── tracers │ ├── test_base_tracer.py │ ├── test_context_tracer.py │ └── test_noop_tracer.py └── tox.ini /.coveragerc: -------------------------------------------------------------------------------- 1 | [run] 2 | branch = True 3 | omit = 4 | # Test cases 5 | context/*/tests/* 6 | contrib/*/tests/* 7 | # Auto generated files 8 | contrib/opencensus-ext-jaeger/opencensus/ext/jaeger/trace_exporter/gen/* 9 | # Side-effect introduced by namespace packages 10 | opencensus/__init__.py 11 | opencensus/common/__init__.py 12 | 13 | [report] 14 | fail_under = 100 15 | show_missing = True 16 | exclude_lines = 17 | # Re-enable the standard pragma 18 | pragma: NO COVER 19 | # Ignore debug-only repr 20 | def __repr__ 21 | omit = 22 | # Test cases 23 | context/*/tests/* 24 | # Side-effect introduced by namespace packages 25 | contrib/*/opencensus/__init__.py 26 | contrib/*/opencensus/ext/__init__.py 27 | opencensus/__init__.py 28 | opencensus/common/__init__.py 29 | # Auto generated files 30 | contrib/opencensus-ext-jaeger/opencensus/ext/jaeger/trace_exporter/gen/* 31 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Code owners file. 2 | # This file controls who is tagged for review for any given pull request. 3 | 4 | # For anything not explicitly taken by someone else: 5 | * @census-instrumentation/global-owners @aabmass @hectorhdzg @jeremydvoss @lzchen 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Create a report to help us improve 4 | labels: bug 5 | --- 6 | 7 | **Describe your environment.** Describe any aspect of your environment relevant to the problem, including your Python version, [platform](https://docs.python.org/3/library/platform.html), version numbers of installed dependencies, information about your cloud hosting provider, etc. If you're reporting a problem with a specific version of a library in this repo, please check whether the problem has been fixed on master. 8 | 9 | **Steps to reproduce.** 10 | Describe exactly how to reproduce the error. Include a code sample if applicable. 11 | 12 | **What is the expected behavior?** 13 | What did you expect to see? 14 | 15 | **What is the actual behavior?** 16 | What did you see instead? 17 | 18 | **Additional context.** 19 | Add any other context about the problem here. 20 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: Suggest an idea for this project 4 | labels: feature-request 5 | --- 6 | 7 | Before opening a feature request against this repo, consider whether the feature should/could be implemented in the [other OpenCensus client libraries](https://github.com/census-instrumentation). If so, please [open an issue on opencensus-specs](https://github.com/census-instrumentation/opencensus-specs/issues/new) first. 8 | 9 | **Is your feature request related to a problem?** 10 | If so, provide a concise description of the problem. 11 | 12 | **Describe the solution you'd like.** 13 | What do you want to happen instead? What is the expected behavior? 14 | 15 | **Describe alternatives you've considered.** 16 | Which alternative solutions or features have you considered? 17 | 18 | **Additional context.** 19 | Add any other context about the feature request here. 20 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | name: CodeQL Analysis 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches-ignore: 7 | - 'release/*' 8 | 9 | jobs: 10 | CodeQL-Build: 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - name: Checkout repository 15 | uses: actions/checkout@v2 16 | 17 | # Initializes the CodeQL tools for scanning. 18 | - name: Initialize CodeQL 19 | uses: github/codeql-action/init@v1 20 | with: 21 | languages: python 22 | 23 | - name: Autobuild 24 | uses: github/codeql-action/autobuild@v1 25 | 26 | - name: Perform CodeQL Analysis 27 | uses: github/codeql-action/analyze@v1 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.py[cod] 2 | *.sw[op] 3 | 4 | # C extensions 5 | *.so 6 | 7 | # Packages 8 | *.egg 9 | *.egg-info 10 | dist 11 | build 12 | eggs 13 | parts 14 | bin 15 | var 16 | sdist 17 | develop-eggs 18 | .installed.cfg 19 | lib 20 | lib64 21 | __pycache__ 22 | venv*/ 23 | 24 | # Installer logs 25 | pip-log.txt 26 | 27 | # Unit test / coverage reports 28 | .coverage 29 | .nox 30 | .tox 31 | .cache 32 | htmlcov 33 | 34 | # Translations 35 | *.mo 36 | 37 | # Mac 38 | .DS_Store 39 | 40 | # Mr Developer 41 | .mr.developer.cfg 42 | .project 43 | .pydevproject 44 | 45 | # JetBrains 46 | .idea 47 | 48 | # VSCode 49 | .vscode 50 | 51 | # Built documentation 52 | docs/_build 53 | docs/_build_doc2dash 54 | 55 | # Virtual environment 56 | env/ 57 | venv/ 58 | coverage.xml 59 | 60 | # System test environment variables. 61 | system_tests/local_test_setup 62 | 63 | # Make sure a generated file isn't accidentally committed. 64 | pylintrc 65 | pylintrc.test 66 | 67 | # Ignore default file, used for exporting the trace spans. 68 | opencensus-traces.json 69 | -------------------------------------------------------------------------------- /.isort.cfg: -------------------------------------------------------------------------------- 1 | [settings] 2 | include_trailing_comma=True 3 | force_grid_wrap=0 4 | use_parentheses=True 5 | line_length=79 6 | 7 | ; 3 stands for Vertical Hanging Indent, e.g. 8 | ; from third_party import ( 9 | ; lib1, 10 | ; lib2, 11 | ; lib3, 12 | ; ) 13 | ; docs: https://github.com/timothycrosley/isort#multi-line-output-modes 14 | multi_line_output=3 15 | known_future_library = six,six.moves,__future__ 16 | known_third_party=azure-core,azure-identity,google,mock,pymysql,sqlalchemy,psycopg2,mysql,requests,django,pytest,grpc,flask,bitarray,prometheus_client,psutil,pymongo,wrapt,thrift,retrying,pyramid,werkzeug,gevent 17 | known_first_party=opencensus -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include README.rst 2 | global-exclude *.pyc 3 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | SPHINXPROJ = OPENCENSUS 8 | SOURCEDIR = docs 9 | BUILDDIR = docs/build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /RELEASING.md: -------------------------------------------------------------------------------- 1 | # Release OpenCensus Python 2 | 3 | ## Steps 4 | 5 | ### Update the version number in `setup.py` 6 | 7 | ### Create a Github release 8 | 9 | Then the Circle CI will build the package and upload it to PyPI automatically. 10 | -------------------------------------------------------------------------------- /context/opencensus-context/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## Unreleased 4 | 5 | ## 0.1.3 6 | Released 2022-08-03 7 | 8 | - Move `version.py` file into `runtime_context` folder 9 | ([#1143](https://github.com/census-instrumentation/opencensus-python/pull/1143)) 10 | 11 | ## 0.1.2 12 | Released 2020-06-29 13 | 14 | - Release source distribution 15 | 16 | ## 0.1.1 17 | Released 2019-05-31 18 | 19 | - Updated docs and examples 20 | 21 | ## 0.1.0 22 | Released 2019-04-08 23 | 24 | - Initial version 25 | -------------------------------------------------------------------------------- /context/opencensus-context/examples/py27.py: -------------------------------------------------------------------------------- 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.common.runtime_context import RuntimeContext 16 | 17 | RuntimeContext.register_slot('correlation_context', lambda: {}) 18 | 19 | 20 | def hello(name): 21 | correlation_context = RuntimeContext.correlation_context.copy() 22 | correlation_context['name'] = name 23 | RuntimeContext.correlation_context = correlation_context 24 | 25 | print(RuntimeContext) 26 | 27 | 28 | if __name__ == '__main__': 29 | print(RuntimeContext) 30 | RuntimeContext.correlation_context['test'] = True 31 | print(RuntimeContext) 32 | hello('hello') 33 | RuntimeContext.clear() 34 | print(RuntimeContext) 35 | -------------------------------------------------------------------------------- /context/opencensus-context/opencensus/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /context/opencensus-context/opencensus/common/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /context/opencensus-context/opencensus/common/runtime_context/version.py: -------------------------------------------------------------------------------- 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 | __version__ = '0.2.dev0' 16 | -------------------------------------------------------------------------------- /context/opencensus-context/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /contrib/opencensus-correlation/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## Unreleased 4 | 5 | ## 0.3.0 6 | Released 2019-05-31 7 | 8 | - Add this changelog. 9 | -------------------------------------------------------------------------------- /contrib/opencensus-correlation/README.rst: -------------------------------------------------------------------------------- 1 | W3C Correlation Context 2 | ============================================================================ 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opencensus-correlation.svg 7 | :target: https://pypi.org/project/opencensus-correlation/ 8 | -------------------------------------------------------------------------------- /contrib/opencensus-correlation/opencensus/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-correlation/opencensus/common/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-correlation/opencensus/common/correlationcontext/__init__.py: -------------------------------------------------------------------------------- 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.common.correlationcontext.correlationcontext import ( 16 | CorrelationContext, 17 | ) 18 | 19 | __all__ = ['CorrelationContext'] 20 | -------------------------------------------------------------------------------- /contrib/opencensus-correlation/opencensus/common/correlationcontext/correlationcontext.py: -------------------------------------------------------------------------------- 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 | 16 | class CorrelationContext(object): 17 | pass 18 | -------------------------------------------------------------------------------- /contrib/opencensus-correlation/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /contrib/opencensus-correlation/tests/__init__.py: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /contrib/opencensus-correlation/tests/test_correlation_context.py: -------------------------------------------------------------------------------- 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 | import unittest 16 | 17 | from opencensus.common.correlationcontext import CorrelationContext 18 | 19 | 20 | class CorrelationContextTest(unittest.TestCase): 21 | def test_ctor_default(self): 22 | self.assertTrue(CorrelationContext()) 23 | -------------------------------------------------------------------------------- /contrib/opencensus-correlation/version.py: -------------------------------------------------------------------------------- 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 | __version__ = '0.4.dev0' 16 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-azure/examples/logs/correlated.py: -------------------------------------------------------------------------------- 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 | import logging 16 | 17 | from opencensus.ext.azure.log_exporter import AzureLogHandler 18 | from opencensus.ext.azure.trace_exporter import AzureExporter 19 | from opencensus.trace import config_integration 20 | from opencensus.trace.samplers import ProbabilitySampler 21 | from opencensus.trace.tracer import Tracer 22 | 23 | config_integration.trace_integrations(['logging']) 24 | 25 | logger = logging.getLogger(__name__) 26 | 27 | # TODO: you need to specify the instrumentation key in a connection string 28 | # and place it in the APPLICATIONINSIGHTS_CONNECTION_STRING 29 | # environment variable. 30 | handler = AzureLogHandler() 31 | logger.addHandler(handler) 32 | 33 | tracer = Tracer(exporter=AzureExporter(), sampler=ProbabilitySampler(1.0)) 34 | 35 | logger.warning('Before the span') 36 | with tracer.span(name='test'): 37 | logger.warning('In the span') 38 | logger.warning('After the span') 39 | 40 | input("...") 41 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-azure/examples/logs/error.py: -------------------------------------------------------------------------------- 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 | import logging 16 | 17 | from opencensus.ext.azure.log_exporter import AzureLogHandler 18 | 19 | logger = logging.getLogger(__name__) 20 | # TODO: you need to specify the instrumentation key in a connection string 21 | # and place it in the APPLICATIONINSIGHTS_CONNECTION_STRING 22 | # environment variable. 23 | logger.addHandler(AzureLogHandler()) 24 | 25 | 26 | def main(): 27 | try: 28 | return 1 / 0 # generate a ZeroDivisionError 29 | except Exception: 30 | logger.exception('Captured an exception.') 31 | 32 | 33 | if __name__ == '__main__': 34 | main() 35 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-azure/examples/logs/event.py: -------------------------------------------------------------------------------- 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 | import logging 16 | 17 | from opencensus.ext.azure.log_exporter import AzureEventHandler 18 | 19 | logger = logging.getLogger(__name__) 20 | # TODO: you need to specify the instrumentation key in a connection string 21 | # and place it in the APPLICATIONINSIGHTS_CONNECTION_STRING 22 | # environment variable. 23 | logger.addHandler(AzureEventHandler()) 24 | logger.setLevel(logging.INFO) 25 | logger.info('Hello, World!') 26 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-azure/examples/logs/properties.py: -------------------------------------------------------------------------------- 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 | import logging 16 | 17 | from opencensus.ext.azure.log_exporter import AzureLogHandler 18 | 19 | logger = logging.getLogger(__name__) 20 | # TODO: you need to specify the instrumentation key in a connection string 21 | # and place it in the APPLICATIONINSIGHTS_CONNECTION_STRING 22 | # environment variable. 23 | logger.addHandler(AzureLogHandler()) 24 | 25 | properties = {'custom_dimensions': {'key_1': 'value_1', 'key_2': 'value_2'}} 26 | 27 | # Use properties in logging statements 28 | logger.warning('action', extra=properties) 29 | 30 | # Use properties in exception logs 31 | try: 32 | result = 1 / 0 # generate a ZeroDivisionError 33 | except Exception: 34 | logger.exception('Captured an exception.', extra=properties) 35 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-azure/examples/logs/simple.py: -------------------------------------------------------------------------------- 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 | import logging 16 | 17 | from opencensus.ext.azure.log_exporter import AzureLogHandler 18 | 19 | logger = logging.getLogger(__name__) 20 | # TODO: you need to specify the instrumentation key in a connection string 21 | # and place it in the APPLICATIONINSIGHTS_CONNECTION_STRING 22 | # environment variable. 23 | logger.addHandler(AzureLogHandler()) 24 | 25 | logger.warning("Hello World!") 26 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-azure/examples/traces/client.py: -------------------------------------------------------------------------------- 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 | import requests 16 | 17 | from opencensus.ext.azure.trace_exporter import AzureExporter 18 | from opencensus.trace import config_integration 19 | from opencensus.trace.samplers import ProbabilitySampler 20 | from opencensus.trace.tracer import Tracer 21 | 22 | config_integration.trace_integrations(['requests']) 23 | # TODO: you need to specify the instrumentation key in a connection string 24 | # and place it in the APPLICATIONINSIGHTS_CONNECTION_STRING 25 | # environment variable. 26 | tracer = Tracer(exporter=AzureExporter(), sampler=ProbabilitySampler(1.0)) 27 | with tracer.span(name='parent'): 28 | with tracer.span(name='child'): 29 | response = requests.get(url='http://example.com/') 30 | print(response.status_code) 31 | print(response.text) 32 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-azure/examples/traces/credential.py: -------------------------------------------------------------------------------- 1 | # Copyright 2021, 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 | from azure.identity import ClientSecretCredential 15 | 16 | from opencensus.ext.azure.trace_exporter import AzureExporter 17 | from opencensus.trace.samplers import ProbabilitySampler 18 | from opencensus.trace.tracer import Tracer 19 | 20 | tenant_id = "" 21 | client_id = "" 22 | client_secret = "" 23 | 24 | credential = ClientSecretCredential( 25 | tenant_id=tenant_id, 26 | client_id=client_id, 27 | client_secret=client_secret 28 | ) 29 | 30 | tracer = Tracer( 31 | exporter=AzureExporter( 32 | credential=credential, connection_string=""), 33 | sampler=ProbabilitySampler(1.0) 34 | ) 35 | 36 | with tracer.span(name='foo'): 37 | print('Hello, World!') 38 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-azure/examples/traces/custom.py: -------------------------------------------------------------------------------- 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 flask import Flask 16 | 17 | from opencensus.ext.flask.flask_middleware import FlaskMiddleware 18 | 19 | app = Flask(__name__) 20 | # TODO: replace the all-zero GUID with your instrumentation key. 21 | app.config['OPENCENSUS'] = { 22 | 'TRACE': { 23 | 'SAMPLER': 'opencensus.trace.samplers.ProbabilitySampler(rate=1.0)', 24 | 'EXPORTER': '''opencensus.ext.azure.trace_exporter.AzureExporter( 25 | connection_string= 26 | 'InstrumentationKey=00000000-0000-0000-0000-000000000000', 27 | )''', 28 | }, 29 | } 30 | middleware = FlaskMiddleware(app) 31 | 32 | 33 | @app.route('/') 34 | def hello(): 35 | return 'Hello World!' 36 | 37 | 38 | if __name__ == '__main__': 39 | import logging 40 | logger = logging.getLogger('werkzeug') 41 | logger.setLevel(logging.ERROR) 42 | app.run(host='localhost', port=8080, threaded=True) 43 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-azure/examples/traces/django/logfile: -------------------------------------------------------------------------------- 1 | 2022-10-26 15:48:57,700 INFO This is an INFO level log entry. 2 | 2022-10-26 15:48:57,700 WARNING This is a WARNING level log entry. 3 | 2022-10-26 15:48:57,701 ERROR This is an ERROR level log entry. 4 | 2022-10-26 15:48:57,702 CRITICAL This is a CRITICAL level log entry. 5 | 2022-10-26 16:10:22,849 INFO This is an INFO level log entry. 6 | 2022-10-26 16:10:22,850 WARNING This is a WARNING level log entry. 7 | 2022-10-26 16:10:22,850 ERROR This is an ERROR level log entry. 8 | 2022-10-26 16:10:22,850 CRITICAL This is a CRITICAL level log entry. 9 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-azure/examples/traces/django/mysite/db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/census-instrumentation/opencensus-python/cd020b07f06024b6c9243c514b5413cef46f4775/contrib/opencensus-ext-azure/examples/traces/django/mysite/db.sqlite3 -------------------------------------------------------------------------------- /contrib/opencensus-ext-azure/examples/traces/django/mysite/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Copyright 2019, OpenCensus Authors 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | """Django's command-line utility for administrative tasks.""" 17 | import os 18 | import sys 19 | 20 | 21 | def main(): 22 | """Run administrative tasks.""" 23 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings') 24 | try: 25 | from django.core.management import execute_from_command_line 26 | except ImportError as exc: 27 | raise ImportError( 28 | "Couldn't import Django. Are you sure it's installed and " 29 | "available on your PYTHONPATH environment variable? Did you " 30 | "forget to activate a virtual environment?" 31 | ) from exc 32 | execute_from_command_line(sys.argv) 33 | 34 | 35 | if __name__ == '__main__': 36 | main() 37 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-azure/examples/traces/django/mysite/mysite/__init__.py: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-azure/examples/traces/django/mysite/mysite/asgi.py: -------------------------------------------------------------------------------- 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 | ASGI config for mysite project. 16 | 17 | It exposes the ASGI callable as a module-level variable named ``application``. 18 | 19 | For more information on this file, see 20 | https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/ 21 | """ 22 | 23 | import os 24 | 25 | from django.core.asgi import get_asgi_application 26 | 27 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings') 28 | 29 | application = get_asgi_application() 30 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-azure/examples/traces/django/mysite/mysite/urls.py: -------------------------------------------------------------------------------- 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 | """mysite URL Configuration 15 | 16 | The `urlpatterns` list routes URLs to views. For more information please see: 17 | https://docs.djangoproject.com/en/3.2/topics/http/urls/ 18 | Examples: 19 | Function views 20 | 1. Add an import: from my_app import views 21 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 22 | Class-based views 23 | 1. Add an import: from other_app.views import Home 24 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 25 | Including another URLconf 26 | 1. Import the include() function: from django.urls import include, path 27 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 28 | """ 29 | from django.contrib import admin 30 | from django.urls import include, path 31 | 32 | urlpatterns = [ 33 | path('admin/', admin.site.urls), 34 | path('', include('polls.urls')), 35 | ] 36 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-azure/examples/traces/django/mysite/mysite/wsgi.py: -------------------------------------------------------------------------------- 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 | WSGI config for mysite project. 16 | 17 | It exposes the WSGI callable as a module-level variable named ``application``. 18 | 19 | For more information on this file, see 20 | https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/ 21 | """ 22 | 23 | import os 24 | 25 | from django.core.wsgi import get_wsgi_application 26 | 27 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings') 28 | 29 | application = get_wsgi_application() 30 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-azure/examples/traces/django/mysite/polls/__init__.py: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-azure/examples/traces/django/mysite/polls/admin.py: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-azure/examples/traces/django/mysite/polls/apps.py: -------------------------------------------------------------------------------- 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 | from django.apps import AppConfig 15 | 16 | 17 | class PollsConfig(AppConfig): 18 | default_auto_field = 'django.db.models.BigAutoField' 19 | name = 'polls' 20 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-azure/examples/traces/django/mysite/polls/migrations/__init__.py: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-azure/examples/traces/django/mysite/polls/models.py: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-azure/examples/traces/django/mysite/polls/tests.py: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-azure/examples/traces/django/mysite/polls/urls.py: -------------------------------------------------------------------------------- 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 | from django.urls import path 15 | 16 | from . import views 17 | 18 | urlpatterns = [ 19 | path('', views.index, name='index'), 20 | ] 21 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-azure/examples/traces/django/mysite/polls/views.py: -------------------------------------------------------------------------------- 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 | import logging 15 | 16 | from django.http import HttpResponse 17 | 18 | # Logging configured through settings.LOGGING in settings.py 19 | logger = logging.getLogger('custom') 20 | 21 | 22 | # Distributed tracing configured through settings.OPENCENSUS in settings.py 23 | def index(request): 24 | logger.debug('This is a DEBUG level log entry.') 25 | logger.info('This is an INFO level log entry.') 26 | logger.warning('This is a WARNING level log entry.') 27 | logger.error('This is an ERROR level log entry.') 28 | logger.critical('This is a CRITICAL level log entry.') 29 | return HttpResponse("Hello, world. You're at the polls index.") 30 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-azure/examples/traces/simple.py: -------------------------------------------------------------------------------- 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.trace_exporter import AzureExporter 16 | from opencensus.trace.samplers import ProbabilitySampler 17 | from opencensus.trace.tracer import Tracer 18 | 19 | # TODO: you need to specify the instrumentation key in a connection string 20 | # and place it in the APPLICATIONINSIGHTS_CONNECTION_STRING 21 | # environment variable. 22 | tracer = Tracer(exporter=AzureExporter(), sampler=ProbabilitySampler(1.0)) 23 | 24 | with tracer.span(name='foo'): 25 | print('Hello, World!') 26 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-azure/opencensus/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-azure/opencensus/ext/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-azure/opencensus/ext/azure/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-azure/opencensus/ext/azure/common/version.py: -------------------------------------------------------------------------------- 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 | __version__ = '1.1.dev0' 16 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-azure/opencensus/ext/azure/statsbeat/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-azure/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-datadog/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## Unreleased 4 | 5 | ## 0.1.0 6 | Released 2019-11-26 7 | 8 | - Initial version 9 | ([#793](https://github.com/census-instrumentation/opencensus-python/pull/793)) 10 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-datadog/examples/datadog.py: -------------------------------------------------------------------------------- 1 | from flask import Flask 2 | 3 | from opencensus.ext.datadog.traces import DatadogTraceExporter, Options 4 | from opencensus.ext.flask.flask_middleware import FlaskMiddleware 5 | from opencensus.trace.samplers import AlwaysOnSampler 6 | 7 | app = Flask(__name__) 8 | middleware = FlaskMiddleware(app, 9 | excludelist_paths=['/healthz'], 10 | sampler=AlwaysOnSampler(), 11 | exporter=DatadogTraceExporter( 12 | Options(service='python-export-test', 13 | global_tags={"stack": "example"}))) 14 | 15 | 16 | @app.route('/') 17 | def hello(): 18 | return 'Hello World!' 19 | 20 | 21 | if __name__ == '__main__': 22 | app.run(host='0.0.0.0', port=8080, threaded=True) 23 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-datadog/opencensus/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-datadog/opencensus/ext/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-datadog/opencensus/ext/datadog/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-datadog/opencensus/ext/datadog/transport.py: -------------------------------------------------------------------------------- 1 | import platform 2 | 3 | import requests 4 | 5 | 6 | class DDTransport(object): 7 | """ DDTransport contains all the logic for sending Traces to Datadog 8 | 9 | :type trace_addr: str 10 | :param trace_addr: trace_addr specifies the host[:port] address of the 11 | Datadog Trace Agent. 12 | """ 13 | def __init__(self, trace_addr): 14 | self._trace_addr = trace_addr 15 | 16 | self._headers = { 17 | "Datadog-Meta-Lang": "python", 18 | "Datadog-Meta-Lang-Interpreter": platform.platform(), 19 | # Following the example of the Golang version it is prefixed 20 | # OC for Opencensus. 21 | "Datadog-Meta-Tracer-Version": "OC/0.0.1", 22 | "Content-Type": "application/json", 23 | } 24 | 25 | @property 26 | def trace_addr(self): 27 | """ specifies the host[:port] address of the Datadog Trace Agent. 28 | """ 29 | return self._trace_addr 30 | 31 | @property 32 | def headers(self): 33 | """ specifies the headers that will be attached to HTTP request sent to DD. 34 | """ 35 | return self._headers 36 | 37 | def send_traces(self, trace): 38 | """ Sends traces to the Datadog Tracing Agent 39 | 40 | :type trace: dic 41 | :param trace: Trace dictionary 42 | """ 43 | 44 | requests.post("http://" + self.trace_addr + "/v0.4/traces", 45 | json=trace, 46 | headers=self.headers) 47 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-datadog/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-datadog/tests/transport_test.py: -------------------------------------------------------------------------------- 1 | # import unittest 2 | 3 | # import mock 4 | 5 | # from opencensus.ext.datadog.transport import DDTransport 6 | 7 | 8 | # class TestTraces(unittest.TestCase): 9 | # def setUp(self): 10 | # pass 11 | 12 | # @mock.patch('requests.post', return_value=None) 13 | # def test_send_traces(self, mr_mock): 14 | # transport = DDTransport('test') 15 | # transport.send_traces({}) 16 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-datadog/version.py: -------------------------------------------------------------------------------- 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 | __version__ = '0.2.dev0' 16 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-dbapi/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## Unreleased 4 | 5 | ## 0.1.2 6 | Released 2019-04-24 7 | 8 | - Updated docs and examples 9 | 10 | ## 0.1.1 11 | Released 2019-04-08 12 | 13 | - Cosmetic changes 14 | 15 | ## 0.1.0 16 | Released 2019-03-19 17 | 18 | - Initial version 19 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-dbapi/README.rst: -------------------------------------------------------------------------------- 1 | OpenCensus Database API Integration 2 | ============================================================================ 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opencensus-ext-dbapi.svg 7 | :target: https://pypi.org/project/opencensus-ext-dbapi/ 8 | 9 | Installation 10 | ------------ 11 | 12 | :: 13 | 14 | pip install opencensus-ext-dbapi 15 | 16 | Usage 17 | ----- 18 | 19 | The OpenCensus Database API Integration library provides the database 20 | integration infrastructure for extensions `opencensus-ext-mysql`_ 21 | and `opencensus-ext-pymysql`_. 22 | 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 `_ 30 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-dbapi/opencensus/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-dbapi/opencensus/ext/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-dbapi/opencensus/ext/dbapi/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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.dbapi import trace 16 | 17 | __all__ = ['trace'] 18 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-dbapi/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-dbapi/version.py: -------------------------------------------------------------------------------- 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 | __version__ = '0.2.dev0' 16 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-django/README.rst: -------------------------------------------------------------------------------- 1 | OpenCensus Django Integration 2 | ============================================================================ 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opencensus-ext-django.svg 7 | :target: https://pypi.org/project/opencensus-ext-django/ 8 | 9 | Installation 10 | ------------ 11 | 12 | :: 13 | 14 | pip install opencensus-ext-django 15 | 16 | Usage 17 | ----- 18 | 19 | For tracing Django requests, you will need to add the following line to 20 | the ``MIDDLEWARE`` section in the Django ``settings.py`` file. 21 | 22 | .. code:: python 23 | 24 | MIDDLEWARE = [ 25 | ... 26 | 'opencensus.ext.django.middleware.OpencensusMiddleware', 27 | ] 28 | 29 | Additional configuration can be provided, please read 30 | `Customization `_ 31 | for a complete reference. 32 | 33 | .. code:: python 34 | 35 | OPENCENSUS = { 36 | 'TRACE': { 37 | 'SAMPLER': 'opencensus.trace.samplers.ProbabilitySampler(rate=1)', 38 | 'EXPORTER': '''opencensus.ext.ocagent.trace_exporter.TraceExporter( 39 | service_name='foobar', 40 | )''', 41 | } 42 | } 43 | 44 | References 45 | ---------- 46 | 47 | * `OpenCensus Project `_ 48 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-django/examples/app/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-django/examples/app/forms.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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 django import forms 16 | 17 | 18 | class HelloForm(forms.Form): 19 | fname = forms.CharField(max_length=40) 20 | lname = forms.CharField(max_length=40) 21 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-django/examples/app/templates/home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
{% csrf_token %} 19 | First Name:
20 | 21 |
22 | Last Name:
23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-django/examples/manage.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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 | import os 16 | import sys 17 | 18 | if __name__ == "__main__": 19 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app.settings") 20 | 21 | from django.core.management import execute_from_command_line 22 | 23 | execute_from_command_line(sys.argv) 24 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-django/opencensus/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-django/opencensus/ext/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-django/opencensus/ext/django/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-django/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-django/version.py: -------------------------------------------------------------------------------- 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 | __version__ = '0.9.dev0' 16 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-fastapi/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## Unreleased 4 | 5 | ## 0.1.0 6 | 7 | Released 2023-03-10 8 | 9 | - Initial version 10 | ([#1124](https://github.com/census-instrumentation/opencensus-python/pull/1124)) 11 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-fastapi/README.rst: -------------------------------------------------------------------------------- 1 | OpenCensus FastAPI Integration 2 | ============================================================================ 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opencensus-ext-fastapi.svg 7 | :target: https://pypi.org/project/opencensus-ext-fastapi/ 8 | 9 | Installation 10 | ------------ 11 | 12 | :: 13 | 14 | pip install opencensus-ext-fastapi 15 | 16 | Usage 17 | ----- 18 | 19 | .. code:: python 20 | 21 | from fastapi import FastAPI 22 | from opencensus.ext.fastapi.fastapi_middleware import FastAPIMiddleware 23 | 24 | app = FastAPI(__name__) 25 | app.add_middleware(FastAPIMiddleware) 26 | 27 | @app.get('/') 28 | def hello(): 29 | return 'Hello World!' 30 | 31 | Additional configuration can be provided, please read 32 | `Customization `_ 33 | for a complete reference. 34 | 35 | .. code:: python 36 | 37 | app.add_middleware( 38 | FastAPIMiddleware, 39 | excludelist_paths=["paths"], 40 | excludelist_hostnames=["hostnames"], 41 | sampler=sampler, 42 | exporter=exporter, 43 | propagator=propagator, 44 | ) 45 | 46 | 47 | References 48 | ---------- 49 | 50 | * `OpenCensus Project `_ 51 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-fastapi/opencensus/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-fastapi/opencensus/ext/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-fastapi/opencensus/ext/fastapi/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-fastapi/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-fastapi/version.py: -------------------------------------------------------------------------------- 1 | # Copyright 2022, 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 | __version__ = '0.2.dev0' 16 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-flask/README.rst: -------------------------------------------------------------------------------- 1 | OpenCensus Flask Integration 2 | ============================================================================ 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opencensus-ext-flask.svg 7 | :target: https://pypi.org/project/opencensus-ext-flask/ 8 | 9 | Installation 10 | ------------ 11 | 12 | :: 13 | 14 | pip install opencensus-ext-flask 15 | 16 | Usage 17 | ----- 18 | 19 | .. code:: python 20 | 21 | from flask import Flask 22 | from opencensus.ext.flask.flask_middleware import FlaskMiddleware 23 | 24 | app = Flask(__name__) 25 | middleware = FlaskMiddleware(app, excludelist_paths=['_ah/health']) 26 | 27 | @app.route('/') 28 | def hello(): 29 | return 'Hello World!' 30 | 31 | if __name__ == '__main__': 32 | import logging 33 | logger = logging.getLogger('werkzeug') 34 | logger.setLevel(logging.ERROR) 35 | app.run(host='localhost', port=8080, threaded=True) 36 | 37 | Additional configuration can be provided, please read 38 | `Customization `_ 39 | for a complete reference. 40 | 41 | .. code:: python 42 | 43 | app.config['OPENCENSUS'] = { 44 | 'TRACE': { 45 | 'SAMPLER': 'opencensus.trace.samplers.ProbabilitySampler(rate=1)', 46 | 'EXPORTER': '''opencensus.ext.ocagent.trace_exporter.TraceExporter( 47 | service_name='foobar', 48 | )''', 49 | } 50 | } 51 | 52 | References 53 | ---------- 54 | 55 | * `OpenCensus Project `_ 56 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-flask/examples/simple.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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 flask import Flask 16 | 17 | from opencensus.ext.flask.flask_middleware import FlaskMiddleware 18 | 19 | app = Flask(__name__) 20 | middleware = FlaskMiddleware(app) 21 | 22 | 23 | @app.route('/') 24 | def hello(): 25 | return 'Hello World!' 26 | 27 | 28 | if __name__ == '__main__': 29 | import logging 30 | logger = logging.getLogger('werkzeug') 31 | logger.setLevel(logging.ERROR) 32 | app.run(host='localhost', port=8080, threaded=True) 33 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-flask/opencensus/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-flask/opencensus/ext/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-flask/opencensus/ext/flask/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-flask/opencensus/ext/flask/common/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-flask/opencensus/ext/flask/common/version.py: -------------------------------------------------------------------------------- 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 | __version__ = '0.9.dev0' 16 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-flask/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-gevent/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## Unreleased 4 | 5 | ## 0.1.0 6 | Released 2019-05-31 7 | 8 | - Initial version 9 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-gevent/README.rst: -------------------------------------------------------------------------------- 1 | OpenCensus gevent helper 2 | ============================================================================ 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opencensus-ext-gevent.svg 7 | :target: https://pypi.org/project/opencensus-ext-gevent/ 8 | 9 | Installation 10 | ------------ 11 | 12 | :: 13 | 14 | pip install opencensus-ext-gevent 15 | 16 | Usage 17 | ----- 18 | 19 | As gevent is to date `incompatible `_ with 20 | the new context variables the **OpenCensus gevent helper** configures OpenCensus to use 21 | a compatible thread based runtime context implementation. 22 | 23 | No action apart from installing the package is needed as it listens to events 24 | `emitted by gevent `_ once 25 | patching via ``patch_all`` is complete. 26 | 27 | 28 | Warning 29 | ------- 30 | 31 | OpenCensus itself is completely compatible with gevent. Be aware though that not all 32 | available OpenCensus integrations are compatible. 33 | 34 | You should check this on a case by case basis. 35 | 36 | 37 | References 38 | ---------- 39 | 40 | * `OpenCensus Project `_ 41 | * `gevent `_ 42 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-gevent/opencensus/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-gevent/opencensus/ext/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-gevent/opencensus/ext/gevent/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-gevent/opencensus/ext/gevent/geventcompatibility.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | import gevent.monkey 4 | 5 | 6 | def patch_opencensus(event): 7 | # Switch from the default runtime context using ContextVar to one 8 | # using thread locals. Needed until gevent supports ContextVar. 9 | # See https://github.com/gevent/gevent/issues/1407 10 | import opencensus.common.runtime_context as runtime_context 11 | 12 | if not gevent.monkey.is_module_patched("contextvars"): 13 | runtime_context.RuntimeContext = ( 14 | runtime_context._ThreadLocalRuntimeContext() 15 | ) 16 | 17 | logging.warning("OpenCensus patched for gevent compatibility") 18 | else: 19 | logging.warning( 20 | "OpenCensus is already compatible with your gevent version. " 21 | "Feel free to uninstall the opencensus-ext-gevent package." 22 | ) 23 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-gevent/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-gevent/version.py: -------------------------------------------------------------------------------- 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 | __version__ = '0.2.dev0' 16 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-google-cloud-clientlibs/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## Unreleased 4 | 5 | ## 0.1.3 6 | Released 2021-10-04 7 | - Added missing google-cloud-core dependency 8 | [#1049](https://github.com/census-instrumentation/opencensus-python/pull/1049) 9 | 10 | ## 0.1.2 11 | Released 2019-04-24 12 | 13 | - Updated docs and examples 14 | 15 | ## 0.1.1 16 | Released 2019-04-08 17 | 18 | - Cosmetic changes 19 | 20 | ## 0.1.0 21 | Released 2019-03-19 22 | 23 | - Initial version 24 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-google-cloud-clientlibs/README.rst: -------------------------------------------------------------------------------- 1 | OpenCensus Google Cloud Client Libraries Integration 2 | ============================================================================ 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opencensus-ext-google-cloud-clientlibs.svg 7 | :target: https://pypi.org/project/opencensus-ext-google-cloud-clientlibs/ 8 | 9 | OpenCensus can trace HTTP and gRPC requests made with the `Cloud client libraries`_. 10 | The request URL, method, and status will be collected. 11 | 12 | You can enable Google Cloud client libraries integration by specifying ``'google_cloud_clientlibs'`` to ``trace_integrations``. 13 | 14 | .. _Cloud client libraries: https://github.com/GoogleCloudPlatform/google-cloud-python#google-cloud-python-client 15 | 16 | Installation 17 | ------------ 18 | 19 | :: 20 | 21 | pip install opencensus-ext-google-cloud-clientlibs 22 | 23 | Usage 24 | ----- 25 | 26 | .. code:: python 27 | 28 | from opencensus.trace import config_integration 29 | 30 | config_integration.trace_integrations(['google_cloud_clientlibs']) 31 | 32 | References 33 | ---------- 34 | 35 | * `OpenCensus Project `_ 36 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-google-cloud-clientlibs/opencensus/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-google-cloud-clientlibs/opencensus/ext/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-google-cloud-clientlibs/opencensus/ext/google_cloud_clientlibs/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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.google_cloud_clientlibs import trace 16 | 17 | __all__ = ['trace'] 18 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-google-cloud-clientlibs/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-google-cloud-clientlibs/version.py: -------------------------------------------------------------------------------- 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 | __version__ = '0.2.dev0' 16 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-grpc/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## Unreleased 4 | 5 | ## 0.7.2 6 | Released 2021-01-14 7 | 8 | - Extract byte size from proto-plus messages 9 | ([#976](https://github.com/census-instrumentation/opencensus-python/pull/976)) 10 | 11 | ## 0.7.1 12 | Released 2019-08-05 13 | 14 | - Update for core library changes 15 | 16 | ## 0.3.0 17 | Released 2019-05-31 18 | 19 | - Limit span attachments 20 | 21 | ## 0.2.0 22 | Released 2019-04-24 23 | 24 | - Create WrappedResponseIterator for intercepted bi-directional rpc stream. 25 | 26 | ## 0.1.1 27 | Released 2019-04-08 28 | 29 | - Cosmetic changes 30 | 31 | ## 0.1.0 32 | Released 2019-03-19 33 | 34 | - Initial version 35 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-grpc/examples/hello_world.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2017, 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 | syntax = "proto3"; 16 | 17 | option java_multiple_files = true; 18 | option java_package = "io.grpc.examples.helloworld"; 19 | option java_outer_classname = "HelloWorldProto"; 20 | 21 | package helloworld; 22 | 23 | // The hello world service definition. 24 | service Greeter { 25 | // Say hello to the request sender (unary-unary) 26 | rpc SayHello (HelloRequest) returns (HelloReply) {} 27 | } 28 | 29 | // The request message containing the sender's name. 30 | message HelloRequest { 31 | string name = 1; 32 | } 33 | 34 | // The response message containing the greetings 35 | message HelloReply { 36 | string message = 1; 37 | } 38 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-grpc/opencensus/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-grpc/opencensus/ext/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-grpc/opencensus/ext/grpc/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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 | UNARY_UNARY = 'unary_unary' 16 | UNARY_STREAM = 'unary_stream' 17 | STREAM_UNARY = 'stream_unary' 18 | STREAM_STREAM = 'stream_stream' 19 | 20 | GRPC_TRACE_KEY = 'grpc-trace-bin' 21 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-grpc/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-grpc/version.py: -------------------------------------------------------------------------------- 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 | __version__ = '0.8.dev0' 16 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-httplib/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## Unreleased 4 | 5 | ## 0.7.4 6 | Released 2021-01-14 7 | 8 | - Change blacklist to excludelist 9 | ([#977](https://github.com/census-instrumentation/opencensus-python/pull/977)) 10 | 11 | ## 0.7.3 12 | Released 2020-02-03 13 | 14 | - Added `component` span attribute 15 | 16 | ## 0.7.2 17 | Released 2019-08-26 18 | 19 | - Updated `http.status_code` attribute to be an int. 20 | ([#755](https://github.com/census-instrumentation/opencensus-python/pull/755)) 21 | 22 | ## 0.7.1 23 | Released 2019-08-06 24 | 25 | - Support exporter changes in `opencensus>=0.7.0` 26 | 27 | ## 0.1.3 28 | Released 2019-05-31 29 | 30 | - Minor improvements 31 | 32 | ## 0.1.2 33 | Released 2019-04-24 34 | 35 | - Updated docs and examples 36 | 37 | ## 0.1.1 38 | Released 2019-04-08 39 | 40 | - Cosmetic changes 41 | 42 | ## 0.1.0 43 | Released 2019-03-19 44 | 45 | - Initial version 46 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-httplib/README.rst: -------------------------------------------------------------------------------- 1 | OpenCensus httplib Integration 2 | ============================================================================ 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opencensus-ext-httplib.svg 7 | :target: https://pypi.org/project/opencensus-ext-httplib/ 8 | 9 | OpenCensus can trace HTTP requests made with the httplib library. 10 | 11 | You can enable requests integration by specifying ``'httplib'`` to ``trace_integrations``. 12 | 13 | It's possible to configure a list of URL you don't want traced. See requests integration 14 | for more information. The only difference is that you need to specify hostname and port 15 | every time. 16 | 17 | Installation 18 | ------------ 19 | 20 | :: 21 | 22 | pip install opencensus-ext-httplib 23 | 24 | Usage 25 | ----- 26 | 27 | .. code:: python 28 | 29 | import requests 30 | from opencensus.trace import config_integration 31 | from opencensus.trace.tracer import Tracer 32 | 33 | config_integration.trace_integrations(['httplib']) 34 | tracer = Tracer() 35 | 36 | with tracer.span(name='parent'): 37 | response = requests.get('https://www.wikipedia.org/wiki/Rabbit') 38 | 39 | References 40 | ---------- 41 | 42 | * `OpenCensus Project `_ 43 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-httplib/opencensus/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-httplib/opencensus/ext/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-httplib/opencensus/ext/httplib/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-httplib/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-httplib/version.py: -------------------------------------------------------------------------------- 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 | __version__ = '0.8.dev0' 16 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-httpx/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## Unreleased 4 | 5 | ## 0.1.0 6 | 7 | Released 2023-01-18 8 | 9 | - Initial release 10 | ([#1098](https://github.com/census-instrumentation/opencensus-python/pull/1098)) 11 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-httpx/README.rst: -------------------------------------------------------------------------------- 1 | OpenCensus httpx Integration 2 | ============================================================================ 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opencensus-ext-httpx.svg 7 | :target: https://pypi.org/project/opencensus-ext-httpx/ 8 | 9 | OpenCensus can trace HTTP requests made with the `httpx package `_. The request URL, 10 | method, and status will be collected. 11 | 12 | You can enable httpx integration by specifying ``'httpx'`` to ``trace_integrations``. 13 | 14 | Only the hostname must be specified if only the hostname is specified in the URL request. 15 | 16 | 17 | Installation 18 | ------------ 19 | 20 | :: 21 | 22 | pip install opencensus-ext-httpx 23 | 24 | Usage 25 | ----- 26 | 27 | .. code:: python 28 | 29 | import httpx 30 | from opencensus.trace import config_integration 31 | from opencensus.trace.tracer import Tracer 32 | 33 | if __name__ == '__main__': 34 | config_integration.trace_integrations(['httpx']) 35 | tracer = Tracer() 36 | with tracer.span(name='parent'): 37 | response = httpx.get(url='https://www.example.org') 38 | 39 | References 40 | ---------- 41 | 42 | * `OpenCensus Project `_ 43 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-httpx/opencensus/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/census-instrumentation/opencensus-python/cd020b07f06024b6c9243c514b5413cef46f4775/contrib/opencensus-ext-httpx/opencensus/__init__.py -------------------------------------------------------------------------------- /contrib/opencensus-ext-httpx/opencensus/ext/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/census-instrumentation/opencensus-python/cd020b07f06024b6c9243c514b5413cef46f4775/contrib/opencensus-ext-httpx/opencensus/ext/__init__.py -------------------------------------------------------------------------------- /contrib/opencensus-ext-httpx/opencensus/ext/httpx/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/census-instrumentation/opencensus-python/cd020b07f06024b6c9243c514b5413cef46f4775/contrib/opencensus-ext-httpx/opencensus/ext/httpx/__init__.py -------------------------------------------------------------------------------- /contrib/opencensus-ext-httpx/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-httpx/version.py: -------------------------------------------------------------------------------- 1 | __version__ = '0.2.dev0' 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-jaeger/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## Unreleased 4 | 5 | ## 0.7.1 6 | Released 2019-08-05 7 | 8 | - Update for core library changes 9 | 10 | ## 0.2.2 11 | Released 2019-05-31 12 | 13 | - Minor improvements 14 | 15 | ## 0.2.1 16 | Released 2019-04-24 17 | 18 | - Updated docs and examples 19 | 20 | ## 0.2.0 21 | Released 2019-04-08 22 | 23 | - Update for package changes in core library 24 | 25 | ## 0.1.0 26 | Released 2019-03-19 27 | 28 | - Initial version 29 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-jaeger/README.rst: -------------------------------------------------------------------------------- 1 | OpenCensus Jaeger Exporter 2 | ============================================================================ 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opencensus-ext-jaeger.svg 7 | :target: https://pypi.org/project/opencensus-ext-jaeger/ 8 | 9 | Installation 10 | ------------ 11 | 12 | :: 13 | 14 | pip install opencensus-ext-jaeger 15 | 16 | Usage 17 | ----- 18 | 19 | The **OpenCensus Jaeger Exporter** allows you to export `OpenCensus`_ traces to `Jaeger`_. 20 | 21 | .. _Jaeger: https://www.jaegertracing.io/ 22 | .. _OpenCensus: https://github.com/census-instrumentation/opencensus-python/ 23 | 24 | .. code:: python 25 | 26 | from opencensus.ext.jaeger.trace_exporter import JaegerExporter 27 | from opencensus.trace import tracer as tracer_module 28 | 29 | tracer = tracer_module.Tracer(exporter=JaegerExporter( 30 | service_name='my service', 31 | agent_host_name='localhost', 32 | agent_port=6831, 33 | )) 34 | 35 | with tracer.span(name='hello'): 36 | print('Hello, World!') 37 | 38 | References 39 | ---------- 40 | 41 | * `Jaeger `_ 42 | * `OpenCensus Project `_ 43 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-jaeger/opencensus/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-jaeger/opencensus/ext/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-jaeger/opencensus/ext/jaeger/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-jaeger/opencensus/ext/jaeger/trace_exporter/gen/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 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 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-jaeger/opencensus/ext/jaeger/trace_exporter/gen/jaeger/__init__.py: -------------------------------------------------------------------------------- 1 | __all__ = ['agent', 'jaeger'] 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-jaeger/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-jaeger/version.py: -------------------------------------------------------------------------------- 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 | __version__ = '0.8.dev0' 16 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-logging/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## Unreleased 4 | 5 | ## 0.1.0 6 | Released 2019-05-31 7 | 8 | - Initial version 9 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-logging/README.rst: -------------------------------------------------------------------------------- 1 | OpenCensus logging Integration 2 | ============================================================================ 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opencensus-ext-logging.svg 7 | :target: https://pypi.org/project/opencensus-ext-logging/ 8 | 9 | The logging integration enriches the log records with trace ID, span ID and sampling flag. 10 | The following attributes will be added to ``LogRecord``: 11 | 12 | * traceId 13 | * spanId 14 | * traceSampled 15 | 16 | Note that this only takes effect for loggers created after the integration. 17 | 18 | Installation 19 | ------------ 20 | 21 | :: 22 | 23 | pip install opencensus-ext-logging 24 | 25 | Usage 26 | ----- 27 | 28 | .. code:: python 29 | 30 | import logging 31 | 32 | from opencensus.trace import config_integration 33 | from opencensus.trace.samplers import AlwaysOnSampler 34 | from opencensus.trace.tracer import Tracer 35 | 36 | config_integration.trace_integrations(['logging']) 37 | logging.basicConfig(format='%(asctime)s traceId=%(traceId)s spanId=%(spanId)s %(message)s') 38 | tracer = Tracer(sampler=AlwaysOnSampler()) 39 | 40 | logger = logging.getLogger(__name__) 41 | logger.warning('Before the span') 42 | with tracer.span(name='hello'): 43 | logger.warning('In the span') 44 | logger.warning('After the span') 45 | 46 | 47 | References 48 | ---------- 49 | 50 | * `OpenCensus Project `_ 51 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-logging/opencensus/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-logging/opencensus/ext/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-logging/opencensus/ext/logging/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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.logging import trace 16 | 17 | __all__ = ['trace'] 18 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-logging/opencensus/ext/logging/trace.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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 | import logging 16 | 17 | from opencensus.log import TraceLogger 18 | from opencensus.trace import integrations 19 | 20 | 21 | def trace_integration(tracer=None): 22 | """Replace the global default logging class with `TraceLogger`. 23 | 24 | Loggers created after the integration will produce `LogRecord`s 25 | with extra traceId, spanId, and traceSampled attributes from the opencensus 26 | context. 27 | """ 28 | logging.setLoggerClass(TraceLogger) 29 | # pylint: disable=protected-access 30 | integrations.add_integration(integrations._Integrations.LOGGING) 31 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-logging/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-logging/tests/test_logging_integration.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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 | import logging 16 | import unittest 17 | 18 | from opencensus.trace import config_integration 19 | 20 | 21 | class TestLoggingIntegration(unittest.TestCase): 22 | @classmethod 23 | def setUpClass(cls): 24 | cls._old_logger_class = logging.getLoggerClass() 25 | 26 | @classmethod 27 | def tearDownClass(cls): 28 | logging.setLoggerClass(cls._old_logger_class) 29 | 30 | def test_integration(self): 31 | self.assertEqual(self._old_logger_class, logging.getLoggerClass()) 32 | config_integration.trace_integrations(['logging']) 33 | self.assertNotEqual(self._old_logger_class, logging.getLoggerClass()) 34 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-logging/version.py: -------------------------------------------------------------------------------- 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 | __version__ = '0.2.dev0' 16 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-mysql/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## Unreleased 4 | 5 | ## 0.1.2 6 | Released 2019-04-24 7 | 8 | - Updated docs and examples 9 | 10 | ## 0.1.1 11 | Released 2019-04-08 12 | 13 | - Cosmetic changes 14 | 15 | ## 0.1.0 16 | Released 2019-03-19 17 | 18 | - Initial version 19 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-mysql/README.rst: -------------------------------------------------------------------------------- 1 | OpenCensus MySQL Integration 2 | ============================================================================ 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opencensus-ext-mysql.svg 7 | :target: https://pypi.org/project/opencensus-ext-mysql/ 8 | 9 | The integration with MySQL supports the `mysql-connector`_ library and is specified 10 | to ``trace_integrations`` using ``'mysql'``. 11 | 12 | .. _mysql-connector: https://pypi.org/project/mysql-connector 13 | 14 | Installation 15 | ------------ 16 | 17 | :: 18 | 19 | pip install opencensus-ext-mysql 20 | 21 | Usage 22 | ----- 23 | 24 | .. code:: python 25 | 26 | from opencensus.trace import config_integration 27 | 28 | config_integration.trace_integrations(['mysql']) 29 | 30 | References 31 | ---------- 32 | 33 | * `OpenCensus Project `_ 34 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-mysql/opencensus/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-mysql/opencensus/ext/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-mysql/opencensus/ext/mysql/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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.mysql import trace 16 | 17 | __all__ = ['trace'] 18 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-mysql/opencensus/ext/mysql/trace.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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 | import inspect 16 | import logging 17 | 18 | import mysql.connector 19 | 20 | from opencensus.ext.dbapi import trace 21 | from opencensus.trace import integrations 22 | 23 | MODULE_NAME = 'mysql' 24 | 25 | CONN_WRAP_METHOD = 'connect' 26 | 27 | 28 | def trace_integration(tracer=None): 29 | """Wrap the mysql connector to trace it.""" 30 | logging.info('Integrated module: {}'.format(MODULE_NAME)) 31 | conn_func = getattr(mysql.connector, CONN_WRAP_METHOD) 32 | conn_module = inspect.getmodule(conn_func) 33 | wrapped = trace.wrap_conn(conn_func) 34 | setattr(conn_module, CONN_WRAP_METHOD, wrapped) 35 | # pylint: disable=protected-access 36 | integrations.add_integration(integrations._Integrations.MYSQL) 37 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-mysql/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-mysql/tests/test_mysql_trace.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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 | import unittest 16 | 17 | import mock 18 | 19 | from opencensus.ext.mysql import trace 20 | 21 | 22 | class Test_mysql_trace(unittest.TestCase): 23 | 24 | def test_trace_integration(self): 25 | 26 | def mock_wrap(func): 27 | return 'mock call' 28 | 29 | mock_call = 'mock call' 30 | mock_inspect = mock.Mock() 31 | mock_mysql_module = mock.Mock() 32 | 33 | mock_inspect.getmodule.return_value = mock_mysql_module 34 | 35 | patch_wrap = mock.patch( 36 | 'opencensus.ext.mysql.trace.trace.wrap_conn', 37 | side_effect=mock_wrap) 38 | patch_inspect = mock.patch( 39 | 'opencensus.ext.mysql.trace.inspect', 40 | mock_inspect) 41 | 42 | with patch_wrap, patch_inspect: 43 | trace.trace_integration() 44 | 45 | self.assertEqual(mock_mysql_module.connect, mock_call) 46 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-mysql/version.py: -------------------------------------------------------------------------------- 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 | __version__ = '0.2.dev0' 16 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-ocagent/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## Unreleased 4 | 5 | ## 0.7.1 6 | Released 2019-08-05 7 | 8 | - Update for core library changes 9 | 10 | ## 0.4.0 11 | Released 2019-05-31 12 | 13 | - Remove well_known_types.Error and well_known_types.ParseError. Note this 14 | could be a breaking change if you depend on an older version of protobuf and 15 | use ParseError. 16 | 17 | ## 0.3.0 18 | Released 2019-04-24 19 | 20 | - Add stats exporter 21 | 22 | ## 0.2.0 23 | Released 2019-04-08 24 | 25 | - Update for package changes in core library 26 | - Update generated protos 27 | - Fix UTC timestamp reporting bug 28 | 29 | ## 0.1.0 30 | Released 2019-03-19 31 | 32 | - Initial version 33 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-ocagent/README.rst: -------------------------------------------------------------------------------- 1 | OpenCensus OC-Agent Exporter 2 | ============================================================================ 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opencensus-ext-ocagent.svg 7 | :target: https://pypi.org/project/opencensus-ext-ocagent/ 8 | 9 | Installation 10 | ------------ 11 | 12 | :: 13 | 14 | pip install opencensus-ext-ocagent 15 | 16 | Usage 17 | ----- 18 | 19 | Stats 20 | ~~~~~ 21 | 22 | .. code:: python 23 | 24 | from opencensus.ext.ocagent import stats_exporter as ocagent_stats_exporter 25 | 26 | ocagent_stats_exporter.new_stats_exporter( 27 | service_name='service_name', 28 | endpoint='localhost:55678') 29 | 30 | References 31 | ---------- 32 | 33 | * `OpenCensus Project `_ 34 | * `OpenCensus Services `_ 35 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-ocagent/opencensus/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-ocagent/opencensus/ext/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-ocagent/opencensus/ext/ocagent/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-ocagent/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-ocagent/version.py: -------------------------------------------------------------------------------- 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 | __version__ = '0.8.dev0' 16 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-postgresql/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## Unreleased 4 | 5 | ## 0.1.2 6 | Released 2019-04-24 7 | 8 | - Updated docs and examples 9 | 10 | ## 0.1.1 11 | Released 2019-04-08 12 | 13 | - Cosmetic changes 14 | 15 | ## 0.1.0 16 | Released 2019-03-19 17 | 18 | - Initial version 19 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-postgresql/README.rst: -------------------------------------------------------------------------------- 1 | OpenCensus PostgreSQL Integration 2 | ============================================================================ 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opencensus-ext-postgresql.svg 7 | :target: https://pypi.org/project/opencensus-ext-postgresql/ 8 | 9 | The integration with PostgreSQL supports the `psycopg2`_ library and is specified 10 | to ``trace_integrations`` using ``'postgresql'``. 11 | 12 | .. _psycopg2: https://pypi.org/project/psycopg2 13 | 14 | Installation 15 | ------------ 16 | 17 | :: 18 | 19 | pip install opencensus-ext-postgresql 20 | 21 | Usage 22 | ----- 23 | 24 | .. code:: python 25 | 26 | from opencensus.trace import config_integration 27 | 28 | config_integration.trace_integrations(['postgresql']) 29 | 30 | References 31 | ---------- 32 | 33 | * `OpenCensus Project `_ 34 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-postgresql/opencensus/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-postgresql/opencensus/ext/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-postgresql/opencensus/ext/postgresql/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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.postgresql import trace 16 | 17 | __all__ = ['trace'] 18 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-postgresql/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-postgresql/version.py: -------------------------------------------------------------------------------- 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 | __version__ = '0.2.dev0' 16 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-prometheus/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## Unreleased 4 | 5 | ## 0.2.1 6 | Released 2019-04-24 7 | 8 | - Updated docs and examples 9 | 10 | ## 0.2.0 11 | Released 2019-04-08 12 | 13 | - Update for package changes in core library 14 | 15 | ## 0.1.0 16 | Released 2019-22-19 17 | 18 | - Initial version 19 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-prometheus/opencensus/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-prometheus/opencensus/ext/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-prometheus/opencensus/ext/prometheus/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-prometheus/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-prometheus/version.py: -------------------------------------------------------------------------------- 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 | __version__ = '0.3.dev0' 16 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-pymongo/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## Unreleased 4 | 5 | ## 0.7.1 6 | Released 2019-08-05 7 | 8 | - Changed attributes names to make it compatible with 9 | [OpenTelemetry](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/data-semantic-conventions.md), 10 | maintaining OpenCensus specs fidelity 11 | ([#738](https://github.com/census-instrumentation/opencensus-python/pull/738)) 12 | 13 | ## 0.1.3 14 | Released 2019-05-31 15 | 16 | - Include aggregation pipeline in trace attributes 17 | - Fix support command dictionaries 18 | 19 | ## 0.1.2 20 | Released 2019-04-24 21 | 22 | - Updated docs and examples 23 | 24 | ## 0.1.1 25 | Released 2019-04-08 26 | 27 | - Cosmetic changes 28 | 29 | ## 0.1.0 30 | Released 2019-03-19 31 | 32 | - Initial version 33 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-pymongo/README.rst: -------------------------------------------------------------------------------- 1 | OpenCensus pymongo Integration 2 | ============================================================================ 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opencensus-ext-pymongo.svg 7 | :target: https://pypi.org/project/opencensus-ext-pymongo/ 8 | 9 | The integration with MongoDB supports the `pymongo`_ library and is specified 10 | to ``trace_integrations`` using ``'pymongo'``. 11 | 12 | .. _pymongo: https://pypi.org/project/pymongo 13 | 14 | Installation 15 | ------------ 16 | 17 | :: 18 | 19 | pip install opencensus-ext-pymongo 20 | 21 | Usage 22 | ----- 23 | 24 | .. code:: python 25 | 26 | from opencensus.trace import config_integration 27 | 28 | config_integration.trace_integrations(['pymongo']) 29 | 30 | References 31 | ---------- 32 | 33 | * `OpenCensus Project `_ 34 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-pymongo/opencensus/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-pymongo/opencensus/ext/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-pymongo/opencensus/ext/pymongo/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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.pymongo import trace 16 | 17 | __all__ = ['trace'] 18 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-pymongo/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-pymongo/version.py: -------------------------------------------------------------------------------- 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 | __version__ = '0.8.dev0' 16 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-pymysql/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## Unreleased 4 | 5 | ## 0.1.2 6 | Released 2019-04-24 7 | 8 | - Updated docs and examples 9 | 10 | ## 0.1.1 11 | Released 2019-04-08 12 | 13 | - Cosmetic changes 14 | 15 | ## 0.1.0 16 | Released 2019-03-19 17 | 18 | - Initial version 19 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-pymysql/README.rst: -------------------------------------------------------------------------------- 1 | OpenCensus PyMySQL Integration 2 | ============================================================================ 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opencensus-ext-pymysql.svg 7 | :target: https://pypi.org/project/opencensus-ext-pymysql/ 8 | 9 | Installation 10 | ------------ 11 | 12 | :: 13 | 14 | pip install opencensus-ext-pymysql 15 | 16 | Usage 17 | ----- 18 | 19 | .. code:: python 20 | 21 | from opencensus.trace import config_integration 22 | 23 | config_integration.trace_integrations(['pymysql']) 24 | 25 | References 26 | ---------- 27 | 28 | * `OpenCensus Project `_ 29 | 30 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-pymysql/opencensus/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-pymysql/opencensus/ext/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-pymysql/opencensus/ext/pymysql/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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.pymysql import trace 16 | 17 | __all__ = ['trace'] 18 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-pymysql/opencensus/ext/pymysql/trace.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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 | import inspect 16 | import logging 17 | 18 | import pymysql 19 | 20 | from opencensus.ext.dbapi import trace 21 | from opencensus.trace import integrations 22 | 23 | MODULE_NAME = 'pymysql' 24 | 25 | CONN_WRAP_METHOD = 'connect' 26 | 27 | 28 | def trace_integration(tracer=None): 29 | """Wrap the mysql connector to trace it.""" 30 | logging.info('Integrated module: {}'.format(MODULE_NAME)) 31 | conn_func = getattr(pymysql, CONN_WRAP_METHOD) 32 | conn_module = inspect.getmodule(conn_func) 33 | wrapped = trace.wrap_conn(conn_func) 34 | setattr(conn_module, CONN_WRAP_METHOD, wrapped) 35 | # pylint: disable=protected-access 36 | integrations.add_integration(integrations._Integrations.PYMYSQL) 37 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-pymysql/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-pymysql/tests/test_pymysql_trace.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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 | import unittest 16 | 17 | import mock 18 | 19 | from opencensus.ext.pymysql import trace 20 | 21 | 22 | class Test_pymysql_trace(unittest.TestCase): 23 | 24 | def test_trace_integration(self): 25 | 26 | def mock_wrap(func): 27 | return 'mock call' 28 | 29 | mock_call = 'mock call' 30 | mock_inspect = mock.Mock() 31 | mock_pymysql_module = mock.Mock() 32 | 33 | mock_inspect.getmodule.return_value = mock_pymysql_module 34 | 35 | patch_wrap = mock.patch( 36 | 'opencensus.ext.pymysql.trace.trace.wrap_conn', 37 | side_effect=mock_wrap) 38 | patch_inspect = mock.patch( 39 | 'opencensus.ext.pymysql.trace.inspect', 40 | mock_inspect) 41 | 42 | with patch_wrap, patch_inspect: 43 | trace.trace_integration() 44 | 45 | self.assertEqual(mock_pymysql_module.connect, mock_call) 46 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-pymysql/version.py: -------------------------------------------------------------------------------- 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 | __version__ = '0.2.dev0' 16 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-pyramid/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## Unreleased 4 | 5 | ## 0.7.4 6 | Released 2021-01-14 7 | 8 | - Change blacklist to excludelist 9 | ([#977](https://github.com/census-instrumentation/opencensus-python/pull/977)) 10 | 11 | ## 0.7.1 12 | Released 2019-08-26 13 | 14 | - Updated `http.status_code` attribute to be an int. 15 | ([#755](https://github.com/census-instrumentation/opencensus-python/pull/755)) 16 | 17 | ## 0.7.0 18 | Released 2019-07-31 19 | 20 | - Updated span attributes to include some missing attributes listed [here](https://github.com/census-instrumentation/opencensus-specs/blob/master/trace/HTTP.md#attributes) 21 | ([#735](https://github.com/census-instrumentation/opencensus-python/pull/735)) 22 | 23 | ## 0.3.0 24 | Released 2019-04-24 25 | 26 | - Refactor configuration, keep consistent with Flask/Django 27 | - Use W3C TraceContext propagation by default 28 | 29 | ## 0.2.0 30 | Released 2019-04-08 31 | 32 | - Update for package changes in core library 33 | 34 | ## 0.1.0 35 | Released 2019-03-19 36 | 37 | - Initial version 38 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-pyramid/README.rst: -------------------------------------------------------------------------------- 1 | OpenCensus Pyramid Integration 2 | ============================================================================ 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opencensus-ext-pyramid.svg 7 | :target: https://pypi.org/project/opencensus-ext-pyramid/ 8 | 9 | Installation 10 | ------------ 11 | 12 | :: 13 | 14 | pip install opencensus-ext-pyramid 15 | 16 | Usage 17 | ----- 18 | 19 | In your application, add the pyramid tween and your requests will be 20 | traced. 21 | 22 | .. code:: python 23 | 24 | def main(global_config, **settings): 25 | config = Configurator(settings=settings) 26 | 27 | config.add_tween('opencensus.ext.pyramid' 28 | '.pyramid_middleware.OpenCensusTweenFactory') 29 | 30 | Additional configuration can be provided, please read 31 | `Customization `_ 32 | for a complete reference. 33 | 34 | .. code:: python 35 | 36 | from opencensus.trace import print_exporter 37 | from opencensus.trace import samplers 38 | 39 | settings = { 40 | 'OPENCENSUS': { 41 | 'TRACE': { 42 | 'EXPORTER': print_exporter.PrintExporter(), 43 | 'SAMPLER': samplers.ProbabilitySampler(rate=0.5), 44 | } 45 | } 46 | } 47 | 48 | config = Configurator(settings=settings) 49 | 50 | References 51 | ---------- 52 | 53 | * `OpenCensus Project `_ 54 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-pyramid/examples/app/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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 | import requests 16 | from pyramid.config import Configurator 17 | from pyramid.response import Response 18 | from pyramid.tweens import MAIN 19 | from pyramid.view import view_config 20 | 21 | 22 | @view_config(route_name='hello') 23 | def hello(request): 24 | return Response('Hello world!') 25 | 26 | 27 | @view_config(route_name='trace_requests') 28 | def trace_requests(request): 29 | response = requests.get('http://www.google.com') 30 | return Response(response.status_code) 31 | 32 | 33 | def main(global_config, **settings): 34 | config = Configurator(settings=settings) 35 | 36 | config.add_route('hello', '/') 37 | config.add_route('trace_requests', '/requests') 38 | 39 | config.add_tween('opencensus.ext.pyramid' 40 | '.pyramid_middleware.OpenCensusTweenFactory', 41 | over=MAIN) 42 | 43 | config.scan() 44 | 45 | return config.make_wsgi_app() 46 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-pyramid/examples/simple.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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 wsgiref.simple_server import make_server 16 | 17 | from app import main 18 | from opencensus.trace import config_integration, print_exporter, samplers 19 | 20 | config_integration.trace_integrations(['requests']) 21 | 22 | 23 | def run_app(): 24 | settings = { 25 | 'OPENCENSUS': { 26 | 'TRACE': { 27 | 'EXPORTER': print_exporter.PrintExporter(), 28 | 'SAMPLER': samplers.ProbabilitySampler(rate=1), 29 | } 30 | } 31 | } 32 | 33 | app = main({}, **settings) 34 | server = make_server('localhost', 8080, app) 35 | server.serve_forever() 36 | 37 | 38 | if __name__ == '__main__': 39 | run_app() 40 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-pyramid/opencensus/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-pyramid/opencensus/ext/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-pyramid/opencensus/ext/pyramid/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/census-instrumentation/opencensus-python/cd020b07f06024b6c9243c514b5413cef46f4775/contrib/opencensus-ext-pyramid/opencensus/ext/pyramid/__init__.py -------------------------------------------------------------------------------- /contrib/opencensus-ext-pyramid/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-pyramid/version.py: -------------------------------------------------------------------------------- 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 | __version__ = '0.8.dev0' 16 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-requests/README.rst: -------------------------------------------------------------------------------- 1 | OpenCensus requests Integration 2 | ============================================================================ 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opencensus-ext-requests.svg 7 | :target: https://pypi.org/project/opencensus-ext-requests/ 8 | 9 | OpenCensus can trace HTTP requests made with the `requests package`_. The request URL, 10 | method, and status will be collected. 11 | 12 | You can enable requests integration by specifying ``'requests'`` to ``trace_integrations``. 13 | 14 | It's possible to configure a list of URL you don't want traced. By default the request to exporter 15 | won't be traced. It's configurable by giving an array of hostname/port to the attribute 16 | ``excludelist_hostnames`` in OpenCensus context's attributes: 17 | 18 | Only the hostname must be specified if only the hostname is specified in the URL request. 19 | 20 | .. _Requests package: https://pypi.python.org/pypi/requests 21 | 22 | Installation 23 | ------------ 24 | 25 | :: 26 | 27 | pip install opencensus-ext-requests 28 | 29 | Usage 30 | ----- 31 | 32 | .. code:: python 33 | 34 | import requests 35 | from opencensus.trace import config_integration 36 | from opencensus.trace.tracer import Tracer 37 | 38 | if __name__ == '__main__': 39 | config_integration.trace_integrations(['requests']) 40 | tracer = Tracer() 41 | with tracer.span(name='parent'): 42 | response = requests.get(url='https://www.wikipedia.org/wiki/Rabbit') 43 | 44 | References 45 | ---------- 46 | 47 | * `OpenCensus Project `_ 48 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-requests/opencensus/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-requests/opencensus/ext/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-requests/opencensus/ext/requests/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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.requests import trace 16 | 17 | __all__ = ['trace'] 18 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-requests/opencensus/ext/requests/common/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-requests/opencensus/ext/requests/common/version.py: -------------------------------------------------------------------------------- 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 | __version__ = '0.9.dev0' 16 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-requests/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-sqlalchemy/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## Unreleased 4 | 5 | ## 0.1.2 6 | Released 2019-04-24 7 | 8 | - Updated docs and examples 9 | 10 | ## 0.1.1 11 | Released 2019-04-08 12 | 13 | - Cosmetic changes 14 | 15 | ## 0.1.0 16 | Released 2019-03-19 17 | 18 | - Initial version 19 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-sqlalchemy/README.rst: -------------------------------------------------------------------------------- 1 | OpenCensus SQLAlchemy Integration 2 | ============================================================================ 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opencensus-ext-sqlalchemy.svg 7 | :target: https://pypi.org/project/opencensus-ext-sqlalchemy/ 8 | 9 | You can trace usage of the `sqlalchemy package`_, regardless of the underlying 10 | database, by specifying ``'sqlalchemy'`` to ``trace_integrations``. 11 | 12 | .. _SQLAlchemy package: https://pypi.org/project/SQLAlchemy 13 | 14 | .. note:: If you enable tracing of SQLAlchemy as well as the underlying database 15 | driver, you will get duplicate spans. Instead, just trace SQLAlchemy. 16 | 17 | Installation 18 | ------------ 19 | 20 | :: 21 | 22 | pip install opencensus-ext-sqlalchemy 23 | 24 | Usage 25 | ----- 26 | 27 | .. code:: python 28 | 29 | from opencensus.trace import config_integration 30 | 31 | config_integration.trace_integrations(['sqlalchemy']) 32 | 33 | References 34 | ---------- 35 | 36 | * `OpenCensus Project `_ 37 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-sqlalchemy/opencensus/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-sqlalchemy/opencensus/ext/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-sqlalchemy/opencensus/ext/sqlalchemy/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-sqlalchemy/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-sqlalchemy/version.py: -------------------------------------------------------------------------------- 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 | __version__ = '0.2.dev0' 16 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-stackdriver/opencensus/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-stackdriver/opencensus/ext/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-stackdriver/opencensus/ext/stackdriver/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-stackdriver/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-stackdriver/version.py: -------------------------------------------------------------------------------- 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 | __version__ = '0.9.dev0' 16 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-threading/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## Unreleased 4 | 5 | ## 0.1.2 6 | Released 2019-04-24 7 | 8 | - Updated docs and examples 9 | 10 | ## 0.1.1 11 | Released 2019-04-08 12 | 13 | - Cosmetic changes 14 | 15 | ## 0.1.0 16 | Released 2019-03-19 17 | 18 | - Initial version 19 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-threading/README.rst: -------------------------------------------------------------------------------- 1 | OpenCensus threading Integration 2 | ============================================================================ 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opencensus-ext-threading.svg 7 | :target: https://pypi.org/project/opencensus-ext-threading/ 8 | 9 | OpenCensus can propagate trace across threads when using the threading package. 10 | 11 | You can enable Threading integration by specifying ``'threading'`` to ``trace_integrations``. 12 | 13 | Installation 14 | ------------ 15 | 16 | :: 17 | 18 | pip install opencensus-ext-threading 19 | 20 | Usage 21 | ----- 22 | 23 | .. code:: python 24 | 25 | from opencensus.trace import config_integration 26 | 27 | config_integration.trace_integrations(['threading']) 28 | 29 | References 30 | ---------- 31 | 32 | * `OpenCensus Project `_ 33 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-threading/opencensus/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-threading/opencensus/ext/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-threading/opencensus/ext/threading/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 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 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-threading/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-threading/version.py: -------------------------------------------------------------------------------- 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 | __version__ = '0.2.dev0' 16 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-zipkin/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## Unreleased 4 | 5 | ## 0.2.2 6 | Released 2019-05-31 7 | 8 | - Minor improvements 9 | 10 | ## 0.2.1 11 | Released 2019-04-24 12 | 13 | - Updated docs and examples 14 | 15 | ## 0.2.0 16 | Released 2019-04-08 17 | 18 | - Update for package changes in core library 19 | 20 | ## 0.1.0 21 | Released 2019-03-19 22 | 23 | - Initial version 24 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-zipkin/README.rst: -------------------------------------------------------------------------------- 1 | OpenCensus Zipkin Exporter 2 | ============================================================================ 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opencensus-ext-zipkin.svg 7 | :target: https://pypi.org/project/opencensus-ext-zipkin/ 8 | 9 | Installation 10 | ------------ 11 | 12 | :: 13 | 14 | pip install opencensus-ext-zipkin 15 | 16 | Usage 17 | ----- 18 | 19 | The **OpenCensus Zipkin Exporter** allows you to export `OpenCensus`_ traces to `Zipkin`_. 20 | 21 | .. _OpenCensus: https://github.com/census-instrumentation/opencensus-python/ 22 | .. _Zipkin: https://zipkin.io/ 23 | 24 | .. code:: python 25 | 26 | from opencensus.ext.zipkin.trace_exporter import ZipkinExporter 27 | from opencensus.trace import tracer as tracer_module 28 | 29 | tracer = tracer_module.Tracer(exporter=ZipkinExporter( 30 | service_name='my service', 31 | host_name='localhost', 32 | port=9411, 33 | )) 34 | 35 | with tracer.span(name='hello'): 36 | print('Hello, World!') 37 | 38 | References 39 | ---------- 40 | 41 | * `OpenCensus Project `_ 42 | * `Zipkin `_ 43 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-zipkin/opencensus/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-zipkin/opencensus/ext/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-zipkin/opencensus/ext/zipkin/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-zipkin/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /contrib/opencensus-ext-zipkin/version.py: -------------------------------------------------------------------------------- 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 | __version__ = '0.3.dev0' 16 | -------------------------------------------------------------------------------- /docs/.nojekyll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/census-instrumentation/opencensus-python/cd020b07f06024b6c9243c514b5413cef46f4775/docs/.nojekyll -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. OPENCENSUS documentation master file, created by 2 | sphinx-quickstart on Mon Oct 30 12:42:31 2017. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to OPENCENSUS's documentation! 7 | ====================================== 8 | 9 | .. toctree:: 10 | :maxdepth: 2 11 | :hidden: 12 | 13 | trace/index 14 | 15 | Getting started 16 | --------------- 17 | 18 | The ``opencensus`` library is ``pip`` install-able: 19 | 20 | .. code-block:: console 21 | 22 | $ pip install opencensus 23 | 24 | Fore more information on setting up your Python development environment, such as installing ``pip`` on your system, please refer to `Python Development Environment Setup Guide`_ for Google Cloud Platform. 25 | 26 | .. _Python Development Environment Setup Guide: https://cloud.google.com/python/setup 27 | -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | setuptools >= 36.4.0 2 | sphinx >= 1.6.3 3 | 4 | context/opencensus-context 5 | contrib/opencensus-correlation 6 | . 7 | -------------------------------------------------------------------------------- /docs/trace/api/binary_format_propagation.rst: -------------------------------------------------------------------------------- 1 | Propagator - BinaryFormatPropagator 2 | =================================== 3 | 4 | .. automodule:: opencensus.trace.propagation.binary_format 5 | :members: 6 | :show-inheritance: 7 | -------------------------------------------------------------------------------- /docs/trace/api/context_tracer.rst: -------------------------------------------------------------------------------- 1 | Context Tracer 2 | ============== 3 | 4 | .. automodule:: opencensus.trace.tracers.context_tracer 5 | :members: 6 | :show-inheritance: 7 | -------------------------------------------------------------------------------- /docs/trace/api/execution_context.rst: -------------------------------------------------------------------------------- 1 | Execution Context 2 | ================= 3 | 4 | .. automodule:: opencensus.trace.execution_context 5 | :members: 6 | :show-inheritance: 7 | -------------------------------------------------------------------------------- /docs/trace/api/file_exporter.rst: -------------------------------------------------------------------------------- 1 | Exporter - File Exporter 2 | ======================== 3 | 4 | .. automodule:: opencensus.trace.file_exporter 5 | :members: 6 | :show-inheritance: 7 | -------------------------------------------------------------------------------- /docs/trace/api/google_cloud_format_propagation.rst: -------------------------------------------------------------------------------- 1 | Propagator - GoogleCloudFormatPropagator 2 | ======================================== 3 | 4 | .. automodule:: opencensus.trace.propagation.google_cloud_format 5 | :members: 6 | :show-inheritance: 7 | -------------------------------------------------------------------------------- /docs/trace/api/index.rst: -------------------------------------------------------------------------------- 1 | API Documentation 2 | ================= 3 | 4 | .. toctree:: 5 | 6 | span 7 | span_context 8 | tracer 9 | execution_context 10 | trace_options 11 | always_on_sampler 12 | always_off_sampler 13 | probability_sampler 14 | print_exporter 15 | logging_exporter 16 | stackdriver_exporter 17 | zipkin_exporter 18 | file_exporter 19 | binary_format_propagation 20 | google_cloud_format_propagation 21 | text_format_propagation 22 | trace_context_http_header_format_propagation 23 | noop_tracer 24 | context_tracer 25 | -------------------------------------------------------------------------------- /docs/trace/api/logging_exporter.rst: -------------------------------------------------------------------------------- 1 | Exporter - Logging Exporter 2 | =========================== 3 | 4 | .. automodule:: opencensus.trace.logging_exporter 5 | :members: 6 | :show-inheritance: 7 | -------------------------------------------------------------------------------- /docs/trace/api/noop_tracer.rst: -------------------------------------------------------------------------------- 1 | Noop Tracer 2 | =========== 3 | 4 | .. automodule:: opencensus.trace.tracers.noop_tracer 5 | :members: 6 | :show-inheritance: 7 | -------------------------------------------------------------------------------- /docs/trace/api/print_exporter.rst: -------------------------------------------------------------------------------- 1 | Exporter - Print Exporter 2 | ========================= 3 | 4 | .. automodule:: opencensus.trace.print_exporter 5 | :members: 6 | :show-inheritance: 7 | -------------------------------------------------------------------------------- /docs/trace/api/samplers.rst: -------------------------------------------------------------------------------- 1 | Samplers 2 | ======== 3 | 4 | .. automodule:: opencensus.trace.samplers 5 | :members: 6 | :show-inheritance: 7 | -------------------------------------------------------------------------------- /docs/trace/api/span.rst: -------------------------------------------------------------------------------- 1 | Span 2 | ==== 3 | 4 | .. automodule:: opencensus.trace.span 5 | :members: 6 | :show-inheritance: 7 | -------------------------------------------------------------------------------- /docs/trace/api/span_context.rst: -------------------------------------------------------------------------------- 1 | Span Context 2 | ============ 3 | 4 | .. automodule:: opencensus.trace.span_context 5 | :members: 6 | :show-inheritance: 7 | -------------------------------------------------------------------------------- /docs/trace/api/stackdriver_exporter.rst: -------------------------------------------------------------------------------- 1 | Exporter - Stackdriver Exporter 2 | =============================== 3 | 4 | .. automodule:: opencensus.ext.stackdriver.trace_exporter 5 | :members: 6 | :show-inheritance: 7 | -------------------------------------------------------------------------------- /docs/trace/api/text_format_propagation.rst: -------------------------------------------------------------------------------- 1 | Propagator - TextFormatPropagator 2 | ================================= 3 | 4 | .. automodule:: opencensus.trace.propagation.text_format 5 | :members: 6 | :show-inheritance: 7 | -------------------------------------------------------------------------------- /docs/trace/api/trace_context_http_header_format_propagation.rst: -------------------------------------------------------------------------------- 1 | Propagator - TraceContextPropagator 2 | =================================== 3 | 4 | .. automodule:: opencensus.trace.propagation.trace_context_http_header_format 5 | :members: 6 | :show-inheritance: 7 | -------------------------------------------------------------------------------- /docs/trace/api/trace_options.rst: -------------------------------------------------------------------------------- 1 | Trace Options 2 | ============= 3 | 4 | .. automodule:: opencensus.trace.trace_options 5 | :members: 6 | :show-inheritance: 7 | -------------------------------------------------------------------------------- /docs/trace/api/tracer.rst: -------------------------------------------------------------------------------- 1 | Request Tracer 2 | ============== 3 | 4 | .. automodule:: opencensus.trace.tracer 5 | :members: 6 | :show-inheritance: 7 | -------------------------------------------------------------------------------- /docs/trace/api/zipkin_exporter.rst: -------------------------------------------------------------------------------- 1 | Exporter - Zipkin Exporter 2 | ========================== 3 | 4 | .. automodule:: opencensus.ext.zipkin.trace_exporter 5 | :members: 6 | :show-inheritance: 7 | -------------------------------------------------------------------------------- /docs/trace/index.rst: -------------------------------------------------------------------------------- 1 | .. toctree:: 2 | :maxdepth: 2 3 | :hidden: 4 | 5 | usage 6 | api/index 7 | -------------------------------------------------------------------------------- /opencensus/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /opencensus/common/__init__.py: -------------------------------------------------------------------------------- 1 | __path__ = __import__('pkgutil').extend_path(__path__, __name__) 2 | -------------------------------------------------------------------------------- /opencensus/common/configuration/__init__.py: -------------------------------------------------------------------------------- 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 | import importlib 16 | 17 | __all__ = ['Namespace', 'load'] 18 | 19 | 20 | class Namespace(object): 21 | def __init__(self, name, parent=None): 22 | self.parent = parent 23 | self.name = name 24 | 25 | def __getattr__(self, name): 26 | return type(self)(name, self) 27 | 28 | def __str__(self): 29 | if self.parent is None: 30 | return self.name 31 | return '{!s}.{}'.format(self.parent, self.name) 32 | 33 | def __call__(self, *args, **kwargs): 34 | ctor = getattr(importlib.import_module(str(self.parent)), self.name) 35 | return ctor(*args, **kwargs) 36 | 37 | @classmethod 38 | def eval(cls, expr): 39 | return eval(expr, {}, {'opencensus': cls('opencensus')}) 40 | 41 | 42 | def load(expr): 43 | """Dynamically import OpenCensus components and evaluate the provided 44 | configuration expression. 45 | """ 46 | return Namespace.eval(expr) 47 | -------------------------------------------------------------------------------- /opencensus/common/http_handler/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 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 | try: 16 | # For Python 3.0 and later 17 | from urllib.request import urlopen, Request 18 | from urllib.error import HTTPError, URLError 19 | except ImportError: 20 | # Fall back to Python 2's urllib2 21 | from urllib2 import urlopen, Request 22 | from urllib2 import HTTPError, URLError 23 | 24 | 25 | import socket 26 | 27 | _REQUEST_TIMEOUT = 2 # in secs 28 | 29 | 30 | def get_request(request_url, request_headers=dict()): 31 | """Execute http get request on given request_url with optional headers 32 | """ 33 | request = Request(request_url) 34 | for key, val in request_headers.items(): 35 | request.add_header(key, val) 36 | 37 | try: 38 | response = urlopen(request, timeout=_REQUEST_TIMEOUT) 39 | response_content = response.read() 40 | except (HTTPError, URLError, socket.timeout): 41 | response_content = None 42 | 43 | return response_content 44 | -------------------------------------------------------------------------------- /opencensus/common/monitored_resource/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/census-instrumentation/opencensus-python/cd020b07f06024b6c9243c514b5413cef46f4775/opencensus/common/monitored_resource/__init__.py -------------------------------------------------------------------------------- /opencensus/common/transports/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 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 | -------------------------------------------------------------------------------- /opencensus/common/transports/base.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 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 | """Module containing base class for transport.""" 16 | 17 | 18 | class Transport(object): 19 | """Base class for transport. 20 | 21 | Subclasses of :class:`Transport` must override :meth:`export`. 22 | """ 23 | def export(self, datas): 24 | """Export the data.""" 25 | raise NotImplementedError 26 | 27 | def flush(self): 28 | """Submit any pending data. 29 | 30 | For blocking/sync transports, this is a no-op. 31 | """ 32 | -------------------------------------------------------------------------------- /opencensus/common/transports/sync.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 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.common.transports import base 16 | from opencensus.trace import execution_context 17 | 18 | 19 | class SyncTransport(base.Transport): 20 | def __init__(self, exporter): 21 | self.exporter = exporter 22 | 23 | def export(self, datas): 24 | # Used to suppress tracking of requests in export 25 | execution_context.set_is_exporter(True) 26 | self.exporter.emit(datas) 27 | # Reset the context 28 | execution_context.set_is_exporter(False) 29 | -------------------------------------------------------------------------------- /opencensus/common/version/__init__.py: -------------------------------------------------------------------------------- 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 | __version__ = '0.12.dev0' 16 | -------------------------------------------------------------------------------- /opencensus/metrics/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/census-instrumentation/opencensus-python/cd020b07f06024b6c9243c514b5413cef46f4775/opencensus/metrics/__init__.py -------------------------------------------------------------------------------- /opencensus/metrics/export/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/census-instrumentation/opencensus-python/cd020b07f06024b6c9243c514b5413cef46f4775/opencensus/metrics/export/__init__.py -------------------------------------------------------------------------------- /opencensus/metrics/label_value.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 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 | 16 | class LabelValue(object): 17 | """The label values associated with the TimeSeries. 18 | 19 | :type value: str 20 | :param value: the value for the label 21 | """ 22 | def __init__(self, value=None): 23 | self._value = value 24 | 25 | def __repr__(self): 26 | return ("{}({})" 27 | .format( 28 | type(self).__name__, 29 | self.value, 30 | )) 31 | 32 | @property 33 | def value(self): 34 | """the value for the label""" 35 | return self._value 36 | 37 | def __eq__(self, other): 38 | return isinstance(other, LabelValue) and \ 39 | self.value == other.value 40 | 41 | def __hash__(self): 42 | return hash(self.value) 43 | -------------------------------------------------------------------------------- /opencensus/stats/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 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 | -------------------------------------------------------------------------------- /opencensus/stats/bucket_boundaries.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 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 | 16 | class BucketBoundaries(object): 17 | """The bucket boundaries for a histogram 18 | 19 | :type boundaries: list(float) 20 | :param boundaries: boundaries for the buckets in the underlying histogram 21 | 22 | """ 23 | def __init__(self, boundaries=None): 24 | self._boundaries = list(boundaries or []) 25 | 26 | @property 27 | def boundaries(self): 28 | """the current boundaries""" 29 | return self._boundaries 30 | 31 | def is_valid_boundaries(self, boundaries): 32 | """checks if the boundaries are in ascending order""" 33 | if boundaries is not None: 34 | min_ = boundaries[0] 35 | for value in boundaries: 36 | if value < min_: 37 | return False 38 | else: 39 | min_ = value 40 | return True 41 | return False 42 | -------------------------------------------------------------------------------- /opencensus/stats/execution_context.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 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.common.runtime_context import RuntimeContext 16 | 17 | _measure_to_view_map_slot = RuntimeContext.register_slot( 18 | 'measure_to_view_map', 19 | lambda: {}) 20 | 21 | 22 | def get_measure_to_view_map(): 23 | return RuntimeContext.measure_to_view_map 24 | 25 | 26 | def set_measure_to_view_map(measure_to_view_map): 27 | RuntimeContext.measure_to_view_map = measure_to_view_map 28 | 29 | 30 | def clear(): 31 | """Clear the context, used in test.""" 32 | _measure_to_view_map_slot.clear() 33 | -------------------------------------------------------------------------------- /opencensus/stats/stats_recorder.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 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.stats import execution_context 16 | from opencensus.stats.measure_to_view_map import MeasureToViewMap 17 | from opencensus.stats.measurement_map import MeasurementMap 18 | 19 | 20 | class StatsRecorder(object): 21 | """Stats Recorder provides methods to record stats against tags 22 | 23 | """ 24 | def __init__(self): 25 | if execution_context.get_measure_to_view_map() == {}: 26 | execution_context.set_measure_to_view_map(MeasureToViewMap()) 27 | 28 | self.measure_to_view_map = execution_context.get_measure_to_view_map() 29 | 30 | def new_measurement_map(self): 31 | """Creates a new MeasurementMap in order to record stats 32 | :returns a MeasurementMap for recording multiple measurements 33 | """ 34 | return MeasurementMap(self.measure_to_view_map) 35 | -------------------------------------------------------------------------------- /opencensus/tags/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 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.common.runtime_context import RuntimeContext 16 | from opencensus.tags.tag import Tag 17 | from opencensus.tags.tag_key import TagKey 18 | from opencensus.tags.tag_map import TagMap 19 | from opencensus.tags.tag_value import TagValue 20 | 21 | __all__ = ['Tag', 'TagContext', 'TagKey', 'TagValue', 'TagMap'] 22 | 23 | TagContext = RuntimeContext.register_slot('tag_context', None) 24 | -------------------------------------------------------------------------------- /opencensus/tags/propagation/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 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 | -------------------------------------------------------------------------------- /opencensus/tags/tag.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 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 collections import namedtuple 16 | 17 | from opencensus.tags.tag_key import TagKey 18 | from opencensus.tags.tag_value import TagValue 19 | 20 | Tag_ = namedtuple('Tag', ['key', 'value']) 21 | 22 | 23 | class Tag(Tag_): 24 | """A tag, in the format [KEY]:[VALUE]. 25 | 26 | :type key: str 27 | :param key: The name of the tag 28 | 29 | :type value: str 30 | :param value: The value of the tag 31 | 32 | """ 33 | def __new__(cls, key, value): 34 | return super(Tag, cls).__new__( 35 | cls, 36 | key=TagKey(key), 37 | value=TagValue(value), 38 | ) 39 | -------------------------------------------------------------------------------- /opencensus/tags/tag_key.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 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.tags.validation import is_valid_tag_name 16 | 17 | _TAG_NAME_ERROR = \ 18 | 'tag name must not be empty,' \ 19 | 'no longer than 255 characters and of ascii values between 32 - 126' 20 | 21 | 22 | class TagKey(str): 23 | """A tag key with a property name""" 24 | 25 | def __new__(cls, name): 26 | """Create and return a new tag key 27 | 28 | :type name: str 29 | :param name: The name of the key 30 | :return: TagKey 31 | """ 32 | if not isinstance(name, cls): 33 | if not is_valid_tag_name(name): 34 | raise ValueError(_TAG_NAME_ERROR) 35 | return super(TagKey, cls).__new__(cls, name) 36 | -------------------------------------------------------------------------------- /opencensus/tags/tag_value.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 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.tags.validation import is_valid_tag_value 16 | 17 | _TAG_VALUE_ERROR = \ 18 | 'tag value must not be longer than 255 characters ' \ 19 | 'and of ascii values between 32 - 126' 20 | 21 | 22 | class TagValue(str): 23 | """The value of a tag""" 24 | 25 | def __new__(cls, value): 26 | """Create and return a new tag value 27 | 28 | :type value: str 29 | :param value: A string representing the value of a key in a tag 30 | :return: TagValue 31 | """ 32 | if not isinstance(value, cls): 33 | if not is_valid_tag_value(value): 34 | raise ValueError(_TAG_VALUE_ERROR) 35 | return super(TagValue, cls).__new__(cls, value) 36 | -------------------------------------------------------------------------------- /opencensus/tags/validation.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 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 | 16 | def is_legal_chars(value): 17 | return all(32 <= ord(char) <= 126 for char in value) 18 | 19 | 20 | def is_valid_tag_name(name): 21 | """Checks if the name of a tag key is valid 22 | 23 | :type name: str 24 | :param name: name to check 25 | 26 | :rtype: bool 27 | :returns: True if it valid, else returns False 28 | """ 29 | return is_legal_chars(name) if 0 < len(name) <= 255 else False 30 | 31 | 32 | def is_valid_tag_value(value): 33 | """Checks if the value is valid 34 | 35 | :type value: str 36 | :param value: the value to be checked 37 | 38 | :rtype: bool 39 | :returns: True if valid, if not, False. 40 | 41 | """ 42 | return is_legal_chars(value) if len(value) <= 255 else False 43 | -------------------------------------------------------------------------------- /opencensus/trace/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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.trace.span import Span 16 | 17 | __all__ = ['Span'] 18 | -------------------------------------------------------------------------------- /opencensus/trace/config_integration.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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 | import importlib 16 | import logging 17 | 18 | log = logging.getLogger(__name__) 19 | 20 | 21 | def trace_integrations(integrations, tracer=None): 22 | """Enable tracing on the selected integrations. 23 | :type integrations: list 24 | :param integrations: The integrations to be traced. 25 | """ 26 | integrated = [] 27 | 28 | for item in integrations: 29 | module_name = 'opencensus.ext.{}.trace'.format(item) 30 | try: 31 | module = importlib.import_module(module_name) 32 | module.trace_integration(tracer=tracer) 33 | integrated.append(item) 34 | except Exception as e: 35 | log.warning('Failed to integrate module: {}'.format(module_name)) 36 | log.warning('{}'.format(e)) 37 | 38 | return integrated 39 | -------------------------------------------------------------------------------- /opencensus/trace/exceptions_status.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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 google.rpc import code_pb2 16 | 17 | from opencensus.trace.status import Status 18 | 19 | CANCELLED = Status(code_pb2.CANCELLED) 20 | INVALID_URL = Status(code_pb2.INVALID_ARGUMENT, message='invalid URL') 21 | TIMEOUT = Status(code_pb2.DEADLINE_EXCEEDED, message='request timed out') 22 | 23 | 24 | def unknown(exception): 25 | return Status.from_exception(exception) 26 | -------------------------------------------------------------------------------- /opencensus/trace/propagation/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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 | -------------------------------------------------------------------------------- /opencensus/trace/tracers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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 | -------------------------------------------------------------------------------- /scripts/pylint.sh: -------------------------------------------------------------------------------- 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 | set -ev 16 | 17 | # Run pylint on directories 18 | function pylint_dir { 19 | python -m pip install --upgrade pylint 20 | pylint $(find context/ contrib opencensus/ tests/ examples/ -type f -name "*.py") 21 | # TODO fix lint errors 22 | return $? 23 | } 24 | 25 | pylint_dir 26 | -------------------------------------------------------------------------------- /scripts/twine_upload.sh: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 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 | set -ev 16 | 17 | # If this is not a CircleCI tag, no-op. 18 | if [[ -z "$CIRCLE_TAG" ]]; then 19 | echo "This is not a release tag. Doing nothing." 20 | exit 0 21 | fi 22 | 23 | BASEDIR=$PWD 24 | 25 | echo -e "[pypi]" >> ~/.pypirc 26 | echo -e "username = $PYPI_USERNAME" >> ~/.pypirc 27 | echo -e "password = $PYPI_PASSWORD" >> ~/.pypirc 28 | 29 | # Ensure that we have the latest versions of Twine, Wheel, and Setuptools. 30 | python3 -m pip install --upgrade twine wheel setuptools 31 | 32 | # Build the distributions. 33 | python3 setup.py bdist_wheel 34 | 35 | for d in context/*/ contrib/*/ ; do 36 | pushd . 37 | cd "$d" 38 | python3 setup.py bdist_wheel --dist-dir "$BASEDIR/dist/" 39 | popd 40 | done 41 | 42 | # Upload the distributions. 43 | for p in dist/* ; do 44 | twine upload --skip-existing $p 45 | done 46 | -------------------------------------------------------------------------------- /scripts/update_docs.sh: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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 | set -ev 16 | 17 | # Build docs 18 | function build_docs { 19 | rm -rf docs/build/ 20 | cp README.rst docs/trace/usage.rst 21 | sed -i '1s/.*/OpenCensus Trace for Python/' docs/trace/usage.rst 22 | sed -i '2s/.*/===========================/' docs/trace/usage.rst 23 | make html 24 | return $? 25 | } 26 | 27 | build_docs 28 | 29 | cp -R docs/build/html/* docs/ 30 | rm -rf docs/build 31 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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 | -------------------------------------------------------------------------------- /tests/system/set_credential.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright 2017, OpenCensus Authors 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # Set credential env var 17 | export GOOGLE_APPLICATION_CREDENTIALS='google_application_credentials' 18 | 19 | # Decrypt credentials 20 | if [ -n "$GOOGLE_APPLICATION_CREDENTIALS" ]; then 21 | openssl aes-256-cbc -d -a -k "$GOOGLE_CREDENTIALS_PASSPHRASE" \ 22 | -in credentials.json.enc \ 23 | -out "$GOOGLE_APPLICATION_CREDENTIALS" 24 | else 25 | echo "No credentials. System tests will not run." 26 | exit 1 27 | fi 28 | -------------------------------------------------------------------------------- /tests/system/trace/django/app/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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 | -------------------------------------------------------------------------------- /tests/system/trace/django/app/forms.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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 django import forms 16 | 17 | 18 | class HelloForm(forms.Form): 19 | fname = forms.CharField(max_length=40) 20 | lname = forms.CharField(max_length=40) 21 | -------------------------------------------------------------------------------- /tests/system/trace/django/app/templates/home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | {% csrf_token %} 19 | First Name:
20 | 21 |
22 | Last Name:
23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /tests/system/trace/django/manage.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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 | import os 16 | import sys 17 | 18 | if __name__ == "__main__": 19 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app.settings") 20 | 21 | from django.core.management import execute_from_command_line 22 | 23 | execute_from_command_line(sys.argv) 24 | -------------------------------------------------------------------------------- /tests/system/trace/flask/.dockerignore: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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 | .dockerignore 16 | Dockerfile 17 | .git 18 | .hg 19 | .svn 20 | -------------------------------------------------------------------------------- /tests/unit/common/test_configuration.py: -------------------------------------------------------------------------------- 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 | import unittest 16 | 17 | from opencensus.common import configuration 18 | 19 | 20 | class TestConfiguration(unittest.TestCase): 21 | def test_load_import_error(self): 22 | with self.assertRaises(ImportError): 23 | configuration.load('opencensus.nonexist.foo()') 24 | 25 | def test_load_name_error(self): 26 | with self.assertRaises(NameError): 27 | configuration.load('nonexist.foo()') 28 | 29 | def test_load_syntax_error(self): 30 | with self.assertRaises(SyntaxError): 31 | configuration.load(')') 32 | 33 | def test_load(self): 34 | ns = configuration.load( 35 | 'opencensus.common.configuration.Namespace("foo")' 36 | ) 37 | self.assertEqual(ns.name, 'foo') 38 | -------------------------------------------------------------------------------- /tests/unit/common/transports/test_common_base_transport.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 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 | import unittest 16 | 17 | 18 | class TestCommonBaseTransport(unittest.TestCase): 19 | def test_export_abstract(self): 20 | from opencensus.common.transports import base 21 | 22 | transport = base.Transport() 23 | trace = {} 24 | 25 | with self.assertRaises(NotImplementedError): 26 | transport.export(trace) 27 | 28 | def test_flush_abstract_and_optional(self): 29 | from opencensus.common.transports import base 30 | 31 | transport = base.Transport() 32 | transport.flush() 33 | -------------------------------------------------------------------------------- /tests/unit/common/transports/test_sync.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 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 | import unittest 16 | 17 | import mock 18 | 19 | from opencensus.common.transports import sync 20 | 21 | 22 | class TestSyncTransport(unittest.TestCase): 23 | def test_constructor(self): 24 | exporter = mock.Mock() 25 | transport = sync.SyncTransport(exporter) 26 | 27 | self.assertEqual(transport.exporter, exporter) 28 | 29 | def test_export(self): 30 | exporter = mock.Mock() 31 | transport = sync.SyncTransport(exporter) 32 | data = { 33 | 'traceId': 'test1', 34 | 'spans': [{}, {}], 35 | } 36 | transport.export(data) 37 | self.assertTrue(True) 38 | -------------------------------------------------------------------------------- /tests/unit/stats/test_base_stats.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 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 | import unittest 16 | 17 | import mock 18 | 19 | from opencensus.stats import base_exporter 20 | 21 | 22 | class TestBaseStats(unittest.TestCase): 23 | def test_emit(self): 24 | exp = base_exporter.StatsExporter() 25 | view_data = [] 26 | 27 | with self.assertRaises(NotImplementedError): 28 | exp.emit(view_data) 29 | 30 | def test_register_view(self): 31 | exp = base_exporter.StatsExporter() 32 | view = mock.Mock() 33 | 34 | with self.assertRaises(NotImplementedError): 35 | exp.on_register_view(view) 36 | -------------------------------------------------------------------------------- /tests/unit/stats/test_stats_execution_context.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 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 | import unittest 16 | 17 | from opencensus.stats import execution_context 18 | 19 | 20 | class TestExecutionContext(unittest.TestCase): 21 | 22 | def tearDown(self): 23 | execution_context.clear() 24 | 25 | def test_get_and_set(self): 26 | execution_context.clear() 27 | execution_context.get_measure_to_view_map() 28 | self.assertEqual({}, execution_context.get_measure_to_view_map()) 29 | 30 | measure_to_view_map = {'key1', 'val1'} 31 | execution_context.set_measure_to_view_map(measure_to_view_map) 32 | 33 | execution_context.get_measure_to_view_map() 34 | self.assertEqual(measure_to_view_map, 35 | execution_context.get_measure_to_view_map()) 36 | -------------------------------------------------------------------------------- /tests/unit/tags/test_tag.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 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 | import unittest 16 | 17 | from opencensus.tags import Tag 18 | 19 | 20 | class TestTag(unittest.TestCase): 21 | 22 | def test_constructor(self): 23 | key = 'key1' 24 | value = 'value1' 25 | tag = Tag(key=key, value=value) 26 | 27 | self.assertEqual(tag.key, key) 28 | self.assertEqual(tag.value, value) 29 | self.assertRaises(ValueError, lambda: Tag(key='', value=value)) 30 | self.assertRaises(ValueError, lambda: Tag(key=key, value='\0')) 31 | -------------------------------------------------------------------------------- /tests/unit/tags/test_tag_value.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Copyright 2018, OpenCensus Authors 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | import unittest 18 | 19 | from opencensus.tags import TagValue 20 | 21 | 22 | class TestTagValue(unittest.TestCase): 23 | def test_constructor(self): 24 | tag_value = TagValue('value') 25 | 26 | self.assertIsNotNone(tag_value) 27 | self.assertEqual(tag_value, 'value') 28 | 29 | def test_check_value(self): 30 | test_val1 = 'e9nnb1ixRnvzBH1TUonCG5IsV3ba2PMKjAbSxdLFFpgxFKhZHfi92ajNH6EARaK9FGGShk2EeZ4XObwqIPBwi7j4ZSRR1ZWXtS15keA1h4c9CxeAdakcxxUN0YH6mLJ0BygwRbdbMSeOIPWLo7iyGCil4njKOxH6HF7k0aN4BQl03HQZoXe0t0gd5xKQW37ePNA4FRVZlbLbib3GCF7BeKeA0DKMtuRu27r2hDGEFAmvqh3JEnqOy4gDbhFubaLblr4R4GOHo' # noqa 31 | self.assertRaises(ValueError, TagValue, test_val1) 32 | 33 | tag_val2 = TagValue('testVal') 34 | self.assertIsNotNone(tag_val2) 35 | 36 | test_val3 = 'Æ!01kr' 37 | self.assertRaises(ValueError, TagValue, test_val3) 38 | -------------------------------------------------------------------------------- /tests/unit/trace/exporters/test_base_exporter.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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 | import unittest 16 | 17 | 18 | class TestBaseExporter(unittest.TestCase): 19 | 20 | def test_export_abstract(self): 21 | from opencensus.trace import base_exporter 22 | 23 | exporter = base_exporter.Exporter() 24 | trace = {} 25 | 26 | with self.assertRaises(NotImplementedError): 27 | exporter.export(trace) 28 | 29 | def test_emit_abstract(self): 30 | from opencensus.trace import base_exporter 31 | 32 | exporter = base_exporter.Exporter() 33 | trace = {} 34 | 35 | with self.assertRaises(NotImplementedError): 36 | exporter.emit(trace) 37 | -------------------------------------------------------------------------------- /tests/unit/trace/exporters/test_print_exporter.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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 | import unittest 16 | 17 | 18 | class TestPrintExporter(unittest.TestCase): 19 | 20 | @staticmethod 21 | def _get_target_class(): 22 | from opencensus.trace.print_exporter import PrintExporter 23 | 24 | return PrintExporter 25 | 26 | def _make_one(self, *args, **kw): 27 | return self._get_target_class()(*args, **kw) 28 | 29 | def test_emit(self): 30 | traces = {} 31 | exporter = self._make_one() 32 | 33 | exporter.emit(traces) 34 | 35 | def test_export(self): 36 | exporter = self._make_one(transport=MockTransport) 37 | exporter.export({}) 38 | 39 | self.assertTrue(exporter.transport.export_called) 40 | 41 | 42 | class MockTransport(object): 43 | def __init__(self, exporter=None): 44 | self.export_called = False 45 | self.exporter = exporter 46 | 47 | def export(self, trace): 48 | self.export_called = True 49 | -------------------------------------------------------------------------------- /tests/unit/trace/samplers/test_always_off.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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 | import unittest 16 | 17 | import mock 18 | 19 | 20 | class TestAlwaysOffSampler(unittest.TestCase): 21 | def test_should_sample(self): 22 | from opencensus.trace import samplers 23 | 24 | sampler = samplers.AlwaysOffSampler() 25 | mock_context = mock.Mock() 26 | mock_context.trace_id = 'fake_id' 27 | should_sample = sampler.should_sample(mock_context) 28 | 29 | self.assertFalse(should_sample) 30 | -------------------------------------------------------------------------------- /tests/unit/trace/samplers/test_always_on.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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 | import unittest 16 | 17 | import mock 18 | 19 | 20 | class TestAlwaysOnSampler(unittest.TestCase): 21 | def test_should_sample(self): 22 | from opencensus.trace import samplers 23 | 24 | sampler = samplers.AlwaysOnSampler() 25 | mock_context = mock.Mock() 26 | mock_context.trace_id = 'fake_id' 27 | should_sample = sampler.should_sample(mock_context) 28 | 29 | self.assertTrue(should_sample) 30 | -------------------------------------------------------------------------------- /tests/unit/trace/samplers/test_base_sampler.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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 | import unittest 16 | 17 | import mock 18 | 19 | 20 | class TestBaseSampler(unittest.TestCase): 21 | def test_should_sample_abstract(self): 22 | from opencensus.trace import samplers 23 | 24 | sampler = samplers.Sampler() 25 | 26 | mock_context = mock.Mock() 27 | mock_context.trace_id = 'fake_id' 28 | 29 | with self.assertRaises(NotImplementedError): 30 | sampler.should_sample(mock_context) 31 | -------------------------------------------------------------------------------- /tests/unit/trace/tracers/test_noop_tracer.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 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 | import unittest 16 | 17 | from opencensus.trace.tracers import noop_tracer 18 | 19 | 20 | class TestNoopTracer(unittest.TestCase): 21 | 22 | def test_list_collected_spans(self): 23 | tracer = noop_tracer.NoopTracer() 24 | 25 | spans = tracer.list_collected_spans() 26 | 27 | self.assertIsNone(spans) 28 | --------------------------------------------------------------------------------