Skip to content

Commit 30d755f

Browse files
author
Alex Boten
committed
fixing merge changes, removing BoundedDict
Signed-off-by: Alex Boten <[email protected]>
1 parent 7c99d6f commit 30d755f

File tree

2 files changed

+46
-74
lines changed

2 files changed

+46
-74
lines changed

ext/opentelemetry-ext-flask/tests/test_flask_integration.py

+38-47
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,19 @@ def hello_endpoint(helloid):
4242
self.client = Client(self.app, BaseResponse)
4343

4444
def test_simple(self):
45-
expected_attrs = BoundedDict.from_map(
46-
MAX_NUM_ATTRIBUTES,
47-
{
48-
"component": "http",
49-
"http.method": "GET",
50-
"http.server_name": "localhost",
51-
"http.scheme": "http",
52-
"host.port": 80,
53-
"http.host": "localhost",
54-
"http.target": "/hello/123",
55-
"http.flavor": "1.1",
56-
"http.route": "/hello/<int:helloid>",
57-
"http.status_text": "OK",
58-
"http.status_code": 200,
59-
},
60-
)
45+
expected_attrs = {
46+
"component": "http",
47+
"http.method": "GET",
48+
"http.server_name": "localhost",
49+
"http.scheme": "http",
50+
"host.port": 80,
51+
"http.host": "localhost",
52+
"http.target": "/hello/123",
53+
"http.flavor": "1.1",
54+
"http.route": "/hello/<int:helloid>",
55+
"http.status_text": "OK",
56+
"http.status_code": 200,
57+
}
6158
resp = self.client.get("/hello/123")
6259
self.assertEqual(200, resp.status_code)
6360
self.assertEqual([b"Hello: 123"], list(resp.response))
@@ -68,21 +65,18 @@ def test_simple(self):
6865
self.assertEqual(span_list[0].attributes, expected_attrs)
6966

7067
def test_404(self):
71-
expected_attrs = BoundedDict.from_map(
72-
MAX_NUM_ATTRIBUTES,
73-
{
74-
"component": "http",
75-
"http.method": "POST",
76-
"http.server_name": "localhost",
77-
"http.scheme": "http",
78-
"host.port": 80,
79-
"http.host": "localhost",
80-
"http.target": "/bye",
81-
"http.flavor": "1.1",
82-
"http.status_text": "NOT FOUND",
83-
"http.status_code": 404,
84-
},
85-
)
68+
expected_attrs = {
69+
"component": "http",
70+
"http.method": "POST",
71+
"http.server_name": "localhost",
72+
"http.scheme": "http",
73+
"host.port": 80,
74+
"http.host": "localhost",
75+
"http.target": "/bye",
76+
"http.flavor": "1.1",
77+
"http.status_text": "NOT FOUND",
78+
"http.status_code": 404,
79+
}
8680
resp = self.client.post("/bye")
8781
self.assertEqual(404, resp.status_code)
8882
resp.close()
@@ -93,22 +87,19 @@ def test_404(self):
9387
self.assertEqual(span_list[0].attributes, expected_attrs)
9488

9589
def test_internal_error(self):
96-
expected_attrs = BoundedDict.from_map(
97-
MAX_NUM_ATTRIBUTES,
98-
{
99-
"component": "http",
100-
"http.method": "GET",
101-
"http.server_name": "localhost",
102-
"http.scheme": "http",
103-
"host.port": 80,
104-
"http.host": "localhost",
105-
"http.target": "/hello/500",
106-
"http.flavor": "1.1",
107-
"http.route": "/hello/<int:helloid>",
108-
"http.status_text": "INTERNAL SERVER ERROR",
109-
"http.status_code": 500,
110-
},
111-
)
90+
expected_attrs = {
91+
"component": "http",
92+
"http.method": "GET",
93+
"http.server_name": "localhost",
94+
"http.scheme": "http",
95+
"host.port": 80,
96+
"http.host": "localhost",
97+
"http.target": "/hello/500",
98+
"http.flavor": "1.1",
99+
"http.route": "/hello/<int:helloid>",
100+
"http.status_text": "INTERNAL SERVER ERROR",
101+
"http.status_code": 500,
102+
}
112103
resp = self.client.get("/hello/500")
113104
self.assertEqual(500, resp.status_code)
114105
resp.close()

ext/opentelemetry-ext-testutil/src/opentelemetry/ext/testutil/wsgitestutil.py

+8-27
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import wsgiref.util as wsgiref_util
44

55
from opentelemetry import trace as trace_api
6-
from opentelemetry.sdk.trace import Tracer, export
6+
from opentelemetry.sdk.trace import TracerSource, export
77
from opentelemetry.sdk.trace.export.in_memory_span_exporter import (
88
InMemorySpanExporter,
99
)
@@ -12,32 +12,17 @@
1212
class WsgiTestBase(unittest.TestCase):
1313
@classmethod
1414
def setUpClass(cls):
15-
trace_api.set_preferred_tracer_implementation(lambda T: Tracer())
15+
trace_api.set_preferred_tracer_source_implementation(
16+
lambda T: TracerSource()
17+
)
1618

1719
def setUp(self):
18-
self.span = mock.create_autospec(trace_api.Span, spec_set=True)
19-
tracer = trace_api.Tracer()
20+
tracer_source = trace_api.tracer_source()
21+
2022
self.memory_exporter = InMemorySpanExporter()
2123
span_processor = export.SimpleExportSpanProcessor(self.memory_exporter)
22-
tracer.add_span_processor(span_processor)
23-
24-
self.get_tracer_patcher = mock.patch.object(
25-
trace_api.TracerSource,
26-
"get_tracer",
27-
autospec=True,
28-
spec_set=True,
29-
return_value=tracer,
30-
)
31-
self.get_tracer_patcher.start()
32-
33-
self.start_span_patcher = mock.patch.object(
34-
tracer,
35-
"start_span",
36-
autospec=True,
37-
spec_set=True,
38-
return_value=self.span,
39-
)
40-
self.start_span = self.start_span_patcher.start()
24+
tracer_source.add_span_processor(span_processor)
25+
4126
self.write_buffer = io.BytesIO()
4227
self.write = self.write_buffer.write
4328

@@ -48,10 +33,6 @@ def setUp(self):
4833
self.response_headers = None
4934
self.exc_info = None
5035

51-
def tearDown(self):
52-
self.get_tracer_patcher.stop()
53-
self.start_span_patcher.stop()
54-
5536
def start_response(self, status, response_headers, exc_info=None):
5637
self.status = status
5738
self.response_headers = response_headers

0 commit comments

Comments
 (0)