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 integration #213

Closed
ilslv opened this issue May 8, 2022 · 3 comments · Fixed by #258 or #261
Closed

tracing integration #213

ilslv opened this issue May 8, 2022 · 3 comments · Fixed by #258 or #261
Assignees
Labels
enhancement Improvement of existing features or bugfix k::refactor Refactoring, technical debt elimination and other improvements of existing code base
Milestone

Comments

@ilslv
Copy link
Member

ilslv commented May 8, 2022

I believe we can support better logging by integrating support for brilliant tracing crate, as current solution described in #177 is quite unintuitive and requires additional setup.

We can implement custom tracing::Subscriber and pass Feature, Scenario and Step context inside tracing::Span. So we can retrieve this information and pass logging event as a new kind of cucumber::Events for logging them, when appropriate time comes.

Unresolved questions, that require additional investigations:

  1. spawning a future, that will log after a Step has been finished may lead to strange output behaviour
#[given(...)]
fn delayed_log(w: &mut World) {
    spawn(
        async {
            sleep(Duration::from_secs(1).await;
            tracing::info!("Delayed");
        }
        .instrument(tracing::Span::current())
    )
}

Moreover, spawned Futures by default don't inherit Span from context they were spawned from. See tokio-rs/tracing#394 for more info.

  1. Possible integrations with existing tracing ecosystem.
@ilslv ilslv added enhancement Improvement of existing features or bugfix rfc labels May 8, 2022
@tyranron
Copy link
Member

tyranron commented May 10, 2022

@ilslv for the reasoning it's slightly unclear what challenges/problems it allows us to solve? What we will be capable with it rather than without it?

@ilslv
Copy link
Member Author

ilslv commented May 10, 2022

@tyranron this will allow to log something in colored mode and with concurrent execution. Logs captured during some Step execution will be printed only when this Step is actually outputted to the terminal.
This is especially useful, when debugging an error. For now, you have to set concurrent=1 and color=never to actually get the idea, when the particular log occurred. And if reproducing an error requires concurrent execution of multiple Scenarios, you are stuck figuring out, which logs correspond to failed Scenario.

@tyranron
Copy link
Member

@ilslv seems reasonable. I think we should give it a try at least.

@tyranron tyranron removed the rfc label May 11, 2022
@tyranron tyranron added the k::refactor Refactoring, technical debt elimination and other improvements of existing code base label Nov 1, 2022
@tyranron tyranron added this to the 0.20.0 milestone Feb 27, 2023
@ilslv ilslv mentioned this issue Mar 1, 2023
15 tasks
tyranron added a commit that referenced this issue Mar 3, 2023
- add `tracing` Cargo feature
- add `Log` variant to `event::Scenario`
- describe "`tracing` integration" Book chapter

Co-authored-by: Kai Ren <[email protected]>
tyranron pushed a commit that referenced this issue Mar 7, 2023
#261, #213)

- add `embeddings` field to `writer::json::Step` and `writer::json::HookResult`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement of existing features or bugfix k::refactor Refactoring, technical debt elimination and other improvements of existing code base
Projects
None yet
2 participants