-
Notifications
You must be signed in to change notification settings - Fork 498
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Thanks to commit XXXX ("Refactor common parts of handle_client and handle_ws_client to function."), we now have separate tracing spans for the connection establishment phase and for the forwarring phase of each connection. This commit sets up OpenTelemetry tracing and exporter, so that they can be exported as OpenTelemetry traces as well. This adds tracing to all outgoing HTTP requests. A separate (child) span is created for each outgoing HTTP request, and the tracing context is also propagated to the server in the HTTP headers. Use the 'reqwest-middleware' crate to do that. If tracing is enabled in the control plane and compute node too, you can now get an end-to-end distributed trace of what happens when a new connection is established, starting from the handshake with the client, creating the 'start_compute' operation in the control plane, starting the compute node, all the way to down to fetching the base backup and the availability checks in compute_ctl.
- Loading branch information
Showing
9 changed files
with
145 additions
and
21 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use tracing_opentelemetry::OpenTelemetryLayer; | ||
use tracing_subscriber::layer::SubscriberExt; | ||
use tracing_subscriber::prelude::*; | ||
|
||
/// Initialize logging to stdout, and OpenTelemetry tracing and exporter | ||
/// | ||
/// Logging is configured using either `default_log_level` or | ||
/// `RUST_LOG` environment variable as default log level. | ||
/// | ||
/// OpenTelemetry is configured with OTLP/HTTP exporter. It picks up | ||
/// configuration from environment variables. For example, to change the destination, | ||
/// set `OTEL_EXPORTER_OTLP_ENDPOINT=http://jaeger:4318`. See | ||
/// https://opentelemetry.io/docs/reference/specification/sdk-environment-variables/ | ||
/// | ||
pub async fn init_tracing_and_logging(default_log_level: &str) -> anyhow::Result<()> { | ||
// Initialize Logging | ||
let env_filter = tracing_subscriber::EnvFilter::try_from_default_env() | ||
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new(default_log_level)); | ||
|
||
let fmt_layer = tracing_subscriber::fmt::layer() | ||
.with_target(false) | ||
.with_writer(std::io::stderr); | ||
|
||
// Initialize OpenTelemetry | ||
let otlp_layer = tracing_utils::init_tracing("proxy") | ||
.await | ||
.map(OpenTelemetryLayer::new); | ||
|
||
// Put it all together | ||
tracing_subscriber::registry() | ||
.with(env_filter) | ||
.with(otlp_layer) | ||
.with(fmt_layer) | ||
.init(); | ||
tracing::info!("logging and tracing started"); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters