Title: Logging: don't import grpc if grpc disabled · Issue #12 · googleapis/python-logging · GitHub
Open Graph Title: Logging: don't import grpc if grpc disabled · Issue #12 · googleapis/python-logging
X Title: Logging: don't import grpc if grpc disabled · Issue #12 · googleapis/python-logging
Description: I noticed the Stackdriver module supports usage with grpc installed, which is great. However it currently still tries to import _gapic even if grpc usage is explicitly disabled via env var. This causes some additional latency for cli & s...
Open Graph Description: I noticed the Stackdriver module supports usage with grpc installed, which is great. However it currently still tries to import _gapic even if grpc usage is explicitly disabled via env var. This ca...
X Description: I noticed the Stackdriver module supports usage with grpc installed, which is great. However it currently still tries to import _gapic even if grpc usage is explicitly disabled via env var. This ca...
Opengraph URL: https://github.com/googleapis/python-logging/issues/12
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Logging: don't import grpc if grpc disabled","articleBody":"I noticed the Stackdriver module supports usage with grpc installed, which is great. However it currently still tries to import _gapic even if grpc usage is explicitly disabled via env var. This causes some additional latency for cli \u0026 serverless usage.\r\n\r\n```\r\n$ cat x.py\r\nimport time\r\nimport sys\r\n\r\n\r\ndef main():\r\n mcount = len(sys.modules)\r\n t = time.time()\r\n from google.cloud.logging import Client\r\n print(\"modules:%d %0.2f sec\" % (\r\n len(sys.modules) - mcount, time.time() - t))\r\n\r\n\r\nif __name__ == '__main__':\r\n main()\r\n```\r\n\r\nso this tries two tests, one with the default google.cloud.logging.client imports, and one where the try/except around the _gapic imports is replaced with the except clause ie modification of these lines\r\nhttps://github.com/googleapis/google-cloud-python/blob/master/logging/google/cloud/logging/client.py#L21\r\n\r\n## default import \r\n```\r\n(custodian) bash-3.2$ python x.py \r\nmodules:576 0.51 sec\r\n(custodian) bash-3.2$ python x.py \r\nmodules:576 0.50 sec\r\n(custodian) bash-3.2$ python x.py \r\nmodules:576 0.44 sec\r\n(custodian) bash-3.2$ python x.py \r\nmodules:576 0.47 sec\r\n```\r\n\r\n## Disable import of _gapi in\r\n\r\n```\r\n(custodian) bash-3.2$ python x.py \r\nmodules:510 0.38 sec\r\n(custodian) bash-3.2$ python x.py \r\nmodules:510 0.37 sec\r\n(custodian) bash-3.2$ python x.py \r\nmodules:510 0.37 sec\r\n(custodian) bash-3.2$ python x.py \r\nmodules:510 0.38 sec\r\n(custodian) bash-3.2$ python x.py \r\nmodules:510 0.37 sec\r\n```\r\n\r\nso baseline improvement for cli / serverless execution of ~100ms. for serverless environments this effect is more pronounced I've noticed.\r\n\r\nIdeally the DISABLE_GRPC environment could be checked before attempting to import the _gapic modules.","author":{"url":"https://github.com/kapilt","@type":"Person","name":"kapilt"},"datePublished":"2018-12-24T17:51:04.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/12/python-logging/issues/12"}
| 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:1f299a15-4f6e-34b0-b39d-b4db8b091a32 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C9B2:139708:31221B8:4401B93:6A508710 |
| html-safe-nonce | f66762038bfa4ba98817d4c08b1ae6a3dd97d58e2195447a20bd8d1d0a8eac19 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOUIyOjEzOTcwODozMTIyMUI4OjQ0MDFCOTM6NkE1MDg3MTAiLCJ2aXNpdG9yX2lkIjoiMzIwODU2MzU4MjY1MDYzMTg0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | c838fce238269f3419e455da099f1046d441bd31b334cb9b3da47f34ad390c5e |
| hovercard-subject-tag | issue:560390101 |
| 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/12/issue_layout |
| twitter:image | https://opengraph.githubassets.com/26ff8bdce8f2405d128c499c84b9d6105cff8e166bfabff20569b0d6a7f06763/googleapis/python-logging/issues/12 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/26ff8bdce8f2405d128c499c84b9d6105cff8e166bfabff20569b0d6a7f06763/googleapis/python-logging/issues/12 |
| og:image:alt | I noticed the Stackdriver module supports usage with grpc installed, which is great. However it currently still tries to import _gapic even if grpc usage is explicitly disabled via env var. This ca... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | kapilt |
| hostname | github.com |
| expected-hostname | github.com |
| None | d6dc8294eb500fa36bbc57472d61fe87c522f9c3c1d64f70f4926f66a66a7efb |
| 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 | 7ac0ad2f2c7e4b9056617355fd9e33e22b0c8df9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width