xfy 4562dd5a7d docs: 添加子目录 AGENTS.md 文档
deepinit 生成的子目录级 AGENTS.md 文件,帮助 AI agents 理解各功能模块:
- docs/config/: advanced, basic, caching, load-balancing, lua, rewriting, security, ssl
- docs/lua/: api-gateway, authentication, caching, dynamic-routing, logging-monitoring, middleware, rate-limiting, websocket

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-23 10:35:49 +08:00

42 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!-- Parent: ../AGENTS.md -->
<!-- Generated: 2026-04-23 | Updated: 2026-04-23 -->
# logging-monitoring
## Purpose
日志和监控示例目录,演示如何使用 Lua 实现自定义日志格式、指标收集等监控功能。
## Key Files
| File | Description |
|------|-------------|
| `README.md` | 功能说明和使用指南 |
| `log_formatter.lua` | 日志格式化器:自定义日志格式、字段提取 |
| `metrics.lua` | 指标收集请求计数、延迟统计、Prometheus 格式 |
| `nginx.conf` | NGINX 配置示例:日志钩子集成 |
## For AI Agents
### Working In This Directory
- 日志格式支持 JSON、文本格式
- 指标可导出为 Prometheus 格式
- 支持请求级别的详细日志
- 监控数据可存储到共享字典
### Testing Requirements
- 日志和指标逻辑通过单元测试验证
- 测试日志格式、指标计算正确性
### Common Patterns
- 日志字段:`ngx.log(ngx.INFO, json.encode(log_entry))`
- 指标计数:`metrics_dict:incr("request_count")`
- Prometheus 格式:`# TYPE http_requests_total counter`
## Dependencies
### Internal
- `../../../internal/lua/` - Lua 脚本引擎
- `../../../internal/logging/` - 日志系统实现
<!-- MANUAL: -->