Skip to content

Commit

Permalink
fix(chain): Fixed telemetry data sending to HTTPS endpoint (#2329)
Browse files Browse the repository at this point in the history
We already have a record of breaking Telemetry once in a while not even noticing this fact till much later, thus I decided not only to fix it, but also put some logging there.

## Test Plan

* Manually checked that the fix works (openssl is statically linked and
system root CA certificates still get detected and used)
* Added "info" logger to report Telemetry issues (I choose "info" level
to indicate that it is not critical, and node can operate just fine
with that when the message appears in the logs; it is expected to be silent most of the time)
  • Loading branch information
frol authored Mar 30, 2020
1 parent 35c1797 commit 191f5ef
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
8 changes: 5 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions chain/telemetry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ edition = "2018"

[dependencies]
openssl = { version = "0.10", features = ["vendored"] }
openssl-probe = "0.1.2"
actix-web = { version = "2.0.0", features = [ "openssl" ] }
futures = "0.3"
actix = "0.9.0"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
tracing = "0.1"
8 changes: 7 additions & 1 deletion chain/telemetry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use actix::{Actor, Addr, Context, Handler, Message};
use actix_web::client::{Client, Connector};
use futures::FutureExt;
use serde_derive::{Deserialize, Serialize};
use tracing::info;

/// Timeout for establishing connection.
const CONNECT_TIMEOUT: Duration = Duration::from_secs(10);
Expand Down Expand Up @@ -33,6 +34,7 @@ impl Default for TelemetryActor {

impl TelemetryActor {
pub fn new(config: TelemetryConfig) -> Self {
openssl_probe::init_ssl_cert_env_vars();
let client = Client::build()
.timeout(CONNECT_TIMEOUT)
.connector(
Expand Down Expand Up @@ -60,7 +62,11 @@ impl Handler<TelemetryEvent> for TelemetryActor {
.post(endpoint)
.header("Content-Type", "application/json")
.send_json(&msg.content)
.map(drop),
.map(|response| {
if let Err(error) = response {
info!(target: "telemetry", "Telemetry data could not be sent due to: {}", error);
}
}),
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion near/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use near::{get_default_home, get_store_path, init_configs, load_config, start_wi
use near_primitives::types::Version;

fn init_logging(verbose: Option<&str>) {
let mut env_filter = EnvFilter::new("tokio_reactor=info,near=info,stats=info");
let mut env_filter = EnvFilter::new("tokio_reactor=info,near=info,stats=info,telemetry=info");

if let Some(module) = verbose {
env_filter = env_filter
Expand Down

0 comments on commit 191f5ef

Please sign in to comment.