mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-08-02 19:47:17 +08:00
Remove metrics from main branch (#312)
This commit is contained in:
@ -22,7 +22,6 @@ from django.test import Client
|
||||
from django.test.utils import setup_test_environment, teardown_test_environment
|
||||
|
||||
from opentelemetry.instrumentation.django import DjangoInstrumentor
|
||||
from opentelemetry.sdk.util import get_dict_as_key
|
||||
from opentelemetry.test.test_base import TestBase
|
||||
from opentelemetry.test.wsgitestutil import WsgiTestBase
|
||||
from opentelemetry.trace import SpanKind
|
||||
@ -142,26 +141,6 @@ class TestMiddleware(TestBase, WsgiTestBase):
|
||||
self.assertEqual(span.attributes["http.status_code"], 200)
|
||||
self.assertEqual(span.attributes["http.status_text"], "OK")
|
||||
|
||||
self.assertIsNotNone(_django_instrumentor.meter)
|
||||
self.assertEqual(len(_django_instrumentor.meter.instruments), 1)
|
||||
recorder = list(_django_instrumentor.meter.instruments.values())[0]
|
||||
match_key = get_dict_as_key(
|
||||
{
|
||||
"http.flavor": "1.1",
|
||||
"http.method": "GET",
|
||||
"http.status_code": "200",
|
||||
"http.url": "http://testserver/traced/",
|
||||
}
|
||||
)
|
||||
for key in recorder.bound_instruments.keys():
|
||||
self.assertEqual(key, match_key)
|
||||
# pylint: disable=protected-access
|
||||
bound = recorder.bound_instruments.get(key)
|
||||
for view_data in bound.view_datas:
|
||||
self.assertEqual(view_data.labels, key)
|
||||
self.assertEqual(view_data.aggregator.current.count, 1)
|
||||
self.assertGreaterEqual(view_data.aggregator.current.sum, 0)
|
||||
|
||||
def test_not_recording(self):
|
||||
mock_tracer = Mock()
|
||||
mock_span = Mock()
|
||||
@ -220,8 +199,6 @@ class TestMiddleware(TestBase, WsgiTestBase):
|
||||
self.assertEqual(span.attributes["http.route"], "^error/")
|
||||
self.assertEqual(span.attributes["http.scheme"], "http")
|
||||
self.assertEqual(span.attributes["http.status_code"], 500)
|
||||
self.assertIsNotNone(_django_instrumentor.meter)
|
||||
self.assertEqual(len(_django_instrumentor.meter.instruments), 1)
|
||||
|
||||
self.assertEqual(len(span.events), 1)
|
||||
event = span.events[0]
|
||||
@ -229,23 +206,6 @@ class TestMiddleware(TestBase, WsgiTestBase):
|
||||
self.assertEqual(event.attributes["exception.type"], "ValueError")
|
||||
self.assertEqual(event.attributes["exception.message"], "error")
|
||||
|
||||
recorder = list(_django_instrumentor.meter.instruments.values())[0]
|
||||
match_key = get_dict_as_key(
|
||||
{
|
||||
"http.flavor": "1.1",
|
||||
"http.method": "GET",
|
||||
"http.status_code": "500",
|
||||
"http.url": "http://testserver/error/",
|
||||
}
|
||||
)
|
||||
for key in recorder.bound_instruments.keys():
|
||||
self.assertEqual(key, match_key)
|
||||
# pylint: disable=protected-access
|
||||
bound = recorder.bound_instruments.get(key)
|
||||
for view_data in bound.view_datas:
|
||||
self.assertEqual(view_data.labels, key)
|
||||
self.assertEqual(view_data.aggregator.current.count, 1)
|
||||
|
||||
def test_exclude_lists(self):
|
||||
client = Client()
|
||||
client.get("/excluded_arg/123")
|
||||
|
Reference in New Issue
Block a user