NAlexPear / tracing-stackdriver

Stackdriver-compatible tracing Subscriber

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom fields with names containing periods

divergentdave opened this issue · comments

As of version 0.6.2, custom field names containing periods were accepted, and transformed using Inflector into camel case field names. Cloud Logging would ultimately retain these as part of the jsonPayload field of the LogEntry object. In version 0.7.0, fields containing a period are dropped unless they are special http_request or labels fields. The match arm that does so says that well-formatted logs should not be affected. Would you be open to changing this to allow fields with periods in their names? I'd be happy to send a PR for this.

Here's a reproduction in the form of a test case:

#[test]
fn includes_custom_fields_with_dot() {
    let events = run_with_tracing::<BTreeMap<String, serde_json::Value>>(|| {
        tracing::info!(foo.bar = "value", "message")
    })
    .expect("Error converting test buffer to JSON");

    let event = events.first().expect("No event heard");
    assert_eq!(
        event.get("fooBar"),
        Some(&serde_json::json!("value")),
        "full event: {:?}",
        event
    );
}

If this is affecting you, I'd happily accept a PR to make aggressive camelCasing the default behavior.

Published as part of v0.7.1