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

Commit 52b974f

Browse files
victoraugustollsreyang
authored andcommitted
Hotfix/django flask pyramid status code (#755)
1 parent de131c7 commit 52b974f

File tree

18 files changed

+74
-15
lines changed

18 files changed

+74
-15
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Changelog
22

33
## Unreleased
4+
- Updated `django`, `flask`, `httplib`, `requests` and `pyramid` modules.
5+
([#755](https://github.com/census-instrumentation/opencensus-python/pull/755))
46
- Added `http code` to `grpc code` status code mapping on `utils`
57
([#746](https://github.com/census-instrumentation/opencensus-python/pull/746))
68

contrib/opencensus-ext-django/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Changelog
22

33
## Unreleased
4+
- Updated `http.status_code` attribute to be an int.
5+
([#755](https://github.com/census-instrumentation/opencensus-python/pull/755))
46

57
## 0.7.0
68
Released 2019-07-31

contrib/opencensus-ext-django/examples/app/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def greetings(request):
5959

6060
def trace_requests(request):
6161
response = requests.get('http://www.google.com')
62-
return HttpResponse(str(response.status_code))
62+
return HttpResponse(response.status_code)
6363

6464

6565
def mysql_trace(request):

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def process_response(self, request, response):
215215
span = _get_django_span()
216216
span.add_attribute(
217217
attribute_key=HTTP_STATUS_CODE,
218-
attribute_value=str(response.status_code))
218+
attribute_value=response.status_code)
219219

220220
_set_django_attributes(span, request)
221221

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def test_process_response(self):
222222
'http.path': u'/wiki/Rabbit',
223223
'http.route': u'/wiki/Rabbit',
224224
'http.url': u'http://testserver/wiki/Rabbit',
225-
'http.status_code': '200',
225+
'http.status_code': 200,
226226
'django.user.id': '123',
227227
'django.user.name': 'test_name'
228228
}
@@ -277,7 +277,7 @@ def test_process_response_unfinished_child_span(self):
277277
'http.path': u'/wiki/Rabbit',
278278
'http.route': u'/wiki/Rabbit',
279279
'http.url': u'http://testserver/wiki/Rabbit',
280-
'http.status_code': '500',
280+
'http.status_code': 500,
281281
'django.user.id': '123',
282282
'django.user.name': 'test_name'
283283
}

contrib/opencensus-ext-flask/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Changelog
22

33
## Unreleased
4+
- Updated `http.status_code` attribute to be an int.
5+
([#755](https://github.com/census-instrumentation/opencensus-python/pull/755))
46

57
## 0.7.1
68
Released 2019-08-05

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def _after_request(self, response):
181181
)
182182
tracer.add_attribute_to_current_span(
183183
HTTP_STATUS_CODE,
184-
str(response.status_code)
184+
response.status_code
185185
)
186186
except Exception: # pragma: NO COVER
187187
log.error('Failed to trace request', exc_info=True)

contrib/opencensus-ext-flask/tests/test_flask_middleware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ def test__after_request_sampled(self):
305305
'http.path': u'/wiki/Rabbit',
306306
'http.url': u'http://localhost/wiki/Rabbit',
307307
'http.route': u'/wiki/<entry>',
308-
'http.status_code': u'200'
308+
'http.status_code': 200
309309
}
310310

311311
self.assertEqual(span.attributes, expected_attributes)

contrib/opencensus-ext-httplib/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Changelog
22

33
## Unreleased
4+
- Updated `http.status_code` attribute to be an int.
5+
([#755](https://github.com/census-instrumentation/opencensus-python/pull/755))
46

57
## 0.7.1
68
Released 2019-08-06

contrib/opencensus-ext-httplib/opencensus/ext/httplib/trace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def call(self, *args, **kwargs):
121121

122122
# Add the status code to attributes
123123
_tracer.add_attribute_to_current_span(
124-
HTTP_STATUS_CODE, str(result.status))
124+
HTTP_STATUS_CODE, result.status)
125125

126126
_tracer.end_span()
127127
return result

0 commit comments

Comments
 (0)