-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
1,235 additions
and
341 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
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 |
---|---|---|
@@ -1,15 +1,16 @@ | ||
FROM python:3.8 | ||
FROM python:3.11 | ||
WORKDIR /app/ | ||
|
||
COPY testapps/backend/ /app/ | ||
RUN pip install -r requirements.txt | ||
|
||
COPY setup.py /pinpoint-c-agent/setup.py | ||
COPY common/ /pinpoint-c-agent/common | ||
COPY README /pinpoint-c-agent/README | ||
COPY plugins/PY /pinpoint-c-agent/plugins/PY | ||
COPY src/PY /pinpoint-c-agent/src/PY | ||
|
||
RUN pip install -r requirements.txt | ||
RUN cd /pinpoint-c-agent && pip install -e . | ||
|
||
# EXPOSE 8000 | ||
CMD [ "uvicorn", "main:app","--host=0.0.0.0","--port=8000","--reload" ] | ||
EXPOSE 80 | ||
CMD [ "python", "app.py" ] |
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,9 @@ | ||
composer.phar | ||
vendor | ||
.idea/ | ||
Cache | ||
__class_index_table | ||
*.ast | ||
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control | ||
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file | ||
composer.lock |
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,39 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: UTF-8 -*- | ||
|
||
|
||
import pymysql | ||
|
||
|
||
class DBControl(object): | ||
|
||
def __init__(self, ip, user, pw, db=None): | ||
self.ip = ip | ||
self.user = user | ||
self.pw = pw | ||
self.db = db | ||
self.conn = None | ||
self.cursor = None | ||
|
||
def con_db(self): | ||
if self.db is None: | ||
self.conn = pymysql.connect(host=self.ip, user=self.user, passwd=self.pw) | ||
else: | ||
self.conn = pymysql.connect(host=self.ip,user=self.user,passwd=self.pw, db=self.db) | ||
if self.conn is None: | ||
print("Connect to Database failed!") | ||
else: | ||
self.cursor = self.conn.cursor() | ||
|
||
def db_select(self, sql): | ||
self.cursor.execute(sql) | ||
result = self.cursor.fetchall() | ||
r = [] | ||
for res in result: | ||
r.append(res) | ||
return r | ||
|
||
def db_close(self): | ||
self.cursor.close() | ||
self.conn.commit() | ||
self.conn.close() |
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,32 @@ | ||
# 将pinpoint集成到Flask中 | ||
|
||
|
||
## 集成Pinpoint | ||
|
||
> 确保安装了pinpointPy模块。([如何安装pinpointPy模块](../../../DOC/PY/Readme-CN.md)) | ||
1. 将```pinpoint``` 目录复制到您项目的根目录, 将 PinPointMiddleWare 添加到您的应用程序中。 | ||
|
||
``` | ||
app = Flask(__name__) | ||
from PinPointMiddleWare import PinPointMiddleWare | ||
app.wsgi_app = PinPointMiddleWare(app,app.wsgi_app) | ||
...... | ||
``` | ||
2. 将[插件](../plugins)复制到```pinpoint``` 目录。 ```plugin``` 里的插件是一些示例,您也可以根据这些例子编写您自己的插件。 | ||
3. Hook 您所关心的函数。 | ||
> Example: flask/test_recursion.py | ||
Hook the function ```fact``` by add ```@PinpointCommonPlugin( __name__)``` just before it. | ||
``` | ||
from pinpointPy.CommonPlugin import PinpointCommonPlugin | ||
@PinpointCommonPlugin( __name__) | ||
def fact(n): | ||
...... | ||
``` | ||
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,32 @@ | ||
# Integrating Pinpoint Into Flask | ||
|
||
|
||
## Integrating pinpoint | ||
|
||
> Make sure pinpointPy module has been installed. ([How to Install pinpointPy module](../../../DOC/PY/Readme.md)) | ||
1. Copy ```pinpoint``` directory to your project root. Add PinPointMiddleWare to your application. | ||
|
||
``` | ||
app = Flask(__name__) | ||
from PinPointMiddleWare import PinPointMiddleWare | ||
app.wsgi_app = PinPointMiddleWare(app,app.wsgi_app) | ||
...... | ||
``` | ||
2. Copy [plugins](../plugins) to the ```pinpoint``` directory . Plugins in ```plugin``` are some examples, you can also write your own plugin according to these examples. | ||
3. Hook the function you cared. | ||
> Example: flask/test_recursion.py | ||
Hook the function ```fact``` by add ```@PinpointCommonPlugin('', __name__)``` just before it. | ||
``` | ||
from pinpointPy.CommonPlugin import PinpointCommonPlugin | ||
@PinpointCommonPlugin(__name__) | ||
def fact(n): | ||
...... | ||
``` | ||
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,26 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: UTF-8 -*- | ||
|
||
import redis | ||
|
||
|
||
class RedisControl(object): | ||
|
||
def __init__(self, host, port): | ||
self.host = host | ||
self.port = port | ||
self.conn = None | ||
|
||
def connection(self): | ||
self.conn = redis.Redis(host=self.host, port=self.port) | ||
|
||
def set(self, key, value): | ||
self.conn.set(key, value) | ||
return self.conn.get(key) | ||
|
||
def get(self, key): | ||
return "%s:%s" % (key, self.conn.get(key)) | ||
|
||
def delete(self, key): | ||
self.conn.delete(key) | ||
return "Delete %s success!" |
Empty file.
Oops, something went wrong.