py2docfx 0.1.16.dev2064350__py3-none-any.whl → 0.1.17__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (388) hide show
  1. py2docfx/convert_prepare/environment.py +1 -3
  2. py2docfx/convert_prepare/get_source.py +1 -6
  3. py2docfx/convert_prepare/package_info.py +1 -1
  4. py2docfx/docfx_yaml/miss_reference.py +1 -1
  5. py2docfx/docfx_yaml/parameter_utils.py +58 -6
  6. py2docfx/docfx_yaml/tests/roots/test-translator-typing/code_with_typing.py +14 -0
  7. py2docfx/docfx_yaml/tests/roots/test-translator-typing/conf.py +18 -0
  8. py2docfx/docfx_yaml/tests/test_translator_typing.py +39 -0
  9. py2docfx/docfx_yaml/utils.py +2 -2
  10. py2docfx/venv/basevenv/Lib/site-packages/certifi/__init__.py +1 -1
  11. py2docfx/venv/basevenv/Lib/site-packages/certifi/core.py +1 -32
  12. py2docfx/venv/basevenv/Lib/site-packages/charset_normalizer/cli/__main__.py +62 -2
  13. py2docfx/venv/basevenv/Lib/site-packages/charset_normalizer/constant.py +17 -0
  14. py2docfx/venv/basevenv/Lib/site-packages/charset_normalizer/legacy.py +1 -3
  15. py2docfx/venv/basevenv/Lib/site-packages/charset_normalizer/md.py +19 -14
  16. py2docfx/venv/basevenv/Lib/site-packages/charset_normalizer/utils.py +6 -0
  17. py2docfx/venv/basevenv/Lib/site-packages/charset_normalizer/version.py +1 -1
  18. py2docfx/venv/basevenv/Lib/site-packages/packaging/__init__.py +1 -1
  19. py2docfx/venv/basevenv/Lib/site-packages/packaging/_elffile.py +1 -2
  20. py2docfx/venv/basevenv/Lib/site-packages/packaging/_manylinux.py +1 -2
  21. py2docfx/venv/basevenv/Lib/site-packages/packaging/_parser.py +1 -2
  22. py2docfx/venv/basevenv/Lib/site-packages/packaging/_tokenizer.py +5 -4
  23. py2docfx/venv/basevenv/Lib/site-packages/packaging/licenses/__init__.py +1 -1
  24. py2docfx/venv/basevenv/Lib/site-packages/packaging/markers.py +53 -22
  25. py2docfx/venv/basevenv/Lib/site-packages/packaging/metadata.py +1 -2
  26. py2docfx/venv/basevenv/Lib/site-packages/packaging/specifiers.py +1 -2
  27. py2docfx/venv/basevenv/Lib/site-packages/packaging/tags.py +39 -0
  28. py2docfx/venv/basevenv/Lib/site-packages/pkg_resources/__init__.py +6 -7
  29. py2docfx/venv/basevenv/Lib/site-packages/pygments/__init__.py +1 -1
  30. py2docfx/venv/basevenv/Lib/site-packages/pygments/lexers/_sql_builtins.py +106 -0
  31. py2docfx/venv/basevenv/Lib/site-packages/pygments/lexers/scripting.py +5 -3
  32. py2docfx/venv/basevenv/Lib/site-packages/pygments/lexers/sql.py +24 -118
  33. py2docfx/venv/basevenv/Lib/site-packages/requests/__version__.py +2 -2
  34. py2docfx/venv/basevenv/Lib/site-packages/requests/compat.py +12 -0
  35. py2docfx/venv/basevenv/Lib/site-packages/requests/models.py +3 -1
  36. py2docfx/venv/basevenv/Lib/site-packages/requests/utils.py +6 -16
  37. py2docfx/venv/basevenv/Lib/site-packages/setuptools/__init__.py +0 -38
  38. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_discovery.py +33 -0
  39. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_distutils/command/build_scripts.py +1 -1
  40. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_distutils/command/config.py +0 -2
  41. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_distutils/compilers/C/tests/test_unix.py +63 -0
  42. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_distutils/compilers/C/unix.py +5 -6
  43. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_entry_points.py +4 -0
  44. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_normalization.py +0 -2
  45. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_path.py +12 -3
  46. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_reqs.py +1 -1
  47. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_scripts.py +361 -0
  48. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_shutil.py +6 -0
  49. py2docfx/venv/basevenv/Lib/site-packages/setuptools/build_meta.py +25 -37
  50. py2docfx/venv/basevenv/Lib/site-packages/setuptools/command/bdist_egg.py +9 -11
  51. py2docfx/venv/basevenv/Lib/site-packages/setuptools/command/bdist_wheel.py +1 -1
  52. py2docfx/venv/basevenv/Lib/site-packages/setuptools/command/build_ext.py +29 -28
  53. py2docfx/venv/basevenv/Lib/site-packages/setuptools/command/develop.py +39 -179
  54. py2docfx/venv/basevenv/Lib/site-packages/setuptools/command/easy_install.py +17 -2352
  55. py2docfx/venv/basevenv/Lib/site-packages/setuptools/command/editable_wheel.py +14 -31
  56. py2docfx/venv/basevenv/Lib/site-packages/setuptools/command/egg_info.py +0 -2
  57. py2docfx/venv/basevenv/Lib/site-packages/setuptools/command/install.py +3 -55
  58. py2docfx/venv/basevenv/Lib/site-packages/setuptools/command/install_scripts.py +5 -11
  59. py2docfx/venv/basevenv/Lib/site-packages/setuptools/command/sdist.py +1 -1
  60. py2docfx/venv/basevenv/Lib/site-packages/setuptools/compat/py310.py +11 -0
  61. py2docfx/venv/basevenv/Lib/site-packages/setuptools/dist.py +10 -12
  62. py2docfx/venv/basevenv/Lib/site-packages/setuptools/installer.py +34 -29
  63. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/contexts.py +0 -14
  64. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/fixtures.py +235 -0
  65. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/integration/test_pbr.py +20 -0
  66. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_build_meta.py +0 -24
  67. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_develop.py +1 -64
  68. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_dist.py +2 -2
  69. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_dist_info.py +0 -63
  70. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_editable_install.py +15 -41
  71. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_egg_info.py +3 -2
  72. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_scripts.py +12 -0
  73. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_wheel.py +12 -36
  74. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_windows_wrappers.py +3 -4
  75. py2docfx/venv/basevenv/Lib/site-packages/setuptools/wheel.py +49 -24
  76. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/__init__.py +6 -0
  77. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/arabic_stemmer.py +798 -797
  78. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/armenian_stemmer.py +212 -213
  79. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/basestemmer.py +20 -54
  80. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/basque_stemmer.py +202 -228
  81. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/catalan_stemmer.py +370 -375
  82. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/danish_stemmer.py +63 -61
  83. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/dutch_porter_stemmer.py +466 -0
  84. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/dutch_stemmer.py +1217 -343
  85. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/english_stemmer.py +295 -264
  86. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/esperanto_stemmer.py +588 -0
  87. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/estonian_stemmer.py +850 -0
  88. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/finnish_stemmer.py +144 -143
  89. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/french_stemmer.py +308 -246
  90. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/german_stemmer.py +224 -167
  91. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/greek_stemmer.py +1314 -1313
  92. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/hindi_stemmer.py +39 -38
  93. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/hungarian_stemmer.py +231 -256
  94. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/indonesian_stemmer.py +61 -64
  95. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/irish_stemmer.py +101 -106
  96. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/italian_stemmer.py +272 -272
  97. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/lithuanian_stemmer.py +233 -240
  98. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/nepali_stemmer.py +108 -134
  99. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/norwegian_stemmer.py +108 -63
  100. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/porter_stemmer.py +101 -108
  101. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/portuguese_stemmer.py +241 -250
  102. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/romanian_stemmer.py +332 -296
  103. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/russian_stemmer.py +178 -179
  104. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/serbian_stemmer.py +2331 -2332
  105. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/spanish_stemmer.py +254 -259
  106. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/swedish_stemmer.py +143 -70
  107. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/tamil_stemmer.py +638 -1491
  108. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/turkish_stemmer.py +326 -292
  109. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/yiddish_stemmer.py +245 -246
  110. py2docfx/venv/basevenv/Lib/site-packages/urllib3/_version.py +2 -2
  111. py2docfx/venv/basevenv/Lib/site-packages/urllib3/connection.py +87 -38
  112. py2docfx/venv/basevenv/Lib/site-packages/urllib3/contrib/emscripten/fetch.py +20 -0
  113. py2docfx/venv/basevenv/Lib/site-packages/urllib3/poolmanager.py +17 -1
  114. py2docfx/venv/basevenv/Lib/site-packages/urllib3/response.py +53 -24
  115. py2docfx/venv/basevenv/Lib/site-packages/urllib3/util/request.py +12 -4
  116. py2docfx/venv/basevenv/Lib/site-packages/urllib3/util/ssl_.py +1 -1
  117. py2docfx/venv/venv1/Lib/site-packages/azure/core/_version.py +1 -1
  118. py2docfx/venv/venv1/Lib/site-packages/azure/core/pipeline/_base_async.py +1 -1
  119. py2docfx/venv/venv1/Lib/site-packages/azure/core/pipeline/transport/_aiohttp.py +1 -1
  120. py2docfx/venv/venv1/Lib/site-packages/azure/core/pipeline/transport/_base_async.py +2 -1
  121. py2docfx/venv/venv1/Lib/site-packages/azure/core/pipeline/transport/_requests_asyncio.py +1 -1
  122. py2docfx/venv/venv1/Lib/site-packages/azure/core/rest/_aiohttp.py +2 -2
  123. py2docfx/venv/venv1/Lib/site-packages/azure/core/rest/_requests_asyncio.py +1 -1
  124. py2docfx/venv/venv1/Lib/site-packages/azure/core/tracing/opentelemetry.py +13 -1
  125. py2docfx/venv/venv1/Lib/site-packages/azure/core/utils/_pipeline_transport_rest_shared_async.py +2 -1
  126. py2docfx/venv/venv1/Lib/site-packages/azure/core/utils/_utils.py +1 -1
  127. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_constants.py +1 -0
  128. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/default.py +23 -2
  129. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/environment.py +12 -16
  130. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/service_fabric.py +22 -1
  131. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/user_password.py +10 -6
  132. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/vscode.py +13 -4
  133. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/auth_code_redirect_handler.py +3 -5
  134. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/msal_client.py +2 -1
  135. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_persistent_cache.py +3 -2
  136. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_version.py +1 -1
  137. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/azd_cli.py +1 -1
  138. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/azure_cli.py +1 -1
  139. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/azure_powershell.py +1 -1
  140. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/chained.py +1 -1
  141. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/default.py +22 -2
  142. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/environment.py +2 -2
  143. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/service_fabric.py +17 -1
  144. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/vscode.py +4 -4
  145. py2docfx/venv/venv1/Lib/site-packages/certifi/__init__.py +1 -1
  146. py2docfx/venv/venv1/Lib/site-packages/certifi/core.py +1 -32
  147. py2docfx/venv/venv1/Lib/site-packages/charset_normalizer/cli/__main__.py +62 -2
  148. py2docfx/venv/venv1/Lib/site-packages/charset_normalizer/constant.py +17 -0
  149. py2docfx/venv/venv1/Lib/site-packages/charset_normalizer/legacy.py +1 -3
  150. py2docfx/venv/venv1/Lib/site-packages/charset_normalizer/md.py +19 -14
  151. py2docfx/venv/venv1/Lib/site-packages/charset_normalizer/utils.py +6 -0
  152. py2docfx/venv/venv1/Lib/site-packages/charset_normalizer/version.py +1 -1
  153. py2docfx/venv/venv1/Lib/site-packages/cryptography/__about__.py +2 -2
  154. py2docfx/venv/venv1/Lib/site-packages/cryptography/__init__.py +2 -2
  155. py2docfx/venv/venv1/Lib/site-packages/cryptography/fernet.py +2 -1
  156. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/_oid.py +35 -2
  157. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/backends/openssl/backend.py +33 -10
  158. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/__init__.pyi +14 -5
  159. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/ocsp.pyi +2 -2
  160. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/__init__.pyi +3 -0
  161. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/aead.pyi +49 -45
  162. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/ciphers.pyi +2 -2
  163. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/ed25519.pyi +2 -1
  164. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/ed448.pyi +2 -1
  165. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/hashes.pyi +10 -1
  166. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/hmac.pyi +3 -2
  167. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/kdf.pyi +8 -2
  168. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/keys.pyi +3 -2
  169. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/poly1305.pyi +6 -4
  170. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/x25519.pyi +2 -1
  171. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/x448.pyi +2 -1
  172. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/pkcs12.pyi +9 -3
  173. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/pkcs7.pyi +7 -6
  174. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/test_support.pyi +2 -1
  175. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/x509.pyi +79 -12
  176. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/openssl/_conditional.py +9 -1
  177. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/openssl/binding.py +2 -1
  178. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/decrepit/ciphers/algorithms.py +5 -0
  179. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/_cipheralgorithm.py +4 -2
  180. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/_serialization.py +1 -2
  181. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/asymmetric/dh.py +12 -0
  182. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/asymmetric/dsa.py +16 -3
  183. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/asymmetric/ec.py +47 -3
  184. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/asymmetric/ed25519.py +16 -3
  185. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/asymmetric/ed448.py +16 -3
  186. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/asymmetric/rsa.py +14 -0
  187. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/asymmetric/x25519.py +14 -1
  188. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/asymmetric/x448.py +14 -1
  189. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/ciphers/algorithms.py +6 -6
  190. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/ciphers/base.py +5 -4
  191. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/ciphers/modes.py +18 -18
  192. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/hashes.py +5 -1
  193. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/kdf/concatkdf.py +5 -4
  194. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/kdf/hkdf.py +4 -4
  195. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/kdf/kbkdf.py +7 -4
  196. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/kdf/pbkdf2.py +1 -1
  197. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/kdf/x963kdf.py +1 -1
  198. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/padding.py +7 -121
  199. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/serialization/__init__.py +2 -0
  200. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/serialization/pkcs12.py +21 -1
  201. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/serialization/pkcs7.py +48 -6
  202. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/serialization/ssh.py +68 -18
  203. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/twofactor/hotp.py +3 -2
  204. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/twofactor/totp.py +2 -1
  205. py2docfx/venv/venv1/Lib/site-packages/cryptography/utils.py +15 -3
  206. py2docfx/venv/venv1/Lib/site-packages/cryptography/x509/__init__.py +3 -0
  207. py2docfx/venv/venv1/Lib/site-packages/cryptography/x509/base.py +39 -6
  208. py2docfx/venv/venv1/Lib/site-packages/cryptography/x509/extensions.py +100 -49
  209. py2docfx/venv/venv1/Lib/site-packages/cryptography/x509/name.py +27 -15
  210. py2docfx/venv/venv1/Lib/site-packages/cryptography/x509/ocsp.py +60 -25
  211. py2docfx/venv/venv1/Lib/site-packages/cryptography/x509/oid.py +2 -0
  212. py2docfx/venv/venv1/Lib/site-packages/cryptography/x509/verification.py +6 -0
  213. py2docfx/venv/venv1/Lib/site-packages/google/api_core/bidi.py +17 -4
  214. py2docfx/venv/venv1/Lib/site-packages/google/api_core/client_info.py +6 -0
  215. py2docfx/venv/venv1/Lib/site-packages/google/api_core/gapic_v1/client_info.py +1 -0
  216. py2docfx/venv/venv1/Lib/site-packages/google/api_core/retry/retry_base.py +13 -4
  217. py2docfx/venv/venv1/Lib/site-packages/google/api_core/retry/retry_streaming.py +7 -6
  218. py2docfx/venv/venv1/Lib/site-packages/google/api_core/retry/retry_streaming_async.py +8 -5
  219. py2docfx/venv/venv1/Lib/site-packages/google/api_core/retry/retry_unary.py +7 -6
  220. py2docfx/venv/venv1/Lib/site-packages/google/api_core/retry/retry_unary_async.py +7 -6
  221. py2docfx/venv/venv1/Lib/site-packages/google/api_core/version.py +1 -1
  222. py2docfx/venv/venv1/Lib/site-packages/google/auth/_default.py +2 -36
  223. py2docfx/venv/venv1/Lib/site-packages/google/auth/_helpers.py +240 -0
  224. py2docfx/venv/venv1/Lib/site-packages/google/auth/aio/_helpers.py +62 -0
  225. py2docfx/venv/venv1/Lib/site-packages/google/auth/aio/transport/aiohttp.py +6 -0
  226. py2docfx/venv/venv1/Lib/site-packages/google/auth/compute_engine/_metadata.py +5 -1
  227. py2docfx/venv/venv1/Lib/site-packages/google/auth/compute_engine/credentials.py +2 -1
  228. py2docfx/venv/venv1/Lib/site-packages/google/auth/identity_pool.py +91 -2
  229. py2docfx/venv/venv1/Lib/site-packages/google/auth/impersonated_credentials.py +75 -0
  230. py2docfx/venv/venv1/Lib/site-packages/google/auth/transport/__init__.py +1 -0
  231. py2docfx/venv/venv1/Lib/site-packages/google/auth/transport/_aiohttp_requests.py +8 -1
  232. py2docfx/venv/venv1/Lib/site-packages/google/auth/transport/_http_client.py +3 -1
  233. py2docfx/venv/venv1/Lib/site-packages/google/auth/transport/requests.py +4 -1
  234. py2docfx/venv/venv1/Lib/site-packages/google/auth/transport/urllib3.py +15 -5
  235. py2docfx/venv/venv1/Lib/site-packages/google/auth/version.py +1 -1
  236. py2docfx/venv/venv1/Lib/site-packages/google/oauth2/id_token.py +12 -0
  237. py2docfx/venv/venv1/Lib/site-packages/google/oauth2/webauthn_types.py +1 -1
  238. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/__init__.py +1 -1
  239. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/any.py +15 -1
  240. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/any_pb2.py +3 -3
  241. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/api_pb2.py +3 -3
  242. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/compiler/plugin_pb2.py +3 -3
  243. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/descriptor.py +15 -2
  244. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/descriptor_pb2.py +258 -113
  245. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/descriptor_pool.py +22 -8
  246. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/duration_pb2.py +3 -3
  247. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/empty_pb2.py +3 -3
  248. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/field_mask_pb2.py +3 -3
  249. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/internal/decoder.py +106 -23
  250. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/internal/field_mask.py +3 -1
  251. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/internal/python_edition_defaults.py +1 -1
  252. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/internal/python_message.py +21 -18
  253. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/internal/testing_refleaks.py +8 -2
  254. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/internal/well_known_types.py +60 -43
  255. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/json_format.py +4 -5
  256. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/message_factory.py +16 -0
  257. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/runtime_version.py +2 -2
  258. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/source_context_pb2.py +3 -3
  259. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/struct_pb2.py +3 -3
  260. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/text_format.py +11 -7
  261. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/timestamp_pb2.py +3 -3
  262. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/type_pb2.py +3 -3
  263. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/wrappers_pb2.py +3 -3
  264. py2docfx/venv/venv1/Lib/site-packages/google/rpc/error_details_pb2.py +29 -23
  265. py2docfx/venv/venv1/Lib/site-packages/google/rpc/error_details_pb2.pyi +41 -2
  266. py2docfx/venv/venv1/Lib/site-packages/msal/application.py +1 -0
  267. py2docfx/venv/venv1/Lib/site-packages/msal/individual_cache.py +9 -5
  268. py2docfx/venv/venv1/Lib/site-packages/msal/managed_identity.py +4 -5
  269. py2docfx/venv/venv1/Lib/site-packages/msal/sku.py +1 -1
  270. py2docfx/venv/venv1/Lib/site-packages/msal/throttled_http_client.py +58 -30
  271. py2docfx/venv/venv1/Lib/site-packages/opencensus/__init__.py +1 -1
  272. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/__init__.py +1 -1
  273. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/__init__.py +1 -1
  274. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/common/__init__.py +138 -138
  275. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/common/exporter.py +93 -93
  276. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/common/processor.py +63 -63
  277. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/common/protocol.py +206 -206
  278. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/common/storage.py +205 -205
  279. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/common/transport.py +355 -355
  280. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/common/utils.py +79 -79
  281. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/common/version.py +15 -15
  282. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/log_exporter/__init__.py +314 -314
  283. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/metrics_exporter/__init__.py +190 -190
  284. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/metrics_exporter/standard_metrics/__init__.py +62 -62
  285. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/metrics_exporter/standard_metrics/cpu.py +50 -50
  286. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/metrics_exporter/standard_metrics/http_requests.py +176 -176
  287. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/metrics_exporter/standard_metrics/memory.py +42 -42
  288. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/metrics_exporter/standard_metrics/process.py +87 -87
  289. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/statsbeat/__init__.py +1 -1
  290. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/statsbeat/state.py +50 -50
  291. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/statsbeat/statsbeat.py +100 -100
  292. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/statsbeat/statsbeat_metrics.py +480 -480
  293. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/trace_exporter/__init__.py +236 -236
  294. py2docfx/venv/venv1/Lib/site-packages/packaging/__init__.py +1 -1
  295. py2docfx/venv/venv1/Lib/site-packages/packaging/_elffile.py +1 -2
  296. py2docfx/venv/venv1/Lib/site-packages/packaging/_manylinux.py +1 -2
  297. py2docfx/venv/venv1/Lib/site-packages/packaging/_parser.py +1 -2
  298. py2docfx/venv/venv1/Lib/site-packages/packaging/_tokenizer.py +5 -4
  299. py2docfx/venv/venv1/Lib/site-packages/packaging/licenses/__init__.py +1 -1
  300. py2docfx/venv/venv1/Lib/site-packages/packaging/markers.py +53 -22
  301. py2docfx/venv/venv1/Lib/site-packages/packaging/metadata.py +1 -2
  302. py2docfx/venv/venv1/Lib/site-packages/packaging/specifiers.py +1 -2
  303. py2docfx/venv/venv1/Lib/site-packages/packaging/tags.py +39 -0
  304. py2docfx/venv/venv1/Lib/site-packages/pkg_resources/__init__.py +6 -7
  305. py2docfx/venv/venv1/Lib/site-packages/requests/__version__.py +2 -2
  306. py2docfx/venv/venv1/Lib/site-packages/requests/compat.py +12 -0
  307. py2docfx/venv/venv1/Lib/site-packages/requests/models.py +3 -1
  308. py2docfx/venv/venv1/Lib/site-packages/requests/utils.py +6 -16
  309. py2docfx/venv/venv1/Lib/site-packages/rsa/__init__.py +2 -2
  310. py2docfx/venv/venv1/Lib/site-packages/rsa/asn1.py +52 -52
  311. py2docfx/venv/venv1/Lib/site-packages/rsa/cli.py +321 -321
  312. py2docfx/venv/venv1/Lib/site-packages/rsa/common.py +184 -184
  313. py2docfx/venv/venv1/Lib/site-packages/rsa/core.py +53 -53
  314. py2docfx/venv/venv1/Lib/site-packages/rsa/key.py +858 -858
  315. py2docfx/venv/venv1/Lib/site-packages/rsa/parallel.py +96 -96
  316. py2docfx/venv/venv1/Lib/site-packages/rsa/pem.py +134 -134
  317. py2docfx/venv/venv1/Lib/site-packages/rsa/pkcs1.py +485 -485
  318. py2docfx/venv/venv1/Lib/site-packages/rsa/pkcs1_v2.py +100 -100
  319. py2docfx/venv/venv1/Lib/site-packages/rsa/prime.py +198 -198
  320. py2docfx/venv/venv1/Lib/site-packages/rsa/py.typed +1 -1
  321. py2docfx/venv/venv1/Lib/site-packages/rsa/randnum.py +95 -95
  322. py2docfx/venv/venv1/Lib/site-packages/rsa/transform.py +72 -72
  323. py2docfx/venv/venv1/Lib/site-packages/rsa/util.py +97 -97
  324. py2docfx/venv/venv1/Lib/site-packages/setuptools/__init__.py +0 -38
  325. py2docfx/venv/venv1/Lib/site-packages/setuptools/_discovery.py +33 -0
  326. py2docfx/venv/venv1/Lib/site-packages/setuptools/_distutils/command/build_scripts.py +1 -1
  327. py2docfx/venv/venv1/Lib/site-packages/setuptools/_distutils/command/config.py +0 -2
  328. py2docfx/venv/venv1/Lib/site-packages/setuptools/_distutils/compilers/C/tests/test_unix.py +63 -0
  329. py2docfx/venv/venv1/Lib/site-packages/setuptools/_distutils/compilers/C/unix.py +5 -6
  330. py2docfx/venv/venv1/Lib/site-packages/setuptools/_entry_points.py +4 -0
  331. py2docfx/venv/venv1/Lib/site-packages/setuptools/_normalization.py +0 -2
  332. py2docfx/venv/venv1/Lib/site-packages/setuptools/_path.py +12 -3
  333. py2docfx/venv/venv1/Lib/site-packages/setuptools/_reqs.py +1 -1
  334. py2docfx/venv/venv1/Lib/site-packages/setuptools/_scripts.py +361 -0
  335. py2docfx/venv/venv1/Lib/site-packages/setuptools/_shutil.py +6 -0
  336. py2docfx/venv/venv1/Lib/site-packages/setuptools/build_meta.py +25 -37
  337. py2docfx/venv/venv1/Lib/site-packages/setuptools/command/bdist_egg.py +9 -11
  338. py2docfx/venv/venv1/Lib/site-packages/setuptools/command/bdist_wheel.py +1 -1
  339. py2docfx/venv/venv1/Lib/site-packages/setuptools/command/build_ext.py +29 -28
  340. py2docfx/venv/venv1/Lib/site-packages/setuptools/command/develop.py +39 -179
  341. py2docfx/venv/venv1/Lib/site-packages/setuptools/command/easy_install.py +17 -2352
  342. py2docfx/venv/venv1/Lib/site-packages/setuptools/command/editable_wheel.py +14 -31
  343. py2docfx/venv/venv1/Lib/site-packages/setuptools/command/egg_info.py +0 -2
  344. py2docfx/venv/venv1/Lib/site-packages/setuptools/command/install.py +3 -55
  345. py2docfx/venv/venv1/Lib/site-packages/setuptools/command/install_scripts.py +5 -11
  346. py2docfx/venv/venv1/Lib/site-packages/setuptools/command/sdist.py +1 -1
  347. py2docfx/venv/venv1/Lib/site-packages/setuptools/compat/py310.py +11 -0
  348. py2docfx/venv/venv1/Lib/site-packages/setuptools/dist.py +10 -12
  349. py2docfx/venv/venv1/Lib/site-packages/setuptools/installer.py +34 -29
  350. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/contexts.py +0 -14
  351. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/fixtures.py +235 -0
  352. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/integration/test_pbr.py +20 -0
  353. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_build_meta.py +0 -24
  354. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_develop.py +1 -64
  355. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_dist.py +2 -2
  356. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_dist_info.py +0 -63
  357. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_editable_install.py +15 -41
  358. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_egg_info.py +3 -2
  359. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_scripts.py +12 -0
  360. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_wheel.py +12 -36
  361. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_windows_wrappers.py +3 -4
  362. py2docfx/venv/venv1/Lib/site-packages/setuptools/wheel.py +49 -24
  363. py2docfx/venv/venv1/Lib/site-packages/typing_extensions.py +357 -703
  364. py2docfx/venv/venv1/Lib/site-packages/urllib3/_version.py +2 -2
  365. py2docfx/venv/venv1/Lib/site-packages/urllib3/connection.py +87 -38
  366. py2docfx/venv/venv1/Lib/site-packages/urllib3/contrib/emscripten/fetch.py +20 -0
  367. py2docfx/venv/venv1/Lib/site-packages/urllib3/poolmanager.py +17 -1
  368. py2docfx/venv/venv1/Lib/site-packages/urllib3/response.py +53 -24
  369. py2docfx/venv/venv1/Lib/site-packages/urllib3/util/request.py +12 -4
  370. py2docfx/venv/venv1/Lib/site-packages/urllib3/util/ssl_.py +1 -1
  371. {py2docfx-0.1.16.dev2064350.dist-info → py2docfx-0.1.17.dist-info}/METADATA +1 -1
  372. {py2docfx-0.1.16.dev2064350.dist-info → py2docfx-0.1.17.dist-info}/RECORD +374 -372
  373. {py2docfx-0.1.16.dev2064350.dist-info → py2docfx-0.1.17.dist-info}/WHEEL +1 -1
  374. py2docfx/venv/basevenv/Lib/site-packages/setuptools/package_index.py +0 -1137
  375. py2docfx/venv/basevenv/Lib/site-packages/setuptools/sandbox.py +0 -536
  376. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/server.py +0 -86
  377. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_easy_install.py +0 -1476
  378. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_packageindex.py +0 -267
  379. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_sandbox.py +0 -134
  380. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/application.py +0 -119
  381. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/application.py +0 -121
  382. py2docfx/venv/venv1/Lib/site-packages/setuptools/package_index.py +0 -1137
  383. py2docfx/venv/venv1/Lib/site-packages/setuptools/sandbox.py +0 -536
  384. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/server.py +0 -86
  385. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_easy_install.py +0 -1476
  386. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_packageindex.py +0 -267
  387. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_sandbox.py +0 -134
  388. {py2docfx-0.1.16.dev2064350.dist-info → py2docfx-0.1.17.dist-info}/top_level.txt +0 -0
@@ -1,480 +1,480 @@
1
- # Copyright 2019, OpenCensus Authors
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- import datetime
16
- import json
17
- import os
18
- import platform
19
- import re
20
- import threading
21
-
22
- import requests
23
-
24
- from opencensus.ext.azure.common.transport import _requests_lock, _requests_map
25
- from opencensus.ext.azure.common.version import __version__ as ext_version
26
- from opencensus.metrics.export.gauge import (
27
- DerivedDoubleGauge,
28
- DerivedLongGauge,
29
- LongGauge,
30
- )
31
- from opencensus.metrics.label_key import LabelKey
32
- from opencensus.metrics.label_value import LabelValue
33
- from opencensus.trace.integrations import _Integrations, get_integrations
34
-
35
- _AIMS_URI = "http://169.254.169.254/metadata/instance/compute"
36
- _AIMS_API_VERSION = "api-version=2017-12-01"
37
- _AIMS_FORMAT = "format=json"
38
-
39
- _DEFAULT_NON_EU_STATS_CONNECTION_STRING = "InstrumentationKey=c4a29126-a7cb-47e5-b348-11414998b11e;IngestionEndpoint=https://westus-0.in.applicationinsights.azure.com/" # noqa: E501
40
- _DEFAULT_EU_STATS_CONNECTION_STRING = "InstrumentationKey=7dc56bab-3c0c-4e9f-9ebb-d1acadee8d0f;IngestionEndpoint=https://westeurope-5.in.applicationinsights.azure.com/" # noqa: E501
41
- _DEFAULT_STATS_SHORT_EXPORT_INTERVAL = 900 # 15 minutes
42
- _DEFAULT_STATS_LONG_EXPORT_INTERVAL = 86400 # 24 hours
43
- _EU_ENDPOINTS = [
44
- "westeurope",
45
- "northeurope",
46
- "francecentral",
47
- "francesouth",
48
- "germanywestcentral",
49
- "norwayeast",
50
- "norwaywest",
51
- "swedencentral",
52
- "switzerlandnorth",
53
- "switzerlandwest",
54
- "uksouth",
55
- "ukwest",
56
- ]
57
-
58
- _ATTACH_METRIC_NAME = "Attach"
59
- _FEATURE_METRIC_NAME = "Feature"
60
- _REQ_SUCCESS_NAME = "Request Success Count"
61
- _REQ_FAILURE_NAME = "Request Failure Count"
62
- _REQ_DURATION_NAME = "Request Duration"
63
- _REQ_RETRY_NAME = "Retry Count"
64
- _REQ_THROTTLE_NAME = "Throttle Count"
65
- _REQ_EXCEPTION_NAME = "Exception Count"
66
-
67
- _NETWORK_STATSBEAT_NAMES = (
68
- _REQ_SUCCESS_NAME,
69
- _REQ_FAILURE_NAME,
70
- _REQ_DURATION_NAME,
71
- _REQ_RETRY_NAME,
72
- _REQ_THROTTLE_NAME,
73
- _REQ_EXCEPTION_NAME,
74
- )
75
-
76
- _ENDPOINT_TYPES = ["breeze"]
77
- _RP_NAMES = ["appsvc", "functions", "vm", "unknown"]
78
-
79
- _HOST_PATTERN = re.compile('^https?://(?:www\\.)?([^/.]+)')
80
-
81
-
82
- class _FEATURE_TYPES:
83
- FEATURE = 0
84
- INSTRUMENTATION = 1
85
-
86
-
87
- class _StatsbeatFeature:
88
- NONE = 0
89
- DISK_RETRY = 1
90
- AAD = 2
91
-
92
-
93
- def _get_stats_connection_string(endpoint):
94
- cs_env = os.environ.get("APPLICATION_INSIGHTS_STATS_CONNECTION_STRING")
95
- if cs_env:
96
- return cs_env
97
- else:
98
- for ep in _EU_ENDPOINTS:
99
- if ep in endpoint:
100
- # Use statsbeat EU endpoint if user is in EU region
101
- return _DEFAULT_EU_STATS_CONNECTION_STRING
102
- return _DEFAULT_NON_EU_STATS_CONNECTION_STRING
103
-
104
-
105
- def _get_stats_short_export_interval():
106
- ei_env = os.environ.get("APPLICATION_INSIGHTS_STATS_SHORT_EXPORT_INTERVAL")
107
- if ei_env:
108
- return int(ei_env)
109
- else:
110
- return _DEFAULT_STATS_SHORT_EXPORT_INTERVAL
111
-
112
-
113
- def _get_stats_long_export_interval():
114
- ei_env = os.environ.get("APPLICATION_INSIGHTS_STATS_LONG_EXPORT_INTERVAL")
115
- if ei_env:
116
- return int(ei_env)
117
- else:
118
- return _DEFAULT_STATS_LONG_EXPORT_INTERVAL
119
-
120
-
121
- _STATS_SHORT_EXPORT_INTERVAL = _get_stats_short_export_interval()
122
- _STATS_LONG_EXPORT_INTERVAL = _get_stats_long_export_interval()
123
- _STATS_LONG_INTERVAL_THRESHOLD = _STATS_LONG_EXPORT_INTERVAL / _STATS_SHORT_EXPORT_INTERVAL # noqa: E501
124
-
125
-
126
- def _get_common_properties():
127
- properties = []
128
- properties.append(
129
- LabelKey("rp", 'name of the rp, e.g. appsvc, vm, function, aks, etc.'))
130
- properties.append(LabelKey("attach", 'codeless or sdk'))
131
- properties.append(LabelKey("cikey", 'customer ikey'))
132
- properties.append(LabelKey("runtimeVersion", 'Python version'))
133
- properties.append(LabelKey("os", 'os of application being instrumented'))
134
- properties.append(LabelKey("language", 'Python'))
135
- properties.append(LabelKey("version", 'sdkVersion - version of the ext'))
136
- return properties
137
-
138
-
139
- def _get_attach_properties():
140
- properties = _get_common_properties()
141
- properties.insert(1, LabelKey("rpId", 'unique id of rp'))
142
- return properties
143
-
144
-
145
- def _get_network_properties(value=None):
146
- properties = _get_common_properties()
147
- properties.append(LabelKey("endpoint", "ingestion endpoint type"))
148
- properties.append(LabelKey("host", "destination of ingestion endpoint"))
149
- if value is None:
150
- properties.append(LabelKey("statusCode", "ingestion service response code")) # noqa: E501
151
- elif value == "Exception":
152
- properties.append(LabelKey("exceptionType", "language specific exception type")) # noqa: E501
153
- return properties
154
-
155
-
156
- def _get_feature_properties():
157
- properties = _get_common_properties()
158
- properties.insert(4, LabelKey("feature", 'represents enabled features'))
159
- properties.insert(4, LabelKey("type", 'type, either feature or instrumentation')) # noqa: E501
160
- return properties
161
-
162
-
163
- def _get_success_count_value():
164
- with _requests_lock:
165
- interval_count = _requests_map.get('success', 0)
166
- _requests_map['success'] = 0
167
- return interval_count
168
-
169
-
170
- def _get_failure_count_value(status_code):
171
- interval_count = 0
172
- if status_code:
173
- with _requests_lock:
174
- if _requests_map.get('failure'):
175
- interval_count = _requests_map.get('failure').get(status_code, 0) # noqa: E501
176
- _requests_map['failure'][status_code] = 0
177
- return interval_count
178
-
179
-
180
- def _get_average_duration_value():
181
- with _requests_lock:
182
- interval_duration = _requests_map.get('duration', 0)
183
- interval_count = _requests_map.get('count', 0)
184
- _requests_map['duration'] = 0
185
- _requests_map['count'] = 0
186
- if interval_duration > 0 and interval_count > 0:
187
- result = interval_duration / interval_count
188
- # Convert to milliseconds
189
- return result * 1000.0
190
- return 0
191
-
192
-
193
- def _get_retry_count_value(status_code):
194
- interval_count = 0
195
- if status_code:
196
- with _requests_lock:
197
- if _requests_map.get('retry'):
198
- interval_count = _requests_map.get('retry').get(status_code, 0)
199
- _requests_map['retry'][status_code] = 0
200
- return interval_count
201
-
202
-
203
- def _get_throttle_count_value(status_code):
204
- interval_count = 0
205
- if status_code:
206
- with _requests_lock:
207
- if _requests_map.get('throttle'):
208
- interval_count = _requests_map.get('throttle').get(status_code, 0) # noqa: E501
209
- _requests_map['throttle'][status_code] = 0
210
- return interval_count
211
-
212
-
213
- def _get_exception_count_value(exc_type):
214
- interval_count = 0
215
- if exc_type:
216
- with _requests_lock:
217
- if _requests_map.get('exception'):
218
- interval_count = _requests_map.get('exception').get(exc_type, 0) # noqa: E501
219
- _requests_map['exception'][exc_type] = 0
220
- return interval_count
221
-
222
-
223
- def _shorten_host(host):
224
- if not host:
225
- host = ""
226
- match = _HOST_PATTERN.match(host)
227
- if match:
228
- host = match.group(1)
229
- return host
230
-
231
-
232
- class _StatsbeatMetrics:
233
-
234
- def __init__(self, options):
235
- self._options = options
236
- self._instrumentation_key = options.instrumentation_key
237
- self._feature = _StatsbeatFeature.NONE
238
- if options.enable_local_storage:
239
- self._feature |= _StatsbeatFeature.DISK_RETRY
240
- if options.credential:
241
- self._feature |= _StatsbeatFeature.AAD
242
- self._stats_lock = threading.Lock()
243
- self._vm_data = {}
244
- self._vm_retry = True
245
- self._rp = _RP_NAMES[3]
246
- self._os_type = platform.system()
247
- # Attach metrics - metrics related to rp (resource provider)
248
- self._attach_metric = LongGauge(
249
- _ATTACH_METRIC_NAME,
250
- 'Statsbeat metric related to rp integrations',
251
- 'count',
252
- _get_attach_properties(),
253
- )
254
- # Keep track of how many iterations until long export
255
- self._long_threshold_count = 0
256
- # Network metrics - metrics related to request calls to Breeze
257
- self._network_metrics = {}
258
- # Map of gauge function -> metric
259
- # Gauge function is the callback used to populate the metric value
260
- self._network_metrics[_get_success_count_value] = DerivedLongGauge(
261
- _REQ_SUCCESS_NAME,
262
- 'Statsbeat metric tracking request success count',
263
- 'count',
264
- _get_network_properties(),
265
- )
266
- self._network_metrics[_get_failure_count_value] = DerivedLongGauge(
267
- _REQ_FAILURE_NAME,
268
- 'Statsbeat metric tracking request failure count',
269
- 'count',
270
- _get_network_properties(),
271
- )
272
- self._network_metrics[_get_average_duration_value] = DerivedDoubleGauge( # noqa: E501
273
- _REQ_DURATION_NAME,
274
- 'Statsbeat metric tracking average request duration',
275
- 'avg',
276
- _get_network_properties(value="Duration"),
277
- )
278
- self._network_metrics[_get_retry_count_value] = DerivedLongGauge(
279
- _REQ_RETRY_NAME,
280
- 'Statsbeat metric tracking request retry count',
281
- 'count',
282
- _get_network_properties(),
283
- )
284
- self._network_metrics[_get_throttle_count_value] = DerivedLongGauge(
285
- _REQ_THROTTLE_NAME,
286
- 'Statsbeat metric tracking request throttle count',
287
- 'count',
288
- _get_network_properties(),
289
- )
290
- self._network_metrics[_get_exception_count_value] = DerivedLongGauge(
291
- _REQ_EXCEPTION_NAME,
292
- 'Statsbeat metric tracking request exception count',
293
- 'count',
294
- _get_network_properties(value="Exception"),
295
- )
296
- # feature/instrumentation metrics
297
- # metrics related to what features and instrumentations are enabled
298
- self._feature_metric = LongGauge(
299
- _FEATURE_METRIC_NAME,
300
- 'Statsbeat metric related to features enabled', # noqa: E501
301
- 'count',
302
- _get_feature_properties(),
303
- )
304
- # Instrumentation metric uses same name/properties as feature
305
- self._instrumentation_metric = LongGauge(
306
- _FEATURE_METRIC_NAME,
307
- 'Statsbeat metric related to instrumentations enabled', # noqa: E501
308
- 'count',
309
- _get_feature_properties(),
310
- )
311
-
312
- # Metrics that are sent on application start
313
- def get_initial_metrics(self):
314
- stats_metrics = []
315
- if self._attach_metric:
316
- attach_metric = self._get_attach_metric()
317
- if attach_metric:
318
- stats_metrics.append(attach_metric)
319
- if self._feature_metric:
320
- feature_metric = self._get_feature_metric()
321
- if feature_metric:
322
- stats_metrics.append(feature_metric)
323
- if self._instrumentation_metric:
324
- instr_metric = self._get_instrumentation_metric()
325
- if instr_metric:
326
- stats_metrics.append(instr_metric)
327
- return stats_metrics
328
-
329
- # Metrics sent every statsbeat interval
330
- def get_metrics(self):
331
- metrics = []
332
- try:
333
- # Initial metrics use the long export interval
334
- # Only export once long count hits threshold
335
- with self._stats_lock:
336
- self._long_threshold_count = self._long_threshold_count + 1
337
- if self._long_threshold_count >= _STATS_LONG_INTERVAL_THRESHOLD: # noqa: E501
338
- metrics.extend(self.get_initial_metrics())
339
- self._long_threshold_count = 0
340
- network_metrics = self._get_network_metrics()
341
- metrics.extend(network_metrics)
342
- except Exception:
343
- pass
344
-
345
- return metrics
346
-
347
- def _get_network_metrics(self):
348
- properties = self._get_common_properties()
349
- properties.append(LabelValue(_ENDPOINT_TYPES[0])) # endpoint
350
- host = _shorten_host(self._options.endpoint)
351
- properties.append(LabelValue(host)) # host
352
- metrics = []
353
- for fn, metric in self._network_metrics.items():
354
- if metric.descriptor.name == _REQ_SUCCESS_NAME:
355
- properties.append(LabelValue(200))
356
- metric.create_time_series(properties, fn)
357
- properties.pop()
358
- elif metric.descriptor.name == _REQ_FAILURE_NAME:
359
- for code in _requests_map.get('failure', {}).keys():
360
- properties.append(LabelValue(code))
361
- metric.create_time_series(properties, fn, status_code=code)
362
- properties.pop()
363
- elif metric.descriptor.name == _REQ_DURATION_NAME:
364
- metric.create_time_series(properties, fn)
365
- elif metric.descriptor.name == _REQ_RETRY_NAME:
366
- for code in _requests_map.get('retry', {}).keys():
367
- properties.append(LabelValue(code))
368
- metric.create_time_series(properties, fn, status_code=code)
369
- properties.pop()
370
- elif metric.descriptor.name == _REQ_THROTTLE_NAME:
371
- for code in _requests_map.get('throttle', {}).keys():
372
- properties.append(LabelValue(code))
373
- metric.create_time_series(properties, fn, status_code=code)
374
- properties.pop()
375
- elif metric.descriptor.name == _REQ_EXCEPTION_NAME:
376
- for exc_type in _requests_map.get('exception', {}).keys():
377
- properties.append(LabelValue(exc_type))
378
- metric.create_time_series(properties, fn, exc_type=exc_type) # noqa: E501
379
- properties.pop()
380
-
381
- stats_metric = metric.get_metric(datetime.datetime.utcnow())
382
- # metric will be None if status_code or exc_type is invalid
383
- # for success count, this will never be None
384
- if stats_metric is not None:
385
- # we handle not exporting of None and 0 values in the exporter
386
- metrics.append(stats_metric)
387
- return metrics
388
-
389
- def _get_feature_metric(self):
390
- # Don't export if feature list is None
391
- if self._feature is _StatsbeatFeature.NONE:
392
- return None
393
- properties = self._get_common_properties()
394
- properties.insert(4, LabelValue(self._feature)) # feature long
395
- properties.insert(4, LabelValue(_FEATURE_TYPES.FEATURE)) # type
396
- self._feature_metric.get_or_create_time_series(properties)
397
- return self._feature_metric.get_metric(datetime.datetime.utcnow())
398
-
399
- def _get_instrumentation_metric(self):
400
- integrations = get_integrations()
401
- # Don't export if instrumentation list is None
402
- if integrations is _Integrations.NONE:
403
- return None
404
- properties = self._get_common_properties()
405
- properties.insert(4, LabelValue(get_integrations())) # instr long
406
- properties.insert(4, LabelValue(_FEATURE_TYPES.INSTRUMENTATION)) # type # noqa: E501
407
- self._instrumentation_metric.get_or_create_time_series(properties)
408
- return self._instrumentation_metric.get_metric(datetime.datetime.utcnow()) # noqa: E501
409
-
410
- def _get_attach_metric(self):
411
- properties = []
412
- rp = ''
413
- rpId = ''
414
- # rp, rpId
415
- if os.environ.get("WEBSITE_SITE_NAME") is not None:
416
- # Web apps
417
- rp = _RP_NAMES[0]
418
- rpId = '{}/{}'.format(
419
- os.environ.get("WEBSITE_SITE_NAME"),
420
- os.environ.get("WEBSITE_HOME_STAMPNAME", '')
421
- )
422
- elif os.environ.get("FUNCTIONS_WORKER_RUNTIME") is not None:
423
- # Function apps
424
- rp = _RP_NAMES[1]
425
- rpId = os.environ.get("WEBSITE_HOSTNAME")
426
- elif self._vm_retry and self._get_azure_compute_metadata():
427
- # VM
428
- rp = _RP_NAMES[2]
429
- rpId = '{}/{}'.format(
430
- self._vm_data.get("vmId", ''),
431
- self._vm_data.get("subscriptionId", ''))
432
- self._os_type = self._vm_data.get("osType", '')
433
- else:
434
- # Not in any rp or VM metadata failed
435
- rp = _RP_NAMES[3]
436
- rpId = _RP_NAMES[3]
437
-
438
- self._rp = rp
439
- properties.extend(self._get_common_properties())
440
- properties.insert(1, LabelValue(rpId)) # rpid
441
- self._attach_metric.get_or_create_time_series(properties)
442
- return self._attach_metric.get_metric(datetime.datetime.utcnow())
443
-
444
- def _get_common_properties(self):
445
- properties = []
446
- properties.append(LabelValue(self._rp)) # rp
447
- properties.append(LabelValue("sdk")) # attach type
448
- properties.append(LabelValue(self._instrumentation_key)) # cikey
449
- # runTimeVersion
450
- properties.append(LabelValue(platform.python_version()))
451
- properties.append(LabelValue(self._os_type or platform.system())) # os
452
- properties.append(LabelValue("python")) # language
453
- properties.append(LabelValue(ext_version)) # version
454
- return properties
455
-
456
- def _get_azure_compute_metadata(self):
457
- try:
458
- request_url = "{0}?{1}&{2}".format(
459
- _AIMS_URI, _AIMS_API_VERSION, _AIMS_FORMAT)
460
- response = requests.get(
461
- request_url, headers={"MetaData": "True"}, timeout=5.0)
462
- except (requests.exceptions.ConnectionError, requests.Timeout):
463
- # Not in VM
464
- self._vm_retry = False
465
- return False
466
- except requests.exceptions.RequestException:
467
- self._vm_retry = True # retry
468
- return False
469
-
470
- try:
471
- text = response.text
472
- self._vm_data = json.loads(text)
473
- except Exception: # pylint: disable=broad-except
474
- # Error in reading response body, retry
475
- self._vm_retry = True
476
- return False
477
-
478
- # Vm data is perpetually updated
479
- self._vm_retry = True
480
- return True
1
+ # Copyright 2019, OpenCensus Authors
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ import datetime
16
+ import json
17
+ import os
18
+ import platform
19
+ import re
20
+ import threading
21
+
22
+ import requests
23
+
24
+ from opencensus.ext.azure.common.transport import _requests_lock, _requests_map
25
+ from opencensus.ext.azure.common.version import __version__ as ext_version
26
+ from opencensus.metrics.export.gauge import (
27
+ DerivedDoubleGauge,
28
+ DerivedLongGauge,
29
+ LongGauge,
30
+ )
31
+ from opencensus.metrics.label_key import LabelKey
32
+ from opencensus.metrics.label_value import LabelValue
33
+ from opencensus.trace.integrations import _Integrations, get_integrations
34
+
35
+ _AIMS_URI = "http://169.254.169.254/metadata/instance/compute"
36
+ _AIMS_API_VERSION = "api-version=2017-12-01"
37
+ _AIMS_FORMAT = "format=json"
38
+
39
+ _DEFAULT_NON_EU_STATS_CONNECTION_STRING = "InstrumentationKey=c4a29126-a7cb-47e5-b348-11414998b11e;IngestionEndpoint=https://westus-0.in.applicationinsights.azure.com/" # noqa: E501
40
+ _DEFAULT_EU_STATS_CONNECTION_STRING = "InstrumentationKey=7dc56bab-3c0c-4e9f-9ebb-d1acadee8d0f;IngestionEndpoint=https://westeurope-5.in.applicationinsights.azure.com/" # noqa: E501
41
+ _DEFAULT_STATS_SHORT_EXPORT_INTERVAL = 900 # 15 minutes
42
+ _DEFAULT_STATS_LONG_EXPORT_INTERVAL = 86400 # 24 hours
43
+ _EU_ENDPOINTS = [
44
+ "westeurope",
45
+ "northeurope",
46
+ "francecentral",
47
+ "francesouth",
48
+ "germanywestcentral",
49
+ "norwayeast",
50
+ "norwaywest",
51
+ "swedencentral",
52
+ "switzerlandnorth",
53
+ "switzerlandwest",
54
+ "uksouth",
55
+ "ukwest",
56
+ ]
57
+
58
+ _ATTACH_METRIC_NAME = "Attach"
59
+ _FEATURE_METRIC_NAME = "Feature"
60
+ _REQ_SUCCESS_NAME = "Request Success Count"
61
+ _REQ_FAILURE_NAME = "Request Failure Count"
62
+ _REQ_DURATION_NAME = "Request Duration"
63
+ _REQ_RETRY_NAME = "Retry Count"
64
+ _REQ_THROTTLE_NAME = "Throttle Count"
65
+ _REQ_EXCEPTION_NAME = "Exception Count"
66
+
67
+ _NETWORK_STATSBEAT_NAMES = (
68
+ _REQ_SUCCESS_NAME,
69
+ _REQ_FAILURE_NAME,
70
+ _REQ_DURATION_NAME,
71
+ _REQ_RETRY_NAME,
72
+ _REQ_THROTTLE_NAME,
73
+ _REQ_EXCEPTION_NAME,
74
+ )
75
+
76
+ _ENDPOINT_TYPES = ["breeze"]
77
+ _RP_NAMES = ["appsvc", "functions", "vm", "unknown"]
78
+
79
+ _HOST_PATTERN = re.compile('^https?://(?:www\\.)?([^/.]+)')
80
+
81
+
82
+ class _FEATURE_TYPES:
83
+ FEATURE = 0
84
+ INSTRUMENTATION = 1
85
+
86
+
87
+ class _StatsbeatFeature:
88
+ NONE = 0
89
+ DISK_RETRY = 1
90
+ AAD = 2
91
+
92
+
93
+ def _get_stats_connection_string(endpoint):
94
+ cs_env = os.environ.get("APPLICATION_INSIGHTS_STATS_CONNECTION_STRING")
95
+ if cs_env:
96
+ return cs_env
97
+ else:
98
+ for ep in _EU_ENDPOINTS:
99
+ if ep in endpoint:
100
+ # Use statsbeat EU endpoint if user is in EU region
101
+ return _DEFAULT_EU_STATS_CONNECTION_STRING
102
+ return _DEFAULT_NON_EU_STATS_CONNECTION_STRING
103
+
104
+
105
+ def _get_stats_short_export_interval():
106
+ ei_env = os.environ.get("APPLICATION_INSIGHTS_STATS_SHORT_EXPORT_INTERVAL")
107
+ if ei_env:
108
+ return int(ei_env)
109
+ else:
110
+ return _DEFAULT_STATS_SHORT_EXPORT_INTERVAL
111
+
112
+
113
+ def _get_stats_long_export_interval():
114
+ ei_env = os.environ.get("APPLICATION_INSIGHTS_STATS_LONG_EXPORT_INTERVAL")
115
+ if ei_env:
116
+ return int(ei_env)
117
+ else:
118
+ return _DEFAULT_STATS_LONG_EXPORT_INTERVAL
119
+
120
+
121
+ _STATS_SHORT_EXPORT_INTERVAL = _get_stats_short_export_interval()
122
+ _STATS_LONG_EXPORT_INTERVAL = _get_stats_long_export_interval()
123
+ _STATS_LONG_INTERVAL_THRESHOLD = _STATS_LONG_EXPORT_INTERVAL / _STATS_SHORT_EXPORT_INTERVAL # noqa: E501
124
+
125
+
126
+ def _get_common_properties():
127
+ properties = []
128
+ properties.append(
129
+ LabelKey("rp", 'name of the rp, e.g. appsvc, vm, function, aks, etc.'))
130
+ properties.append(LabelKey("attach", 'codeless or sdk'))
131
+ properties.append(LabelKey("cikey", 'customer ikey'))
132
+ properties.append(LabelKey("runtimeVersion", 'Python version'))
133
+ properties.append(LabelKey("os", 'os of application being instrumented'))
134
+ properties.append(LabelKey("language", 'python'))
135
+ properties.append(LabelKey("version", 'sdkVersion - version of the ext'))
136
+ return properties
137
+
138
+
139
+ def _get_attach_properties():
140
+ properties = _get_common_properties()
141
+ properties.insert(1, LabelKey("rpId", 'unique id of rp'))
142
+ return properties
143
+
144
+
145
+ def _get_network_properties(value=None):
146
+ properties = _get_common_properties()
147
+ properties.append(LabelKey("endpoint", "ingestion endpoint type"))
148
+ properties.append(LabelKey("host", "destination of ingestion endpoint"))
149
+ if value is None:
150
+ properties.append(LabelKey("statusCode", "ingestion service response code")) # noqa: E501
151
+ elif value == "Exception":
152
+ properties.append(LabelKey("exceptionType", "language specific exception type")) # noqa: E501
153
+ return properties
154
+
155
+
156
+ def _get_feature_properties():
157
+ properties = _get_common_properties()
158
+ properties.insert(4, LabelKey("feature", 'represents enabled features'))
159
+ properties.insert(4, LabelKey("type", 'type, either feature or instrumentation')) # noqa: E501
160
+ return properties
161
+
162
+
163
+ def _get_success_count_value():
164
+ with _requests_lock:
165
+ interval_count = _requests_map.get('success', 0)
166
+ _requests_map['success'] = 0
167
+ return interval_count
168
+
169
+
170
+ def _get_failure_count_value(status_code):
171
+ interval_count = 0
172
+ if status_code:
173
+ with _requests_lock:
174
+ if _requests_map.get('failure'):
175
+ interval_count = _requests_map.get('failure').get(status_code, 0) # noqa: E501
176
+ _requests_map['failure'][status_code] = 0
177
+ return interval_count
178
+
179
+
180
+ def _get_average_duration_value():
181
+ with _requests_lock:
182
+ interval_duration = _requests_map.get('duration', 0)
183
+ interval_count = _requests_map.get('count', 0)
184
+ _requests_map['duration'] = 0
185
+ _requests_map['count'] = 0
186
+ if interval_duration > 0 and interval_count > 0:
187
+ result = interval_duration / interval_count
188
+ # Convert to milliseconds
189
+ return result * 1000.0
190
+ return 0
191
+
192
+
193
+ def _get_retry_count_value(status_code):
194
+ interval_count = 0
195
+ if status_code:
196
+ with _requests_lock:
197
+ if _requests_map.get('retry'):
198
+ interval_count = _requests_map.get('retry').get(status_code, 0)
199
+ _requests_map['retry'][status_code] = 0
200
+ return interval_count
201
+
202
+
203
+ def _get_throttle_count_value(status_code):
204
+ interval_count = 0
205
+ if status_code:
206
+ with _requests_lock:
207
+ if _requests_map.get('throttle'):
208
+ interval_count = _requests_map.get('throttle').get(status_code, 0) # noqa: E501
209
+ _requests_map['throttle'][status_code] = 0
210
+ return interval_count
211
+
212
+
213
+ def _get_exception_count_value(exc_type):
214
+ interval_count = 0
215
+ if exc_type:
216
+ with _requests_lock:
217
+ if _requests_map.get('exception'):
218
+ interval_count = _requests_map.get('exception').get(exc_type, 0) # noqa: E501
219
+ _requests_map['exception'][exc_type] = 0
220
+ return interval_count
221
+
222
+
223
+ def _shorten_host(host):
224
+ if not host:
225
+ host = ""
226
+ match = _HOST_PATTERN.match(host)
227
+ if match:
228
+ host = match.group(1)
229
+ return host
230
+
231
+
232
+ class _StatsbeatMetrics:
233
+
234
+ def __init__(self, options):
235
+ self._options = options
236
+ self._instrumentation_key = options.instrumentation_key
237
+ self._feature = _StatsbeatFeature.NONE
238
+ if options.enable_local_storage:
239
+ self._feature |= _StatsbeatFeature.DISK_RETRY
240
+ if options.credential:
241
+ self._feature |= _StatsbeatFeature.AAD
242
+ self._stats_lock = threading.Lock()
243
+ self._vm_data = {}
244
+ self._vm_retry = True
245
+ self._rp = _RP_NAMES[3]
246
+ self._os_type = platform.system()
247
+ # Attach metrics - metrics related to rp (resource provider)
248
+ self._attach_metric = LongGauge(
249
+ _ATTACH_METRIC_NAME,
250
+ 'Statsbeat metric related to rp integrations',
251
+ 'count',
252
+ _get_attach_properties(),
253
+ )
254
+ # Keep track of how many iterations until long export
255
+ self._long_threshold_count = 0
256
+ # Network metrics - metrics related to request calls to Breeze
257
+ self._network_metrics = {}
258
+ # Map of gauge function -> metric
259
+ # Gauge function is the callback used to populate the metric value
260
+ self._network_metrics[_get_success_count_value] = DerivedLongGauge(
261
+ _REQ_SUCCESS_NAME,
262
+ 'Statsbeat metric tracking request success count',
263
+ 'count',
264
+ _get_network_properties(),
265
+ )
266
+ self._network_metrics[_get_failure_count_value] = DerivedLongGauge(
267
+ _REQ_FAILURE_NAME,
268
+ 'Statsbeat metric tracking request failure count',
269
+ 'count',
270
+ _get_network_properties(),
271
+ )
272
+ self._network_metrics[_get_average_duration_value] = DerivedDoubleGauge( # noqa: E501
273
+ _REQ_DURATION_NAME,
274
+ 'Statsbeat metric tracking average request duration',
275
+ 'avg',
276
+ _get_network_properties(value="Duration"),
277
+ )
278
+ self._network_metrics[_get_retry_count_value] = DerivedLongGauge(
279
+ _REQ_RETRY_NAME,
280
+ 'Statsbeat metric tracking request retry count',
281
+ 'count',
282
+ _get_network_properties(),
283
+ )
284
+ self._network_metrics[_get_throttle_count_value] = DerivedLongGauge(
285
+ _REQ_THROTTLE_NAME,
286
+ 'Statsbeat metric tracking request throttle count',
287
+ 'count',
288
+ _get_network_properties(),
289
+ )
290
+ self._network_metrics[_get_exception_count_value] = DerivedLongGauge(
291
+ _REQ_EXCEPTION_NAME,
292
+ 'Statsbeat metric tracking request exception count',
293
+ 'count',
294
+ _get_network_properties(value="Exception"),
295
+ )
296
+ # feature/instrumentation metrics
297
+ # metrics related to what features and instrumentations are enabled
298
+ self._feature_metric = LongGauge(
299
+ _FEATURE_METRIC_NAME,
300
+ 'Statsbeat metric related to features enabled', # noqa: E501
301
+ 'count',
302
+ _get_feature_properties(),
303
+ )
304
+ # Instrumentation metric uses same name/properties as feature
305
+ self._instrumentation_metric = LongGauge(
306
+ _FEATURE_METRIC_NAME,
307
+ 'Statsbeat metric related to instrumentations enabled', # noqa: E501
308
+ 'count',
309
+ _get_feature_properties(),
310
+ )
311
+
312
+ # Metrics that are sent on application start
313
+ def get_initial_metrics(self):
314
+ stats_metrics = []
315
+ if self._attach_metric:
316
+ attach_metric = self._get_attach_metric()
317
+ if attach_metric:
318
+ stats_metrics.append(attach_metric)
319
+ if self._feature_metric:
320
+ feature_metric = self._get_feature_metric()
321
+ if feature_metric:
322
+ stats_metrics.append(feature_metric)
323
+ if self._instrumentation_metric:
324
+ instr_metric = self._get_instrumentation_metric()
325
+ if instr_metric:
326
+ stats_metrics.append(instr_metric)
327
+ return stats_metrics
328
+
329
+ # Metrics sent every statsbeat interval
330
+ def get_metrics(self):
331
+ metrics = []
332
+ try:
333
+ # Initial metrics use the long export interval
334
+ # Only export once long count hits threshold
335
+ with self._stats_lock:
336
+ self._long_threshold_count = self._long_threshold_count + 1
337
+ if self._long_threshold_count >= _STATS_LONG_INTERVAL_THRESHOLD: # noqa: E501
338
+ metrics.extend(self.get_initial_metrics())
339
+ self._long_threshold_count = 0
340
+ network_metrics = self._get_network_metrics()
341
+ metrics.extend(network_metrics)
342
+ except Exception:
343
+ pass
344
+
345
+ return metrics
346
+
347
+ def _get_network_metrics(self):
348
+ properties = self._get_common_properties()
349
+ properties.append(LabelValue(_ENDPOINT_TYPES[0])) # endpoint
350
+ host = _shorten_host(self._options.endpoint)
351
+ properties.append(LabelValue(host)) # host
352
+ metrics = []
353
+ for fn, metric in self._network_metrics.items():
354
+ if metric.descriptor.name == _REQ_SUCCESS_NAME:
355
+ properties.append(LabelValue(200))
356
+ metric.create_time_series(properties, fn)
357
+ properties.pop()
358
+ elif metric.descriptor.name == _REQ_FAILURE_NAME:
359
+ for code in _requests_map.get('failure', {}).keys():
360
+ properties.append(LabelValue(code))
361
+ metric.create_time_series(properties, fn, status_code=code)
362
+ properties.pop()
363
+ elif metric.descriptor.name == _REQ_DURATION_NAME:
364
+ metric.create_time_series(properties, fn)
365
+ elif metric.descriptor.name == _REQ_RETRY_NAME:
366
+ for code in _requests_map.get('retry', {}).keys():
367
+ properties.append(LabelValue(code))
368
+ metric.create_time_series(properties, fn, status_code=code)
369
+ properties.pop()
370
+ elif metric.descriptor.name == _REQ_THROTTLE_NAME:
371
+ for code in _requests_map.get('throttle', {}).keys():
372
+ properties.append(LabelValue(code))
373
+ metric.create_time_series(properties, fn, status_code=code)
374
+ properties.pop()
375
+ elif metric.descriptor.name == _REQ_EXCEPTION_NAME:
376
+ for exc_type in _requests_map.get('exception', {}).keys():
377
+ properties.append(LabelValue(exc_type))
378
+ metric.create_time_series(properties, fn, exc_type=exc_type) # noqa: E501
379
+ properties.pop()
380
+
381
+ stats_metric = metric.get_metric(datetime.datetime.utcnow())
382
+ # metric will be None if status_code or exc_type is invalid
383
+ # for success count, this will never be None
384
+ if stats_metric is not None:
385
+ # we handle not exporting of None and 0 values in the exporter
386
+ metrics.append(stats_metric)
387
+ return metrics
388
+
389
+ def _get_feature_metric(self):
390
+ # Don't export if feature list is None
391
+ if self._feature is _StatsbeatFeature.NONE:
392
+ return None
393
+ properties = self._get_common_properties()
394
+ properties.insert(4, LabelValue(self._feature)) # feature long
395
+ properties.insert(4, LabelValue(_FEATURE_TYPES.FEATURE)) # type
396
+ self._feature_metric.get_or_create_time_series(properties)
397
+ return self._feature_metric.get_metric(datetime.datetime.utcnow())
398
+
399
+ def _get_instrumentation_metric(self):
400
+ integrations = get_integrations()
401
+ # Don't export if instrumentation list is None
402
+ if integrations is _Integrations.NONE:
403
+ return None
404
+ properties = self._get_common_properties()
405
+ properties.insert(4, LabelValue(get_integrations())) # instr long
406
+ properties.insert(4, LabelValue(_FEATURE_TYPES.INSTRUMENTATION)) # type # noqa: E501
407
+ self._instrumentation_metric.get_or_create_time_series(properties)
408
+ return self._instrumentation_metric.get_metric(datetime.datetime.utcnow()) # noqa: E501
409
+
410
+ def _get_attach_metric(self):
411
+ properties = []
412
+ rp = ''
413
+ rpId = ''
414
+ # rp, rpId
415
+ if os.environ.get("FUNCTIONS_WORKER_RUNTIME") is not None:
416
+ # Function apps
417
+ rp = _RP_NAMES[1]
418
+ rpId = os.environ.get("WEBSITE_HOSTNAME")
419
+ elif os.environ.get("WEBSITE_SITE_NAME") is not None:
420
+ # Web apps
421
+ rp = _RP_NAMES[0]
422
+ rpId = '{}/{}'.format(
423
+ os.environ.get("WEBSITE_SITE_NAME"),
424
+ os.environ.get("WEBSITE_HOME_STAMPNAME", '')
425
+ )
426
+ elif self._vm_retry and self._get_azure_compute_metadata():
427
+ # VM
428
+ rp = _RP_NAMES[2]
429
+ rpId = '{}/{}'.format(
430
+ self._vm_data.get("vmId", ''),
431
+ self._vm_data.get("subscriptionId", ''))
432
+ self._os_type = self._vm_data.get("osType", '')
433
+ else:
434
+ # Not in any rp or VM metadata failed
435
+ rp = _RP_NAMES[3]
436
+ rpId = _RP_NAMES[3]
437
+
438
+ self._rp = rp
439
+ properties.extend(self._get_common_properties())
440
+ properties.insert(1, LabelValue(rpId)) # rpid
441
+ self._attach_metric.get_or_create_time_series(properties)
442
+ return self._attach_metric.get_metric(datetime.datetime.utcnow())
443
+
444
+ def _get_common_properties(self):
445
+ properties = []
446
+ properties.append(LabelValue(self._rp)) # rp
447
+ properties.append(LabelValue("sdk")) # attach type
448
+ properties.append(LabelValue(self._instrumentation_key)) # cikey
449
+ # runTimeVersion
450
+ properties.append(LabelValue(platform.python_version()))
451
+ properties.append(LabelValue(self._os_type or platform.system())) # os
452
+ properties.append(LabelValue("python")) # language
453
+ properties.append(LabelValue(ext_version)) # version
454
+ return properties
455
+
456
+ def _get_azure_compute_metadata(self):
457
+ try:
458
+ request_url = "{0}?{1}&{2}".format(
459
+ _AIMS_URI, _AIMS_API_VERSION, _AIMS_FORMAT)
460
+ response = requests.get(
461
+ request_url, headers={"MetaData": "True"}, timeout=5.0)
462
+ except (requests.exceptions.ConnectionError, requests.Timeout):
463
+ # Not in VM
464
+ self._vm_retry = False
465
+ return False
466
+ except requests.exceptions.RequestException:
467
+ self._vm_retry = True # retry
468
+ return False
469
+
470
+ try:
471
+ text = response.text
472
+ self._vm_data = json.loads(text)
473
+ except Exception: # pylint: disable=broad-except
474
+ # Error in reading response body, retry
475
+ self._vm_retry = True
476
+ return False
477
+
478
+ # Vm data is perpetually updated
479
+ self._vm_retry = True
480
+ return True