pub struct Providers { /* private fields */ }Expand description
Lightweight client for provider operations without database.
This type provides access to provider-level operations (parsing, diagnostics) without requiring a full workspace with database indexing.
§When to use Providers vs Client
| Operation | Providers | Client |
|---|---|---|
| Parse log files | Yes | Yes (via .providers()) |
| Run diagnostics | Yes | Yes (via .system()) |
| Check/inspect files | Yes | Yes (via .system()) |
| List sessions | No | Yes |
| Query sessions | No | Yes |
| Watch events | No | Yes |
| Index operations | No | Yes |
Use Providers for:
- Quick file parsing without workspace setup
- Diagnostics on provider log directories
- CI/CD validation of log files
- Tools that only need read-only file access
Use Client for:
- Session browsing and querying
- Real-time event monitoring
- Full workspace operations
Implementations§
Source§impl Providers
impl Providers
Sourcepub fn detect() -> Result<Self>
pub fn detect() -> Result<Self>
Create with auto-detected providers from system paths.
Scans default log directories for each supported provider (Claude Code, Codex, Gemini) and enables those that exist.
§Examples
use agtrace_sdk::Providers;
let providers = Providers::detect()?;
println!("Detected {} providers", providers.list().len());Sourcepub fn with_config(config: Config) -> Self
pub fn with_config(config: Config) -> Self
Create with explicit configuration.
§Examples
use agtrace_sdk::{Providers, types::Config};
let config = Config::detect_providers()?;
let providers = Providers::with_config(config);Sourcepub fn builder() -> ProvidersBuilder
pub fn builder() -> ProvidersBuilder
Create a builder for fine-grained configuration.
§Examples
use agtrace_sdk::Providers;
let providers = Providers::builder()
.provider("claude_code", "/custom/.claude/projects")
.build()?;Sourcepub fn parse_auto(&self, path: &Path) -> Result<Vec<AgentEvent>>
pub fn parse_auto(&self, path: &Path) -> Result<Vec<AgentEvent>>
Parse a log file with auto-detected provider.
Automatically detects the appropriate provider based on file path and parses it into events.
§Examples
use agtrace_sdk::Providers;
use std::path::Path;
let providers = Providers::detect()?;
let events = providers.parse_auto(Path::new("/path/to/session.jsonl"))?;
for event in &events {
println!("{:?}", event.payload);
}Sourcepub fn parse_file(
&self,
path: &Path,
provider_name: &str,
) -> Result<Vec<AgentEvent>>
pub fn parse_file( &self, path: &Path, provider_name: &str, ) -> Result<Vec<AgentEvent>>
Parse a log file with a specific provider.
§Examples
use agtrace_sdk::Providers;
use std::path::Path;
let providers = Providers::detect()?;
let events = providers.parse_file(Path::new("/path/to/log.jsonl"), "claude_code")?;Sourcepub fn diagnose(&self) -> Result<Vec<DiagnoseResult>>
pub fn diagnose(&self) -> Result<Vec<DiagnoseResult>>
Run diagnostics on all configured providers.
Scans each provider’s log directory and reports parsing statistics.
§Examples
use agtrace_sdk::Providers;
let providers = Providers::detect()?;
let results = providers.diagnose()?;
for result in &results {
let success_rate = if result.total_files > 0 {
(result.successful as f64 / result.total_files as f64) * 100.0
} else {
100.0
};
println!("{}: {:.1}% success ({}/{})",
result.provider_name,
success_rate,
result.successful,
result.total_files);
}Sourcepub fn check_file(
&self,
path: &Path,
provider: Option<&str>,
) -> Result<CheckResult>
pub fn check_file( &self, path: &Path, provider: Option<&str>, ) -> Result<CheckResult>
Check if a file can be parsed.
§Examples
use agtrace_sdk::Providers;
use std::path::Path;
let providers = Providers::detect()?;
let result = providers.check_file(Path::new("/path/to/log.jsonl"), None)?;
println!("Status: {:?}", result.status);Sourcepub fn inspect_file(
path: &Path,
lines: usize,
json_format: bool,
) -> Result<InspectResult>
pub fn inspect_file( path: &Path, lines: usize, json_format: bool, ) -> Result<InspectResult>
Inspect raw file contents.
Returns the first N lines of the file, optionally parsed as JSON.
§Examples
use agtrace_sdk::Providers;
use std::path::Path;
let result = Providers::inspect_file(Path::new("/path/to/log.jsonl"), 10, true)?;
println!("Showing {} of {} lines", result.shown_lines, result.total_lines);Sourcepub fn list(&self) -> Vec<(&String, &ProviderConfig)>
pub fn list(&self) -> Vec<(&String, &ProviderConfig)>
List configured providers.
§Examples
use agtrace_sdk::Providers;
let providers = Providers::detect()?;
for (name, config) in providers.list() {
println!("{}: {:?}", name, config.log_root);
}Sourcepub fn provider_configs(&self) -> &[(String, PathBuf)]
pub fn provider_configs(&self) -> &[(String, PathBuf)]
Get provider configurations as (name, log_root) pairs.