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

Commit 2d16ea4

Browse files
authored
Remove blacklist sensitive language (#977)
1 parent 82deeb3 commit 2d16ea4

File tree

25 files changed

+128
-109
lines changed

25 files changed

+128
-109
lines changed

.pylintrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
# run arbitrary code.
66
extension-pkg-whitelist=
77

8-
# Add files or directories to the blacklist. They should be base names, not
8+
# Add files or directories to the excludelist. They should be base names, not
99
# paths.
1010
ignore=CVS
1111

12-
# Add files or directories matching the regex patterns to the blacklist. The
12+
# Add files or directories matching the regex patterns to the excludelist. The
1313
# regex matches against base names, not paths.
1414
ignore-patterns=
1515

CHANGELOG.md

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

55
- PeriodicMetricTask flush on exit
66
([#943](https://github.com/census-instrumentation/opencensus-python/pull/943))
7+
- Change blacklist to excludelist
8+
([#977](https://github.com/census-instrumentation/opencensus-python/pull/977))
79

810
## 0.7.10
911
Released 2020-06-29

README.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ Customization
118118

119119
There are several things you can customize in OpenCensus:
120120

121-
* **Blacklist**, which excludes certain hosts and paths from being tracked.
121+
* **Excludelist**, which excludes certain hosts and paths from being tracked.
122122
By default, the health check path for the App Engine flexible environment is
123-
not tracked, you can turn it on by excluding it from the blacklist setting.
123+
not tracked, you can turn it on by excluding it from the excludelist setting.
124124

125125
* **Exporter**, which sends the traces.
126126
By default, the traces are printed to stdout in JSON format. You can choose
@@ -174,8 +174,8 @@ information, please read the
174174
175175
'OPENCENSUS': {
176176
'TRACE': {
177-
'BLACKLIST_HOSTNAMES': ['localhost', '127.0.0.1'],
178-
'BLACKLIST_PATHS': ['_ah/health'],
177+
'EXCLUDELIST_HOSTNAMES': ['localhost', '127.0.0.1'],
178+
'EXCLUDELIST_PATHS': ['_ah/health'],
179179
'SAMPLER': 'opencensus.trace.samplers.ProbabilitySampler(rate=1)',
180180
'EXPORTER': '''opencensus.ext.ocagent.trace_exporter.TraceExporter(
181181
service_name='foobar',

contrib/opencensus-ext-datadog/examples/datadog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
app = Flask(__name__)
88
middleware = FlaskMiddleware(app,
9-
blacklist_paths=['/healthz'],
9+
excludelist_paths=['/healthz'],
1010
sampler=AlwaysOnSampler(),
1111
exporter=DatadogTraceExporter(
1212
Options(service='python-export-test',

contrib/opencensus-ext-django/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## Unreleased
44

5+
- Change blacklist to excludelist
6+
([#977](https://github.com/census-instrumentation/opencensus-python/pull/977))
7+
58
## 0.7.2
69
Released 2019-09-30
710

contrib/opencensus-ext-django/opencensus/ext/django/middleware.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
REQUEST_THREAD_LOCAL_KEY = 'django_request'
4747
SPAN_THREAD_LOCAL_KEY = 'django_span'
4848

49-
BLACKLIST_PATHS = 'BLACKLIST_PATHS'
50-
BLACKLIST_HOSTNAMES = 'BLACKLIST_HOSTNAMES'
49+
EXCLUDELIST_PATHS = 'EXCLUDELIST_PATHS'
50+
EXCLUDELIST_HOSTNAMES = 'EXCLUDELIST_HOSTNAMES'
5151

5252
log = logging.getLogger(__name__)
5353

@@ -160,9 +160,9 @@ def __init__(self, get_response=None):
160160
if isinstance(self.propagator, six.string_types):
161161
self.propagator = configuration.load(self.propagator)
162162

163-
self.blacklist_paths = settings.get(BLACKLIST_PATHS, None)
163+
self.excludelist_paths = settings.get(EXCLUDELIST_PATHS, None)
164164

165-
self.blacklist_hostnames = settings.get(BLACKLIST_HOSTNAMES, None)
165+
self.excludelist_hostnames = settings.get(EXCLUDELIST_HOSTNAMES, None)
166166

167167
if django.VERSION >= (2,): # pragma: NO COVER
168168
connection.execute_wrappers.append(_trace_db_call)
@@ -173,8 +173,8 @@ def process_request(self, request):
173173
:type request: :class:`~django.http.request.HttpRequest`
174174
:param request: Django http request.
175175
"""
176-
# Do not trace if the url is blacklisted
177-
if utils.disable_tracing_url(request.path, self.blacklist_paths):
176+
# Do not trace if the url is excludelisted
177+
if utils.disable_tracing_url(request.path, self.excludelist_paths):
178178
return
179179

180180
# Add the request to thread local
@@ -183,8 +183,8 @@ def process_request(self, request):
183183
request)
184184

185185
execution_context.set_opencensus_attr(
186-
'blacklist_hostnames',
187-
self.blacklist_hostnames)
186+
'excludelist_hostnames',
187+
self.excludelist_hostnames)
188188

189189
try:
190190
# Start tracing this request
@@ -234,8 +234,8 @@ def process_view(self, request, view_func, *args, **kwargs):
234234
function name add set it as the span name.
235235
"""
236236

237-
# Do not trace if the url is blacklisted
238-
if utils.disable_tracing_url(request.path, self.blacklist_paths):
237+
# Do not trace if the url is excludelisted
238+
if utils.disable_tracing_url(request.path, self.excludelist_paths):
239239
return
240240

241241
try:
@@ -248,8 +248,8 @@ def process_view(self, request, view_func, *args, **kwargs):
248248
log.error('Failed to trace request', exc_info=True)
249249

250250
def process_response(self, request, response):
251-
# Do not trace if the url is blacklisted
252-
if utils.disable_tracing_url(request.path, self.blacklist_paths):
251+
# Do not trace if the url is excludelisted
252+
if utils.disable_tracing_url(request.path, self.excludelist_paths):
253253
return response
254254

255255
try:

contrib/opencensus-ext-django/tests/test_django_middleware.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,17 @@ def test_process_request(self):
127127

128128
self.assertEqual(span.name, 'mock.mock.Mock')
129129

130-
def test_blacklist_path(self):
130+
def test_excludelist_path(self):
131131
from opencensus.ext.django import middleware
132132

133133
execution_context.clear()
134134

135-
blacklist_paths = ['test_blacklist_path']
135+
excludelist_paths = ['test_excludelist_path']
136136
settings = type('Test', (object,), {})
137137
settings.OPENCENSUS = {
138138
'TRACE': {
139139
'SAMPLER': 'opencensus.trace.samplers.AlwaysOnSampler()', # noqa
140-
'BLACKLIST_PATHS': blacklist_paths,
140+
'EXCLUDELIST_PATHS': excludelist_paths,
141141
'EXPORTER': mock.Mock(),
142142
}
143143
}
@@ -148,11 +148,11 @@ def test_blacklist_path(self):
148148
with patch_settings:
149149
middleware_obj = middleware.OpencensusMiddleware()
150150

151-
django_request = RequestFactory().get('/test_blacklist_path')
151+
django_request = RequestFactory().get('/test_excludelist_path')
152152
disabled = utils.disable_tracing_url(django_request.path,
153-
blacklist_paths)
153+
excludelist_paths)
154154
self.assertTrue(disabled)
155-
self.assertEqual(middleware_obj.blacklist_paths, blacklist_paths)
155+
self.assertEqual(middleware_obj.excludelist_paths, excludelist_paths)
156156

157157
# test process_request
158158
middleware_obj.process_request(django_request)

contrib/opencensus-ext-flask/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## Unreleased
44

5+
- Change blacklist to excludelist
6+
([#977](https://github.com/census-instrumentation/opencensus-python/pull/977))
7+
58
## 0.7.3
69
Released 2019-10-01
710

contrib/opencensus-ext-flask/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Usage
2222
from opencensus.ext.flask.flask_middleware import FlaskMiddleware
2323
2424
app = Flask(__name__)
25-
middleware = FlaskMiddleware(app, blacklist_paths=['_ah/health'])
25+
middleware = FlaskMiddleware(app, excludelist_paths=['_ah/health'])
2626
2727
@app.route('/')
2828
def hello():

contrib/opencensus-ext-flask/opencensus/ext/flask/flask_middleware.py

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
HTTP_URL = attributes_helper.COMMON_ATTRIBUTES['HTTP_URL']
4141
HTTP_STATUS_CODE = attributes_helper.COMMON_ATTRIBUTES['HTTP_STATUS_CODE']
4242

43-
BLACKLIST_PATHS = 'BLACKLIST_PATHS'
44-
BLACKLIST_HOSTNAMES = 'BLACKLIST_HOSTNAMES'
43+
EXCLUDELIST_PATHS = 'EXCLUDELIST_PATHS'
44+
EXCLUDELIST_HOSTNAMES = 'EXCLUDELIST_HOSTNAMES'
4545

4646
log = logging.getLogger(__name__)
4747

@@ -52,8 +52,8 @@ class FlaskMiddleware(object):
5252
:type app: :class: `~flask.Flask`
5353
:param app: A flask application.
5454
55-
:type blacklist_paths: list
56-
:param blacklist_paths: Paths that do not trace.
55+
:type excludelist_paths: list
56+
:param excludelist_paths: Paths that do not trace.
5757
5858
:type sampler: :class:`~opencensus.trace.samplers.base.Sampler`
5959
:param sampler: A sampler. It should extend from the base
@@ -76,10 +76,10 @@ class FlaskMiddleware(object):
7676
:class:`.TextFormatPropagator`.
7777
"""
7878

79-
def __init__(self, app=None, blacklist_paths=None, sampler=None,
79+
def __init__(self, app=None, excludelist_paths=None, sampler=None,
8080
exporter=None, propagator=None):
8181
self.app = app
82-
self.blacklist_paths = blacklist_paths
82+
self.excludelist_paths = excludelist_paths
8383
self.sampler = sampler
8484
self.exporter = exporter
8585
self.propagator = propagator
@@ -112,10 +112,10 @@ def init_app(self, app):
112112
if isinstance(self.propagator, six.string_types):
113113
self.propagator = configuration.load(self.propagator)
114114

115-
self.blacklist_paths = settings.get(BLACKLIST_PATHS,
116-
self.blacklist_paths)
115+
self.excludelist_paths = settings.get(EXCLUDELIST_PATHS,
116+
self.excludelist_paths)
117117

118-
self.blacklist_hostnames = settings.get(BLACKLIST_HOSTNAMES, None)
118+
self.excludelist_hostnames = settings.get(EXCLUDELIST_HOSTNAMES, None)
119119

120120
self.setup_trace()
121121

@@ -129,8 +129,10 @@ def _before_request(self):
129129
130130
See: http://flask.pocoo.org/docs/0.12/api/#flask.Flask.before_request
131131
"""
132-
# Do not trace if the url is blacklisted
133-
if utils.disable_tracing_url(flask.request.url, self.blacklist_paths):
132+
# Do not trace if the url is in the exclude list
133+
if utils.disable_tracing_url(
134+
flask.request.url, self.excludelist_paths
135+
):
134136
return
135137

136138
try:
@@ -161,8 +163,8 @@ def _before_request(self):
161163
HTTP_URL, str(flask.request.url)
162164
)
163165
execution_context.set_opencensus_attr(
164-
'blacklist_hostnames',
165-
self.blacklist_hostnames
166+
'excludelist_hostnames',
167+
self.excludelist_hostnames
166168
)
167169
except Exception: # pragma: NO COVER
168170
log.error('Failed to trace request', exc_info=True)
@@ -172,8 +174,10 @@ def _after_request(self, response):
172174
173175
See: http://flask.pocoo.org/docs/0.12/api/#flask.Flask.after_request
174176
"""
175-
# Do not trace if the url is blacklisted
176-
if utils.disable_tracing_url(flask.request.url, self.blacklist_paths):
177+
# Do not trace if the url is in the exclude list
178+
if utils.disable_tracing_url(
179+
flask.request.url, self.excludelist_paths
180+
):
177181
return response
178182

179183
try:
@@ -193,8 +197,10 @@ def _after_request(self, response):
193197
return response
194198

195199
def _teardown_request(self, exception):
196-
# Do not trace if the url is blacklisted
197-
if utils.disable_tracing_url(flask.request.url, self.blacklist_paths):
200+
# Do not trace if the url is in the exclude list
201+
if utils.disable_tracing_url(
202+
flask.request.url, self.excludelist_paths
203+
):
198204
return
199205

200206
try:

0 commit comments

Comments
 (0)