Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 15, 2025

Hardcoded cache sizes (500, 5000) in src/metrics.py are now configurable.

Changes

  • src/config.py: Add MetricsConfig class with three cache size parameters
  • src/metrics.py: Replace hardcoded values with config lookups
  • env.example: Document new environment variables

New Environment Variables

Variable Default Description
METRICS_RESPONSE_TIMES_CACHE_SIZE 500 API response times cache
METRICS_DOC_METRICS_CACHE_SIZE 5000 Document metrics cache
METRICS_ALERTS_CACHE_SIZE 500 Alerts cache

Usage

# Before: hardcoded
if len(metrics.response_times) > 1000:
    metrics.response_times = metrics.response_times[-500:]

# After: configurable
cache_size = get_config().metrics.response_times_cache_size
if len(metrics.response_times) > cache_size * 2:
    metrics.response_times = metrics.response_times[-cache_size:]
Original prompt

This section details on the original issue you should resolve

<issue_title>Metrics cache sizes hardcoded</issue_title>
<issue_description>## 问题描述
缓存大小硬编码。

受影响的文件

  • src/metrics.py 行 112, 132, 178

硬编码的缓存大小

  • 500
  • 5000

解决方案

应该配置以下环境变量:

  • METRICS_RESPONSE_TIMES_CACHE_SIZE 等</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: BukeLy <19304666+BukeLy@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix hardcoded metrics cache sizes in code feat: Make metrics cache sizes configurable via environment variables Dec 15, 2025
Copilot AI requested a review from BukeLy December 15, 2025 09:51
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.

Metrics cache sizes hardcoded

2 participants