Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
lzchen committed Dec 8, 2020
2 parents 1d0db15 + 3b48a38 commit dd2d20f
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ package_dir=
=src
packages=find_namespace:
install_requires =
opentelemetry-api == 0.16.dev0
opentelemetry-sdk == 0.16.dev0
opentelemetry-api == 0.17.dev0
opentelemetry-sdk == 0.17.dev0

[options.packages.find]
where = src
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ def test_traced_get(self):
self.assertEqual(span.attributes["http.status_text"], "OK")

self.assertIsNotNone(_django_instrumentor.meter)
self.assertEqual(len(_django_instrumentor.meter.metrics), 1)
recorder = _django_instrumentor.meter.metrics.pop()
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",
Expand Down Expand Up @@ -222,15 +222,15 @@ def test_error(self):
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.metrics), 1)
self.assertEqual(len(_django_instrumentor.meter.instruments), 1)

self.assertEqual(len(span.events), 1)
event = span.events[0]
self.assertEqual(event.name, "exception")
self.assertEqual(event.attributes["exception.type"], "ValueError")
self.assertEqual(event.attributes["exception.message"], "error")

recorder = _django_instrumentor.meter.metrics.pop()
recorder = list(_django_instrumentor.meter.instruments.values())[0]
match_key = get_dict_as_key(
{
"http.flavor": "1.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ def test_basic(self):
)

self.assertIsNotNone(RequestsInstrumentor().meter)
self.assertEqual(len(RequestsInstrumentor().meter.metrics), 1)
recorder = RequestsInstrumentor().meter.metrics.pop()
self.assertEqual(len(RequestsInstrumentor().meter.instruments), 1)
recorder = list(RequestsInstrumentor().meter.instruments.values())[0]
match_key = get_dict_as_key(
{
"http.flavor": "1.1",
Expand Down Expand Up @@ -287,8 +287,8 @@ def test_requests_exception_without_response(self, *_, **__):
self.assertEqual(span.status.status_code, StatusCode.ERROR)

self.assertIsNotNone(RequestsInstrumentor().meter)
self.assertEqual(len(RequestsInstrumentor().meter.metrics), 1)
recorder = RequestsInstrumentor().meter.metrics.pop()
self.assertEqual(len(RequestsInstrumentor().meter.instruments), 1)
recorder = list(RequestsInstrumentor().meter.instruments.values())[0]
match_key = get_dict_as_key(
{
"http.method": "GET",
Expand Down Expand Up @@ -328,8 +328,8 @@ def test_requests_exception_with_response(self, *_, **__):
)
self.assertEqual(span.status.status_code, StatusCode.ERROR)
self.assertIsNotNone(RequestsInstrumentor().meter)
self.assertEqual(len(RequestsInstrumentor().meter.metrics), 1)
recorder = RequestsInstrumentor().meter.metrics.pop()
self.assertEqual(len(RequestsInstrumentor().meter.instruments), 1)
recorder = list(RequestsInstrumentor().meter.instruments.values())[0]
match_key = get_dict_as_key(
{
"http.method": "GET",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_system_metrics_constructor(self):
mock_get_meter.return_value = meter
SystemMetrics(self.memory_metrics_exporter)

self.assertEqual(len(meter.observers), 18)
self.assertEqual(len(meter.instruments), 18)

observer_names = [
"system.cpu.time",
Expand All @@ -60,7 +60,7 @@ def test_system_metrics_constructor(self):
"runtime.{}.gc_count".format(self.implementation),
]

for observer in meter.observers:
for observer in meter.instruments.values():
self.assertIn(observer.name, observer_names)
observer_names.remove(observer.name)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_get_none(self):

def test_get_(self):
getter = CarrierGetter()
carrier = {"HTTP_TEST_KEY":"val"}
carrier = {"HTTP_TEST_KEY": "val"}
val = getter.get(carrier, "test-key")
self.assertEqual(val, ["val"])

Expand Down
34 changes: 33 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,39 @@ commands_pre =
python -m pip install {toxinidir}/opentelemetry-python-core/opentelemetry-sdk
python -m pip install {toxinidir}/opentelemetry-python-core/tests/util
python -m pip install {toxinidir}/opentelemetry-python-core/opentelemetry-instrumentation
python scripts/eachdist.py install --editable --with-test-deps
python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-wsgi[test]
python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-dbapi[test]
python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-asgi[test]
python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-botocore[test]
python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-django[test]
python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-starlette[test]
python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-grpc[test]
python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-falcon[test]
python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-boto[test]
python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-flask[test]
python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-sqlalchemy[test]
python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-celery[test]
python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-sklearn[test]
python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-redis[test]
python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-fastapi[test]
python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-jinja2[test]
python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-pymemcache[test]
python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-psycopg2[test]
python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-aiohttp-client[test]
python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-system-metrics[test]
python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-aiopg[test]
python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-sqlite3[test]
python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-pyramid[test]
python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-requests[test]
python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-pymysql[test]
python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-pymongo[test]
python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-elasticsearch[test]
python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-asyncpg[test]
python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-tornado[test]
python -m pip install -e {toxinidir}/instrumentation/opentelemetry-instrumentation-mysql[test]
python -m pip install -e {toxinidir}/exporter/opentelemetry-exporter-prometheus-remote-write[test]
python -m pip install -e {toxinidir}/exporter/opentelemetry-exporter-datadog[test]
python -m pip install -e {toxinidir}/sdk-extension/opentelemetry-sdk-extension-aws[test]

commands =
python scripts/eachdist.py lint --check-only
Expand Down

0 comments on commit dd2d20f

Please sign in to comment.