-
Notifications
You must be signed in to change notification settings - Fork 26
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
Inital opentelemetry
layout
#400
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,11 @@ thiserror = "1.0.30" | |
lazy_static = "1.4.0" | ||
tracing = "0.1.37" | ||
tracing-subscriber = "0.3.17" | ||
opentelemetry-appender-tracing = { version = "0.27.0", default-features = false} | ||
opentelemetry = { version = "0.27.0", default-features = false, features = ["trace"] } | ||
opentelemetry_sdk = { version = "0.27.0", default-features = false, features = ["trace", "rt-tokio"] } | ||
opentelemetry-http = { version = "0.27.0", default-features = false} | ||
opentelemetry-otlp = { version = "0.27.0", features = ["logs", "http-json", "reqwest-client"] } | ||
Comment on lines
+38
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: I used the I did this because we currently only support the |
||
bincode = "1.3.3" | ||
miette = { version = "7.2.0", features = ["fancy"] } | ||
tokio = { version = "^1.40", features = ["rt", "rt-multi-thread", "signal"] } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,13 @@ use tokio::task::JoinHandle; | |
use tokio_util::sync::CancellationToken; | ||
use tracing::{debug, warn}; | ||
use tracing_subscriber::{filter::Targets, prelude::*}; | ||
use opentelemetry_appender_tracing::layer; | ||
use opentelemetry_otlp::WithExportConfig; | ||
use opentelemetry_otlp::{LogExporter, Protocol}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: I only export logs and not traces (spans) or metrics just because I only needed logs to make sure it works |
||
use opentelemetry_sdk::{ | ||
logs::LoggerProvider, | ||
runtime, | ||
}; | ||
|
||
use dolos::prelude::*; | ||
|
||
|
@@ -62,6 +69,18 @@ pub fn open_data_stores(config: &crate::Config) -> Result<Stores, Error> { | |
pub fn setup_tracing(config: &LoggingConfig) -> miette::Result<()> { | ||
let level = config.max_level; | ||
|
||
let exporter = LogExporter::builder() | ||
.with_http() | ||
.with_endpoint("http://localhost:4318/v1/logs") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: this should be configured automatically for you from an env variable (https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#endpoint-urls-for-otlphttp), but I just set it explicitly here |
||
.with_protocol(Protocol::HttpJson) | ||
.build().unwrap(); | ||
|
||
let provider = LoggerProvider::builder() | ||
.with_simple_exporter(exporter) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we want to use |
||
// .with_batch_exporter(exporter, runtime::Tokio) | ||
.build(); | ||
let layer = layer::OpenTelemetryTracingBridge::new(&provider); | ||
|
||
let mut filter = Targets::new() | ||
.with_target("dolos", level) | ||
.with_target("gasket", level); | ||
|
@@ -84,6 +103,7 @@ pub fn setup_tracing(config: &LoggingConfig) -> miette::Result<()> { | |
{ | ||
tracing_subscriber::registry() | ||
.with(tracing_subscriber::fmt::layer()) | ||
.with(layer) | ||
.with(filter) | ||
.init(); | ||
} | ||
|
@@ -92,6 +112,7 @@ pub fn setup_tracing(config: &LoggingConfig) -> miette::Result<()> { | |
{ | ||
tracing_subscriber::registry() | ||
.with(tracing_subscriber::fmt::layer()) | ||
.with(layer) | ||
.with(console_subscriber::spawn()) | ||
.with(filter) | ||
.init(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -186,7 +186,8 @@ impl Config { | |
} | ||
} | ||
|
||
fn main() -> Result<()> { | ||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
Comment on lines
+189
to
+190
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I don't have this,
Note that I don't need this to run There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I realize now that unfortunately this breaks
note: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They recently (December 2024) updated the docs on how to get the However, it turns out that, unfortunately, using the
However, I can't seems to get it to work because
There are some issues that were resolved in opentelemetry that sound like they might be relevant such as open-telemetry/opentelemetry-rust#2431, but they are not released yet. More generally, I wonder if open-telemetry/opentelemetry-rust#2386 might make the integration easier |
||
let args = Cli::parse(); | ||
let config = Config::new(&args.config) | ||
.into_diagnostic() | ||
|
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.
note: I only added the system to forward the
tracing
crate to opentelemtry, but not other cratesthat is to say, I noticed in Dolos (and maybe downstream crates?) you occasionally use
use log::
which won't be forwarded