Skip to content

Commit 087495f

Browse files
authored
Merge pull request #28 from omnia-network/chore/docs
chore: update readme and arguments docs
2 parents 6ec44e9 + 03b366c commit 087495f

File tree

2 files changed

+29
-35
lines changed

2 files changed

+29
-35
lines changed

README.md

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,29 @@ Make sure you have the **Rust toolchain** installed. You can find instructions [
1515
## Standalone
1616

1717
1. Run the gateway:
18-
```
18+
19+
In **debug** mode:
20+
```bash
1921
cargo run
2022
```
21-
2. After the gateway starts, it prints something like:
23+
In **release** mode:
24+
```bash
25+
cargo build --release
2226
27+
./target/release/ic_websocket_gateway
2328
```
24-
2023-08-01T07:55:58.315793Z INFO ic_websocket_gateway::manager: Gateway Agent principal: sqdfl-mr4km-2hfjy-gajqo-xqvh7-hf4mf-nra4i-3it6l-neaw4-soolw-tae
25-
```
2629

27-
This is the principal that the gateway uses to interact with the canister IC WebSocket CDK.
30+
2. The output in the terminal should look like (some lines are omitted for brevity):
31+
32+
```bash
33+
...
2834
29-
3. Copy the gateway principal as you will need it to initialize the canister CDK, so that the canister can authenticate the gateway. How to do this is explained in the [ic_websocket_example](https://github.com/omnia-network/ic_websocket_example#running-the-project-locally) README.
35+
2024-03-14T11:19:33.649874Z INFO ic_websocket_gateway: Gateway Agent principal: lk7eq-k74k2-khrsw-n2xau-7ujb2-f5ao7-zkpqn-cbbx2-4xn3f-aibn4-uae
36+
37+
...
38+
39+
2024-03-14T11:19:33.650018Z INFO ic_websocket_gateway::manager: Start accepting incoming connections
40+
```
3041

3142
### Options available
3243

@@ -38,7 +49,7 @@ There are some command line arguments that you can set when running the gateway:
3849
| `--polling-interval` | The interval (in **milliseconds**) at which the gateway will poll the canisters for new messages. | `100` |
3950
| `--tls-certificate-pem-path` | The path to the TLS certificate file. See [Obtain a TLS certificate](#obtain-a-tls-certificate) for more details. | _empty_ |
4051
| `--tls-certificate-key-pem-path` | The path to the TLS private key file. See [Obtain a TLS certificate](#obtain-a-tls-certificate) for more details. | _empty_ |
41-
| `--opentelemetry-collector-endpoint` | Jaeger agent endpoint for the telemetry in the format <host>:<port>. See [Tracing telemetry](#tracing-telemetry) for more details. | _empty_ |
52+
| `--opentelemetry-collector-endpoint` | OpenTelemetry collector endpoint. See [Tracing telemetry](#tracing-telemetry) for more details. | _empty_ |
4253

4354
## Docker
4455

@@ -127,28 +138,16 @@ The gateway uses the [opentelemetry](https://docs.rs/opentelemetry) crate and [G
127138
- set the `--opentelemetry-collector-endpoint` argument to point to the opentelemetry collector endpoint (leaving it empty or unset will disable tracing telemetry);
128139
- optionally set the `RUST_LOG_TELEMETRY` environment variable, which defaults to `trace`, following the same principles described in the [Configure logging](#configure-logging) section.
129140

130-
If you're deploying the gateway locally for testing from the [docker-compose.yml](./docker-compose.yml) file, you can run both an opentelemetry collector and grafana together with the gateway by:
131-
132-
```
133-
docker compose --profile telemetry-local up -d
134-
```
135-
136-
Before you do so, make sure you set the following varibales in the `.env` file:
141+
If you're deploying the gateway with Docker (see the [Docker](#docker) section), make sure you set the following varibales in the `.env` file:
137142
143+
**Local**:
138144
```
139145
OPENTELEMETRY_COLLECTOR_ENDPOINT=grpc://otlp_collector:4317
140146
GRAFANA_TEMPO_ENDPOINT=tempo:4318
141147
GRAFANA_TEMPO_LOCAL=true
142148
```
143149
144-
If you are deploying the gateway in production and want to send the telemetry traces to Grafana Cloud, you only need to deploy the OTLP collector. To do so, run:
145-
146-
```
147-
docker compose --profile telemetry-prod up -d
148-
```
149-
150-
Before you do so, make sure you set the following varibales in the `.env` file:
151-
150+
**Production**:
152151
```
153152
OPENTELEMETRY_COLLECTOR_ENDPOINT=grpc://otlp_collector:4317
154153
GRAFANA_TEMPO_ENDPOINT=your-grafana-cloud-tempo-endpoint
@@ -289,11 +288,11 @@ Feel free to open issues, pull requests, join our [Discord](https://discord.com/
289288
- [Linkedin](https://linkedin.com/in/massimoalbarello)
290289
- [Twitter](https://twitter.com/MaxAlbarello)
291290
- [Calendly](https://cal.com/massimoalbarello/meeting)
292-
291+
- [Email](mailto:[email protected])
293292

294293
## Luca Bertelli
295294

296295
- [Linkedin](https://www.linkedin.com/in/luca-bertelli-407041128/)
297296
- [Twitter](https://twitter.com/ilbert_luca)
298297
- [Calendly](https://cal.com/lucabertelli/ic-websocket)
299-
298+
- [Email](mailto:[email protected])

src/ic-websocket-gateway/src/main.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::{
2+
gateway_metrics::init_metrics,
23
gateway_tracing::{init_tracing, InitTracingResult},
3-
gateway_metrics::{init_metrics},
44
manager::Manager,
55
ws_listener::TlsConfig,
66
};
@@ -12,10 +12,10 @@ use tracing::info;
1212
mod canister_poller;
1313
mod client_session;
1414
mod client_session_handler;
15+
mod gateway_metrics;
1516
mod gateway_tracing;
1617
mod manager;
1718
mod ws_listener;
18-
mod gateway_metrics;
1919

2020
mod tests {
2121
mod canister_poller;
@@ -25,15 +25,15 @@ mod tests {
2525
#[structopt(name = "Gateway", about = "IC WS Gateway")]
2626
struct DeploymentInfo {
2727
#[structopt(long, default_value = "http://127.0.0.1:4943")]
28-
/// the URL of the IC network
28+
/// The URL of the IC network. For mainnet, use `https://icp-api.io`.
2929
ic_network_url: String,
3030

3131
#[structopt(long, default_value = "0.0.0.0:8080")]
32-
/// address at which the WebSocket Gateway is reachable
32+
/// Address at which the WebSocket Gateway is reachable.
3333
gateway_address: String,
3434

3535
#[structopt(long, default_value = "100")]
36-
/// time interval (in milliseconds) at which the canister is polled
36+
/// Time interval (in milliseconds) at which the canisters are polled.
3737
polling_interval: u64,
3838

3939
#[structopt(long)]
@@ -43,12 +43,7 @@ struct DeploymentInfo {
4343
tls_certificate_key_pem_path: Option<String>,
4444

4545
#[structopt(long)]
46-
/// Jaeger agent endpoint for the telemetry in the format <host>:<port>
47-
///
48-
/// To run a Jaeger instance that listens on port 6831:
49-
/// ```bash
50-
/// docker run -d -p6831:6831/udp -p6832:6832/udp -p16686:16686 -p14268:14268 jaegertracing/all-in-one:latest
51-
/// ```
46+
/// OpenTelemetry collector endpoint for the telemetry.
5247
opentelemetry_collector_endpoint: Option<String>,
5348
}
5449

0 commit comments

Comments
 (0)