NAlexPear / tracing-stackdriver

Stackdriver-compatible tracing Subscriber

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Any place for the logging.googleapis.com/insertId & logging.googleapis.com/labels in logs?

rickmartensnl opened this issue · comments

I am wondering if you were open to adding the logging.googleapis.com/insertId and logging.googleapis.com/labels to the logging mechanism.

It would be useful since I have an X-Request-Id header, and I wish to like to add this to the logs. On top of that, I would like to add some labels, such as the version, and name of the app to the labels.

If I try to log it like this:

info!(
    "logging.googleapis.com/insertId" = %uuid_string,
    "Request received"
);

It generates this:

{
   "time": "2023-02-22T22:32:20.165614Z",
   "target": "backend_rs::middlewares::logger",
   "logging.googleapis.com/sourceLocation": {
      "file": "src/middlewares/logger.rs",
      "line": "104"
   },
   "severity": "INFO",
   "loggingGoogleapisComInsertId": "b2d24a9b-8a5f-4210-843f-65a2a51525e5",
   "message": "Request received",
}

Thanks in advance!

I'd certainly be open to a pull request if this is something that you'd like to contribute!

Thanks!

Pull Request has been made.

@rickmartensnl Value for "logging.googleapis.com/insertId" will limit entries in GCP to one record only with that unique value. Was it your intention here? To add X-Request-Id to log entries in scope of HTTP request you would have to go with spanId or trace. https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry