Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
author zkscpqm <qmcpzks@naver.com> 1595084266 +0300 committer kezhenxu94 <kezhenxu94@163.com> 1596458512 +0800 gpgsig -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEE/Eo3KEa/qP7Oqvu/Ng+pfz8mM0wFAl8oBhAACgkQNg+pfz8m M0y/bBAAoBBwE54/GJ00JQ8tgn5xqNo1bfqlBcNa6obvXJbkvFwt/knVEU+fuKxm p/jGahr2EyHzhXTh4XUo5xxlK+xgTid5JHRopjgTY3MgbEG/397tcS2+1P8NQUCB Lh+OxX5V4Gm0GqvFP02zrsHjBiJYL1TVz4R8PomuE+w7fuNyuqPtNMUt5ILsZz/3 X3X7JJnbJqjKK5fEcerPKPUL3Ee+muazoCuR5KFGJ6PbxrVu/YBG3UTTeOhVonOb r7VKicGJSKQZD3nCH8cE56Qwt3uoQE1W0lQ/L1RwE++ixa+vk19FpPlwoup/eYac vYTGjMSgloCpiksGmhLhPU5bOlMxoArqJQg2zHayPfrdFNfgu1qfu+fMciU+8A11 OxhLEjLxAnlEO7wtjcUuVD+siVlmkKeRBxffsoiZTXWFQVbbNnM9Sgrc70ql9KwK uCi3Bcfr2gJctC+vrHEBO2AJX4HtSuhYtpGzKAPc0SHb2niKqqFFZHWa+t5db7zg ixxUrT5j9OSAi4TzDi4/QLEjCt0ECOxJJpeUFMXn4SLHYiSaU5lgV+H5VOxEKotj w3dpHU1J1/mylZ9TauFX703vIc/il8iqKeqc0JFgSa25F0ZjlyfI8MIkwfHA8CNS MTMjnwmcDpOgc/AADPqAz+kwLYLARlvBUkz5uhwqI8slXkpwnrY= =4v88 -----END PGP SIGNATURE----- Created venv builders for linux/windows and req flashers + use documentation (#38) * Created venv builders for linux/windows and req flashers + use documentation * aadd license headers to scripts * moved scripts, updated paths, changed how reqs are installed, updated linux venv bin path * update license checker to accomodate for shebangs and batchfile comments Add ability to collect SQL Parameters in PyMsql plugin (#39) Add plugin for Django Agent (#37) Add ignore_suffix Config (#40) Add Django in document (#42) Add Flask Http Params (#43) * Add Flask Http Params * Add Flask Http Params Co-authored-by: huawei <huawei@bit-s.cn> Add Redis Plugin (#44) Update Redis plugin Component Id (#45) Test: print the diff list when validation failed (#46) feature: add Tornado Plugin (#48) feature: add Kafka Plugin (#50) Enable Django collect http parameters (#49) Add changelog for 0.2.0 (#51) Make plugin compatible with Django < 2.2 (#52) Add Rabbitmq Plugin (#53) chore: add make goal to package release tar ball (#54) Support propagating correlation context (#55) Sync Add changelog for 0.2.0 (#51) Make plugin compatible with Django < 2.2 (#52) Add Rabbitmq Plugin (#53) chore: add make goal to package release tar ball (#54) Support propagating correlation context (#55) Sync
- Loading branch information
1 parent
cca8025
commit 0ac3229
Showing
67 changed files
with
2,515 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,5 @@ __pycache__ | |
build/ | ||
dist/ | ||
*.pyc | ||
/apache_skywalking.egg-info/ | ||
/apache_skywalking.egg-info/ | ||
**/venv/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
blindspin==2.0.1 | ||
certifi==2020.6.20 | ||
chardet==3.0.4 | ||
colorama==0.4.3 | ||
crayons==0.3.1 | ||
deprecation==2.1.0 | ||
docker==4.2.2 | ||
grpcio==1.30.0 | ||
grpcio-tools==1.30.0 | ||
idna==2.10 | ||
packaging==20.4 | ||
protobuf==3.12.2 | ||
PyMySQL==0.9.3 | ||
pyparsing==2.4.7 | ||
pypiwin32==223 | ||
pywin32==228 | ||
requests==2.24.0 | ||
six==1.15.0 | ||
testcontainers==3.0.3 | ||
urllib3==1.25.9 | ||
websocket-client==0.57.0 | ||
Werkzeug==1.0.1 | ||
wrapt==1.12.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# | ||
# 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. | ||
# | ||
import logging | ||
|
||
from skywalking import Layer, Component, config | ||
from skywalking.trace import tags | ||
from skywalking.trace.carrier import Carrier | ||
from skywalking.trace.context import get_context | ||
from skywalking.trace.tags import Tag | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def install(): | ||
try: | ||
from django.core.handlers.base import BaseHandler | ||
from django.core.handlers import exception | ||
|
||
_get_response = BaseHandler.get_response | ||
_handle_uncaught_exception = exception.handle_uncaught_exception | ||
|
||
def _sw_get_response(this, request): | ||
if request is None: | ||
resp = _get_response(this, request) | ||
return resp | ||
|
||
context = get_context() | ||
carrier = Carrier() | ||
for item in carrier: | ||
# Any HTTP headers in the request are converted to META keys by converting all characters to uppercase, | ||
# replacing any hyphens with underscores and adding an HTTP_ prefix to the name. | ||
# https://docs.djangoproject.com/en/3.0/ref/request-response/#django.http.HttpRequest.META | ||
sw_http_header_key = 'HTTP_%s' % item.key.upper().replace('-', '_') | ||
if sw_http_header_key in request.META: | ||
item.val = request.META[sw_http_header_key] | ||
|
||
with context.new_entry_span(op=request.path, carrier=carrier) as span: | ||
span.layer = Layer.Http | ||
span.component = Component.Django | ||
span.peer = '%s:%s' % (request.META.get('REMOTE_ADDR'), request.META.get('REMOTE_PORT') or "80") | ||
|
||
span.tag(Tag(key=tags.HttpMethod, val=request.method)) | ||
span.tag(Tag(key=tags.HttpUrl, val=request.build_absolute_uri().split("?")[0])) | ||
|
||
# you can get request parameters by `request.GET` even though client are using POST or other methods | ||
if config.django_collect_http_params and request.GET: | ||
span.tag(Tag(key=tags.HttpParams, | ||
val=params_tostring(request.GET)[0:config.http_params_length_threshold])) | ||
|
||
resp = _get_response(this, request) | ||
span.tag(Tag(key=tags.HttpStatus, val=resp.status_code)) | ||
if resp.status_code >= 400: | ||
span.error_occurred = True | ||
return resp | ||
|
||
def _sw_handle_uncaught_exception(request, resolver, exc_info): | ||
if exc_info is not None: | ||
entry_span = get_context().active_span() | ||
if entry_span is not None: | ||
entry_span.raised() | ||
|
||
return _handle_uncaught_exception(request, resolver, exc_info) | ||
|
||
BaseHandler.get_response = _sw_get_response | ||
exception.handle_uncaught_exception = _sw_handle_uncaught_exception | ||
except Exception: | ||
logger.warning('failed to install plugin %s', __name__) | ||
|
||
|
||
def params_tostring(params): | ||
return "\n".join([k + '=[' + ",".join(params.getlist(k)) + ']' for k, _ in params.items()]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.