Exemple #1
0
 def test_response_attributes(self):
     OpenTelemetryMiddleware._add_response_attributes(  # noqa pylint: disable=protected-access
         self.span, "404 Not Found")
     expected = (
         mock.call("http.status_code", 404),
         mock.call("http.status_text", "Not Found"),
     )
     self.assertEqual(self.span.set_attribute.call_count, len(expected))
     self.span.set_attribute.assert_has_calls(expected, any_order=True)
Exemple #2
0
 def test_response_attributes_invalid_status_code(self):
     OpenTelemetryMiddleware._add_response_attributes(  # noqa pylint: disable=protected-access
         self.span, "Invalid Status Code")
     self.assertEqual(self.span.set_attribute.call_count, 1)
     self.span.set_attribute.assert_called_with("http.status_text",
                                                "Status Code")