You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(config): Make Metrics Server timeouts configurable (#114)
* chore(conductor): Add new track 'Fix Metrics Server Hardcoded Timeouts'
* feat(config): Add constants and fields for Metrics Server timeouts
* conductor(plan): Mark task 'Update config.go with new constants and fields' as complete
* feat(config): Implement validation and loading for Metrics Server timeouts
* conductor(checkpoint): Checkpoint end of Phase 1
* conductor(plan): Mark phase 'Configuration and Environment' as complete
* feat(http): Update NewDefaultMetricsServer to accept configurable timeouts
* feat(app): Integrate configurable metrics server timeouts into DI container
* conductor(checkpoint): Checkpoint end of Phases 2 & 3
* conductor(plan): Mark track 'Fix Metrics Server Hardcoded Timeouts' as complete
* chore(conductor): Mark track 'Fix Metrics Server Hardcoded Timeouts' as complete
* docs(conductor): Synchronize docs for track 'Fix Metrics Server Hardcoded Timeouts'
* chore(conductor): Archive track 'Fix Metrics Server Hardcoded Timeouts'
* feat(config): Make Metrics Server timeouts configurable
Previously, the Metrics Server used hardcoded timeout values (15s for Read/Write,
60s for Idle). This change introduces environment variables to allow these
timeouts to be configured, improving flexibility in different environments.
Changes:
- Added METRICS_SERVER_READ_TIMEOUT_SECONDS (default: 15s)
- Added METRICS_SERVER_WRITE_TIMEOUT_SECONDS (default: 15s)
- Added METRICS_SERVER_IDLE_TIMEOUT_SECONDS (default: 60s)
- Implemented validation for timeouts (1s to 300s range)
- Updated NewDefaultMetricsServer to accept custom timeout values
- Integrated configuration into the Dependency Injection container
- Updated .env.example with new configuration options
# Specification: Fix Metrics Server Hardcoded Timeouts (REVISED)
2
+
3
+
## Overview
4
+
The Metrics Server in the `secrets` project currently has hardcoded timeout values for Read, Write, and Idle connections (15s, 15s, 60s). This track aims to make these timeouts configurable via environment variables, following the existing configuration pattern.
***Config Update:** Update `internal/config/Config` struct in `internal/config/config.go` to include these new timeout fields.
14
+
***Validation:** Implement validation for these new timeouts (1s to 300s range).
15
+
***Default Values:** Set the default values to 15s/15s/60s in `internal/config/config.go`.
16
+
***.env.example Update:** Add these new environment variables to the `.env.example` file with their default values.
17
+
18
+
2.**Dependency Injection (DI) Integration:**
19
+
* Update `internal/app/Container.initMetricsServer` in `internal/app/di.go` to pass the new timeout values from the configuration to the `MetricsServer` initialization.
20
+
21
+
3.**Metrics Server Update:**
22
+
* Refactor `internal/http/metrics_server.go` to ensure `MetricsServer` uses values provided via DI instead of hardcoded defaults.
23
+
* Update `NewDefaultMetricsServer` or adjust its usage in `di.go` to honor the configured values.
24
+
25
+
## Non-Functional Requirements
26
+
***Consistency:** The configuration naming and validation logic must mirror the existing patterns for the main server.
27
+
28
+
## Acceptance Criteria
29
+
*[ ] New environment variables are successfully loaded into the `Config` struct.
30
+
*[ ] Configuration validation fails if any of the new timeouts are outside the 1s-300s range.
31
+
*[ ]`.env.example` is updated with the new environment variables.
32
+
*[ ] The Metrics Server uses the configured timeout values.
33
+
*[ ] Existing unit tests for `MetricsServer` and `Config` pass.
34
+
*[ ] New unit tests verify that the Metrics Server can be initialized with custom timeout values.
35
+
36
+
## Out of Scope
37
+
* Adding other Metrics Server configuration options.
38
+
* Changing the default values for the main server.
Copy file name to clipboardExpand all lines: conductor/tech-stack.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,7 @@
13
13
## Cryptography & Security
14
14
-**Envelope Encryption:**[gocloud.dev/secrets](https://gocloud.dev/howto/secrets/) - Abstracted access to various KMS providers for root-of-trust encryption.
15
15
-**Password Hashing:**[go-pwdhash](https://github.com/allisson/go-pwdhash) - Argon2id hashing for secure storage of client secrets and passwords.
16
+
-**Configurable Metrics Timeouts:** Environment-controlled Read, Write, and Idle timeouts for the Prometheus metrics server to prevent resource exhaustion.
16
17
-**Request Body Size Limiting:** Middleware to prevent DoS attacks from large payloads.
17
18
-**Rate Limiting:** Per-client and per-IP rate limiting middleware for DoS protection and API abuse prevention.
18
19
-**Secret Value Size Limiting:** Global limit on individual secret values to ensure predictable storage and memory usage.
0 commit comments