From 56fb19680c6d7af6976d5a52f47ec6eab1b82452 Mon Sep 17 00:00:00 2001 From: sroda Date: Wed, 27 Jul 2022 13:42:00 +0300 Subject: [PATCH] Fixed after CR --- .../src/opentelemetry/instrumentation/urllib3/__init__.py | 6 ++++-- .../src/opentelemetry/instrumentation/urllib3/version.py | 2 +- .../tests/test_urllib3_ip_support.py | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/__init__.py b/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/__init__.py index b6685ddc9d..4c83fd8df9 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/__init__.py @@ -205,7 +205,7 @@ def instrumented_urlopen(wrapped, instance, args, kwargs): with _suppress_further_instrumentation(): start_time = default_timer() response = wrapped(*args, **kwargs) - elapsed_time = (default_timer() - start_time) * 1000 + elapsed_time = round((default_timer() - start_time) * 1000) _apply_response(span, response) if callable(response_hook): @@ -227,12 +227,14 @@ def instrumented_urlopen(wrapped, instance, args, kwargs): ) request_size = 0 if body is None else len(body) + response_size = int(response.headers.get("Content-Length", 0)) + duration_histogram.record(elapsed_time, attributes=metric_labels) request_size_histogram.record( request_size, attributes=metric_labels ) response_size_histogram.record( - len(response.data), attributes=metric_labels + response_size, attributes=metric_labels ) return response diff --git a/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/version.py b/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/version.py index 6b2801561b..268a795344 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/version.py +++ b/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.33b0" +__version__ = "0.32b0" diff --git a/instrumentation/opentelemetry-instrumentation-urllib3/tests/test_urllib3_ip_support.py b/instrumentation/opentelemetry-instrumentation-urllib3/tests/test_urllib3_ip_support.py index 17a8ba5159..63c820f846 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib3/tests/test_urllib3_ip_support.py +++ b/instrumentation/opentelemetry-instrumentation-urllib3/tests/test_urllib3_ip_support.py @@ -197,7 +197,7 @@ def test_basic_metric_check_client_size_post(self): self.assertAlmostEqual( data_point.sum, client_duration_estimated, - delta=5000, + delta=100, ) self.assertIn(metric.name, expected_metrics)