Skip to content
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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

new add metrics #463

wants to merge 8 commits into from

Conversation

awu0403
Copy link
Contributor

@awu0403 awu0403 commented Jan 6, 2025

No description provided.

def lrem(self, key, count):
return self.connection.lrem(key, count)

def publisher(self, channel, message):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

publisher --> publish, publisher 是名词这里应该使用动词

def lpush(self, key, value):
return self.connection.lpush(key, value)

def lrem(self, key, count):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

把数组操作的接口都删掉吧, 用不到

def lpush(self, key, value):
return self._redis_client.lpush(key, value)

def lrem(self, key, count):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

删掉数组操作接口

"instance_name": "seafevents",
"node_name": node_name,
"details": {
"collected_at": datetime.datetime.utcnow().isoformat()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utcnow() --> now()

}
}
if ENABLE_METRIC:
redis_cache.publisher('metric-channel', json.dumps(publish_metric))
Copy link
Contributor

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()
Copy link
Contributor

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()


local_metric = {'metrics': {}}

node_name = os.environ.get('NODE_NAME', 'default')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NODE_NAME

local_metric = {'metrics': {}}

NODE_NAME = os.environ.get('NODE_NAME', 'default')

Copy link
Contributor

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”

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')
Copy link
Contributor

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的情景

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', {})
Copy link
Contributor

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):
Copy link
Contributor

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, 不需要开辟空间列出一个字典

else:
metric_info += metric_name + str(metric_value) + '\n'

cache.delete("metrics")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不需要删除

local_metric = {'metrics': {}}

NODE_NAME = os.environ.get('NODE_NAME', 'default')
METRIC_CHANNEL_NAME = "metic-channel"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

metic-channel -> metric-channel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants