|
22 | 22 | from opentelemetry.test.test_base import TestBase
|
23 | 23 | from opentelemetry.test.wsgitestutil import WsgiTestBase
|
24 | 24 | from opentelemetry.trace import SpanKind
|
| 25 | +from opentelemetry.trace.status import StatusCode |
25 | 26 | from opentelemetry.util.http import (
|
26 | 27 | OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_REQUEST,
|
27 | 28 | OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_RESPONSE,
|
@@ -93,6 +94,48 @@ def test_registry_name_is_this_module(self):
|
93 | 94 | config.registry.__name__, __name__.rsplit(".", maxsplit=1)[0]
|
94 | 95 | )
|
95 | 96 |
|
| 97 | + def test_redirect_response_is_not_an_error(self): |
| 98 | + tween_list = "pyramid.tweens.excview_tween_factory" |
| 99 | + config = Configurator(settings={"pyramid.tweens": tween_list}) |
| 100 | + self._common_initialization(config) |
| 101 | + resp = self.client.get("/hello/302") |
| 102 | + self.assertEqual(302, resp.status_code) |
| 103 | + span_list = self.memory_exporter.get_finished_spans() |
| 104 | + self.assertEqual(len(span_list), 1) |
| 105 | + self.assertEqual(span_list[0].status.status_code, StatusCode.UNSET) |
| 106 | + |
| 107 | + PyramidInstrumentor().uninstrument() |
| 108 | + |
| 109 | + self.config = Configurator() |
| 110 | + |
| 111 | + self._common_initialization(self.config) |
| 112 | + |
| 113 | + resp = self.client.get("/hello/302") |
| 114 | + self.assertEqual(302, resp.status_code) |
| 115 | + span_list = self.memory_exporter.get_finished_spans() |
| 116 | + self.assertEqual(len(span_list), 1) |
| 117 | + |
| 118 | + def test_204_empty_response_is_not_an_error(self): |
| 119 | + tween_list = "pyramid.tweens.excview_tween_factory" |
| 120 | + config = Configurator(settings={"pyramid.tweens": tween_list}) |
| 121 | + self._common_initialization(config) |
| 122 | + resp = self.client.get("/hello/204") |
| 123 | + self.assertEqual(204, resp.status_code) |
| 124 | + span_list = self.memory_exporter.get_finished_spans() |
| 125 | + self.assertEqual(len(span_list), 1) |
| 126 | + self.assertEqual(span_list[0].status.status_code, StatusCode.UNSET) |
| 127 | + |
| 128 | + PyramidInstrumentor().uninstrument() |
| 129 | + |
| 130 | + self.config = Configurator() |
| 131 | + |
| 132 | + self._common_initialization(self.config) |
| 133 | + |
| 134 | + resp = self.client.get("/hello/204") |
| 135 | + self.assertEqual(204, resp.status_code) |
| 136 | + span_list = self.memory_exporter.get_finished_spans() |
| 137 | + self.assertEqual(len(span_list), 1) |
| 138 | + |
96 | 139 |
|
97 | 140 | class TestWrappedWithOtherFramework(
|
98 | 141 | InstrumentationTest, TestBase, WsgiTestBase
|
|
0 commit comments