-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new add metrics #463
base: master
Are you sure you want to change the base?
new add metrics #463
Conversation
app/event_redis.py
Outdated
def lrem(self, key, count): | ||
return self.connection.lrem(key, count) | ||
|
||
def publisher(self, channel, message): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
publisher --> publish, publisher 是名词这里应该使用动词
app/event_redis.py
Outdated
def lpush(self, key, value): | ||
return self.connection.lpush(key, value) | ||
|
||
def lrem(self, key, count): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
把数组操作的接口都删掉吧, 用不到
app/event_redis.py
Outdated
def lpush(self, key, value): | ||
return self._redis_client.lpush(key, value) | ||
|
||
def lrem(self, key, count): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
删掉数组操作接口
events/metrics.py
Outdated
"instance_name": "seafevents", | ||
"node_name": node_name, | ||
"details": { | ||
"collected_at": datetime.datetime.utcnow().isoformat() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utcnow() --> now()
seafevent_server/request_handler.py
Outdated
} | ||
} | ||
if ENABLE_METRIC: | ||
redis_cache.publisher('metric-channel', json.dumps(publish_metric)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这种重复的逻辑在外部增加一个函数, def publish_io_qsize_metric(qsize)
app/app.py
Outdated
@@ -38,6 +39,10 @@ def __init__(self, config, seafile_config, | |||
self._file_updates_sender = FileUpdatesSender() | |||
self._repo_old_file_auto_del_scanner = RepoOldFileAutoDelScanner(config) | |||
self._deleted_files_count_cleaner = DeletedFilesCountCleaner(config) | |||
if ENABLE_METRIC: | |||
self._metric_collect = MetricRedisRecord() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
改一下名字, self._metric_redis_recorder = MetricRedisRecorder()
events/metrics.py
Outdated
|
||
local_metric = {'metrics': {}} | ||
|
||
node_name = os.environ.get('NODE_NAME', 'default') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NODE_NAME
events/metrics.py
Outdated
local_metric = {'metrics': {}} | ||
|
||
NODE_NAME = os.environ.get('NODE_NAME', 'default') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
METRIC_CHANNEL_NAME= “metic-channel”
events/metrics.py
Outdated
if message is not None: | ||
metric_data = json.loads(message['data']) | ||
try: | ||
key_name = metric_data.get('instance_name') + ':' + metric_data.get('node_name') + ':' + metric_data.get('metric_name') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
metric_data.get('node_name'), 需要处理一下, 没有node_name的key时为default的情景
events/metrics.py
Outdated
metric_data = json.loads(message['data']) | ||
try: | ||
key_name = metric_data.get('instance_name') + ':' + metric_data.get('node_name') + ':' + metric_data.get('metric_name') | ||
metric_details = metric_data.get('details', {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
metric_data.get('details') or {}
|
||
app = Flask(__name__) | ||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def publish_io_qsize_metric(qsize): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里先判断, if not ENABLE_METRIC: return, 不需要开辟空间列出一个字典
events/metrics.py
Outdated
else: | ||
metric_info += metric_name + str(metric_value) + '\n' | ||
|
||
cache.delete("metrics") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不需要删除
events/metrics.py
Outdated
local_metric = {'metrics': {}} | ||
|
||
NODE_NAME = os.environ.get('NODE_NAME', 'default') | ||
METRIC_CHANNEL_NAME = "metic-channel" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
metic-channel -> metric-channel
No description provided.