Skip to content

Commit

Permalink
Merge branch 'main' into urllib3_request_hook
Browse files Browse the repository at this point in the history
  • Loading branch information
ItayGibel-helios authored Sep 6, 2021
2 parents 2b3dc62 + 0e5853b commit a40540d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 26 deletions.
4 changes: 4 additions & 0 deletions .github/component_owners.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
components:

sdk-extension/opentelemetry-sdk-extension-aws:
- NathanielRN
14 changes: 14 additions & 0 deletions .github/workflows/component-owners.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This action assigns and requires approval from owners of components for
# PRs that are open against those components. Components are defined as
# individual paths within this repository.
name: 'Component Owners'

on:
pull_request_target:

jobs:
run_self:
runs-on: ubuntu-latest
name: Auto Assign Owners
steps:
- uses: dyladan/component-owners@main
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ def response_hook(span, req, resp):
_ENVIRON_EXC = "opentelemetry-falcon.exc"


_excluded_urls = get_excluded_urls("FALCON")
_traced_request_attrs = get_traced_request_attrs("FALCON")
_response_propagation_setter = FuncSetter(falcon.Response.append_header)


Expand Down Expand Up @@ -159,17 +157,21 @@ def __init__(self, *args, **kwargs):

trace_middleware = _TraceMiddleware(
self._tracer,
kwargs.pop("traced_request_attributes", _traced_request_attrs),
kwargs.pop(
"traced_request_attributes", get_traced_request_attrs("FALCON")
),
kwargs.pop("request_hook", None),
kwargs.pop("response_hook", None),
)
middlewares.insert(0, trace_middleware)
kwargs["middleware"] = middlewares

self._excluded_urls = get_excluded_urls("FALCON")
super().__init__(*args, **kwargs)

def __call__(self, env, start_response):
# pylint: disable=E1101
if _excluded_urls.url_disabled(env.get("PATH_INFO", "/")):
if self._excluded_urls.url_disabled(env.get("PATH_INFO", "/")):
return super().__call__(env, start_response)

start_time = _time_ns()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,13 @@
from opentelemetry.semconv.trace import SpanAttributes
from opentelemetry.test.test_base import TestBase
from opentelemetry.trace import StatusCode, format_span_id, format_trace_id
from opentelemetry.util.http import get_excluded_urls, get_traced_request_attrs

from .app import make_app


class TestFalconBase(TestBase):
def setUp(self):
super().setUp()
FalconInstrumentor().instrument(
request_hook=getattr(self, "request_hook", None),
response_hook=getattr(self, "response_hook", None),
)
self.app = make_app()
# pylint: disable=protected-access
self.env_patch = patch.dict(
"os.environ",
{
Expand All @@ -48,20 +41,12 @@ def setUp(self):
},
)
self.env_patch.start()
self.exclude_patch = patch(
"opentelemetry.instrumentation.falcon._excluded_urls",
get_excluded_urls("FALCON"),
)
middleware = self.app._middleware[0][ # pylint:disable=W0212
0
].__self__
self.traced_patch = patch.object(
middleware,
"_traced_request_attrs",
get_traced_request_attrs("FALCON"),

FalconInstrumentor().instrument(
request_hook=getattr(self, "request_hook", None),
response_hook=getattr(self, "response_hook", None),
)
self.exclude_patch.start()
self.traced_patch.start()
self.app = make_app()

def client(self):
return testing.TestClient(self.app)
Expand All @@ -71,8 +56,6 @@ def tearDown(self):
with self.disable_logging():
FalconInstrumentor().uninstrument()
self.env_patch.stop()
self.exclude_patch.stop()
self.traced_patch.stop()


class TestFalconInstrumentation(TestFalconBase):
Expand Down

0 comments on commit a40540d

Please sign in to comment.