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

tracing logs are printed twice #361

Open
Bergmann89 opened this issue Mar 3, 2025 · 0 comments
Open

tracing logs are printed twice #361

Bergmann89 opened this issue Mar 3, 2025 · 0 comments

Comments

@Bergmann89
Copy link

Bergmann89 commented Mar 3, 2025

Hey guys,

I discovered a strange issue with the tracing feature enabled: My tracing logs are displayed twice. I have set up tracing with the following code:

World::cucumber()
     .configure_and_init_tracing(DefaultFields::new(), Format::default(), move |layer| {
            registry().with(EnvFilter::from_default_env().and_then(layer))
        }
    });

And then I have some log outputs inside my step, like this:

#[when(regex = r"^I establish a (?:\s+([^\s]+))? session(?: to ([^\s]+))?$")]
async fn connect(
    world: &mut World,
    mode: Optional<String>,
    remote: Optional<String>,
) -> Result<(), Error> {
    tracing::trace!("connect (mode={mode:?}, remote={remote:?})");

    // [...]

    let span = debug_span!(parent: None, "Session");
    let _span = span.enter();

    let session = open(config).await?;
    world.session = Some(session);
}

I see the log output twice:

2025-03-03T13:44:55.853009Z TRACE scenario:step: swarm_tests::steps: connect (mode=Optional(None), remote=Optional(Some("router-1")))
2025-03-03T13:44:55.853050Z DEBUG scenario:step: swarm_tests::steps: Get address for container `router-1`
2025-03-03T13:44:55.854279Z DEBUG scenario:step: swarm_tests::steps: Address for container `router-1` is `172.19.0.3`
[...]
2025-03-03T13:44:55.853009Z TRACE scenario:step: swarm_tests::steps: connect (mode=Optional(None), remote=Optional(Some("router-1")))
2025-03-03T13:44:55.853050Z DEBUG scenario:step: swarm_tests::steps: Get address for container `router-1`
2025-03-03T13:44:55.854279Z DEBUG scenario:step: swarm_tests::steps: Address for container `router-1` is `172.19.0.3`
[...]

The lines are completely identical. The strange thing is, that this happens for the steps after I created a new root span. I had to create the span as workaround, because cucumber will wait until the current span is closed, which will never happen if my session is stored in my world.

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

No branches or pull requests

1 participant