Skip to content

Commit

Permalink
Merge branch 'main' into feature/asyncio-instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
bourbonkk authored Nov 3, 2023
2 parents 0d23386 + eb6024c commit aa48c40
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 28 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- 'release/*'
pull_request:
env:
CORE_REPO_SHA: 0ef76a5cc39626f783416ca75e43556e2bb2739d
CORE_REPO_SHA: d054dff47d2da663a39b9656d106c3d15f344269

jobs:
build:
Expand Down Expand Up @@ -44,7 +44,7 @@ jobs:
~/.cache/pip
key: v7-build-tox-cache-${{ env.RUN_MATRIX_COMBINATION }}-${{ hashFiles('tox.ini', 'gen-requirements.txt', 'dev-requirements.txt') }}
- name: run tox
run: tox -f ${{ matrix.python-version }}-${{ matrix.package }} -- --benchmark-json=${{ env.RUN_MATRIX_COMBINATION }}-benchmark.json
run: tox -f ${{ matrix.python-version }}-${{ matrix.package }} -- -ra --benchmark-json=${{ env.RUN_MATRIX_COMBINATION }}-benchmark.json
# - name: Find and merge ${{ matrix.package }} benchmarks
# # TODO: Add at least one benchmark to every package type to remove this (#249)
# if: matrix.package == 'sdkextension' || matrix.package == 'propagator'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -656,10 +656,7 @@ def test_no_metric_for_websockets(self):
self.send_input({"type": "websocket.receive", "text": "ping"})
self.send_input({"type": "websocket.disconnect"})
self.get_all_output()
metrics_list = self.memory_metrics_reader.get_metrics_data()
self.assertEqual(
len(metrics_list.resource_metrics[0].scope_metrics), 0
)
self.assertIsNone(self.memory_metrics_reader.get_metrics_data())


class TestAsgiAttributes(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,4 @@ def test_metric_uninstrument(self):
self.assertEqual(len(metrics), 1)
CeleryInstrumentor().uninstrument()

metrics = self.get_metrics()
self.assertEqual(len(metrics), 1)

for metric in metrics:
for point in list(metric.data.data_points):
self.assertEqual(point.count, 1)
self.assertIsNone(self.memory_metrics_reader.get_metrics_data())
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ def test_metrics_one_connection(self):
pool_logging_name=pool_name,
)

metrics = self.get_sorted_metrics()
self.assertEqual(len(metrics), 0)
self.assertIsNone(self.memory_metrics_reader.get_metrics_data())

with engine.connect():
self.assert_pool_idle_used_expected(
Expand All @@ -78,8 +77,7 @@ def test_metrics_without_pool_name(self):
pool_logging_name=pool_name,
)

metrics = self.get_sorted_metrics()
self.assertEqual(len(metrics), 0)
self.assertIsNone(self.memory_metrics_reader.get_metrics_data())

with engine.connect():
self.assert_pool_idle_used_expected(
Expand All @@ -100,8 +98,7 @@ def test_metrics_two_connections(self):
pool_logging_name=pool_name,
)

metrics = self.get_sorted_metrics()
self.assertEqual(len(metrics), 0)
self.assertIsNone(self.memory_metrics_reader.get_metrics_data())

with engine.connect():
with engine.connect():
Expand All @@ -122,8 +119,7 @@ def test_metrics_connections(self):
pool_logging_name=pool_name,
)

metrics = self.get_sorted_metrics()
self.assertEqual(len(metrics), 0)
self.assertIsNone(self.memory_metrics_reader.get_metrics_data())

with engine.connect():
with engine.connect():
Expand Down Expand Up @@ -156,5 +152,4 @@ def test_metric_uninstrument(self):

engine.connect()

metrics = self.get_sorted_metrics()
self.assertEqual(len(metrics), 0)
self.assertIsNone(self.memory_metrics_reader.get_metrics_data())
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
from timeit import default_timer
from urllib import request
from urllib.parse import urlencode
from pytest import mark
from platform import python_implementation
from sys import version_info

import httpretty

Expand Down Expand Up @@ -185,16 +188,27 @@ def test_basic_metric_request_not_empty(self):
),
)

@mark.skipif(
python_implementation() == "PyPy" or version_info.minor == 7,
reason="Fails randomly in 3.7 and pypy"
)
def test_metric_uninstrument(self):
with request.urlopen(self.URL):
metrics = self.get_sorted_metrics()
self.assertEqual(len(metrics), 3)

self.assertEqual(
metrics[0].data.data_points[0].sum, 1
)
self.assertEqual(
metrics[1].data.data_points[0].sum, 0
)
self.assertEqual(
metrics[2].data.data_points[0].sum, 6
)

URLLibInstrumentor().uninstrument()
with request.urlopen(self.URL):
metrics = self.get_sorted_metrics()
self.assertEqual(len(metrics), 3)

for metric in metrics:
for point in list(metric.data.data_points):
self.assertEqual(point.count, 1)
self.assertIsNone(
self.memory_metrics_reader.get_metrics_data()
)

0 comments on commit aa48c40

Please sign in to comment.