Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
skywalking-python
提交
0cf54f51
S
skywalking-python
项目概览
apache
/
skywalking-python
通知
60
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
skywalking-python
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
0cf54f51
编写于
5月 04, 2020
作者:
K
kezhenxu94
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix bug and setup dist process
上级
ae179637
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
170 addition
and
2 deletion
+170
-2
.gitignore
.gitignore
+3
-0
MANIFEST.in
MANIFEST.in
+6
-0
Makefile
Makefile
+9
-0
setup.py
setup.py
+39
-0
skywalking/__init__.py
skywalking/__init__.py
+1
-1
skywalking/plugins/__init__.py
skywalking/plugins/__init__.py
+1
-1
skywalking/plugins/sw_http/__init__.py
skywalking/plugins/sw_http/__init__.py
+54
-0
skywalking/plugins/sw_request/__init__.py
skywalking/plugins/sw_request/__init__.py
+56
-0
skywalking/trace/tags/__init__.py
skywalking/trace/tags/__init__.py
+1
-0
未找到文件。
.gitignore
浏览文件 @
0cf54f51
...
...
@@ -4,3 +4,6 @@
*~
**/*_pb2*
__pycache__
build/
dist/
skywalking_python.egg-info/
MANIFEST.in
0 → 100644
浏览文件 @
0cf54f51
include browser/*.py
include common/*.py
include language_agent/*.py
include management/*.py
include profile/*.py
include service_mesh_probe/*.py
\ No newline at end of file
Makefile
浏览文件 @
0cf54f51
...
...
@@ -24,6 +24,12 @@ setup:
gen
:
python3
-m
grpc_tools.protoc
-I
protocol
--python_out
=
.
--grpc_python_out
=
.
protocol/
**
/
*
.proto
touch
browser/__init__.py
touch
common/__init__.py
touch
language_agent/__init__.py
touch
management/__init__.py
touch
profile/__init__.py
touch
service_mesh_probe/__init__.py
lint
:
clean
flake8
.
--count
--select
=
E9,F63,F7,F82
--show-source
--statistics
...
...
@@ -35,6 +41,9 @@ license: clean
test
:
gen
python3
-m
unittest
-v
install
:
gen
python3 setup.py
install
--force
clean
:
rm
-rf
browser
rm
-rf
common
...
...
s
kywalking/plugins/http/__init__
.py
→
s
etup
.py
浏览文件 @
0cf54f51
...
...
@@ -15,32 +15,25 @@
# limitations under the License.
#
import
inspect
from
skywalking
import
Layer
,
Component
from
skywalking.trace.context
import
get_context
def
install
():
from
http.server
import
BaseHTTPRequestHandler
_handle
=
BaseHTTPRequestHandler
.
handle
def
_sw_handle
(
this
:
BaseHTTPRequestHandler
):
http_methods
=
(
'GET'
,
'HEAD'
,
'POST'
,
'PUT'
,
'DELETE'
,
'CONNECT'
,
'OPTIONS'
,
'TRACE'
,
'PATCH'
)
for
method
in
http_methods
:
if
hasattr
(
this
,
'do_'
+
method
)
and
inspect
.
ismethod
(
getattr
(
this
,
'do_'
+
method
)):
_do_method
=
getattr
(
this
,
'do_'
+
method
)
def
_sw_do_method
():
context
=
get_context
()
with
context
.
new_entry_span
(
op
=
this
.
path
)
as
span
:
span
.
layer
=
Layer
.
Http
span
.
component
=
Component
.
Http
span
.
peer
=
'%s:%s'
%
this
.
client_address
_do_method
()
setattr
(
this
,
'do_'
+
method
,
_sw_do_method
)
_handle
(
this
)
BaseHTTPRequestHandler
.
handle
=
_sw_handle
import
pathlib
from
setuptools
import
setup
,
find_packages
HERE
=
pathlib
.
Path
(
__file__
).
parent
README
=
(
HERE
/
"README.md"
).
read_text
()
setup
(
name
=
"skywalking-python"
,
version
=
"0.1.1"
,
description
=
"Python Agent for Apache SkyWalking"
,
long_description
=
README
,
long_description_content_type
=
"text/markdown"
,
url
=
"https://github.com/SkyAPM/SkyAPM-python/"
,
author
=
"Apache"
,
author_email
=
"dev@skywalking.apache.org"
,
license
=
"Apache 2.0"
,
packages
=
find_packages
(
exclude
=
(
"tests"
,)),
include_package_data
=
True
,
install_requires
=
[],
)
skywalking/__init__.py
浏览文件 @
0cf54f51
...
...
@@ -42,7 +42,7 @@ class Layer(Enum):
class
Kind
(
Enum
):
Local
=
0
Entry
=
1
Exit
=
1
Exit
=
2
@
property
def
is_local
(
self
):
...
...
skywalking/plugins/__init__.py
浏览文件 @
0cf54f51
...
...
@@ -28,6 +28,6 @@ def install():
logger
.
debug
(
'installing plugin %s'
,
modname
)
plugin
=
importer
.
find_module
(
modname
).
load_module
(
modname
)
if
not
hasattr
(
plugin
,
'install'
)
or
inspect
.
ismethod
(
getattr
(
plugin
,
'install'
)):
logger
.
warning
(
'no `install` method in plugin %s, thus the plugin won
\'
t be installed'
)
logger
.
warning
(
'no `install` method in plugin %s, thus the plugin won
\'
t be installed'
,
modname
)
continue
plugin
.
install
()
skywalking/plugins/sw_http/__init__.py
0 → 100644
浏览文件 @
0cf54f51
#
# 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
inspect
import
logging
import
traceback
from
skywalking
import
Layer
,
Component
from
skywalking.trace.context
import
get_context
logger
=
logging
.
getLogger
(
__name__
)
def
install
():
# noinspection PyBroadException
try
:
from
http.server
import
BaseHTTPRequestHandler
_handle
=
BaseHTTPRequestHandler
.
handle
def
_sw_handle
(
this
:
BaseHTTPRequestHandler
):
http_methods
=
(
'GET'
,
'HEAD'
,
'POST'
,
'PUT'
,
'DELETE'
,
'CONNECT'
,
'OPTIONS'
,
'TRACE'
,
'PATCH'
)
for
method
in
http_methods
:
if
hasattr
(
this
,
'do_'
+
method
)
and
inspect
.
ismethod
(
getattr
(
this
,
'do_'
+
method
)):
_do_method
=
getattr
(
this
,
'do_'
+
method
)
def
_sw_do_method
():
context
=
get_context
()
with
context
.
new_entry_span
(
op
=
this
.
path
)
as
span
:
span
.
layer
=
Layer
.
Http
span
.
component
=
Component
.
Http
span
.
peer
=
'%s:%s'
%
this
.
client_address
_do_method
()
setattr
(
this
,
'do_'
+
method
,
_sw_do_method
)
_handle
(
this
)
BaseHTTPRequestHandler
.
handle
=
_sw_handle
except
Exception
:
logger
.
warning
(
'failed to install plugin %s'
,
__name__
)
traceback
.
print_exc
()
skywalking/plugins/request/__init__.py
→
skywalking/plugins/
sw_
request/__init__.py
浏览文件 @
0cf54f51
...
...
@@ -14,34 +14,43 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import
logging
import
traceback
from
skywalking
import
Layer
,
Component
from
skywalking.trace
import
tags
from
skywalking.trace.context
import
get_context
from
skywalking.trace.tags
import
Tag
logger
=
logging
.
getLogger
(
__name__
)
def
install
():
from
urllib.request
import
OpenerDirector
from
urllib.error
import
HTTPError
# noinspection PyBroadException
try
:
from
urllib.request
import
OpenerDirector
from
urllib.error
import
HTTPError
_open
=
OpenerDirector
.
open
_open
=
OpenerDirector
.
open
def
_sw_open
(
this
:
OpenerDirector
,
fullurl
,
data
,
timeout
):
context
=
get_context
()
with
context
.
new_exit_span
(
op
=
fullurl
.
selector
,
peer
=
fullurl
.
host
)
as
span
:
span
.
layer
=
Layer
.
Http
span
.
component
=
Component
.
Http
try
:
res
=
_open
(
this
,
fullurl
,
data
,
timeout
)
span
.
tag
(
Tag
(
key
=
tags
.
HttpMethod
,
val
=
fullurl
.
get_method
()))
span
.
tag
(
Tag
(
key
=
tags
.
HttpUrl
,
val
=
fullurl
.
full_url
))
span
.
tag
(
Tag
(
key
=
tags
.
HttpStatus
,
val
=
res
.
code
))
if
res
.
code
>=
400
:
span
.
error_occurred
=
True
except
HTTPError
as
e
:
span
.
raised
()
raise
e
return
res
def
_sw_open
(
this
:
OpenerDirector
,
fullurl
,
data
,
timeout
):
context
=
get_context
()
with
context
.
new_exit_span
(
op
=
fullurl
.
selector
,
peer
=
fullurl
.
host
)
as
span
:
span
.
layer
=
Layer
.
Http
span
.
component
=
Component
.
Http
try
:
res
=
_open
(
this
,
fullurl
,
data
,
timeout
)
span
.
tag
(
Tag
(
key
=
tags
.
HttpMethod
,
val
=
fullurl
.
get_method
()))
span
.
tag
(
Tag
(
key
=
tags
.
HttpUrl
,
val
=
fullurl
.
full_url
))
span
.
tag
(
Tag
(
key
=
tags
.
HttpStatus
,
val
=
res
.
code
))
if
res
.
code
>=
400
:
span
.
error_occurred
=
True
except
HTTPError
as
e
:
span
.
raised
()
raise
e
return
res
OpenerDirector
.
open
=
_sw_open
OpenerDirector
.
open
=
_sw_open
except
Exception
:
logger
.
warning
(
'failed to install plugin %s'
,
__name__
)
traceback
.
print_exc
()
skywalking/trace/tags/__init__.py
浏览文件 @
0cf54f51
...
...
@@ -18,6 +18,7 @@
from
collections
import
namedtuple
Tag
=
namedtuple
(
'Tag'
,
'key val overridable'
)
Tag
.
__new__
.
__defaults__
=
(
None
,
None
,
False
)
HttpUrl
=
'url'
HttpMethod
=
'http.method'
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录