Skip to content
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

feat(publisher): Introduce Telemetry #299

Merged
merged 9 commits into from
Nov 12, 2024
Merged

Conversation

Jurshsmith
Copy link
Member

This change consolidates all things related to metrics and logging in a dedicated
Telemetry process to give room for processing performance when publishing.

Closes DS-109

This commit improves the `FuelCoreLike` trait definition
allowing us to wrap implementors in a `Arc` reference
@Jurshsmith Jurshsmith force-pushed the aj/DS-109/introduce-telemetry branch 2 times, most recently from 6bf7099 to 06e8bd3 Compare November 2, 2024 14:47
@@ -11,6 +11,7 @@ SURREALDB_URL=127.0.0.1:8000
SURREALDB_USER=root
SURREALDB_PASS=root
CONCURRENCY_LIMIT=16
USE_ELASTIC_LOGGING=false
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to include this environment variable before deploying

Comment on lines -34 to -41
#[arg(
long,
value_name = "ELOG",
env = "USE_ELASTIC_LOGGING",
default_value = "false",
help = "Use elasticsearch logging."
)]
pub use_elastic_logging: bool,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this in a bid to reduce the CLI args.

Comment on lines -193 to -212
// fn set_panic_hook(&mut self) {
// let nats_client = self.nats_client.clone();
// let fuel_service = Arc::clone(&self.fuel_service);
// std::panic::set_hook(Box::new(move |panic_info| {
// let payload = panic_info
// .payload()
// .downcast_ref::<&str>()
// .unwrap_or(&"Unknown panic");
// tracing::error!("Publisher panicked with a message: {:?}", payload);
// let handle = tokio::runtime::Handle::current();
// let nats_client = nats_client.clone();
// let fuel_service = Arc::clone(&fuel_service);
// handle.spawn(async move {
// Publisher::flush_await_all_streams(&nats_client).await;
// Publisher::stop_fuel_service(&fuel_service).await;
// std::process::exit(1);
// });
// }));
// }

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need a new small task for graceful shutdown when Publisher panics

Comment on lines +93 to +96
fn maybe_elog(&self, entry: LogEntry) {
if let Some(elastic_search) = &self.elastic_search {
self.runtime
.spawn(elastic_search::log(elastic_search.clone(), entry));
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This happens within the Telemetry's dedicated ThreadPool, so, we no longer have to delay processing the next block because of ElasticSearch

@Jurshsmith Jurshsmith self-assigned this Nov 2, 2024
This change consolidates all things related to metrics and logging in a dedicated
Telemetry process to give room for processing performance when publishing.
@Jurshsmith Jurshsmith force-pushed the aj/DS-109/introduce-telemetry branch from 87704db to 49f4e0c Compare November 7, 2024 09:41
@Jurshsmith Jurshsmith force-pushed the aj/DS-109/introduce-telemetry branch from c66d993 to 621507c Compare November 10, 2024 23:40
.enable_all()
.build()?;

runtime.block_on(async {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need these block_ons

let server_handle = server.handle();
// spawn the server in the background
tokio::spawn(async move {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have been server_runtime.spawn

let (tx, rx) = mpsc::channel::<RuntimeMessage>(100);
let cli = cli.clone();

tokio::spawn({
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this shoould have been publisher_runtime.spawn


tokio::spawn(async move {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have been fuel_core_runtime.spawn

@@ -1,188 +1,64 @@
//! This binary subscribes to events emitted from a Fuel client or node
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep the main binary in its former shape for now, and then plan around the runtime architecture for each of its processes.

@Jurshsmith Jurshsmith force-pushed the aj/DS-109/introduce-telemetry branch from 54f7844 to d943cde Compare November 11, 2024 10:48
Copy link
Collaborator

@pedronauck pedronauck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test running the entire stack locally to ensure everything is working and the main thread is not being slowing down as it was before?

@pedronauck pedronauck merged commit 572f011 into main Nov 12, 2024
14 checks passed
@pedronauck pedronauck deleted the aj/DS-109/introduce-telemetry branch November 12, 2024 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants