Skip to content

httpRequest and spans #30

@tomocrafter

Description

@tomocrafter

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions