Skip to content

Commit

Permalink
lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jgibo committed May 29, 2024
1 parent 516de12 commit cbb3e4d
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def _finish_tracing_callback(
if isinstance(exc, HTTPError):
status_code = exc.code
description = f"{type(exc).__name__}: {exc}"

response = None
if not exc:
response = future.result()
Expand All @@ -136,8 +136,12 @@ def _finish_tracing_callback(
duration_histogram.record(
response.request_time, attributes=metric_attributes
)
request_size_histogram.record(request_size, attributes=metric_attributes)
response_size_histogram.record(response_size, attributes=metric_attributes)
request_size_histogram.record(
request_size, attributes=metric_attributes
)
response_size_histogram.record(
response_size, attributes=metric_attributes
)

if response_hook:
response_hook(span, future)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
from urllib.error import HTTPError

from http_server_mock import HttpServerMock
from tornado.testing import AsyncHTTPTestCase
from tornado.httpclient import HTTPClientError
from tornado.testing import AsyncHTTPTestCase

from opentelemetry import trace
from opentelemetry.instrumentation.propagators import (
Expand Down Expand Up @@ -603,6 +603,7 @@ def client_response_hook(span, response):

self.memory_exporter.clear()


class TestTornadoHTTPClientInstrumentation(TornadoTest, WsgiTestBase):
def test_http_client_success_response(self):
response = self.fetch("/")
Expand Down Expand Up @@ -646,6 +647,7 @@ def test_http_client_failed_response(self):
self.assertEqual(client.name, "GET")
self.memory_exporter.clear()


class TestTornadoUninstrument(TornadoTest):
def test_uninstrument(self):
response = self.fetch("/")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import Optional
from os import environ
from typing import Optional

from opentelemetry.resource.detector.azure._utils import (
_get_azure_resource_uri,
_is_on_functions,
)
from opentelemetry.sdk.resources import Resource, ResourceDetector
from opentelemetry.semconv.resource import (
CloudPlatformValues,
CloudProviderValues,
ResourceAttributes,
)
from opentelemetry.resource.detector.azure._utils import _get_azure_resource_uri

from ._constants import (
_APP_SERVICE_ATTRIBUTE_ENV_VARS,
_WEBSITE_SITE_NAME,
)

from opentelemetry.resource.detector.azure._utils import _is_on_functions
from ._constants import _APP_SERVICE_ATTRIBUTE_ENV_VARS, _WEBSITE_SITE_NAME


class AzureAppServiceResourceDetector(ResourceDetector):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

from os import environ, getpid

from opentelemetry.resource.detector.azure._utils import (
_get_azure_resource_uri,
_is_on_functions,
)
from opentelemetry.sdk.resources import Resource, ResourceDetector
from opentelemetry.semconv.resource import (
CloudPlatformValues,
Expand All @@ -26,10 +30,6 @@
_REGION_NAME,
_WEBSITE_SITE_NAME,
)
from opentelemetry.resource.detector.azure._utils import (
_get_azure_resource_uri,
_is_on_functions,
)


class AzureFunctionsResourceDetector(ResourceDetector):
Expand Down Expand Up @@ -65,4 +65,3 @@ def detect(self) -> Resource:
attributes[key] = value

return Resource(attributes)

Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_on_app_service(self):
self.assertEqual(
attributes["azure.app.service.stamp"], TEST_WEBSITE_HOME_STAMPNAME
)

@patch.dict(
"os.environ",
{
Expand Down
8 changes: 6 additions & 2 deletions util/opentelemetry-util-http/tests/test_remove_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ def test_remove_credentials(self):
def test_remove_credentials_ipv4_literal(self):
url = "http://someuser:[email protected]:8080/test/path?query=value"
cleaned_url = remove_url_credentials(url)
self.assertEqual(cleaned_url, "http://127.0.0.1:8080/test/path?query=value")
self.assertEqual(
cleaned_url, "http://127.0.0.1:8080/test/path?query=value"
)

def test_remove_credentials_ipv6_literal(self):
url = "http://someuser:somepass@[::1]:8080/test/path?query=value"
cleaned_url = remove_url_credentials(url)
self.assertEqual(cleaned_url, "http://[::1]:8080/test/path?query=value")
self.assertEqual(
cleaned_url, "http://[::1]:8080/test/path?query=value"
)

0 comments on commit cbb3e4d

Please sign in to comment.