probeyang commented on a change in pull request #146:
URL: https://github.com/apache/skywalking-python/pull/146#discussion_r685999758



##########
File path: skywalking/plugins/sw_falcon.py
##########
@@ -0,0 +1,96 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from skywalking import Layer, Component
+from skywalking.trace import tags
+from skywalking.trace.carrier import Carrier
+from skywalking.trace.context import get_context
+from skywalking.trace.span import NoopSpan
+from skywalking.trace.tags import Tag
+
+
+def install():
+    from falcon import API, request, response
+
+    _original_falcon_api = API.__call__
+    _original_falcon_handle_exception = API._handle_exception
+
+    def params_tostring(params):
+        return "\n".join([k + "=" + v for k, v in params.items()])
+
+    def _sw_falcon_api(this: API, env, start_response):
+        context = get_context()
+        carrier = Carrier()
+        headers = get_headers(env)
+        for item in carrier:
+            key = item.key.replace("_", "-") if "_" in item.key else item.key
+            if key.capitalize() in headers:
+                item.val = headers[key.capitalize()]
+        with context.new_entry_span(op="/", carrier=carrier) as span:
+            span.layer = Layer.Http
+            span.component = Component.Falcon
+
+            from falcon import RequestOptions
+
+            req = request.Request(env, RequestOptions())
+            span.op = str(req.url).split("?")[0]
+            span.peer = "%s:%s" % (req.remote_addr, req.port)
+            span.tag(Tag(key=tags.HttpMethod, val=req.method))

Review comment:
       ok, i will set status argument 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to