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

httpRequest and spans #30

Open
tomocrafter opened this issue May 20, 2024 · 0 comments
Open

httpRequest and spans #30

tomocrafter opened this issue May 20, 2024 · 0 comments

Comments

@tomocrafter
Copy link

Hi, Thank you for great crate!
I would like to use this on GCE + Cloud Logging environment but httpRequest does not work well if using with spans in tracing.

I made axum Router as:

    Router::new()
        .route("/health", get(health))
        .layer(
            TraceLayer::new_for_http()
                .make_span_with(|request: &Request<_>| {
                    tracing::info_span!(
                        "http_request",
                        http_request.requestMethod = ?request.method(),
                        http_request.requestUrl = %request.uri(),
                        http_request.protocol = ?request.version(),
                    );
                })
        )

but all of info in tracing::info_span! will be in "spans" field, which should be in "httpRequest".
I tried following code:

    Router::new()
        .route("/health", get(health))
        .layer(
            TraceLayer::new_for_http()
                .make_span_with(|request: &Request<_>| {
                    tracing::info_span!(
                        "http_request",
                        requestMethod = ?request.method(),
                        requestUrl = %request.uri(),
                        protocol = ?request.version(),
                    );
                })
        )

above code does not work either.

Do I need to add http_request every time I do tracing::info!() ?
I hope it can be in spans so I don't need to add those everytime.

Thank you.

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