You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/en/index.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,15 +10,16 @@ Fast, Asynchronous, Concurrent R Application Deployment
10
10
11
11
## Overview
12
12
13
-
Welcome to faucet, your high-performance solution for deploying Plumber APIs and Shiny Applications with speed and efficiency. faucet is a Rust-based server that offers Round Robinand IP Hash load balancing, ensuring seamless scaling and distribution of your R applications. Whether you're a data scientist, developer, or DevOps enthusiast, faucet simplifies deployment, making it easy to manage replicas and balance loads effectively.
13
+
Welcome to faucet, your high-performance solution for deploying Plumber APIs and Shiny Applications with speed and efficiency. faucet is a Rust-based server that offers Round Robin, IP Hash and Cookie Hash load balancing, ensuring seamless scaling and distribution of your R applications. Whether you're a data scientist, developer, or DevOps enthusiast, faucet simplifies deployment, making it easy to manage replicas and balance loads effectively.
14
14
15
15
## Features
16
16
17
17
-**High Performance:** faucet leverages Rust's speed for smooth and efficient execution of R applications.
18
-
-**Load Balancing:** Choose Round Robinor IP Hash load balancing for optimal resource utilization.
18
+
-**Load Balancing:** Choose Round Robin, IP Hash or Cookie Hash load balancing for optimal resource utilization.
19
19
-**Replicas:** Scale Plumber APIs and Shiny Applications effortlessly with multiple replicas.
20
20
-**Simplified Deployment:** faucet streamlines the deployment process for quick setup.
21
21
-**Asynchronous & Concurrent:** Utilizes asynchronous and concurrent processing for resource efficiency and responsive request handling.
22
+
-**Structured Event Tracing:** Gain deep insights into your Shiny applications with detailed, machine-readable logs stored directly in your database.
Copy file name to clipboardExpand all lines: docs/en/logging.md
+64Lines changed: 64 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,6 +46,70 @@ Worker logs are divided into two components: `stdout` and `stderr`.
46
46
level. The source is the worker who owns the underlying process. The message
47
47
is the line of output from the process.
48
48
49
+
## Event Tracing
50
+
51
+
Beyond basic logging, faucet allows you to emit structured "events" from your R Shiny applications. These events provide rich, machine-readable data about what's happening within your application, making it easier to monitor, debug, and analyze its behavior.
52
+
53
+
### Emitting Events from R (Shiny)
54
+
55
+
To send structured events from your Shiny application, use the `faucet` R package. It provides a set of logging functions that wrap the core event emission logic:
56
+
57
+
-`faucet::info()`: For general informational events.
58
+
-`faucet::warn()`: For non-critical issues or warnings.
59
+
-`faucet::error()`: For significant errors that require attention.
60
+
-`faucet::debug()`: For detailed debugging information (typically enabled during development).
61
+
-`faucet::trace()`: For very fine-grained operational details (most verbose).
62
+
63
+
Each of these functions allows you to specify a `message`, an optional `body` for additional data, and a `parent` event to link related actions.
64
+
65
+
**1. Logging a simple informational message**
66
+
67
+
Use the `message` argument for a human-readable description of the event. You can also use `glue` syntax for dynamic messages.
68
+
69
+
```/dev/null/example.R#L1-1
70
+
faucet::info("Application started successfully.")
71
+
```
72
+
73
+
This would generate a structured log entry containing:
74
+
- A unique `event_id` for this specific log.
75
+
-`level: "Info"` indicating it's an informational message.
76
+
-`message: "Application started successfully."`
77
+
78
+
**2. Including additional data with `body`**
79
+
80
+
The `body` argument accepts any R object that can be converted to JSON, such as a list. This is useful for attaching contextual data, diagnostics, or payload details to your events.
- The dynamic message: `"User abc-123 logged in"`.
88
+
- A `body` containing a list with `session_duration_minutes` and `ip_address`, allowing you to store specific metrics or details alongside the log message.
89
+
90
+
**3. Tracing a sequence of operations with `parent`**
91
+
92
+
You can link related events by passing the `event_id` of a previous event as the `parent` argument. This creates a "parent-child" relationship, helping you trace the flow of complex operations through your application.
93
+
94
+
```/dev/null/example.R#L1-2
95
+
event_id_start <- faucet::debug("Starting data retrieval from API.")
- The `debug` event marks the start of an operation, generating its own `event_id`.
102
+
- The subsequent `info` event related to completion will include the `event_id_start` as its `parent_event_id`, clearly indicating that it's a follow-up to the data retrieval initiation.
103
+
104
+
### Storing and Analyzing Event Data
105
+
106
+
All structured events emitted by your Shiny applications are automatically captured by faucet and stored in the `faucet_log_events` table within your PostgreSQL database. This enables you to:
107
+
108
+
-**Query and Filter**: Easily search for specific events based on `level`, `message` content, or data within the `body`.
109
+
-**Analyze Trends**: Track the frequency of certain events or errors over time.
110
+
-**Reconstruct User Journeys**: Use `event_id` and `parent_event_id` to trace a user's interactions or the execution flow of a specific request through your application.
111
+
-**Build Dashboards**: Use the structured data to create monitoring dashboards that provide real-time insights into your application's health and performance.
112
+
49
113
## Filtering logs
50
114
51
115
By default, faucet logs at the `INFO` level, which means that `ERROR`,
0 commit comments