Expand description
§parse-mysql-slowlog streams a slow query and returns a stream of entries from slow logs
from your FramedReader
tokio input of choice.
§Example:
use futures::StreamExt;
use mysql_slowlog_parser::{CodecError, Entry, EntryCodec};
use std::ops::AddAssign;
use std::time::Instant;
use tokio::fs::File;
use tokio_util::codec::FramedRead;
#[tokio::main]
async fn main() {
let start = Instant::now();
let fr = FramedRead::with_capacity(
File::open("assets/slow-test-queries.log")
.await
.unwrap(),
EntryCodec::default(),
400000,
);
let mut i = 0;
let future = fr.for_each(|re: Result<Entry, CodecError>| async move {
let _ = re.unwrap();
i.add_assign(1);
});
future.await;
println!("parsed {} entries in: {}", i, start.elapsed().as_secs_f64());
}
Structs§
- Entry
- a struct representing a single log entry
- Entry
Admin Command - admin command values parsed from sql lines of an entry
- Entry
Call - struct containing details of how long the query took
- Entry
Codec - struct holding contextual information used while decoding
- Entry
Codec Config - Struct to pass along configuration values to codec
- Entry
Context - Values parsed from a query comment, these values are currently overly-specific
- Entry
Session - struct containing information about the connection where the query originated
- Entry
SqlAttributes - struct with information about the Entry’s SQL query
- Entry
SqlStatement Object - Database objects called from within a query
- Entry
Stats - struct with stats on how long a query took and number of rows examined
- Session
Line - values from the User: entry line ex. # User@Host: msandbox[msandbox] @ localhost [] Id: 3
- SqlStatement
Context - Struct containing information parsed from the initial comment in a SQL query
- Stats
Line - values parsed from stats entry line
- Time
Line - A struct holding a
DateTime
parsed from the Time: line of the entry ex:# Time: 2018-02-05T02:46:43.015898Z
Enums§
- Codec
Error - Errors for problems when reading frames from the source
- Entry
Error - Error when building an entry
- Entry
Masking - types of masking to apply when parsing SQL statements
- Entry
SqlType - The SQL statement type of the EntrySqlStatement.
- Entry
Statement - Types of possible statements parsed from the log:
- Read
Error - Error covering problems reading or parsing a log
- Reader
Build Error - errors that occur when building a Reader