Skip to content

Commit be5b901

Browse files
authored
chore: Add link to documentation when config fails (#119)
* chore: Add link to documentation when config fails * docs: Improve instructions * chore: Update link to docs * chore: Cargo update * docs: Fix links * chore: Cargo update
1 parent 7841d26 commit be5b901

File tree

11 files changed

+84
-77
lines changed

11 files changed

+84
-77
lines changed

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ Testing is the responsibility of all contributors as such all contributions must
388388
389389
## Documentation
390390
391-
- See [User Documentation](https://docs.openzeppelin.com/monitor/0.1.0/).
391+
- See [User Documentation](https://docs.openzeppelin.com/monitor).
392392
393393
## Issue and Pull Request Labeling Guidelines
394394

Cargo.lock

+9-28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
In the rapidly evolving world of blockchain technology, effective monitoring is crucial for ensuring security and performance. OpenZeppelin Monitor is a blockchain monitoring service that watches for specific on-chain activities and triggers notifications based on configurable conditions. The service offers multi-chain support with configurable monitoring schedules, flexible trigger conditions, and an extensible architecture for adding new chains.
88

9-
[Install](https://docs.openzeppelin.com/monitor/0.1.0/#getting_started) | [User Docs](https://docs.openzeppelin.com/monitor/0.1.0/) | [Quickstart](https://docs.openzeppelin.com/monitor/0.1.0/quickstart) | [Crate Docs](https://docs.openzeppelin.com/monitor/0.1.0/rust_docs/doc/openzeppelin_monitor/)
9+
[Install](https://docs.openzeppelin.com/monitor#getting_started) | [User Docs](https://docs.openzeppelin.com/monitor) | [Quickstart](https://docs.openzeppelin.com/monitor/quickstart) | [Crate Docs](https://docs.openzeppelin.com/monitor/rust_docs/doc/openzeppelin_monitor/)
1010

1111
## Features
1212

@@ -33,11 +33,11 @@ In the rapidly evolving world of blockchain technology, effective monitoring is
3333

3434
### Installation
3535

36-
View the [Installation](https://docs.openzeppelin.com/monitor/0.1.0/#getting_started) documentation for detailed information. For a quicker introduction, check out the [Quickstart](https://docs.openzeppelin.com/monitor/0.1.0/quickstart) guide.
36+
View the [Installation](https://docs.openzeppelin.com/monitor#getting_started) documentation for detailed information. For a quicker introduction, check out the [Quickstart](https://docs.openzeppelin.com/monitor/quickstart) guide.
3737

3838
### Usage
3939

40-
View the [Usage](https://docs.openzeppelin.com/monitor/0.1.0/#running_the_monitor) documentation for more information.
40+
View the [Usage](https://docs.openzeppelin.com/monitor#running_the_monitor) documentation for more information.
4141

4242
## For Developers
4343

@@ -237,7 +237,7 @@ For security concerns, please refer to our [Security Policy](SECURITY.md).
237237

238238
## Get Help
239239

240-
If you have any questions, first see if the answer to your question can be found in the [User Documentation](https://docs.openzeppelin.com/monitor/0.1.0/).
240+
If you have any questions, first see if the answer to your question can be found in the [User Documentation](https://docs.openzeppelin.com/monitor).
241241

242242
If the answer is not there:
243243

docs/modules/ROOT/pages/index.adoc

+16-7
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ For detailed information about each directory and its contents, see xref:structu
149149

150150
== Installation
151151

152-
=== Option 1: Install Locally
152+
=== Run Locally
153153
. Clone the repository:
154154
+
155155
[source,bash]
@@ -162,21 +162,30 @@ cd openzeppelin-monitor
162162
+
163163
[source,bash]
164164
----
165-
cargo build
165+
cargo build --release
166+
----
167+
168+
. Move the binary to the project root (so that it can access the `./config` folder)
169+
+
170+
[source,bash]
171+
----
172+
mv ./target/release/openzeppelin-monitor .
166173
----
167174

168-
==== Run the CLI:
169175
. View available options:
170176
+
171177
[source,bash]
172178
----
173179
./openzeppelin-monitor --help
180+
181+
# Enable logging to file
182+
./openzeppelin-monitor --log-file
183+
184+
# Enable metrics server
185+
./openzeppelin-monitor --metrics
174186
----
175-
+
176-
. Use `--log-file` to enable file-based logging.
177-
. Use `--metrics` to enable the metrics server.
178187

179-
=== Option 2: Run with Docker
188+
=== Run with Docker
180189

181190
==== Basic Setup
182191

docs/modules/ROOT/pages/quickstart.adoc

+15-7
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ For details on the supported values see xref:index.adoc#basic_configuration[User
3838

3939
== Installation
4040

41-
=== Local Installation
41+
=== Run Locally
4242

4343
. Clone the repository:
4444
+
@@ -52,22 +52,30 @@ cd openzeppelin-monitor
5252
+
5353
[source,bash]
5454
----
55-
cargo build
55+
cargo build --release
5656
----
5757

58-
=== Standalone CLI Usage
58+
. Move the binary to the project root (so that it can access the `./config` folder)
59+
+
60+
[source,bash]
61+
----
62+
mv ./target/release/openzeppelin-monitor .
63+
----
5964

6065
. View available options:
6166
+
6267
[source,bash]
6368
----
6469
./openzeppelin-monitor --help
65-
----
6670
67-
. Enable logging to file with `--log-file`
68-
. Enable metrics server with `--metrics`
71+
# Enable logging to file
72+
./openzeppelin-monitor --log-file
73+
74+
# Enable metrics server
75+
./openzeppelin-monitor --metrics
76+
----
6977

70-
=== Docker Installation
78+
=== Run with Docker
7179

7280
==== Basic Setup
7381

docs/modules/ROOT/pages/rpc.adoc

+12-12
Original file line numberDiff line numberDiff line change
@@ -104,23 +104,23 @@ The retry policy can be customized using the `ExponentialBackoff` builder in the
104104

105105
[source,rust]
106106
----
107-
let retry_policy = ExponentialBackoff::builder()
108-
.base(2)
109-
.retry_bounds(Duration::from_millis(100), Duration::from_secs(4))
110-
.jitter(Jitter::None)
111-
.build_with_max_retries(2);
107+
let retry_policy = ExponentialBackoff::builder()
108+
.base(2)
109+
.retry_bounds(Duration::from_millis(100), Duration::from_secs(4))
110+
.jitter(Jitter::None)
111+
.build_with_max_retries(2);
112112
----
113113

114114
The retry policy can be customized with the following options:
115115

116116
[source,rust]
117117
----
118118
pub struct ExponentialBackoff {
119-
pub max_n_retries: Option<u32>, // Maximum number of allowed retries attempts.
120-
pub min_retry_interval: Duration, // Minimum waiting time between two retry attempts (it can end up being lower when using full jitter).
121-
pub max_retry_interval: Duration, // Maximum waiting time between two retry attempts.
122-
pub jitter: Jitter, // How we apply jitter to the calculated backoff intervals.
123-
pub base: u32, // Base of the exponential.
119+
pub max_n_retries: Option<u32>, // Maximum number of allowed retries attempts.
120+
pub min_retry_interval: Duration, // Minimum waiting time between two retry attempts (it can end up being lower when using full jitter).
121+
pub max_retry_interval: Duration, // Maximum waiting time between two retry attempts.
122+
pub jitter: Jitter, // How we apply jitter to the calculated backoff intervals.
123+
pub base: u32, // Base of the exponential.
124124
}
125125
----
126126

@@ -148,8 +148,8 @@ pub struct StellarTransportClient {
148148
[source,rust]
149149
----
150150
let client = ClientBuilder::new(reqwest::Client::new())
151-
.with(RetryTransientMiddleware::new_with_policy(retry_policy))
152-
.build();
151+
.with(RetryTransientMiddleware::new_with_policy(retry_policy))
152+
.build();
153153
----
154154

155155
=== Implementation Details

docs/modules/ROOT/pages/scripts.adoc

+10-6
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ Custom filter scripts allow you to apply additional conditions to matches detect
1515
=== Implementation Guide
1616

1717
1. Create a script in one of the supported languages:
18-
* Bash
19-
* Python
20-
* JavaScript
18+
* Bash
19+
* Python
20+
* JavaScript
2121

2222
2. Your script will receive a JSON object with the following structure:
23-
23+
* EVM
24+
+
2425
[source,json]
2526
----
26-
// Example for EVM MATCH
2727
{
2828
"args": ["--verbose"],
2929
"monitor_match": {
@@ -140,8 +140,12 @@ Custom filter scripts allow you to apply additional conditions to matches detect
140140
}
141141
}
142142
}
143+
----
143144

144-
// Example for STELLAR MATCH
145+
* Stellar
146+
+
147+
[source,json]
148+
----
145149
{
146150
"args": ["--verbose"],
147151
"monitor_match": {

src/main.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,21 @@ use crate::{
2929
create_block_handler, create_trigger_handler, has_active_monitors, initialize_services,
3030
Result,
3131
},
32-
models::Network,
32+
models::{BlockChainType, Network},
3333
repositories::{MonitorRepository, NetworkRepository, TriggerRepository},
3434
services::{
3535
blockchain::{ClientPool, ClientPoolTrait},
3636
blockwatcher::{BlockTracker, BlockTrackerTrait, BlockWatcherService, FileBlockStorage},
37+
trigger::TriggerExecutionServiceTrait,
38+
},
39+
utils::{
40+
constants::DOCUMENTATION_URL, logging::setup_logging,
41+
metrics::server::create_metrics_server,
3742
},
38-
utils::{logging::setup_logging, metrics::server::create_metrics_server},
3943
};
4044

4145
use clap::{Arg, Command};
4246
use dotenvy::dotenv;
43-
use models::BlockChainType;
44-
use services::trigger::TriggerExecutionServiceTrait;
4547
use std::env::{set_var, var};
4648
use std::sync::Arc;
4749
use tokio::sync::watch;
@@ -142,7 +144,8 @@ async fn main() -> Result<()> {
142144
MonitorRepository<NetworkRepository, TriggerRepository>,
143145
NetworkRepository,
144146
TriggerRepository,
145-
>(None, None, None)?;
147+
>(None, None, None)
148+
.map_err(|e| anyhow::anyhow!("Failed to initialize services: {}. Please refer to the documentation quickstart ({}) on how to configure the service.", e, DOCUMENTATION_URL))?;
146149

147150
// Check if metrics should be enabled from either CLI flag or env var
148151
let metrics_enabled =

src/utils/constants.rs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub const DOCUMENTATION_URL: &str = "https://docs.openzeppelin.com/monitor";

src/utils/mod.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,22 @@
33
//! This module provides various utility functions and types that are used across
44
//! the application. Currently includes:
55
//!
6+
//! - constants: Constants for the application
67
//! - cron_utils: Utilities for working with cron schedules and time intervals
7-
//! - error: Custom error type for more structured error handling
88
//! - expression: Utilities for working with cron expressions
99
//! - logging: Logging utilities
10+
//! - metrics: Metrics utilities
1011
//! - script: Utilities for working with scripts
1112
1213
mod cron_utils;
1314
mod expression;
15+
mod script;
16+
17+
pub mod constants;
1418
pub mod logging;
1519
pub mod metrics;
16-
mod script;
1720

21+
pub use constants::*;
1822
pub use cron_utils::*;
1923
pub use expression::*;
20-
pub use logging::*;
21-
pub use metrics::*;
2224
pub use script::*;

tests/integration/mocks/logging.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
//! - LOG_DATA_DIR: when using file mode, the path of the log file (default "logs/monitor.log")
77
//! Refer to `src/logging/mod.rs` for more details.
88
use chrono::Utc;
9-
use openzeppelin_monitor::utils::{
10-
compute_rolled_file_path,
11-
logging::{setup_logging, space_based_rolling},
9+
use openzeppelin_monitor::utils::logging::{
10+
compute_rolled_file_path, setup_logging, space_based_rolling,
1211
};
1312
use std::{
1413
env, fs,

0 commit comments

Comments
 (0)