-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enabling tracing by usage of opentelemetry #99
base: new-index
Are you sure you want to change the base?
Conversation
Isn't |
They both enhance observability but are complementary. |
I'm still not quite sure I understand the differences. Prometheus can and is being used to track function execution times, for example in these functions (via + #[instrument(skip_all, name="Mempool::utxo")]
pub fn utxo(&self, scripthash: &[u8]) -> Vec<Utxo> {
let _timer = self.latency.with_label_values(&["utxo"]).start_timer();
let entries = match self.history.get(scripthash) {
@@ -209,6 +216,7 @@ impl Mempool {
.collect()
}
+ #[instrument(skip_all, name="Mempool::stats")]
// @XXX avoid code duplication with ChainQuery::stats()?
pub fn stats(&self, scripthash: &[u8]) -> ScriptStats {
let _timer = self.latency.with_label_values(&["stats"]).start_timer();
@@ -258,12 +266,14 @@ impl Mempool {
stats
}
+ #[instrument(skip_all, name="Mempool::txids")]
// Get all txids in the mempool
pub fn txids(&self) -> Vec<&Txid> {
let _timer = self.latency.with_label_values(&["txids"]).start_timer();
self.txstore.keys().collect()
} |
src/bin/electrs.rs
Outdated
@@ -16,7 +16,7 @@ use electrs::{ | |||
errors::*, | |||
metrics::Metrics, | |||
new_index::{precache, ChainQuery, FetchFrom, Indexer, Mempool, Query, Store}, | |||
rest, | |||
otlp_trace, rest, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing newline (should probably cargo fmt
the other changes too)
src/electrum/server.rs
Outdated
@@ -623,7 +643,7 @@ impl Connection { | |||
|
|||
pub fn run(mut self, receiver: Receiver<Message>) { | |||
self.stats.clients.inc(); | |||
conditionally_log_rpc_event!(self, json!({ "event": "connection established" })); | |||
//conditionally_log_rpc_event!(self, json!({ "event": "connection established" })); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this intentionally disabled?
@@ -378,7 +378,7 @@ impl Config { | |||
} else { | |||
stderrlog::Timestamp::Off | |||
}); | |||
log.init().expect("logging initialization failed"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
Cargo.toml
Outdated
@@ -51,7 +51,13 @@ url = "2.2.0" | |||
hyper = "0.14" | |||
hyperlocal = "0.8" | |||
# close to same tokio version as dependent by hyper v0.14 and hyperlocal 0.8 -- things can go awry if they mismatch | |||
tokio = { version = "1", features = ["sync", "macros"] } | |||
tokio = { version = "1", features = ["sync", "macros", "rt-multi-thread", "rt"] } | |||
opentelemetry = { version = "0.20.0", features = ["rt-tokio"] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
6 new (direct) dependencies, oh my 😅
Should we perhaps put this behind a feature flag so that the extra dependencies could be avoided by users that don't require tracing?
It's not critical, but it could aid review if the addition of |
…-type Add support for anchor output type
db37cef
to
0441c07
Compare
@@ -16,6 +16,8 @@ use serde_json::{from_str, from_value, Value}; | |||
use bitcoin::consensus::encode::{deserialize, serialize_hex}; | |||
#[cfg(feature = "liquid")] | |||
use elements::encode::{deserialize, serialize_hex}; | |||
#[cfg(feature = "tracing-enabled")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the feature name should maybe be "otlp-tracing" or "tracing". "enabled" is what we do with it.
@@ -14,6 +14,14 @@ edition = "2018" | |||
[features] | |||
liquid = [ "elements" ] | |||
electrum-discovery = [ "electrum-client"] | |||
tracing-enabled = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's call this "tracing"
How do you feel about defining a no-op |
I've added tracing to the project by introducing mainly telemetry, opentelemetry and Tokyo crates. Having tracing allows analysis of bottleneck functions (functions that take majority of execution time).