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

Commit 3e2ecff

Browse files
committed
Merge branch 'master' of https://github.com/census-instrumentation/opencensus-python into django-db-instrumentation
2 parents f39c289 + 4ca0055 commit 3e2ecff

117 files changed

Lines changed: 3108 additions & 1848 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.circleci/config.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ version: 2
66

77
jobs:
88
build:
9+
branches:
10+
ignore:
11+
- gh-pages
912
docker:
1013
- image: googleapis/nox:0.17.0
1114
- image: mysql:5.7
@@ -44,6 +47,7 @@ jobs:
4447

4548
deployment:
4649
tag_build_for_cci2:
47-
tag: /(([a-z]+)-)*([0-9]+)\.([0-9]+)\.([0-9]+)/
50+
branch: /v([0-9]+)\.([0-9]+)\.([0-9]+)/
51+
tag: /v([0-9]+)\.([0-9]+)\.([0-9]+)/
4852
commands:
4953
- true

README.rst

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,10 @@ For Django, you can configure the blacklist in the ``OPENCENSUS_PARAMS`` in ``se
239239
Framework Integration
240240
---------------------
241241

242-
Census supports integration with popular web frameworks including
243-
Django, Flask, Pyramid, and Webapp2. When the application receives a HTTP request,
244-
the tracer will automatically generate a span context using the trace
245-
information extracted from the request headers and propagated to the
246-
child spans.
242+
Census supports integration with popular web frameworks including Django,
243+
Flask, and Pyramid. When the application receives a HTTP request, the tracer
244+
will automatically generate a span context using the trace information
245+
extracted from the request headers and propagated to the child spans.
247246

248247
Flask
249248
~~~~~
@@ -418,8 +417,29 @@ method, and status will be collected.
418417

419418
You can enable Requests integration by specifying ``'requests'`` to ``trace_integrations``.
420419

420+
It's possible to configure a list of URL you don't want traced. By default the request to exporter
421+
won't be traced. It's configurable by giving an array of hostname/port to the attribute
422+
``blacklist_hostnames`` in OpenCensus context's attributes:
423+
424+
.. code:: python
425+
426+
execution_context.set_opencensus_attr('blacklist_hostnames',['hostname:port'])
427+
428+
Only the hostname must be specified if only the hostname is specified in the URL request.
429+
421430
.. _Requests package: https://pypi.python.org/pypi/requests
422431

432+
Httplib
433+
~~~~~~~~
434+
435+
Census can trace HTTP requests made with the httplib library.
436+
437+
You can enable Requests integration by specifying ``'httplib'`` to ``trace_integrations``.
438+
439+
It's possible to configure a list of URL you don't want traced. See requests integration
440+
for more information. The only difference is that you need to specify hostname and port
441+
every time.
442+
423443
Google Cloud Client Libraries
424444
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
425445

RELEASING.md

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

55
### Update the version number in `setup.py`
66

7-
### Update the version number in `stackdriver_exporter.py`
8-
97
### Create a Github release
108

119
Then the Circle CI will build the package and upload it to PyPI automatically.

docs/trace/usage.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,10 @@ For Django, you can configure the blacklist in the ``OPENCENSUS_PARAMS`` in ``se
182182
Framework Integration
183183
---------------------
184184

185-
Census supports integration with popular web frameworks including
186-
Django, Flask, Pyramid, and Webapp2. When the application receives a HTTP request,
187-
the tracer will automatically generate a span context using the trace
188-
information extracted from the request headers, and propagated to the
189-
child spans.
185+
Census supports integration with popular web frameworks including Django,
186+
Flask, and Pyramid. When the application receives a HTTP request, the tracer
187+
will automatically generate a span context using the trace information
188+
extracted from the request headers, and propagated to the child spans.
190189

191190
Flask
192191
~~~~~

examples/stats/exporter/prometheus.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,18 @@
3434
VIDEO_SIZE_VIEW_NAME = "my.org/views/video_size"
3535
VIDEO_SIZE_DISTRIBUTION = aggregation_module.DistributionAggregation(
3636
[0.0, 16.0 * MiB, 256.0 * MiB])
37-
VIDEO_SIZE_VIEW = view_module.View(VIDEO_SIZE_VIEW_NAME,
38-
"processed video size over time",
39-
[FRONTEND_KEY],
40-
VIDEO_SIZE_MEASURE,
41-
VIDEO_SIZE_DISTRIBUTION)
37+
VIDEO_SIZE_VIEW = view_module.View(
38+
VIDEO_SIZE_VIEW_NAME, "processed video size over time", [FRONTEND_KEY],
39+
VIDEO_SIZE_MEASURE, VIDEO_SIZE_DISTRIBUTION)
4240

4341

4442
def main():
4543
stats = stats_module.Stats()
4644
view_manager = stats.view_manager
4745
stats_recorder = stats.stats_recorder
4846

49-
exporter = prometheus.new_stats_exporter(prometheus.Options(namespace="opencensus"))
47+
exporter = prometheus.new_stats_exporter(
48+
prometheus.Options(namespace="opencensus"))
5049
view_manager.register_exporter(exporter)
5150

5251
# Register view.
@@ -72,8 +71,8 @@ def main():
7271
view_data = view_manager.get_view(VIDEO_SIZE_VIEW_NAME)
7372
pprint(vars(view_data))
7473
for k, v in view_data._tag_value_aggregation_data_map.items():
75-
pprint(k)
76-
pprint(vars(v))
74+
pprint(k)
75+
pprint(vars(v))
7776

7877

7978
if __name__ == '__main__':

examples/stats/exporter/stackdriver.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,17 @@
2929
"my.org/measure/video_size_test2", "size of processed videos", "By")
3030
VIDEO_SIZE_VIEW_NAME = "my.org/views/video_size_test2"
3131
VIDEO_SIZE_DISTRIBUTION = aggregation_module.DistributionAggregation(
32-
[0.0, 16.0 * MiB, 256.0 * MiB])
33-
VIDEO_SIZE_VIEW = view_module.View(VIDEO_SIZE_VIEW_NAME,
34-
"processed video size over time",
35-
[FRONTEND_KEY],
36-
VIDEO_SIZE_MEASURE,
37-
VIDEO_SIZE_DISTRIBUTION)
38-
39-
32+
[0.0, 16.0 * MiB, 256.0 * MiB])
33+
VIDEO_SIZE_VIEW = view_module.View(
34+
VIDEO_SIZE_VIEW_NAME, "processed video size over time", [FRONTEND_KEY],
35+
VIDEO_SIZE_MEASURE, VIDEO_SIZE_DISTRIBUTION)
4036

4137
stats = stats_module.Stats()
4238
view_manager = stats.view_manager
4339
stats_recorder = stats.stats_recorder
4440

45-
exporter = stackdriver.new_stats_exporter(stackdriver.Options(project_id="opencenus-node"))
41+
exporter = stackdriver.new_stats_exporter(
42+
stackdriver.Options(project_id="opencenus-node"))
4643
view_manager.register_exporter(exporter)
4744

4845
# Register view.

examples/stats/helloworld/main.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,9 @@
3333
VIDEO_SIZE_VIEW_NAME = "my.org/views/video_size"
3434
VIDEO_SIZE_DISTRIBUTION = aggregation_module.DistributionAggregation(
3535
[0.0, 16.0 * MiB, 256.0 * MiB])
36-
VIDEO_SIZE_VIEW = view_module.View(VIDEO_SIZE_VIEW_NAME,
37-
"processed video size over time",
38-
[FRONTEND_KEY],
39-
VIDEO_SIZE_MEASURE,
40-
VIDEO_SIZE_DISTRIBUTION)
36+
VIDEO_SIZE_VIEW = view_module.View(
37+
VIDEO_SIZE_VIEW_NAME, "processed video size over time", [FRONTEND_KEY],
38+
VIDEO_SIZE_MEASURE, VIDEO_SIZE_DISTRIBUTION)
4139

4240

4341
def main():
@@ -64,8 +62,8 @@ def main():
6462
view_data = view_manager.get_view(VIDEO_SIZE_VIEW_NAME)
6563
pprint(vars(view_data))
6664
for k, v in view_data._tag_value_aggregation_data_map.items():
67-
pprint(k)
68-
pprint(vars(v))
65+
pprint(k)
66+
pprint(vars(v))
6967

7068

7169
if __name__ == '__main__':

examples/trace/grpc/hello_world_pb2.py

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/trace/grpc/hello_world_pb2_grpc.py

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,44 @@
55

66

77
class GreeterStub(object):
8-
"""The hello world service definition.
8+
"""The hello world service definition.
99
"""
1010

11-
def __init__(self, channel):
12-
"""Constructor.
11+
def __init__(self, channel):
12+
"""Constructor.
1313
1414
Args:
1515
channel: A grpc.Channel.
1616
"""
17-
self.SayHello = channel.unary_unary(
18-
'/helloworld.Greeter/SayHello',
19-
request_serializer=hello__world__pb2.HelloRequest.SerializeToString,
20-
response_deserializer=hello__world__pb2.HelloReply.FromString,
17+
self.SayHello = channel.unary_unary(
18+
'/helloworld.Greeter/SayHello',
19+
request_serializer=hello__world__pb2.HelloRequest.
20+
SerializeToString,
21+
response_deserializer=hello__world__pb2.HelloReply.FromString,
2122
)
2223

2324

2425
class GreeterServicer(object):
25-
"""The hello world service definition.
26+
"""The hello world service definition.
2627
"""
2728

28-
def SayHello(self, request, context):
29-
"""Say hello to the request sender (unary-unary)
29+
def SayHello(self, request, context):
30+
"""Say hello to the request sender (unary-unary)
3031
"""
31-
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
32-
context.set_details('Method not implemented!')
33-
raise NotImplementedError('Method not implemented!')
32+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
33+
context.set_details('Method not implemented!')
34+
raise NotImplementedError('Method not implemented!')
3435

3536

3637
def add_GreeterServicer_to_server(servicer, server):
37-
rpc_method_handlers = {
38-
'SayHello': grpc.unary_unary_rpc_method_handler(
39-
servicer.SayHello,
40-
request_deserializer=hello__world__pb2.HelloRequest.FromString,
41-
response_serializer=hello__world__pb2.HelloReply.SerializeToString,
42-
),
43-
}
44-
generic_handler = grpc.method_handlers_generic_handler(
45-
'helloworld.Greeter', rpc_method_handlers)
46-
server.add_generic_rpc_handlers((generic_handler,))
38+
rpc_method_handlers = {
39+
'SayHello':
40+
grpc.unary_unary_rpc_method_handler(
41+
servicer.SayHello,
42+
request_deserializer=hello__world__pb2.HelloRequest.FromString,
43+
response_serializer=hello__world__pb2.HelloReply.SerializeToString,
44+
),
45+
}
46+
generic_handler = grpc.method_handlers_generic_handler(
47+
'helloworld.Greeter', rpc_method_handlers)
48+
server.add_generic_rpc_handlers((generic_handler, ))

examples/trace/helloworld/django/app/settings.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
1514
"""Django settings for test app."""
1615

1716
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
@@ -66,10 +65,13 @@
6665
]
6766

6867
OPENCENSUS_TRACE = {
69-
'SAMPLER': 'opencensus.trace.samplers.always_on.AlwaysOnSampler',
70-
'EXPORTER': 'opencensus.trace.exporters.stackdriver_exporter.StackdriverExporter',
71-
'PROPAGATOR': 'opencensus.trace.propagation.google_cloud_format.'
72-
'GoogleCloudFormatPropagator',
68+
'SAMPLER':
69+
'opencensus.trace.samplers.always_on.AlwaysOnSampler',
70+
'EXPORTER':
71+
'opencensus.trace.exporters.stackdriver_exporter.StackdriverExporter',
72+
'PROPAGATOR':
73+
'opencensus.trace.propagation.google_cloud_format.'
74+
'GoogleCloudFormatPropagator',
7375
}
7476

7577
OPENCENSUS_TRACE_PARAMS = {
@@ -89,7 +91,6 @@
8991

9092
USE_TZ = True
9193

92-
9394
# Static files (CSS, JavaScript, Images)
9495
# https://docs.djangoproject.com/en/1.8/howto/static-files/
9596

0 commit comments

Comments
 (0)