-
Notifications
You must be signed in to change notification settings - Fork 864
Using InMemorySpanExporter for wsgi/flask tests #306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
39df92d
939900b
7c99d6f
30d755f
cdc0336
f328909
3bfa984
58c7c03
7f03b24
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,26 @@ | ||
| import io | ||
| import unittest | ||
| import unittest.mock as mock | ||
| import wsgiref.util as wsgiref_util | ||
|
|
||
| from opentelemetry import trace as trace_api | ||
| from opentelemetry.sdk.trace import Tracer, export | ||
| from opentelemetry.sdk.trace.export.in_memory_span_exporter import ( | ||
| InMemorySpanExporter, | ||
| ) | ||
|
|
||
|
|
||
| class WsgiTestBase(unittest.TestCase): | ||
| @classmethod | ||
| def setUpClass(cls): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll need to add a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the pointer, I did not know about the reload method, will updated the test.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated |
||
| trace_api.set_preferred_tracer_implementation(lambda T: Tracer()) | ||
|
|
||
| def setUp(self): | ||
| tracer = trace_api.tracer() | ||
| self.span = mock.create_autospec(trace_api.Span, spec_set=True) | ||
| self.start_span_patcher = mock.patch.object( | ||
| tracer, | ||
| "start_span", | ||
| autospec=True, | ||
| spec_set=True, | ||
| return_value=self.span, | ||
| ) | ||
| self.start_span = self.start_span_patcher.start() | ||
|
|
||
| self.memory_exporter = InMemorySpanExporter() | ||
| span_processor = export.SimpleExportSpanProcessor(self.memory_exporter) | ||
| tracer.add_span_processor(span_processor) | ||
|
|
||
| self.write_buffer = io.BytesIO() | ||
| self.write = self.write_buffer.write | ||
|
|
||
|
|
@@ -28,9 +31,6 @@ def setUp(self): | |
| self.response_headers = None | ||
| self.exc_info = None | ||
|
|
||
| def tearDown(self): | ||
| self.start_span_patcher.stop() | ||
|
|
||
| def start_response(self, status, response_headers, exc_info=None): | ||
| self.status = status | ||
| self.response_headers = response_headers | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For expectations, I would not use BoundedDict because attributes could get dropped silently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!