Add More examples (#133)

* add goroutine text

* update

* fix funclatency

* update doc

* update about nginx

* update nginx

* u[date co

* fix compile

* update

* fix
This commit is contained in:
云微
2024-09-02 06:38:39 +00:00
committed by GitHub
parent 9c2bba3e16
commit 2f3ed55972
5 changed files with 258 additions and 6 deletions

View File

@@ -0,0 +1,30 @@
#!/usr/bin/env bpftrace
// Trace the dispatch_command function in MySQL
uprobe:/usr/sbin/mysqld:dispatch_command
{
// Store the start time of the command execution in the map
@start_times[tid] = nsecs;
// Print the process ID and command string
printf("MySQL command executed by PID %d: ", pid);
// The third argument to dispatch_command is the SQL query string
printf("%s\n", str(arg3));
}
uretprobe:/usr/sbin/mysqld:dispatch_command
{
// Retrieve the start time from the map
$start = @start_times[tid];
// Calculate the latency in milliseconds
$delta = (nsecs - $start) / 1000000;
// Print the latency
printf("Latency: %u ms\n", $delta);
// Delete the entry from the map to avoid memory leaks
delete(@start_times[tid]);
}