Skip to content

feat: Add tracing support#123

Draft
DanielVoogsgerd wants to merge 4 commits intoBraneFramework:mainfrom
DanielVoogsgerd:env-loglevel
Draft

feat: Add tracing support#123
DanielVoogsgerd wants to merge 4 commits intoBraneFramework:mainfrom
DanielVoogsgerd:env-loglevel

Conversation

@DanielVoogsgerd
Copy link
Collaborator

@DanielVoogsgerd DanielVoogsgerd commented Aug 29, 2024

This uses the tracing_subscriber with EnvFilter to get log levels that can be set using environment variables.

This also enables branectl to translate a set of environment variables so that every container can get a specific log level set at start

This currently only changes the logging for the brane-api crate as an indication what this would look like.

I am not entirely happy with my solution for the env var translation in branectl, but it is good enough for a draft right now.

@Lut99, what do you think?

Marking this PR as a draft until we hash out how we want to do this, and until all workspace members have been converted.

Fixes: #116

Ok(())
}


Copy link

Choose a reason for hiding this comment

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

Tssk, someone is removing all by formatting whitespace :P

@Lut99
Copy link

Lut99 commented Sep 2, 2024

I'm trying to check out how it looks like, but it seems like the output of brane-api isn't very verbose by default. How can I change it? I tried

BRANE_API_LOG=DEBUG ./target/release/branectl start central

or, to try and trigger your tracing error:

BRANE_LOG=DaskjdhasdEBUG ./target/release/branectl start central

but none of them seem to have any effect on brane-apis deployment, nor do they print!() anything.

Maybe there's something weird with caching here? branectl is a little awkward in these /tmp/docker-compose-*.yml file it generates and then (never?) updates them again. But even so, removing the file and re-running has no effect.

@DanielVoogsgerd
Copy link
Collaborator Author

DanielVoogsgerd commented Oct 8, 2024

I forgot to remove an optimization that it would not generate an overlay if there were no hostname overrides. This did not fail for me before as I used to always set host.docker.internal.

It should "work" now.

Don't expect too much however, it is still very drafty.

if log::max_level() == log::LevelFilter::Debug {
crate::traversals::print::ast::do_traversal(&workflow, std::io::stdout()).unwrap();
}
// TODO: Implement tracing

Check notice

Code scanning / devskim

A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note

Suspicious comment
if let Err(err) = HumanLogger::terminal(DebugMode::Debug).init() {
eprintln!("WARNING: Failed to setup Rust logger: {err} (logging disabled for this session)");
}
// TODO: Set up tracing

Check notice

Code scanning / devskim

A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note

Suspicious comment
args.node_config,
DockerOptions { socket: docker_socket, version: docker_version },
StartOpts { compose_verbose: args.debug || args.trace, version, image_dir, local_aux, skip_import, profile_dir },
// FIXME: Drop compose verbose?

Check notice

Code scanning / devskim

A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note

Suspicious comment
},
CtlSubcommand::Stop { exe, file } => {
if let Err(err) = lifetime::stop(args.debug || args.trace, exe, file, args.node_config) {
// FIXME: Drop compose verbose?

Check notice

Code scanning / devskim

A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note

Suspicious comment
},
CtlSubcommand::Logs { exe, file } => {
if let Err(err) = lifetime::logs(exe, file, args.node_config, LogsOpts { compose_verbose: args.debug || args.trace }).await {
// FIXME: Drop compose verbose?

Check notice

Code scanning / devskim

A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note

Suspicious comment
#[derive(Parser)]
#[clap(version = env!("CARGO_PKG_VERSION"))]
struct Opts {
#[clap(short, long, default_value = "127.0.0.1:8081", env = "ADDRESS")]

Check notice

Code scanning / devskim

Accessing localhost could indicate debug code, or could hinder scaling. Note

Do not leave debug code in production
/// Service address
address: String,
/// Scylla endpoint
#[clap(short, long, default_value = "127.0.0.1", env = "SCYLLA")]

Check notice

Code scanning / devskim

Accessing localhost could indicate debug code, or could hinder scaling. Note

Do not leave debug code in production
#[clap(short, long, default_value = "127.0.0.1", env = "SCYLLA")]
scylla: String,
/// Kafka brokers
#[clap(short, long, default_value = "127.0.0.1:9092", env = "BROKERS")]

Check notice

Code scanning / devskim

Accessing localhost could indicate debug code, or could hinder scaling. Note

Do not leave debug code in production
}))
.map(|reply| {
// TODO#584: remove this workaround
warp::reply::with_header(reply, "Sec-WebSocket-Protocol", "graphql-ws")

Check notice

Code scanning / devskim

A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note

Suspicious comment
eprintln!("WARNING: Failed to setup test logger: {err} (no logging for this session)");
}
}
// TODO: Set up tracing subscriber

Check notice

Code scanning / devskim

A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note

Suspicious comment
This uses the `tracing_subscriber` with `EnvFilter` to get log levels
that can be set using environment variables.

This also enables `branectl` to translate a set of environment variables
so that every container can get a specific log level set at start
This guard clause was a correct optimization before we set loglevels via
overrides
@codecov
Copy link

codecov bot commented Apr 11, 2025

@DanielVoogsgerd DanielVoogsgerd changed the title Improved logging feat: Add tracing support Sep 28, 2025
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.

Improve logging

2 participants