mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-07-30 21:56:07 +08:00
Merge pull request #103 from NathanielRN/move-instrumentation-falcon
Move instrumentation falcon
This commit is contained in:
@ -41,14 +41,14 @@ package_dir=
|
|||||||
packages=find_namespace:
|
packages=find_namespace:
|
||||||
install_requires =
|
install_requires =
|
||||||
falcon ~= 2.0
|
falcon ~= 2.0
|
||||||
opentelemetry-instrumentation-wsgi == 0.15.dev0
|
opentelemetry-instrumentation-wsgi == 0.15b0
|
||||||
opentelemetry-instrumentation == 0.15.dev0
|
opentelemetry-instrumentation == 0.15b0
|
||||||
opentelemetry-api == 0.15.dev0
|
opentelemetry-api == 0.15b0
|
||||||
|
|
||||||
[options.extras_require]
|
[options.extras_require]
|
||||||
test =
|
test =
|
||||||
falcon ~= 2.0
|
falcon ~= 2.0
|
||||||
opentelemetry-test == 0.15.dev0
|
opentelemetry-test == 0.15b0
|
||||||
parameterized == 0.7.4
|
parameterized == 0.7.4
|
||||||
|
|
||||||
[options.packages.find]
|
[options.packages.find]
|
||||||
|
@ -55,7 +55,7 @@ from opentelemetry.instrumentation.falcon.version import __version__
|
|||||||
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
||||||
from opentelemetry.instrumentation.utils import (
|
from opentelemetry.instrumentation.utils import (
|
||||||
extract_attributes_from_object,
|
extract_attributes_from_object,
|
||||||
http_status_to_canonical_code,
|
http_status_to_status_code,
|
||||||
)
|
)
|
||||||
from opentelemetry.trace.status import Status
|
from opentelemetry.trace.status import Status
|
||||||
from opentelemetry.util import ExcludeList, time_ns
|
from opentelemetry.util import ExcludeList, time_ns
|
||||||
@ -115,7 +115,7 @@ class _InstrumentedFalconAPI(falcon.API):
|
|||||||
start_time = time_ns()
|
start_time = time_ns()
|
||||||
|
|
||||||
token = context.attach(
|
token = context.attach(
|
||||||
propagators.extract(otel_wsgi.get_header_from_environ, env)
|
propagators.extract(otel_wsgi.carrier_getter, env)
|
||||||
)
|
)
|
||||||
span = self._tracer.start_span(
|
span = self._tracer.start_span(
|
||||||
otel_wsgi.get_default_span_name(env),
|
otel_wsgi.get_default_span_name(env),
|
||||||
@ -216,7 +216,7 @@ class _TraceMiddleware:
|
|||||||
span.set_attribute("http.status_code", status_code)
|
span.set_attribute("http.status_code", status_code)
|
||||||
span.set_status(
|
span.set_status(
|
||||||
Status(
|
Status(
|
||||||
canonical_code=http_status_to_canonical_code(status_code),
|
status_code=http_status_to_status_code(status_code),
|
||||||
description=reason,
|
description=reason,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -12,4 +12,4 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
__version__ = "0.15.dev0"
|
__version__ = "0.15b0"
|
||||||
|
@ -18,7 +18,7 @@ from falcon import testing
|
|||||||
|
|
||||||
from opentelemetry.instrumentation.falcon import FalconInstrumentor
|
from opentelemetry.instrumentation.falcon import FalconInstrumentor
|
||||||
from opentelemetry.test.test_base import TestBase
|
from opentelemetry.test.test_base import TestBase
|
||||||
from opentelemetry.trace.status import StatusCanonicalCode
|
from opentelemetry.trace.status import StatusCode
|
||||||
from opentelemetry.util import ExcludeList
|
from opentelemetry.util import ExcludeList
|
||||||
|
|
||||||
from .app import make_app
|
from .app import make_app
|
||||||
@ -64,7 +64,7 @@ class TestFalconInstrumentation(TestBase):
|
|||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
span.name, "HelloWorldResource.on_{0}".format(method.lower())
|
span.name, "HelloWorldResource.on_{0}".format(method.lower())
|
||||||
)
|
)
|
||||||
self.assertEqual(span.status.canonical_code, StatusCanonicalCode.OK)
|
self.assertEqual(span.status.status_code, StatusCode.UNSET)
|
||||||
self.assert_span_has_attributes(
|
self.assert_span_has_attributes(
|
||||||
span,
|
span,
|
||||||
{
|
{
|
||||||
@ -91,9 +91,7 @@ class TestFalconInstrumentation(TestBase):
|
|||||||
self.assertEqual(len(spans), 1)
|
self.assertEqual(len(spans), 1)
|
||||||
span = spans[0]
|
span = spans[0]
|
||||||
self.assertEqual(span.name, "HTTP GET")
|
self.assertEqual(span.name, "HTTP GET")
|
||||||
self.assertEqual(
|
self.assertEqual(span.status.status_code, StatusCode.ERROR)
|
||||||
span.status.canonical_code, StatusCanonicalCode.NOT_FOUND
|
|
||||||
)
|
|
||||||
self.assert_span_has_attributes(
|
self.assert_span_has_attributes(
|
||||||
span,
|
span,
|
||||||
{
|
{
|
||||||
@ -122,9 +120,7 @@ class TestFalconInstrumentation(TestBase):
|
|||||||
span = spans[0]
|
span = spans[0]
|
||||||
self.assertEqual(span.name, "ErrorResource.on_get")
|
self.assertEqual(span.name, "ErrorResource.on_get")
|
||||||
self.assertFalse(span.status.is_ok)
|
self.assertFalse(span.status.is_ok)
|
||||||
self.assertEqual(
|
self.assertEqual(span.status.status_code, StatusCode.ERROR)
|
||||||
span.status.canonical_code, StatusCanonicalCode.INTERNAL
|
|
||||||
)
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
span.status.description,
|
span.status.description,
|
||||||
"NameError: name 'non_existent_var' is not defined",
|
"NameError: name 'non_existent_var' is not defined",
|
||||||
|
Reference in New Issue
Block a user