diff options
author | Eric Eastwood <erice@element.io> | 2022-07-26 18:44:21 -0500 |
---|---|---|
committer | Eric Eastwood <erice@element.io> | 2022-07-26 18:44:21 -0500 |
commit | 0cc610ecbe4b0866deae992559e2355949473e4a (patch) | |
tree | ba3b3f532b6ef4d2187e4ca3822005fa429b5ed9 | |
parent | Backfill remote event fetched by MSC3030 so we can paginate from it later (... (diff) | |
download | synapse-0cc610ecbe4b0866deae992559e2355949473e4a.tar.xz |
Migrate to OpenTelemetry tracing
See https://github.com/matrix-org/synapse/issues/11850
37 files changed, 155 insertions, 284 deletions
diff --git a/mypy.ini b/mypy.ini index 6add272990..590ef3a69d 100644 --- a/mypy.ini +++ b/mypy.ini @@ -164,9 +164,6 @@ ignore_missing_imports = True [mypy-pympler.*] ignore_missing_imports = True -[mypy-rust_python_jaeger_reporter.*] -ignore_missing_imports = True - [mypy-saml2.*] ignore_missing_imports = True diff --git a/poetry.lock b/poetry.lock index b62c24ae16..e1ecc6a758 100644 --- a/poetry.lock +++ b/poetry.lock @@ -177,7 +177,7 @@ optional = false python-versions = "*" [package.extras] -test = ["flake8 (==3.7.8)", "hypothesis (==3.55.3)"] +test = ["hypothesis (==3.55.3)", "flake8 (==3.7.8)"] [[package]] name = "constantly" @@ -218,7 +218,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" name = "deprecated" version = "1.2.13" description = "Python @deprecated decorator to deprecate old python classes, functions or methods." -category = "dev" +category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" @@ -410,23 +410,6 @@ requirements_deprecated_finder = ["pipreqs", "pip-api"] colors = ["colorama (>=0.4.3,<0.5.0)"] [[package]] -name = "jaeger-client" -version = "4.8.0" -description = "Jaeger Python OpenTracing Tracer implementation" -category = "main" -optional = true -python-versions = ">=3.7" - -[package.dependencies] -opentracing = ">=2.1,<3.0" -threadloop = ">=1,<2" -thrift = "*" -tornado = ">=4.3" - -[package.extras] -tests = ["mock", "pycurl", "pytest", "pytest-cov", "coverage", "pytest-timeout", "pytest-tornado", "pytest-benchmark", "pytest-localserver", "flake8", "flake8-quotes", "flake8-typing-imports", "codecov", "tchannel (==2.1.0)", "opentracing_instrumentation (>=3,<4)", "prometheus_client (==0.11.0)", "mypy"] - -[[package]] name = "jeepney" version = "0.7.1" description = "Low-level, pure Python DBus protocol wrapper." @@ -435,8 +418,8 @@ optional = false python-versions = ">=3.6" [package.extras] -test = ["pytest", "pytest-trio", "pytest-asyncio", "testpath", "trio", "async-timeout"] -trio = ["trio", "async-generator"] +trio = ["async-generator", "trio"] +test = ["async-timeout", "trio", "testpath", "pytest-asyncio", "pytest-trio", "pytest"] [[package]] name = "jinja2" @@ -535,8 +518,8 @@ attrs = "*" importlib-metadata = {version = ">=1.4", markers = "python_version < \"3.8\""} [package.extras] -dev = ["tox", "twisted", "aiounittest", "mypy (==0.910)", "black (==22.3.0)", "flake8 (==4.0.1)", "isort (==5.9.3)", "build (==0.8.0)", "twine (==4.0.1)"] -test = ["tox", "twisted", "aiounittest"] +test = ["aiounittest", "twisted", "tox"] +dev = ["twine (==4.0.1)", "build (==0.8.0)", "isort (==5.9.3)", "flake8 (==4.0.1)", "black (==22.3.0)", "mypy (==0.910)", "aiounittest", "twisted", "tox"] [[package]] name = "matrix-synapse-ldap3" @@ -552,7 +535,7 @@ service-identity = "*" Twisted = ">=15.1.0" [package.extras] -dev = ["matrix-synapse", "tox", "ldaptor", "mypy (==0.910)", "types-setuptools", "black (==22.3.0)", "flake8 (==4.0.1)", "isort (==5.9.3)"] +dev = ["isort (==5.9.3)", "flake8 (==4.0.1)", "black (==22.3.0)", "types-setuptools", "mypy (==0.910)", "ldaptor", "tox", "matrix-synapse"] [[package]] name = "mccabe" @@ -622,15 +605,36 @@ optional = false python-versions = "*" [[package]] -name = "opentracing" -version = "2.4.0" -description = "OpenTracing API for Python. See documentation at http://opentracing.io" +name = "opentelemetry-api" +version = "1.11.1" +description = "OpenTelemetry Python API" category = "main" optional = true -python-versions = "*" +python-versions = ">=3.6" -[package.extras] -tests = ["doubles", "flake8", "flake8-quotes", "mock", "pytest", "pytest-cov", "pytest-mock", "sphinx", "sphinx-rtd-theme", "six (>=1.10.0,<2.0)", "gevent", "tornado"] +[package.dependencies] +Deprecated = ">=1.2.6" + +[[package]] +name = "opentelemetry-sdk" +version = "1.11.1" +description = "OpenTelemetry Python SDK" +category = "main" +optional = true +python-versions = ">=3.6" + +[package.dependencies] +opentelemetry-api = "1.11.1" +opentelemetry-semantic-conventions = "0.30b1" +typing-extensions = ">=3.7.4" + +[[package]] +name = "opentelemetry-semantic-conventions" +version = "0.30b1" +description = "OpenTelemetry Semantic Conventions" +category = "main" +optional = true +python-versions = ">=3.6" [[package]] name = "packaging" @@ -820,10 +824,10 @@ optional = false python-versions = ">=3.6" [package.extras] +tests = ["coverage[toml] (==5.0.4)", "pytest (>=6.0.0,<7.0.0)"] +docs = ["zope.interface", "sphinx-rtd-theme", "sphinx"] +dev = ["pre-commit", "mypy", "coverage[toml] (==5.0.4)", "pytest (>=6.0.0,<7.0.0)", "cryptography (>=3.3.1)", "zope.interface", "sphinx-rtd-theme", "sphinx"] crypto = ["cryptography (>=3.3.1)"] -dev = ["sphinx", "sphinx-rtd-theme", "zope.interface", "cryptography (>=3.3.1)", "pytest (>=6.0.0,<7.0.0)", "coverage[toml] (==5.0.4)", "mypy", "pre-commit"] -docs = ["sphinx", "sphinx-rtd-theme", "zope.interface"] -tests = ["pytest (>=6.0.0,<7.0.0)", "coverage[toml] (==5.0.4)"] [[package]] name = "pymacaroons" @@ -1129,33 +1133,6 @@ optional = true python-versions = "*" [[package]] -name = "threadloop" -version = "1.0.2" -description = "Tornado IOLoop Backed Concurrent Futures" -category = "main" -optional = true -python-versions = "*" - -[package.dependencies] -tornado = "*" - -[[package]] -name = "thrift" -version = "0.15.0" -description = "Python bindings for the Apache Thrift RPC system" -category = "main" -optional = true -python-versions = "*" - -[package.dependencies] -six = ">=1.7.2" - -[package.extras] -all = ["tornado (>=4.0)", "twisted"] -tornado = ["tornado (>=4.0)"] -twisted = ["twisted"] - -[[package]] name = "tomli" version = "1.2.3" description = "A lil' TOML parser" @@ -1164,14 +1141,6 @@ optional = false python-versions = ">=3.6" [[package]] -name = "tornado" -version = "6.1" -description = "Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed." -category = "main" -optional = true -python-versions = ">= 3.5" - -[[package]] name = "towncrier" version = "21.9.0" description = "Building newsfiles for your project." @@ -1472,7 +1441,7 @@ python-versions = "*" name = "wrapt" version = "1.13.3" description = "Module for decorators, wrappers and monkey patching." -category = "dev" +category = "main" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" @@ -1546,12 +1515,12 @@ docs = ["sphinx", "repoze.sphinx.autointerface"] test = ["zope.i18nmessageid", "zope.testing", "zope.testrunner"] [extras] -all = ["matrix-synapse-ldap3", "psycopg2", "psycopg2cffi", "psycopg2cffi-compat", "pysaml2", "authlib", "lxml", "sentry-sdk", "jaeger-client", "opentracing", "txredisapi", "hiredis", "Pympler"] +all = ["matrix-synapse-ldap3", "psycopg2", "psycopg2cffi", "psycopg2cffi-compat", "pysaml2", "authlib", "lxml", "sentry-sdk", "txredisapi", "hiredis", "Pympler"] cache_memory = ["Pympler"] jwt = ["authlib"] matrix-synapse-ldap3 = ["matrix-synapse-ldap3"] oidc = ["authlib"] -opentracing = ["jaeger-client", "opentracing"] +opentracing = [] postgres = ["psycopg2", "psycopg2cffi", "psycopg2cffi-compat"] redis = ["txredisapi", "hiredis"] saml2 = ["pysaml2"] @@ -1563,7 +1532,7 @@ url_preview = ["lxml"] [metadata] lock-version = "1.1" python-versions = "^3.7.1" -content-hash = "c24bbcee7e86dbbe7cdbf49f91a25b310bf21095452641e7440129f59b077f78" +content-hash = "8e54010315066ba2049baf7617b73ad055d4f34122c1d3c4ffa50bf0a8c4e36e" [metadata.files] attrs = [ @@ -1910,9 +1879,6 @@ isort = [ {file = "isort-5.7.0-py3-none-any.whl", hash = "sha256:fff4f0c04e1825522ce6949973e83110a6e907750cd92d128b0d14aaaadbffdc"}, {file = "isort-5.7.0.tar.gz", hash = "sha256:c729845434366216d320e936b8ad6f9d681aab72dc7cbc2d51bedc3582f3ad1e"}, ] -jaeger-client = [ - {file = "jaeger-client-4.8.0.tar.gz", hash = "sha256:3157836edab8e2c209bd2d6ae61113db36f7ee399e66b1dcbb715d87ab49bfe0"}, -] jeepney = [ {file = "jeepney-0.7.1-py3-none-any.whl", hash = "sha256:1b5a0ea5c0e7b166b2f5895b91a08c14de8915afda4407fb5022a195224958ac"}, {file = "jeepney-0.7.1.tar.gz", hash = "sha256:fa9e232dfa0c498bd0b8a3a73b8d8a31978304dcef0515adc859d4e096f96f4f"}, @@ -2135,8 +2101,17 @@ netaddr = [ {file = "netaddr-0.8.0-py2.py3-none-any.whl", hash = "sha256:9666d0232c32d2656e5e5f8d735f58fd6c7457ce52fc21c98d45f2af78f990ac"}, {file = "netaddr-0.8.0.tar.gz", hash = "sha256:d6cc57c7a07b1d9d2e917aa8b36ae8ce61c35ba3fcd1b83ca31c5a0ee2b5a243"}, ] -opentracing = [ - {file = "opentracing-2.4.0.tar.gz", hash = "sha256:a173117e6ef580d55874734d1fa7ecb6f3655160b8b8974a2a1e98e5ec9c840d"}, +opentelemetry-api = [ + {file = "opentelemetry-api-1.11.1.tar.gz", hash = "sha256:80abf335432930fd7c0635a71f79fda09e9c760ced3430c080aba4155e659c46"}, + {file = "opentelemetry_api-1.11.1-py3-none-any.whl", hash = "sha256:4041e7dbe6380e51555a2e2c50a690a6f3bc3b1fee2954e75bc61348b8840c1a"}, +] +opentelemetry-sdk = [ + {file = "opentelemetry-sdk-1.11.1.tar.gz", hash = "sha256:43e0e9ffc22aa3aa61bcbe4c95704fee608d7b0f961d7ff01bc88caf5e8cb9a8"}, + {file = "opentelemetry_sdk-1.11.1-py3-none-any.whl", hash = "sha256:435545512280d988f8555ba0a42383ec2cd95623a3062f278c19eb084b265d30"}, +] +opentelemetry-semantic-conventions = [ + {file = "opentelemetry-semantic-conventions-0.30b1.tar.gz", hash = "sha256:2fac7c7202602566b87b2ee3c90fbc272be6094725479f8102f083bf425cc253"}, + {file = "opentelemetry_semantic_conventions-0.30b1-py3-none-any.whl", hash = "sha256:5213268cd0a7a8fb94c054e4c1bac8c17586f732eca91769463320f3dcd910bb"}, ] packaging = [ {file = "packaging-21.3-py3-none-any.whl", hash = "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"}, @@ -2488,60 +2463,10 @@ sortedcontainers = [ systemd-python = [ {file = "systemd-python-234.tar.gz", hash = "sha256:fd0e44bf70eadae45aadc292cb0a7eb5b0b6372cd1b391228047d33895db83e7"}, ] -threadloop = [ - {file = "threadloop-1.0.2-py2-none-any.whl", hash = "sha256:5c90dbefab6ffbdba26afb4829d2a9df8275d13ac7dc58dccb0e279992679599"}, - {file = "threadloop-1.0.2.tar.gz", hash = "sha256:8b180aac31013de13c2ad5c834819771992d350267bddb854613ae77ef571944"}, -] -thrift = [ - {file = "thrift-0.15.0.tar.gz", hash = "sha256:87c8205a71cf8bbb111cb99b1f7495070fbc9cabb671669568854210da5b3e29"}, -] tomli = [ {file = "tomli-1.2.3-py3-none-any.whl", hash = "sha256:e3069e4be3ead9668e21cb9b074cd948f7b3113fd9c8bba083f48247aab8b11c"}, {file = "tomli-1.2.3.tar.gz", hash = "sha256:05b6166bff487dc068d322585c7ea4ef78deed501cc124060e0f238e89a9231f"}, ] -tornado = [ - {file = "tornado-6.1-cp35-cp35m-macosx_10_9_x86_64.whl", hash = "sha256:d371e811d6b156d82aa5f9a4e08b58debf97c302a35714f6f45e35139c332e32"}, - {file = "tornado-6.1-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:0d321a39c36e5f2c4ff12b4ed58d41390460f798422c4504e09eb5678e09998c"}, - {file = "tornado-6.1-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:9de9e5188a782be6b1ce866e8a51bc76a0fbaa0e16613823fc38e4fc2556ad05"}, - {file = "tornado-6.1-cp35-cp35m-manylinux2010_i686.whl", hash = "sha256:61b32d06ae8a036a6607805e6720ef00a3c98207038444ba7fd3d169cd998910"}, - {file = "tornado-6.1-cp35-cp35m-manylinux2010_x86_64.whl", hash = "sha256:3e63498f680547ed24d2c71e6497f24bca791aca2fe116dbc2bd0ac7f191691b"}, - {file = "tornado-6.1-cp35-cp35m-manylinux2014_aarch64.whl", hash = "sha256:6c77c9937962577a6a76917845d06af6ab9197702a42e1346d8ae2e76b5e3675"}, - {file = "tornado-6.1-cp35-cp35m-win32.whl", hash = "sha256:6286efab1ed6e74b7028327365cf7346b1d777d63ab30e21a0f4d5b275fc17d5"}, - {file = "tornado-6.1-cp35-cp35m-win_amd64.whl", hash = "sha256:fa2ba70284fa42c2a5ecb35e322e68823288a4251f9ba9cc77be04ae15eada68"}, - {file = "tornado-6.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:0a00ff4561e2929a2c37ce706cb8233b7907e0cdc22eab98888aca5dd3775feb"}, - {file = "tornado-6.1-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:748290bf9112b581c525e6e6d3820621ff020ed95af6f17fedef416b27ed564c"}, - {file = "tornado-6.1-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:e385b637ac3acaae8022e7e47dfa7b83d3620e432e3ecb9a3f7f58f150e50921"}, - {file = "tornado-6.1-cp36-cp36m-manylinux2010_i686.whl", hash = "sha256:25ad220258349a12ae87ede08a7b04aca51237721f63b1808d39bdb4b2164558"}, - {file = "tornado-6.1-cp36-cp36m-manylinux2010_x86_64.whl", hash = "sha256:65d98939f1a2e74b58839f8c4dab3b6b3c1ce84972ae712be02845e65391ac7c"}, - {file = "tornado-6.1-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:e519d64089b0876c7b467274468709dadf11e41d65f63bba207e04217f47c085"}, - {file = "tornado-6.1-cp36-cp36m-win32.whl", hash = "sha256:b87936fd2c317b6ee08a5741ea06b9d11a6074ef4cc42e031bc6403f82a32575"}, - {file = "tornado-6.1-cp36-cp36m-win_amd64.whl", hash = "sha256:cc0ee35043162abbf717b7df924597ade8e5395e7b66d18270116f8745ceb795"}, - {file = "tornado-6.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:7250a3fa399f08ec9cb3f7b1b987955d17e044f1ade821b32e5f435130250d7f"}, - {file = "tornado-6.1-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:ed3ad863b1b40cd1d4bd21e7498329ccaece75db5a5bf58cd3c9f130843e7102"}, - {file = "tornado-6.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:dcef026f608f678c118779cd6591c8af6e9b4155c44e0d1bc0c87c036fb8c8c4"}, - {file = "tornado-6.1-cp37-cp37m-manylinux2010_i686.whl", hash = "sha256:70dec29e8ac485dbf57481baee40781c63e381bebea080991893cd297742b8fd"}, - {file = "tornado-6.1-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:d3f7594930c423fd9f5d1a76bee85a2c36fd8b4b16921cae7e965f22575e9c01"}, - {file = "tornado-6.1-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:3447475585bae2e77ecb832fc0300c3695516a47d46cefa0528181a34c5b9d3d"}, - {file = "tornado-6.1-cp37-cp37m-win32.whl", hash = "sha256:e7229e60ac41a1202444497ddde70a48d33909e484f96eb0da9baf8dc68541df"}, - {file = "tornado-6.1-cp37-cp37m-win_amd64.whl", hash = "sha256:cb5ec8eead331e3bb4ce8066cf06d2dfef1bfb1b2a73082dfe8a161301b76e37"}, - {file = "tornado-6.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:20241b3cb4f425e971cb0a8e4ffc9b0a861530ae3c52f2b0434e6c1b57e9fd95"}, - {file = "tornado-6.1-cp38-cp38-manylinux1_i686.whl", hash = "sha256:c77da1263aa361938476f04c4b6c8916001b90b2c2fdd92d8d535e1af48fba5a"}, - {file = "tornado-6.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:fba85b6cd9c39be262fcd23865652920832b61583de2a2ca907dbd8e8a8c81e5"}, - {file = "tornado-6.1-cp38-cp38-manylinux2010_i686.whl", hash = "sha256:1e8225a1070cd8eec59a996c43229fe8f95689cb16e552d130b9793cb570a288"}, - {file = "tornado-6.1-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:d14d30e7f46a0476efb0deb5b61343b1526f73ebb5ed84f23dc794bdb88f9d9f"}, - {file = "tornado-6.1-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:8f959b26f2634a091bb42241c3ed8d3cedb506e7c27b8dd5c7b9f745318ddbb6"}, - {file = "tornado-6.1-cp38-cp38-win32.whl", hash = "sha256:34ca2dac9e4d7afb0bed4677512e36a52f09caa6fded70b4e3e1c89dbd92c326"}, - {file = "tornado-6.1-cp38-cp38-win_amd64.whl", hash = "sha256:6196a5c39286cc37c024cd78834fb9345e464525d8991c21e908cc046d1cc02c"}, - {file = "tornado-6.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:f0ba29bafd8e7e22920567ce0d232c26d4d47c8b5cf4ed7b562b5db39fa199c5"}, - {file = "tornado-6.1-cp39-cp39-manylinux1_i686.whl", hash = "sha256:33892118b165401f291070100d6d09359ca74addda679b60390b09f8ef325ffe"}, - {file = "tornado-6.1-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:7da13da6f985aab7f6f28debab00c67ff9cbacd588e8477034c0652ac141feea"}, - {file = "tornado-6.1-cp39-cp39-manylinux2010_i686.whl", hash = "sha256:e0791ac58d91ac58f694d8d2957884df8e4e2f6687cdf367ef7eb7497f79eaa2"}, - {file = "tornado-6.1-cp39-cp39-manylinux2010_x86_64.whl", hash = "sha256:66324e4e1beede9ac79e60f88de548da58b1f8ab4b2f1354d8375774f997e6c0"}, - {file = "tornado-6.1-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:a48900ecea1cbb71b8c71c620dee15b62f85f7c14189bdeee54966fbd9a0c5bd"}, - {file = "tornado-6.1-cp39-cp39-win32.whl", hash = "sha256:d3d20ea5782ba63ed13bc2b8c291a053c8d807a8fa927d941bd718468f7b950c"}, - {file = "tornado-6.1-cp39-cp39-win_amd64.whl", hash = "sha256:548430be2740e327b3fe0201abe471f314741efcb0067ec4f2d7dcfb4825f3e4"}, - {file = "tornado-6.1.tar.gz", hash = "sha256:33c6e81d7bd55b468d2e793517c909b139960b6c790a60b7991b9b6b76fb9791"}, -] towncrier = [ {file = "towncrier-21.9.0-py2.py3-none-any.whl", hash = "sha256:fc5a88a2a54988e3a8ed2b60d553599da8330f65722cc607c839614ed87e0f92"}, {file = "towncrier-21.9.0.tar.gz", hash = "sha256:9cb6f45c16e1a1eec9d0e7651165e7be60cd0ab81d13a5c96ca97a498ae87f48"}, diff --git a/pyproject.toml b/pyproject.toml index 4da1331c93..a6df4a26a6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -175,13 +175,13 @@ authlib = { version = ">=0.14.0", optional = true } systemd-python = { version = ">=231", optional = true } lxml = { version = ">=4.2.0", optional = true } sentry-sdk = { version = ">=0.7.2", optional = true } -opentracing = { version = ">=2.2.0", optional = true } -jaeger-client = { version = ">=4.0.0", optional = true } txredisapi = { version = ">=1.4.7", optional = true } hiredis = { version = "*", optional = true } Pympler = { version = "*", optional = true } parameterized = { version = ">=0.7.4", optional = true } idna = { version = ">=2.5", optional = true } +opentelemetry-api = {version = "^1.11.1", optional = true} +opentelemetry-sdk = {version = "^1.11.1", optional = true} [tool.poetry.extras] # NB: Packages that should be part of `pip install matrix-synapse[all]` need to be specified @@ -196,7 +196,7 @@ oidc = ["authlib"] systemd = ["systemd-python"] url_preview = ["lxml"] sentry = ["sentry-sdk"] -opentracing = ["jaeger-client", "opentracing"] +opentelemetry = ["opentelemetry-api", "opentelemetry-sdk"] jwt = ["authlib"] # hiredis is not a *strict* dependency, but it makes things much faster. # (if it is not installed, we fall back to slow code.) @@ -229,8 +229,8 @@ all = [ "lxml", # sentry "sentry-sdk", - # opentracing - "jaeger-client", "opentracing", + # opentelemetry + "opentelemetry-api", "opentelemetry-sdk", # redis "txredisapi", "hiredis", # cache_memory @@ -254,7 +254,6 @@ mypy-zope = "*" types-bleach = ">=4.1.0" types-commonmark = ">=0.9.2" types-jsonschema = ">=3.2.0" -types-opentracing = ">=2.4.2" types-Pillow = ">=8.3.4" types-psycopg2 = ">=2.9.9" types-pyOpenSSL = ">=20.0.7" diff --git a/synapse/api/auth.py b/synapse/api/auth.py index 6e6eaf3805..db8c70f82a 100644 --- a/synapse/api/auth.py +++ b/synapse/api/auth.py @@ -30,7 +30,7 @@ from synapse.api.errors import ( from synapse.appservice import ApplicationService from synapse.http import get_request_user_agent from synapse.http.site import SynapseRequest -from synapse.logging.opentracing import active_span, force_tracing, start_active_span +from synapse.logging.opentelemetry import active_span, force_tracing, start_active_span from synapse.storage.databases.main.registration import TokenLookupResult from synapse.types import Requester, UserID, create_requester diff --git a/synapse/app/_base.py b/synapse/app/_base.py index 923891ae0d..4bc5233d05 100644 --- a/synapse/app/_base.py +++ b/synapse/app/_base.py @@ -62,7 +62,7 @@ from synapse.events.spamcheck import load_legacy_spam_checkers from synapse.events.third_party_rules import load_legacy_third_party_event_rules from synapse.handlers.auth import load_legacy_password_auth_providers from synapse.logging.context import PreserveLoggingContext -from synapse.logging.opentracing import init_tracer +from synapse.logging.opentelemetry import init_tracer from synapse.metrics import install_gc_manager, register_threadpool from synapse.metrics.background_process_metrics import wrap_as_background_process from synapse.metrics.jemalloc import setup_jemalloc_stats diff --git a/synapse/config/tracer.py b/synapse/config/tracer.py index c19270c6c5..5bd96ef9f7 100644 --- a/synapse/config/tracer.py +++ b/synapse/config/tracer.py @@ -24,33 +24,34 @@ class TracerConfig(Config): section = "tracing" def read_config(self, config: JsonDict, **kwargs: Any) -> None: - opentracing_config = config.get("opentracing") - if opentracing_config is None: - opentracing_config = {} + opentelemetry_config = config.get("opentelemetry") + if opentelemetry_config is None: + opentelemetry_config = {} - self.opentracer_enabled = opentracing_config.get("enabled", False) + self.opentelemetry_enabled = opentelemetry_config.get("enabled", False) - self.jaeger_config = opentracing_config.get( + # TODO: no more + self.jaeger_config = opentelemetry_config.get( "jaeger_config", {"sampler": {"type": "const", "param": 1}, "logging": False}, ) self.force_tracing_for_users: Set[str] = set() - if not self.opentracer_enabled: + if not self.opentelemetry_enabled: return - check_requirements("opentracing") + check_requirements("opentelemetry") # The tracer is enabled so sanitize the config - self.opentracer_whitelist: List[str] = opentracing_config.get( + self.opentelemetry_whitelist: List[str] = opentelemetry_config.get( "homeserver_whitelist", [] ) - if not isinstance(self.opentracer_whitelist, list): + if not isinstance(self.opentelemetry_whitelist, list): raise ConfigError("Tracer homeserver_whitelist config is malformed") - force_tracing_for_users = opentracing_config.get("force_tracing_for_users", []) + force_tracing_for_users = opentelemetry_config.get("force_tracing_for_users", []) if not isinstance(force_tracing_for_users, list): raise ConfigError( "Expected a list", ("opentracing", "force_tracing_for_users") diff --git a/synapse/federation/federation_server.py b/synapse/federation/federation_server.py index ae550d3f4d..d269c9c809 100644 --- a/synapse/federation/federation_server.py +++ b/synapse/federation/federation_server.py @@ -61,7 +61,7 @@ from synapse.logging.context import ( nested_logging_context, run_in_background, ) -from synapse.logging.opentracing import log_kv, start_active_span_from_edu, trace +from synapse.logging.opentelemetry import log_kv, start_active_span_from_edu, trace from synapse.metrics.background_process_metrics import wrap_as_background_process from synapse.replication.http.federation import ( ReplicationFederationSendEduRestServlet, diff --git a/synapse/federation/sender/per_destination_queue.py b/synapse/federation/sender/per_destination_queue.py index 41d8b937af..b0c391e387 100644 --- a/synapse/federation/sender/per_destination_queue.py +++ b/synapse/federation/sender/per_destination_queue.py @@ -32,7 +32,7 @@ from synapse.events import EventBase from synapse.federation.units import Edu from synapse.handlers.presence import format_user_presence_state from synapse.logging import issue9533_logger -from synapse.logging.opentracing import SynapseTags, set_tag +from synapse.logging.opentelemetry import SynapseTags, set_tag from synapse.metrics import sent_transactions_counter from synapse.metrics.background_process_metrics import run_as_background_process from synapse.types import ReadReceipt diff --git a/synapse/federation/sender/transaction_manager.py b/synapse/federation/sender/transaction_manager.py index 75081810fd..ef01511ddf 100644 --- a/synapse/federation/sender/transaction_manager.py +++ b/synapse/federation/sender/transaction_manager.py @@ -21,7 +21,7 @@ from synapse.api.errors import HttpResponseException from synapse.events import EventBase from synapse.federation.persistence import TransactionActions from synapse.federation.units import Edu, Transaction -from synapse.logging.opentracing import ( +from synapse.logging.opentelemetry import ( extract_text_map, set_tag, start_active_span_follows_from, diff --git a/synapse/federation/transport/server/_base.py b/synapse/federation/transport/server/_base.py index bb0f8d6b7b..92596d95f9 100644 --- a/synapse/federation/transport/server/_base.py +++ b/synapse/federation/transport/server/_base.py @@ -25,7 +25,7 @@ from synapse.http.server import HttpServer, ServletCallback, is_method_cancellab from synapse.http.servlet import parse_json_object_from_request from synapse.http.site import SynapseRequest from synapse.logging.context import run_in_background -from synapse.logging.opentracing import ( +from synapse.logging.opentelemetry import ( active_span, set_tag, span_context_from_request, diff --git a/synapse/handlers/device.py b/synapse/handlers/device.py index 1a8379854c..824eaf35d9 100644 --- a/synapse/handlers/device.py +++ b/synapse/handlers/device.py @@ -36,7 +36,7 @@ from synapse.api.errors import ( RequestSendFailed, SynapseError, ) -from synapse.logging.opentracing import log_kv, set_tag, trace +from synapse.logging.opentelemetry import log_kv, set_tag, trace from synapse.metrics.background_process_metrics import ( run_as_background_process, wrap_as_background_process, diff --git a/synapse/handlers/devicemessage.py b/synapse/handlers/devicemessage.py index 444c08bc2e..465c4c80ba 100644 --- a/synapse/handlers/devicemessage.py +++ b/synapse/handlers/devicemessage.py @@ -19,7 +19,7 @@ from synapse.api.constants import EduTypes, ToDeviceEventTypes from synapse.api.errors import SynapseError from synapse.api.ratelimiting import Ratelimiter from synapse.logging.context import run_in_background -from synapse.logging.opentracing import ( +from synapse.logging.opentelemetry import ( SynapseTags, get_active_span_text_map, log_kv, diff --git a/synapse/handlers/e2e_keys.py b/synapse/handlers/e2e_keys.py index c938339ddd..5e24c0ef7a 100644 --- a/synapse/handlers/e2e_keys.py +++ b/synapse/handlers/e2e_keys.py @@ -28,7 +28,7 @@ from twisted.internet import defer from synapse.api.constants import EduTypes from synapse.api.errors import CodeMessageException, Codes, NotFoundError, SynapseError from synapse.logging.context import make_deferred_yieldable, run_in_background -from synapse.logging.opentracing import log_kv, set_tag, tag_args, trace +from synapse.logging.opentelemetry import log_kv, set_tag, tag_args, trace from synapse.replication.http.devices import ReplicationUserDevicesResyncRestServlet from synapse.types import ( JsonDict, diff --git a/synapse/handlers/e2e_room_keys.py b/synapse/handlers/e2e_room_keys.py index 28dc08c22a..28909165f5 100644 --- a/synapse/handlers/e2e_room_keys.py +++ b/synapse/handlers/e2e_room_keys.py @@ -25,7 +25,7 @@ from synapse.api.errors import ( StoreError, SynapseError, ) -from synapse.logging.opentracing import log_kv, trace +from synapse.logging.opentelemetry import log_kv, trace from synapse.storage.databases.main.e2e_room_keys import RoomKey from synapse.types import JsonDict from synapse.util.async_helpers import Linearizer diff --git a/synapse/handlers/sync.py b/synapse/handlers/sync.py index d42a414c90..524f1470e6 100644 --- a/synapse/handlers/sync.py +++ b/synapse/handlers/sync.py @@ -25,7 +25,7 @@ from synapse.api.room_versions import KNOWN_ROOM_VERSIONS from synapse.events import EventBase from synapse.handlers.relations import BundledAggregations from synapse.logging.context import current_context -from synapse.logging.opentracing import SynapseTags, log_kv, set_tag, start_active_span +from synapse.logging.opentelemetry import SynapseTags, log_kv, set_tag, start_active_span from synapse.push.clientformat import format_push_rules_for_user from synapse.storage.databases.main.event_push_actions import NotifCounts from synapse.storage.roommember import MemberSummary diff --git a/synapse/http/client.py b/synapse/http/client.py index 084d0a5b84..03d92a1383 100644 --- a/synapse/http/client.py +++ b/synapse/http/client.py @@ -75,7 +75,7 @@ from synapse.http import QuieterFileBodyProducer, RequestTimedOutError, redact_u from synapse.http.proxyagent import ProxyAgent from synapse.http.types import QueryParams from synapse.logging.context import make_deferred_yieldable -from synapse.logging.opentracing import set_tag, start_active_span, tags +from synapse.logging.opentelemetry import set_tag, start_active_span, tags from synapse.types import ISynapseReactor from synapse.util import json_decoder from synapse.util.async_helpers import timeout_deferred diff --git a/synapse/http/matrixfederationclient.py b/synapse/http/matrixfederationclient.py index 3c35b1d2c7..e920566af4 100644 --- a/synapse/http/matrixfederationclient.py +++ b/synapse/http/matrixfederationclient.py @@ -72,9 +72,9 @@ from synapse.http.client import ( ) from synapse.http.federation.matrix_federation_agent import MatrixFederationAgent from synapse.http.types import QueryParams -from synapse.logging import opentracing +from synapse.logging import opentelemetry from synapse.logging.context import make_deferred_yieldable, run_in_background -from synapse.logging.opentracing import set_tag, start_active_span, tags +from synapse.logging.opentelemetry import set_tag, start_active_span, tags from synapse.types import JsonDict from synapse.util import json_decoder from synapse.util.async_helpers import AwakenableSleeper, timeout_deferred @@ -528,7 +528,7 @@ class MatrixFederationHttpClient: # Inject the span into the headers headers_dict: Dict[bytes, List[bytes]] = {} - opentracing.inject_header_dict(headers_dict, request.destination) + opentelemetry.inject_header_dict(headers_dict, request.destination) headers_dict[b"User-Agent"] = [self.version_string_bytes] diff --git a/synapse/http/server.py b/synapse/http/server.py index cf2d6f904b..952d961f31 100644 --- a/synapse/http/server.py +++ b/synapse/http/server.py @@ -60,7 +60,7 @@ from synapse.api.errors import ( ) from synapse.http.site import SynapseRequest from synapse.logging.context import defer_to_thread, preserve_fn, run_in_background -from synapse.logging.opentracing import active_span, start_active_span, trace_servlet +from synapse.logging.opentelemetry import active_span, start_active_span, trace_servlet from synapse.util import json_encoder from synapse.util.caches import intern_dict from synapse.util.iterutils import chunk_seq diff --git a/synapse/logging/opentracing.py b/synapse/logging/opentelemetry.py index ad5cbf46a4..e5e62bd8cf 100644 --- a/synapse/logging/opentracing.py +++ b/synapse/logging/opentelemetry.py @@ -234,54 +234,15 @@ class _DummyTagNames: SPAN_KIND_RPC_CLIENT = INVALID_TAG SPAN_KIND_RPC_SERVER = INVALID_TAG - +# These dependencies are optional so they can fail to import +# and we try: - import opentracing - import opentracing.tags + import opentelemetry - tags = opentracing.tags + # TODO: tags? except ImportError: - opentracing = None # type: ignore[assignment] + opentelemetry = None # type: ignore[assignment] tags = _DummyTagNames # type: ignore[assignment] -try: - from jaeger_client import Config as JaegerConfig - - from synapse.logging.scopecontextmanager import LogContextScopeManager -except ImportError: - JaegerConfig = None # type: ignore - LogContextScopeManager = None # type: ignore - - -try: - from rust_python_jaeger_reporter import Reporter - - # jaeger-client 4.7.0 requires that reporters inherit from BaseReporter, which - # didn't exist before that version. - try: - from jaeger_client.reporter import BaseReporter - except ImportError: - - class BaseReporter: # type: ignore[no-redef] - pass - - @attr.s(slots=True, frozen=True, auto_attribs=True) - class _WrappedRustReporter(BaseReporter): - """Wrap the reporter to ensure `report_span` never throws.""" - - _reporter: Reporter = attr.Factory(Reporter) - - def set_process(self, *args: Any, **kwargs: Any) -> None: - return self._reporter.set_process(*args, **kwargs) - - def report_span(self, span: "opentracing.Span") -> None: - try: - return self._reporter.report_span(span) - except Exception: - logger.exception("Failed to report span") - - RustReporter: Optional[Type[_WrappedRustReporter]] = _WrappedRustReporter -except ImportError: - RustReporter = None logger = logging.getLogger(__name__) @@ -338,7 +299,7 @@ def only_if_tracing(func: Callable[P, R]) -> Callable[P, Optional[R]]: @wraps(func) def _only_if_tracing_inner(*args: P.args, **kwargs: P.kwargs) -> Optional[R]: - if opentracing: + if opentelemetry: return func(*args, **kwargs) else: return None @@ -363,16 +324,16 @@ def ensure_active_span( def ensure_active_span( message: str, ret: Optional[T] = None ) -> Callable[[Callable[P, R]], Callable[P, Union[Optional[T], R]]]: - """Executes the operation only if opentracing is enabled and there is an active span. + """Executes the operation only if opentelemetry is enabled and there is an active span. If there is no active span it logs message at the error level. Args: message: Message which fills in "There was no active span when trying to %s" - in the error log if there is no active span and opentracing is enabled. - ret: return value if opentracing is None or there is no active span. + in the error log if there is no active span and opentelemetry is enabled. + ret: return value if opentelemetry is None or there is no active span. Returns: - The result of the func, falling back to ret if opentracing is disabled or there + The result of the func, falling back to ret if opentelemetry is disabled or there was no active span. """ @@ -383,10 +344,10 @@ def ensure_active_span( def ensure_active_span_inner_2( *args: P.args, **kwargs: P.kwargs ) -> Union[Optional[T], R]: - if not opentracing: + if not opentelemetry: return ret - if not opentracing.tracer.active_span: + if not opentelemetry.trace.get_current_span(): logger.error( "There was no active span when trying to %s." " Did you forget to start one or did a context slip?", @@ -408,41 +369,29 @@ def ensure_active_span( def init_tracer(hs: "HomeServer") -> None: """Set the whitelists and initialise the JaegerClient tracer""" - global opentracing - if not hs.config.tracing.opentracer_enabled: + global opentelemetry + if not hs.config.tracing.opentelemetry_enabled: # We don't have a tracer - opentracing = None # type: ignore[assignment] + opentelemetry = None # type: ignore[assignment] return - if not opentracing or not JaegerConfig: + if not opentelemetry: raise ConfigError( - "The server has been configured to use opentracing but opentracing is not " + "The server has been configured to use OpenTelemetry but OpenTelemetry is not " "installed." ) - # Pull out the jaeger config if it was given. Otherwise set it to something sensible. - # See https://github.com/jaegertracing/jaeger-client-python/blob/master/jaeger_client/config.py + # Pull out of the config if it was given. Otherwise set it to something sensible. + set_homeserver_whitelist(hs.config.tracing.opentelemetry_whitelist) - set_homeserver_whitelist(hs.config.tracing.opentracer_whitelist) + # TODO: opentelemetry_whitelist - from jaeger_client.metrics.prometheus import PrometheusMetricsFactory - - config = JaegerConfig( - config=hs.config.tracing.jaeger_config, - service_name=f"{hs.config.server.server_name} {hs.get_instance_name()}", - scope_manager=LogContextScopeManager(), - metrics_factory=PrometheusMetricsFactory(), - ) - - # If we have the rust jaeger reporter available let's use that. - if RustReporter: - logger.info("Using rust_python_jaeger_reporter library") - assert config.sampler is not None - tracer = config.create_tracer(RustReporter(), config.sampler) - opentracing.set_global_tracer(tracer) - else: - config.initialize_tracer() + provider = opentelemetry.TracerProvider() + processor = opentelemetry.BatchSpanProcessor(opentelemetry.ConsoleSpanExporter()) + provider.add_span_processor(processor) + # Sets the global default tracer provider + trace.set_tracer_provider(provider) # Whitelisting @@ -500,14 +449,14 @@ def start_active_span( scope (Scope) or contextlib.nullcontext """ - if opentracing is None: + if opentelemetry is None: return contextlib.nullcontext() # type: ignore[unreachable] if tracer is None: # use the global tracer by default - tracer = opentracing.tracer + tracer = opentelemetry.trace.get_tracer(__name__) - return tracer.start_active_span( + return tracer.start_as_current_span( operation_name, child_of=child_of, references=references, diff --git a/synapse/metrics/background_process_metrics.py b/synapse/metrics/background_process_metrics.py index 7a1516d3a8..0f93a41b23 100644 --- a/synapse/metrics/background_process_metrics.py +++ b/synapse/metrics/background_process_metrics.py @@ -42,7 +42,7 @@ from synapse.logging.context import ( LoggingContext, PreserveLoggingContext, ) -from synapse.logging.opentracing import SynapseTags, start_active_span +from synapse.logging.opentelemetry import SynapseTags, start_active_span from synapse.metrics._types import Collector if TYPE_CHECKING: diff --git a/synapse/notifier.py b/synapse/notifier.py index c42bb8266a..e34b6cc3e0 100644 --- a/synapse/notifier.py +++ b/synapse/notifier.py @@ -39,7 +39,7 @@ from synapse.events import EventBase from synapse.handlers.presence import format_user_presence_state from synapse.logging import issue9533_logger from synapse.logging.context import PreserveLoggingContext -from synapse.logging.opentracing import log_kv, start_active_span +from synapse.logging.opentelemetry import log_kv, start_active_span from synapse.metrics import LaterGauge from synapse.streams.config import PaginationConfig from synapse.types import ( diff --git a/synapse/push/httppusher.py b/synapse/push/httppusher.py index e96fb45e9f..895a13b84e 100644 --- a/synapse/push/httppusher.py +++ b/synapse/push/httppusher.py @@ -23,7 +23,7 @@ from twisted.internet.interfaces import IDelayedCall from synapse.api.constants import EventTypes from synapse.events import EventBase -from synapse.logging import opentracing +from synapse.logging import opentelemetry from synapse.metrics.background_process_metrics import run_as_background_process from synapse.push import Pusher, PusherConfig, PusherConfigException from synapse.storage.databases.main.event_push_actions import HttpPushAction @@ -198,7 +198,7 @@ class HttpPusher(Pusher): ) for push_action in unprocessed: - with opentracing.start_active_span( + with opentelemetry.start_active_span( "http-push", tags={ "authenticated_entity": self.user_id, diff --git a/synapse/replication/http/_base.py b/synapse/replication/http/_base.py index 561ad5bf04..7237f12de1 100644 --- a/synapse/replication/http/_base.py +++ b/synapse/replication/http/_base.py @@ -28,8 +28,8 @@ from synapse.api.errors import HttpResponseException, SynapseError from synapse.http import RequestTimedOutError from synapse.http.server import HttpServer, is_method_cancellable from synapse.http.site import SynapseRequest -from synapse.logging import opentracing -from synapse.logging.opentracing import trace_with_opname +from synapse.logging import opentelemetry +from synapse.logging.opentelemetry import trace_with_opname from synapse.types import JsonDict from synapse.util.caches.response_cache import ResponseCache from synapse.util.stringutils import random_string @@ -248,7 +248,7 @@ class ReplicationEndpoint(metaclass=abc.ABCMeta): # Add an authorization header, if configured. if replication_secret: headers[b"Authorization"] = [b"Bearer " + replication_secret] - opentracing.inject_header_dict(headers, check_destination=False) + opentelemetry.inject_header_dict(headers, check_destination=False) try: # Keep track of attempts made so we can bail if we don't manage to diff --git a/synapse/replication/tcp/external_cache.py b/synapse/replication/tcp/external_cache.py index a448dd7eb1..c69ba0f73e 100644 --- a/synapse/replication/tcp/external_cache.py +++ b/synapse/replication/tcp/external_cache.py @@ -17,7 +17,7 @@ from typing import TYPE_CHECKING, Any, Optional from prometheus_client import Counter, Histogram -from synapse.logging import opentracing +from synapse.logging import opentelemetry from synapse.logging.context import make_deferred_yieldable from synapse.util import json_decoder, json_encoder @@ -94,9 +94,9 @@ class ExternalCache: logger.debug("Caching %s %s: %r", cache_name, key, encoded_value) - with opentracing.start_active_span( + with opentelemetry.start_active_span( "ExternalCache.set", - tags={opentracing.SynapseTags.CACHE_NAME: cache_name}, + tags={opentelemetry.SynapseTags.CACHE_NAME: cache_name}, ): with response_timer.labels("set").time(): return await make_deferred_yieldable( @@ -113,9 +113,9 @@ class ExternalCache: if self._redis_connection is None: return None - with opentracing.start_active_span( + with opentelemetry.start_active_span( "ExternalCache.get", - tags={opentracing.SynapseTags.CACHE_NAME: cache_name}, + tags={opentelemetry.SynapseTags.CACHE_NAME: cache_name}, ): with response_timer.labels("get").time(): result = await make_deferred_yieldable( diff --git a/synapse/rest/client/keys.py b/synapse/rest/client/keys.py index e3f454896a..6301419cd5 100644 --- a/synapse/rest/client/keys.py +++ b/synapse/rest/client/keys.py @@ -26,7 +26,7 @@ from synapse.http.servlet import ( parse_string, ) from synapse.http.site import SynapseRequest -from synapse.logging.opentracing import log_kv, set_tag, trace_with_opname +from synapse.logging.opentelemetry import log_kv, set_tag, trace_with_opname from synapse.types import JsonDict, StreamToken from ._base import client_patterns, interactive_auth_handler diff --git a/synapse/rest/client/knock.py b/synapse/rest/client/knock.py index ad025c8a45..a8b765b115 100644 --- a/synapse/rest/client/knock.py +++ b/synapse/rest/client/knock.py @@ -24,7 +24,7 @@ from synapse.http.servlet import ( parse_strings_from_args, ) from synapse.http.site import SynapseRequest -from synapse.logging.opentracing import set_tag +from synapse.logging.opentelemetry import set_tag from synapse.rest.client.transactions import HttpTransactionCache from synapse.types import JsonDict, RoomAlias, RoomID diff --git a/synapse/rest/client/room.py b/synapse/rest/client/room.py index 2f513164cb..08ceb15297 100644 --- a/synapse/rest/client/room.py +++ b/synapse/rest/client/room.py @@ -46,7 +46,7 @@ from synapse.http.servlet import ( parse_strings_from_args, ) from synapse.http.site import SynapseRequest -from synapse.logging.opentracing import set_tag +from synapse.logging.opentelemetry import set_tag from synapse.rest.client._base import client_patterns from synapse.rest.client.transactions import HttpTransactionCache from synapse.storage.state import StateFilter diff --git a/synapse/rest/client/sendtodevice.py b/synapse/rest/client/sendtodevice.py index 1a8e9a96d4..76dc2094b7 100644 --- a/synapse/rest/client/sendtodevice.py +++ b/synapse/rest/client/sendtodevice.py @@ -19,7 +19,7 @@ from synapse.http import servlet from synapse.http.server import HttpServer from synapse.http.servlet import assert_params_in_dict, parse_json_object_from_request from synapse.http.site import SynapseRequest -from synapse.logging.opentracing import set_tag, trace_with_opname +from synapse.logging.opentelemetry import set_tag, trace_with_opname from synapse.rest.client.transactions import HttpTransactionCache from synapse.types import JsonDict diff --git a/synapse/rest/client/sync.py b/synapse/rest/client/sync.py index c2989765ce..9f6453f288 100644 --- a/synapse/rest/client/sync.py +++ b/synapse/rest/client/sync.py @@ -37,7 +37,7 @@ from synapse.handlers.sync import ( from synapse.http.server import HttpServer from synapse.http.servlet import RestServlet, parse_boolean, parse_integer, parse_string from synapse.http.site import SynapseRequest -from synapse.logging.opentracing import trace_with_opname +from synapse.logging.opentelemetry import trace_with_opname from synapse.types import JsonDict, StreamToken from synapse.util import json_decoder diff --git a/synapse/storage/controllers/persist_events.py b/synapse/storage/controllers/persist_events.py index cf98b0ab48..3ff544cc2e 100644 --- a/synapse/storage/controllers/persist_events.py +++ b/synapse/storage/controllers/persist_events.py @@ -45,7 +45,7 @@ from twisted.internet import defer from synapse.api.constants import EventTypes, Membership from synapse.events import EventBase from synapse.events.snapshot import EventContext -from synapse.logging import opentracing +from synapse.logging import opentelemetry from synapse.logging.context import PreserveLoggingContext, make_deferred_yieldable from synapse.metrics.background_process_metrics import run_as_background_process from synapse.storage.controllers.state import StateStorageController @@ -223,7 +223,7 @@ class _EventPeristenceQueue(Generic[_PersistResult]): queue.append(end_item) # also add our active opentracing span to the item so that we get a link back - span = opentracing.active_span() + span = opentelemetry.active_span() if span: end_item.parent_opentracing_span_contexts.append(span.context) @@ -234,7 +234,7 @@ class _EventPeristenceQueue(Generic[_PersistResult]): res = await make_deferred_yieldable(end_item.deferred.observe()) # add another opentracing span which links to the persist trace. - with opentracing.start_active_span_follows_from( + with opentelemetry.start_active_span_follows_from( f"{task.name}_complete", (end_item.opentracing_span_context,) ): pass @@ -266,7 +266,7 @@ class _EventPeristenceQueue(Generic[_PersistResult]): queue = self._get_drainining_queue(room_id) for item in queue: try: - with opentracing.start_active_span_follows_from( + with opentelemetry.start_active_span_follows_from( item.task.name, item.parent_opentracing_span_contexts, inherit_force_tracing=True, @@ -355,7 +355,7 @@ class EventsPersistenceStorageController: f"Found an unexpected task type in event persistence queue: {task}" ) - @opentracing.trace + @opentelemetry.trace async def persist_events( self, events_and_contexts: Iterable[Tuple[EventBase, EventContext]], @@ -418,7 +418,7 @@ class EventsPersistenceStorageController: self.main_store.get_room_max_token(), ) - @opentracing.trace + @opentelemetry.trace async def persist_event( self, event: EventBase, context: EventContext, backfilled: bool = False ) -> Tuple[EventBase, PersistedEventPosition, RoomStreamToken]: diff --git a/synapse/storage/database.py b/synapse/storage/database.py index b394a6658b..3445a93225 100644 --- a/synapse/storage/database.py +++ b/synapse/storage/database.py @@ -47,7 +47,7 @@ from twisted.internet.interfaces import IReactorCore from synapse.api.errors import StoreError from synapse.config.database import DatabaseConnectionConfig -from synapse.logging import opentracing +from synapse.logging import opentelemetry from synapse.logging.context import ( LoggingContext, current_context, @@ -422,11 +422,11 @@ class LoggingTransaction: start = time.time() try: - with opentracing.start_active_span( + with opentelemetry.start_active_span( "db.query", tags={ - opentracing.tags.DATABASE_TYPE: "sql", - opentracing.tags.DATABASE_STATEMENT: one_line_sql, + opentelemetry.tags.DATABASE_TYPE: "sql", + opentelemetry.tags.DATABASE_STATEMENT: one_line_sql, }, ): return func(sql, *args, **kwargs) @@ -701,15 +701,15 @@ class DatabasePool: exception_callbacks=exception_callbacks, ) try: - with opentracing.start_active_span( + with opentelemetry.start_active_span( "db.txn", tags={ - opentracing.SynapseTags.DB_TXN_DESC: desc, - opentracing.SynapseTags.DB_TXN_ID: name, + opentelemetry.SynapseTags.DB_TXN_DESC: desc, + opentelemetry.SynapseTags.DB_TXN_ID: name, }, ): r = func(cursor, *args, **kwargs) - opentracing.log_kv({"message": "commit"}) + opentelemetry.log_kv({"message": "commit"}) conn.commit() return r except self.engine.module.OperationalError as e: @@ -725,7 +725,7 @@ class DatabasePool: if i < N: i += 1 try: - with opentracing.start_active_span("db.rollback"): + with opentelemetry.start_active_span("db.rollback"): conn.rollback() except self.engine.module.Error as e1: transaction_logger.warning("[TXN EROLL] {%s} %s", name, e1) @@ -739,7 +739,7 @@ class DatabasePool: if i < N: i += 1 try: - with opentracing.start_active_span("db.rollback"): + with opentelemetry.start_active_span("db.rollback"): conn.rollback() except self.engine.module.Error as e1: transaction_logger.warning( @@ -845,7 +845,7 @@ class DatabasePool: logger.warning("Starting db txn '%s' from sentinel context", desc) try: - with opentracing.start_active_span(f"db.{desc}"): + with opentelemetry.start_active_span(f"db.{desc}"): result = await self.runWithConnection( self.new_transaction, desc, @@ -928,7 +928,7 @@ class DatabasePool: with LoggingContext( str(curr_context), parent_context=parent_context ) as context: - with opentracing.start_active_span( + with opentelemetry.start_active_span( operation_name="db.connection", ): sched_duration_sec = monotonic_time() - start_time @@ -944,7 +944,7 @@ class DatabasePool: "Reconnecting database connection over transaction limit" ) conn.reconnect() - opentracing.log_kv( + opentelemetry.log_kv( {"message": "reconnected due to txn limit"} ) self._txn_counters[tid] = 1 @@ -952,7 +952,7 @@ class DatabasePool: if self.engine.is_connection_closed(conn): logger.debug("Reconnecting closed database connection") conn.reconnect() - opentracing.log_kv({"message": "reconnected"}) + opentelemetry.log_kv({"message": "reconnected"}) if self._txn_limit > 0: self._txn_counters[tid] = 1 diff --git a/synapse/storage/databases/main/deviceinbox.py b/synapse/storage/databases/main/deviceinbox.py index 73c95ffb6f..7a6dfaab72 100644 --- a/synapse/storage/databases/main/deviceinbox.py +++ b/synapse/storage/databases/main/deviceinbox.py @@ -27,7 +27,7 @@ from typing import ( ) from synapse.logging import issue9533_logger -from synapse.logging.opentracing import log_kv, set_tag, trace +from synapse.logging.opentelemetry import log_kv, set_tag, trace from synapse.replication.tcp.streams import ToDeviceStream from synapse.storage._base import SQLBaseStore, db_to_json from synapse.storage.database import ( diff --git a/synapse/storage/databases/main/devices.py b/synapse/storage/databases/main/devices.py index ca0fe8c4be..d475aebf24 100644 --- a/synapse/storage/databases/main/devices.py +++ b/synapse/storage/databases/main/devices.py @@ -32,7 +32,7 @@ from typing_extensions import Literal from synapse.api.constants import EduTypes from synapse.api.errors import Codes, StoreError -from synapse.logging.opentracing import ( +from synapse.logging.opentelemetry import ( get_active_span_text_map, set_tag, trace, diff --git a/synapse/storage/databases/main/e2e_room_keys.py b/synapse/storage/databases/main/e2e_room_keys.py index af59be6b48..082eeef24f 100644 --- a/synapse/storage/databases/main/e2e_room_keys.py +++ b/synapse/storage/databases/main/e2e_room_keys.py @@ -18,7 +18,7 @@ from typing import Dict, Iterable, Mapping, Optional, Tuple, cast from typing_extensions import Literal, TypedDict from synapse.api.errors import StoreError -from synapse.logging.opentracing import log_kv, trace +from synapse.logging.opentelemetry import log_kv, trace from synapse.storage._base import SQLBaseStore, db_to_json from synapse.storage.database import LoggingTransaction from synapse.types import JsonDict, JsonSerializable, StreamKeyType diff --git a/synapse/storage/databases/main/end_to_end_keys.py b/synapse/storage/databases/main/end_to_end_keys.py index 46c0d06157..4689063fa0 100644 --- a/synapse/storage/databases/main/end_to_end_keys.py +++ b/synapse/storage/databases/main/end_to_end_keys.py @@ -36,7 +36,7 @@ from synapse.appservice import ( TransactionOneTimeKeyCounts, TransactionUnusedFallbackKeys, ) -from synapse.logging.opentracing import log_kv, set_tag, trace +from synapse.logging.opentelemetry import log_kv, set_tag, trace from synapse.storage._base import SQLBaseStore, db_to_json from synapse.storage.database import ( DatabasePool, diff --git a/synapse/util/caches/response_cache.py b/synapse/util/caches/response_cache.py index a3eb5f741b..9c6cda446a 100644 --- a/synapse/util/caches/response_cache.py +++ b/synapse/util/caches/response_cache.py @@ -29,7 +29,7 @@ import attr from twisted.internet import defer from synapse.logging.context import make_deferred_yieldable, run_in_background -from synapse.logging.opentracing import ( +from synapse.logging.opentelemetry import ( active_span, start_active_span, start_active_span_follows_from, diff --git a/tests/logging/test_opentracing.py b/tests/logging/test_opentracing.py index 3b14c76d7e..135a8de34a 100644 --- a/tests/logging/test_opentracing.py +++ b/tests/logging/test_opentracing.py @@ -22,7 +22,7 @@ from synapse.logging.context import ( make_deferred_yieldable, run_in_background, ) -from synapse.logging.opentracing import ( +from synapse.logging.opentelemetry import ( start_active_span, start_active_span_follows_from, ) |