Title: Custom logs from a GCP Function do not contain execution-id · Issue #343 · googleapis/python-logging · GitHub
Open Graph Title: Custom logs from a GCP Function do not contain execution-id · Issue #343 · googleapis/python-logging
X Title: Custom logs from a GCP Function do not contain execution-id · Issue #343 · googleapis/python-logging
Description: I am not sure if this is a bug or a misconfiguration issue but we are unable to get the execution-id in our logs. GCP's own function logs like startup/teardown/timeout contain it however our own logs don't. This makes it impossible to co...
Open Graph Description: I am not sure if this is a bug or a misconfiguration issue but we are unable to get the execution-id in our logs. GCP's own function logs like startup/teardown/timeout contain it however our own lo...
X Description: I am not sure if this is a bug or a misconfiguration issue but we are unable to get the execution-id in our logs. GCP's own function logs like startup/teardown/timeout contain it however our ow...
Opengraph URL: https://github.com/googleapis/python-logging/issues/343
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Custom logs from a GCP Function do not contain execution-id","articleBody":"I am not sure if this is a bug or a misconfiguration issue but we are unable to get the `execution-id` in our logs. GCP's own function logs like startup/teardown/timeout contain it however our own logs don't. This makes it impossible to correlate all logs from an instance. \r\n\r\nExample (GCP function startup log)\r\n```\r\n{\r\n insertId: \"000000-a51b0cd9-1f4d-4396-b812-4b35c8878b69\"\r\n labels: {\r\n execution_id: \"j57c7yk340qq\"\r\n }\r\n logName: \"projects/PROJECT-ID/logs/cloudfunctions.googleapis.com%2Fcloud-functions\"\r\n receiveTimestamp: \"2021-06-30T17:37:16.202805413Z\"\r\n resource: {\r\n labels: {\r\n function_name: \"FUNCTION-NAME\",\r\n project_id: \"PROJECT-ID\",\r\n region: \"REGION\"\r\n }\r\n type: \"cloud_function\"\r\n }\r\n severity: \"DEBUG\"\r\n textPayload: \"Function execution started\"\r\n timestamp: \"2021-06-30T17:37:05.341077546Z\"\r\n}\r\n```\r\nWe also tried setting a custom label in `CloudLoggingHandler` with a `trace-id` however GCP's own logs don't reflect the custom `trace-id`. This makes me think that GCP is using a separate logger which attaches the `execution-id` and our logs are isolated from that logger. \r\n\r\n#### Environment details\r\n\r\n - OS type and version: N/A\r\n - Python version: 3.7.9\r\n - pip version: 21.1.2\r\n - `google-cloud-logging` version: 2.3.1\r\n\r\n#### Steps to reproduce\r\n\r\n 1. Create and attach `CloudLoggingHandler` to a logger in a GCP function\r\n 2. Log an `INFO` message\r\n 3. Verify the log does not contain `execution-id` inside `labels`\r\n \r\n#### Code example\r\nA simplified version of our logging setup and a basic event-trigger function.\r\n\r\n```python\r\nimport logging\r\n\r\nimport google.cloud.logging\r\nfrom google.cloud.logging_v2.handlers.handlers import CloudLoggingHandler\r\n\r\n\r\nclass FunctionLogger(logging.Logger):\r\n\r\n def __init__(self, level=logging.NOTSET):\r\n super().__init__(\"logger_name\", level)\r\n\r\n client = google.cloud.logging.Client()\r\n\r\n self._handler = CloudLoggingHandler(client)\r\n\r\n self.propagate = False # prevent logging from root logger\r\n self.addHandler(self._handler)\r\n\r\n\r\ndef handler(event, context=None):\r\n \"\"\"function entry point\"\"\"\r\n logger = FunctionLogger()\r\n\r\n logger.info(\"Test message\")\r\n```\r\n\r\nThanks!!","author":{"url":"https://github.com/amertkara","@type":"Person","name":"amertkara"},"datePublished":"2021-06-30T18:06:38.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/343/python-logging/issues/343"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:1e4bc9b8-657d-5179-0ed0-726e0cbc72dd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A430:2086C7:78CC965:A9A772D:6A50256F |
| html-safe-nonce | 09435a9e7c8b655602b01fdd49576145e475edd911e88cae1db916b72199c212 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNDMwOjIwODZDNzo3OENDOTY1OkE5QTc3MkQ6NkE1MDI1NkYiLCJ2aXNpdG9yX2lkIjoiMjkwNzg4NTc5NTQwMTU0MDk3NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 1ca02e283ac7225afc77f23fd3b1fb93090d923fb6df45dab98d658cec9e9802 |
| hovercard-subject-tag | issue:933965341 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/googleapis/python-logging/343/issue_layout |
| twitter:image | https://opengraph.githubassets.com/338da7a3d3982e0e0ee3962a668221e695b618b184cd9156c4d248f940a6cd58/googleapis/python-logging/issues/343 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/338da7a3d3982e0e0ee3962a668221e695b618b184cd9156c4d248f940a6cd58/googleapis/python-logging/issues/343 |
| og:image:alt | I am not sure if this is a bug or a misconfiguration issue but we are unable to get the execution-id in our logs. GCP's own function logs like startup/teardown/timeout contain it however our own lo... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | amertkara |
| hostname | github.com |
| expected-hostname | github.com |
| None | a08040246389072795e3b4e7b33c6d9a0c564eee02e829a809326d67c418b069 |
| turbo-cache-control | no-preview |
| go-import | github.com/googleapis/python-logging git https://github.com/googleapis/python-logging.git |
| octolytics-dimension-user_id | 16785467 |
| octolytics-dimension-user_login | googleapis |
| octolytics-dimension-repository_id | 226992562 |
| octolytics-dimension-repository_nwo | googleapis/python-logging |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 226992562 |
| octolytics-dimension-repository_network_root_nwo | googleapis/python-logging |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d1b91b18e7330fc458dfd824c61eaed7daa830d6 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width