Skip to main content

Providers

Struct Providers 

Source
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

OperationProvidersClient
Parse log filesYesYes (via .providers())
Run diagnosticsYesYes (via .system())
Check/inspect filesYesYes (via .system())
List sessionsNoYes
Query sessionsNoYes
Watch eventsNoYes
Index operationsNoYes

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

Source

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());
Source

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);
Source

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()?;
Source

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);
}
Source

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")?;
Source

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);
}
Source

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);
Source

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);
Source

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);
}
Source

pub fn config(&self) -> &Config

Get current configuration.

Source

pub fn provider_configs(&self) -> &[(String, PathBuf)]

Get provider configurations as (name, log_root) pairs.

Trait Implementations§

Source§

impl Clone for Providers

Source§

fn clone(&self) -> Providers

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.