sf-debug
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesesf-debug: Salesforce Debug Log Analysis & Troubleshooting
sf-debug: Salesforce调试日志分析与排障
Expert debugging engineer specializing in Apex debug log analysis, governor limit detection, performance optimization, and root cause analysis. Parse logs, identify issues, and automatically suggest fixes.
专业调试工程师,专注于Apex调试日志分析、Governor Limit检测、性能优化和根因分析。可解析日志、识别问题并自动给出修复建议。
Core Responsibilities
核心职责
- Log Analysis: Parse and analyze Apex debug logs for issues
- Governor Limit Detection: Identify SOQL, DML, CPU, and heap limit concerns
- Performance Analysis: Find slow queries, expensive operations, and bottlenecks
- Stack Trace Interpretation: Parse exceptions and identify root causes
- Agentic Fix Suggestions: Automatically suggest code fixes based on issues found
- Query Plan Analysis: Analyze SOQL query performance and selectivity
- 日志分析:解析并分析Apex调试日志以定位问题
- Governor Limit检测:识别SOQL、DML、CPU和堆内存限制相关问题
- 性能分析:查找慢查询、高开销操作和性能瓶颈
- 堆栈跟踪解析:解析异常并识别根本原因
- 智能修复建议:根据发现的问题自动给出代码修复建议
- 查询计划分析:分析SOQL查询的性能和选择性
Workflow (5-Phase Pattern)
工作流程(五阶段模式)
Phase 1: Log Collection
阶段1:日志收集
Use AskUserQuestion to gather:
- Debug context (deployment failure, test failure, runtime error, performance issue)
- Target org alias
- User/Transaction ID if known
- Time range of issue
Then:
- List available logs:
sf apex list log --target-org [alias] - Fetch specific log or tail real-time
- Create TodoWrite tasks
使用AskUserQuestion收集以下信息:
- 调试上下文(部署失败、测试失败、运行时错误、性能问题)
- 目标组织别名
- 已知的用户/事务ID
- 问题发生的时间范围
后续操作:
- 列出可用日志:
sf apex list log --target-org [alias] - 获取特定日志或实时追踪
- 创建TodoWrite任务
Phase 2: Log Retrieval
阶段2:日志获取
List Recent Logs:
bash
sf apex list log --target-org [alias] --jsonGet Specific Log:
bash
sf apex get log --log-id 07Lxx0000000000 --target-org [alias]Tail Logs Real-Time:
bash
sf apex tail log --target-org [alias] --colorSet Debug Level:
bash
sf apex log tail --debug-level FINE --target-org [alias]列出近期日志:
bash
sf apex list log --target-org [alias] --json获取特定日志:
bash
sf apex get log --log-id 07Lxx0000000000 --target-org [alias]实时追踪日志:
bash
sf apex tail log --target-org [alias] --color设置调试级别:
bash
sf apex log tail --debug-level FINE --target-org [alias]Phase 3: Log Analysis
阶段3:日志分析
Parse the debug log and analyze:
┌─────────────────────────────────────────────────────────────────┐
│ DEBUG LOG ANALYSIS │
├─────────────────────────────────────────────────────────────────┤
│ │
│ 1. EXECUTION OVERVIEW │
│ ├── Transaction type (trigger, flow, REST, batch) │
│ ├── Total execution time │
│ └── Entry point identification │
│ │
│ 2. GOVERNOR LIMIT ANALYSIS │
│ ├── SOQL Queries: X/100 │
│ ├── DML Statements: X/150 │
│ ├── DML Rows: X/10,000 │
│ ├── CPU Time: X ms /10,000 ms │
│ ├── Heap Size: X bytes /6,000,000 │
│ └── Callouts: X/100 │
│ │
│ 3. PERFORMANCE HOTSPOTS │
│ ├── Slowest SOQL queries (execution time) │
│ ├── Non-selective queries (full table scan) │
│ ├── Expensive operations (loops, iterations) │
│ └── External callout timing │
│ │
│ 4. EXCEPTIONS & ERRORS │
│ ├── Exception type │
│ ├── Stack trace │
│ ├── Line number │
│ └── Root cause identification │
│ │
│ 5. RECOMMENDATIONS │
│ ├── Immediate fixes │
│ ├── Optimization suggestions │
│ └── Architecture improvements │
│ │
└─────────────────────────────────────────────────────────────────┘解析调试日志并进行分析:
┌─────────────────────────────────────────────────────────────────┐
│ 调试日志分析 │
├─────────────────────────────────────────────────────────────────┤
│ │
│ 1. 执行概览 │
│ ├── 事务类型(触发器、流程、REST、批处理) │
│ ├── 总执行时间 │
│ └── 入口点识别 │
│ │
│ 2. Governor Limit分析 │
│ ├── SOQL查询:X/100 │
│ ├── DML语句:X/150 │
│ ├── DML行数:X/10,000 │
│ ├── CPU时间:X ms /10,000 ms │
│ ├── 堆内存:X bytes /6,000,000 │
│ └── 外部调用:X/100 │
│ │
│ 3. 性能热点 │
│ ├── 最慢的SOQL查询(执行时间) │
│ ├── 非选择性查询(全表扫描) │
│ ├── 高开销操作(循环、迭代) │
│ └── 外部调用耗时 │
│ │
│ 4. 异常与错误 │
│ ├── 异常类型 │
│ ├── 堆栈跟踪 │
│ ├── 行号 │
│ └── 根本原因识别 │
│ │
│ 5. 建议 │
│ ├── 即时修复方案 │
│ ├── 优化建议 │
│ └── 架构改进方案 │
│ │
└─────────────────────────────────────────────────────────────────┘Phase 4: Issue Identification & Fix Suggestions
阶段4:问题识别与修复建议
Governor Limit Analysis Decision Tree:
| Issue | Detection Pattern | Fix Strategy |
|---|---|---|
| SOQL in Loop | | Query before loop, use Map for lookups |
| DML in Loop | | Collect in List, single DML after loop |
| Non-Selective Query | | Add indexed filter or LIMIT |
| CPU Limit | | Optimize algorithms, use async |
| Heap Limit | | Reduce collection sizes, use FOR loops |
| Callout Limit | | Batch callouts, use Queueable |
Auto-Fix Command:
Skill(skill="sf-apex", args="Fix [issue type] in [ClassName] at line [lineNumber]")Governor Limit分析决策树:
| 问题 | 检测模式 | 修复策略 |
|---|---|---|
| 循环内SOQL | | 循环前查询,使用Map进行查找 |
| 循环内DML | | 收集到List中,循环后执行单次DML |
| 非选择性查询 | | 添加索引过滤条件或LIMIT |
| CPU限制 | | 优化算法,使用异步处理 |
| 堆内存限制 | | 减少集合大小,使用FOR循环 |
| 外部调用限制 | | 批量调用,使用Queueable |
自动修复命令:
Skill(skill="sf-apex", args="Fix [issue type] in [ClassName] at line [lineNumber]")Phase 5: Fix Implementation
阶段5:修复实施
- Generate fix using sf-apex skill
- Deploy fix using sf-deploy skill
- Verify fix by re-running and checking logs
- Report results
- 使用sf-apex技能生成修复代码
- 使用sf-deploy技能部署修复
- 重新运行并检查日志以验证修复效果
- 报告结果
Best Practices (100-Point Scoring)
最佳实践(百分制评分)
| Category | Points | Key Rules |
|---|---|---|
| Root Cause | 25 | Correctly identify the actual cause, not symptoms |
| Fix Accuracy | 25 | Suggested fix addresses the root cause |
| Performance Impact | 20 | Fix improves performance, doesn't introduce new issues |
| Completeness | 15 | All related issues identified, not just the first one |
| Clarity | 15 | Explanation is clear and actionable |
Scoring Thresholds:
⭐⭐⭐⭐⭐ 90-100 pts → Expert analysis with optimal fix
⭐⭐⭐⭐ 80-89 pts → Good analysis, effective fix
⭐⭐⭐ 70-79 pts → Acceptable analysis, partial fix
⭐⭐ 60-69 pts → Basic analysis, may miss issues
⭐ <60 pts → Incomplete analysis| 类别 | 分值 | 核心规则 |
|---|---|---|
| 根本原因 | 25 | 准确识别根本原因,而非表面症状 |
| 修复准确性 | 25 | 建议的修复方案针对根本原因 |
| 性能影响 | 20 | 修复提升性能,不引入新问题 |
| 完整性 | 15 | 识别所有相关问题,而非仅第一个问题 |
| 清晰度 | 15 | 解释清晰且可执行 |
评分阈值:
⭐⭐⭐⭐⭐ 90-100分 → 专家级分析,最优修复方案
⭐⭐⭐⭐ 80-89分 → 良好分析,有效修复方案
⭐⭐⭐ 70-79分 → 合格分析,部分修复方案
⭐⭐ 60-69分 → 基础分析,可能遗漏问题
⭐ <60分 → 不完整分析Debug Log Anatomy
调试日志结构
Log Structure
日志格式
XX.X (XXXXX)|TIMESTAMP|EVENT_TYPE|[PARAMS]|DETAILSXX.X (XXXXX)|时间戳|事件类型|[参数]|详情Key Event Types
关键事件类型
| Event | Meaning | Important For |
|---|---|---|
| Transaction begins | Context identification |
| Method/trigger entry | Call stack tracing |
| Query starts | Query analysis |
| Query ends | Query timing |
| DML starts | DML analysis |
| DML ends | DML timing |
| Exception occurs | Error detection |
| Transaction fails | Critical issues |
| Limit snapshot | Governor limits |
| Heap allocation | Memory issues |
| CPU time used | Performance |
| Callout starts | External calls |
| 事件 | 含义 | 适用场景 |
|---|---|---|
| 事务开始 | 上下文识别 |
| 方法/触发器入口 | 调用栈追踪 |
| 查询开始 | 查询分析 |
| 查询结束 | 查询耗时分析 |
| DML开始 | DML分析 |
| DML结束 | DML耗时分析 |
| 发生异常 | 错误检测 |
| 事务失败 | 严重问题 |
| 限制快照 | Governor Limits监控 |
| 堆内存分配 | 内存问题分析 |
| 已用CPU时间 | 性能分析 |
| 外部调用开始 | 外部调用分析 |
Log Levels
日志级别
| Level | Shows |
|---|---|
| NONE | Nothing |
| ERROR | Errors only |
| WARN | Warnings and errors |
| INFO | General info (default) |
| DEBUG | Detailed debug info |
| FINE | Very detailed |
| FINER | Method entry/exit |
| FINEST | Everything |
| 级别 | 显示内容 |
|---|---|
| NONE | 无内容 |
| ERROR | 仅错误信息 |
| WARN | 警告和错误信息 |
| INFO | 常规信息(默认) |
| DEBUG | 详细调试信息 |
| FINE | 非常详细的信息 |
| FINER | 方法入口/出口 |
| FINEST | 所有信息 |
Common Issues & Solutions
常见问题与解决方案
1. SOQL Query in Loop
1. 循环内SOQL查询
Detection:
|SOQL_EXECUTE_BEGIN|[line 45]
|SOQL_EXECUTE_END|[1 row]
... (repeats 50+ times)Analysis Output:
🔴 CRITICAL: SOQL Query in Loop Detected
Location: AccountService.cls, line 45
Impact: 50 queries executed, approaching 100 limit
Pattern: SELECT inside for loop
📝 RECOMMENDED FIX:
Move query BEFORE loop, use Map for lookups:
// Before (problematic)
for (Account acc : accounts) {
Contact c = [SELECT Id FROM Contact WHERE AccountId = :acc.Id LIMIT 1];
}
// After (bulkified)
Map<Id, Contact> contactsByAccount = new Map<Id, Contact>();
for (Contact c : [SELECT Id, AccountId FROM Contact WHERE AccountId IN :accountIds]) {
contactsByAccount.put(c.AccountId, c);
}
for (Account acc : accounts) {
Contact c = contactsByAccount.get(acc.Id);
}检测特征:
|SOQL_EXECUTE_BEGIN|[line 45]
|SOQL_EXECUTE_END|[1 row]
... (重复50次以上)分析输出:
🔴 严重:检测到循环内SOQL查询
位置:AccountService.cls,第45行
影响:已执行50次查询,接近100次限制
模式:FOR循环内包含SELECT语句
📝 推荐修复方案:
将查询移至循环前,使用Map进行查找:
// 修复前(存在问题)
for (Account acc : accounts) {
Contact c = [SELECT Id FROM Contact WHERE AccountId = :acc.Id LIMIT 1];
}
// 修复后(批量处理)
Map<Id, Contact> contactsByAccount = new Map<Id, Contact>();
for (Contact c : [SELECT Id, AccountId FROM Contact WHERE AccountId IN :accountIds]) {
contactsByAccount.put(c.AccountId, c);
}
for (Account acc : accounts) {
Contact c = contactsByAccount.get(acc.Id);
}2. Non-Selective Query
2. 非选择性查询
Detection:
|SOQL_EXECUTE_BEGIN|[line 23]|SELECT Id FROM Lead WHERE Status = 'Open'
|SOQL_EXECUTE_END|[250000 rows queried]Analysis Output:
🟠 WARNING: Non-Selective Query Detected
Location: LeadService.cls, line 23
Rows Scanned: 250,000
Filter Field: Status (not indexed)
📝 RECOMMENDED FIX:
Option 1: Add indexed field to WHERE clause
Option 2: Create custom index on Status field
Option 3: Add LIMIT clause if not all records needed
// Before
List<Lead> leads = [SELECT Id FROM Lead WHERE Status = 'Open'];
// After (with additional selective filter)
List<Lead> leads = [SELECT Id FROM Lead
WHERE Status = 'Open'
AND CreatedDate = LAST_N_DAYS:30
LIMIT 10000];检测特征:
|SOQL_EXECUTE_BEGIN|[line 23]|SELECT Id FROM Lead WHERE Status = 'Open'
|SOQL_EXECUTE_END|[250000 rows queried]分析输出:
🟠 警告:检测到非选择性查询
位置:LeadService.cls,第23行
扫描行数:250,000
过滤字段:Status(未建立索引)
📝 推荐修复方案:
选项1:在WHERE子句中添加带索引的字段
选项2:为Status字段创建自定义索引
选项3:如果不需要所有记录,添加LIMIT子句
// 修复前
List<Lead> leads = [SELECT Id FROM Lead WHERE Status = 'Open'];
// 修复后(添加额外选择性过滤)
List<Lead> leads = [SELECT Id FROM Lead
WHERE Status = 'Open'
AND CreatedDate = LAST_N_DAYS:30
LIMIT 10000];3. CPU Time Limit
3. CPU时间限制
Detection:
|LIMIT_USAGE_FOR_NS|CPU_TIME|9500|10000Analysis Output:
🔴 CRITICAL: CPU Time Limit Approaching (95%)
Used: 9,500 ms
Limit: 10,000 ms (sync) / 60,000 ms (async)
📝 ANALYSIS:
Top CPU consumers:
1. StringUtils.formatAll() - 3,200 ms (line 89)
2. CalculationService.compute() - 2,800 ms (line 156)
3. ValidationHelper.validateAll() - 1,500 ms (line 45)
📝 RECOMMENDED FIX:
1. Move heavy computation to @future or Queueable
2. Optimize algorithms (O(n²) → O(n))
3. Cache repeated calculations
4. Use formula fields instead of Apex where possible检测特征:
|LIMIT_USAGE_FOR_NS|CPU_TIME|9500|10000分析输出:
🔴 严重:CPU时间限制接近阈值(95%)
已使用:9,500 ms
限制:10,000 ms(同步)/ 60,000 ms(异步)
📝 分析:
CPU消耗Top3:
1. StringUtils.formatAll() - 3,200 ms(第89行)
2. CalculationService.compute() - 2,800 ms(第156行)
3. ValidationHelper.validateAll() - 1,500 ms(第45行)
📝 推荐修复方案:
1. 将重计算逻辑移至@future或Queueable
2. 优化算法(从O(n²)优化为O(n))
3. 缓存重复计算结果
4. 尽可能使用公式字段替代Apex逻辑4. Heap Size Limit
4. 堆内存限制
Detection:
|HEAP_ALLOCATE|[5800000]
|LIMIT_USAGE_FOR_NS|HEAP_SIZE|5800000|6000000Analysis Output:
🔴 CRITICAL: Heap Size Limit Approaching (97%)
Used: 5.8 MB
Limit: 6 MB (sync) / 12 MB (async)
📝 ANALYSIS:
Large allocations detected:
1. Line 34: List<Account> - 2.1 MB (50,000 records)
2. Line 78: Map<Id, String> - 1.8 MB
3. Line 112: String concatenation - 1.2 MB
📝 RECOMMENDED FIX:
1. Use SOQL FOR loops instead of querying all at once
2. Process in batches of 200 records
3. Use transient keyword for variables not needed in view state
4. Clear collections when no longer needed
// Before
List<Account> allAccounts = [SELECT Id, Name FROM Account];
// After (SOQL FOR loop - doesn't load all into heap)
for (Account acc : [SELECT Id, Name FROM Account]) {
// Process one at a time
}检测特征:
|HEAP_ALLOCATE|[5800000]
|LIMIT_USAGE_FOR_NS|HEAP_SIZE|5800000|6000000分析输出:
🔴 严重:堆内存限制接近阈值(97%)
已使用:5.8 MB
限制:6 MB(同步)/ 12 MB(异步)
📝 分析:
检测到大内存分配:
1. 第34行:List<Account> - 2.1 MB(50,000条记录)
2. 第78行:Map<Id, String> - 1.8 MB
3. 第112行:字符串拼接 - 1.2 MB
📝 推荐修复方案:
1. 使用SOQL FOR循环替代一次性查询所有记录
2. 按200条记录批量处理
3. 对视图状态中不需要的变量使用transient关键字
4. 不再需要时清空集合
// 修复前
List<Account> allAccounts = [SELECT Id, Name FROM Account];
// 修复后(SOQL FOR循环 - 不会将所有记录加载到堆内存)
for (Account acc : [SELECT Id, Name FROM Account]) {
// 逐个处理记录
}5. Exception Analysis
5. 异常分析
Detection:
|EXCEPTION_THROWN|[line 67]|System.NullPointerException: Attempt to de-reference a null object
|FATAL_ERROR|System.NullPointerException: Attempt to de-reference a null objectAnalysis Output:
🔴 EXCEPTION: System.NullPointerException
Location: ContactService.cls, line 67
Message: Attempt to de-reference a null object
📝 STACK TRACE ANALYSIS:
ContactService.getContactDetails() - line 67
└── AccountController.loadData() - line 34
└── trigger AccountTrigger - line 5
📝 ROOT CAUSE:
Variable 'contact' is null when accessing 'contact.Email'
Likely scenario: Query returned no results
📝 RECOMMENDED FIX:
// Before
Contact contact = [SELECT Email FROM Contact WHERE AccountId = :accId LIMIT 1];
String email = contact.Email; // FAILS if no contact found
// After (null-safe)
List<Contact> contacts = [SELECT Email FROM Contact WHERE AccountId = :accId LIMIT 1];
String email = contacts.isEmpty() ? null : contacts[0].Email;
// Or using safe navigation (API 62.0+)
Contact contact = [SELECT Email FROM Contact WHERE AccountId = :accId LIMIT 1];
String email = contact?.Email;检测特征:
|EXCEPTION_THROWN|[line 67]|System.NullPointerException: Attempt to de-reference a null object
|FATAL_ERROR|System.NullPointerException: Attempt to de-reference a null object分析输出:
🔴 异常:System.NullPointerException
位置:ContactService.cls,第67行
信息:尝试引用空对象
📝 堆栈跟踪分析:
ContactService.getContactDetails() - 第67行
└── AccountController.loadData() - 第34行
└── trigger AccountTrigger - 第5行
📝 根本原因:
访问'contact.Email'时变量'contact'为空
可能场景:查询未返回结果
📝 推荐修复方案:
// 修复前
Contact contact = [SELECT Email FROM Contact WHERE AccountId = :accId LIMIT 1];
String email = contact.Email; // 无联系人时会失败
// 修复后(空安全)
List<Contact> contacts = [SELECT Email FROM Contact WHERE AccountId = :accId LIMIT 1];
String email = contacts.isEmpty() ? null : contacts[0].Email;
// 或使用安全导航(API 62.0+)
Contact contact = [SELECT Email FROM Contact WHERE AccountId = :accId LIMIT 1];
String email = contact?.Email;CLI Command Reference
CLI命令参考
Log Management
日志管理
| Command | Purpose |
|---|---|
| List available logs |
| Download specific log |
| Stream logs real-time |
| Delete logs |
| 命令 | 用途 |
|---|---|
| 列出可用日志 |
| 下载特定日志 |
| 实时流式查看日志 |
| 删除日志 |
Debug Level Control
调试级别控制
bash
undefinedbash
undefinedCreate trace flag for user
为用户创建跟踪标记
sf data create record
--sobject TraceFlag
--values "TracedEntityId='005xx000000000' LogType='USER_DEBUG' DebugLevelId='7dlxx000000000' StartDate='2024-01-01T00:00:00' ExpirationDate='2024-01-02T00:00:00'"
--target-org my-sandbox
--sobject TraceFlag
--values "TracedEntityId='005xx000000000' LogType='USER_DEBUG' DebugLevelId='7dlxx000000000' StartDate='2024-01-01T00:00:00' ExpirationDate='2024-01-02T00:00:00'"
--target-org my-sandbox
sf data create record
--sobject TraceFlag
--values "TracedEntityId='005xx000000000' LogType='USER_DEBUG' DebugLevelId='7dlxx000000000' StartDate='2024-01-01T00:00:00' ExpirationDate='2024-01-02T00:00:00'"
--target-org my-sandbox
--sobject TraceFlag
--values "TracedEntityId='005xx000000000' LogType='USER_DEBUG' DebugLevelId='7dlxx000000000' StartDate='2024-01-01T00:00:00' ExpirationDate='2024-01-02T00:00:00'"
--target-org my-sandbox
Set default debug level
设置默认调试级别
sf config set org-api-version=62.0
undefinedsf config set org-api-version=62.0
undefinedQuery Plan Analysis
查询计划分析
bash
undefinedbash
undefinedUse Developer Console or Tooling API
使用开发者控制台或Tooling API
sf data query
--query "SELECT Id FROM Account WHERE Name = 'Test'"
--target-org my-sandbox
--use-tooling-api
--plan
--query "SELECT Id FROM Account WHERE Name = 'Test'"
--target-org my-sandbox
--use-tooling-api
--plan
---sf data query
--query "SELECT Id FROM Account WHERE Name = 'Test'"
--target-org my-sandbox
--use-tooling-api
--plan
--query "SELECT Id FROM Account WHERE Name = 'Test'"
--target-org my-sandbox
--use-tooling-api
--plan
---Agentic Debug Loop
智能调试循环
When enabled, sf-debug will automatically:
┌─────────────────────────────────────────────────────────────────┐
│ AGENTIC DEBUG LOOP │
├─────────────────────────────────────────────────────────────────┤
│ │
│ 1. Fetch debug logs from the failing operation │
│ 2. Parse logs and identify all issues │
│ 3. Prioritize issues by severity: │
│ 🔴 Critical: Limits exceeded, exceptions │
│ 🟠 Warning: Approaching limits, slow queries │
│ 🟡 Info: Optimization opportunities │
│ 4. For each critical issue: │
│ a. Read the source file at identified line │
│ b. Generate fix using sf-apex skill │
│ c. Deploy fix using sf-deploy skill │
│ d. Re-run operation and check new logs │
│ 5. Report final status and remaining warnings │
│ │
└─────────────────────────────────────────────────────────────────┘启用后,sf-debug将自动执行以下流程:
┌─────────────────────────────────────────────────────────────────┐
│ 智能调试循环 │
├─────────────────────────────────────────────────────────────────┤
│ │
│ 1. 从失败操作中获取调试日志 │
│ 2. 解析日志并识别所有问题 │
│ 3. 按优先级排序问题: │
│ 🔴 严重:超出限制、异常 │
│ 🟠 警告:接近限制、慢查询 │
│ 🟡 信息:优化机会 │
│ 4. 针对每个严重问题: │
│ a. 读取指定行的源文件 │
│ b. 使用sf-apex技能生成修复代码 │
│ c. 使用sf-deploy技能部署修复 │
│ d. 重新运行操作并检查新日志 │
│ 5. 报告最终状态和剩余警告 │
│ │
└─────────────────────────────────────────────────────────────────┘Cross-Skill Integration
跨技能集成
| Skill | When to Use | Example |
|---|---|---|
| sf-apex | Generate fixes for identified issues | |
| sf-testing | Run tests to reproduce issues | |
| sf-deploy | Deploy fixes | |
| sf-data | Create test data for debugging | |
| 技能 | 使用场景 | 示例 |
|---|---|---|
| sf-apex | 为识别的问题生成修复代码 | |
| sf-testing | 运行测试以重现问题 | |
| sf-deploy | 部署修复代码 | |
| sf-data | 创建调试用测试数据 | |
Performance Benchmarks
性能基准
Healthy Limits
健康限制阈值
| Resource | Warning Threshold | Critical Threshold |
|---|---|---|
| SOQL Queries | 80/100 (80%) | 95/100 (95%) |
| DML Statements | 120/150 (80%) | 145/150 (97%) |
| CPU Time | 8,000/10,000 ms | 9,500/10,000 ms |
| Heap Size | 4.8/6 MB | 5.7/6 MB |
| Callouts | 80/100 | 95/100 |
| 资源 | 警告阈值 | 严重阈值 |
|---|---|---|
| SOQL查询 | 80/100(80%) | 95/100(95%) |
| DML语句 | 120/150(80%) | 145/150(97%) |
| CPU时间 | 8,000/10,000 ms | 9,500/10,000 ms |
| 堆内存 | 4.8/6 MB | 5.7/6 MB |
| 外部调用 | 80/100 | 95/100 |
Query Performance
查询性能
| Category | Acceptable | Needs Optimization |
|---|---|---|
| Query Time | < 100ms | > 500ms |
| Rows Scanned | < 10,000 | > 100,000 |
| Selectivity | Indexed filter | Full table scan |
| 类别 | 可接受范围 | 需要优化 |
|---|---|---|
| 查询时间 | < 100ms | > 500ms |
| 扫描行数 | < 10,000 | > 100,000 |
| 选择性 | 使用索引过滤 | 全表扫描 |
Documentation
文档
| Document | Description |
|---|---|
| debug-log-reference.md | Complete debug log event reference |
| cli-commands.md | SF CLI debugging commands |
| benchmarking-guide.md | Dan Appleman's technique, real-world benchmarks |
| log-analysis-tools.md | Apex Log Analyzer, manual analysis patterns |
| 文档 | 描述 |
|---|---|
| debug-log-reference.md | 完整的调试日志事件参考 |
| cli-commands.md | SF CLI调试命令参考 |
| benchmarking-guide.md | Dan Appleman的技术、真实场景基准测试 |
| log-analysis-tools.md | Apex日志分析器、手动分析模式 |
Templates
模板
| Template | Description |
|---|---|
| cpu-heap-optimization.cls | CPU and heap optimization patterns |
| benchmarking-template.cls | Ready-to-run benchmark comparisons |
| soql-in-loop-fix.cls | SOQL bulkification pattern |
| dml-in-loop-fix.cls | DML bulkification pattern |
| null-pointer-fix.cls | Null-safe patterns |
| 模板 | 描述 |
|---|---|
| cpu-heap-optimization.cls | CPU和堆内存优化模式 |
| benchmarking-template.cls | 可直接运行的基准测试对比模板 |
| soql-in-loop-fix.cls | SOQL批量处理模式 |
| dml-in-loop-fix.cls | DML批量处理模式 |
| null-pointer-fix.cls | 空安全模式 |
Credits
致谢
See CREDITS.md for acknowledgments of community resources that shaped this skill.
详见CREDITS.md,感谢为该技能提供支持的社区资源。
Dependencies
依赖项
Required: Target org with CLI authenticated
Recommended: sf-apex (for auto-fix), sf-testing (for reproduction), sf-deploy (for deploying fixes)
sfInstall:
/plugin install github:Jaganpro/sf-skills/sf-debug必需条件:已通过 CLI认证的目标组织
推荐:sf-apex(用于自动修复)、sf-testing(用于问题重现)、sf-deploy(用于部署修复)
sf安装:
/plugin install github:Jaganpro/sf-skills/sf-debugLicense
许可证
MIT License. See LICENSE file.
Copyright (c) 2024-2025 Jag Valaiyapathy
MIT许可证。详见LICENSE文件。
版权所有 (c) 2024-2025 Jag Valaiyapathy