-
Notifications
You must be signed in to change notification settings - Fork 4
multiple opentelemetry fixups #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
5af0397
to
50e6b34
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #27 +/- ##
==========================================
- Coverage 78.67% 78.65% -0.03%
==========================================
Files 472 472
Lines 67635 67657 +22
Branches 10417 10421 +4
==========================================
+ Hits 53215 53218 +3
- Misses 10901 10919 +18
- Partials 3519 3520 +1
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Largely, I'm ok with all these changes. Things are working again in CI, which was my major hang up.
Having said that, something is still not right in that I can not seem to get log data properly out consistently. Whenever Synapse hit's a /health
request, it trips over itself and flushes thousand of log lines about a maximum recursion depth exceeded.
I think this may be as simple as changing
Line 296 in 1556930
return None, None |
at the first value to just be something 'not None', as that is what is tripping up opentelemetry. (As an option, at one of the call sites the user agent string is being produced and when it is 'not None' the just use -
. Similar thing would be ok for me, as this seems to be only used for rendering text display like logs)
Probably a hundred of these
2025-04-18 17:15:41,906 - opentelemetry.attributes - 111 - WARNING - GET-0 - Invalid type NoneType for attribute 'requester' value. Expected one of ['bool', 'str', 'bytes', 'int', 'float'] or a sequence of those types
then a repeating version of
2025-04-18 17:15:41,784 - twisted - 287 - CRITICAL - sentinel -
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/twisted/web/server.py", line 213, in process
self.render(resrc)
File "/usr/local/lib/python3.12/site-packages/synapse/http/site.py", line 329, in render
self._started_processing(servlet_name)
File "/usr/local/lib/python3.12/site-packages/synapse/http/site.py", line 463, in _started_processing
self.synapse_site.access_logger.debug(
File "/usr/local/lib/python3.12/logging/__init__.py", line 1527, in debug
self._log(DEBUG, msg, args, **kwargs)
File "/usr/local/lib/python3.12/logging/__init__.py", line 1684, in _log
self.handle(record)
File "/usr/local/lib/python3.12/logging/__init__.py", line 1700, in handle
self.callHandlers(record)
File "/usr/local/lib/python3.12/logging/__init__.py", line 1762, in callHandlers
hdlr.handle(record)
File "/usr/local/lib/python3.12/logging/__init__.py", line 1028, in handle
self.emit(record)
File "/usr/local/lib/python3.12/site-packages/opentelemetry/sdk/_logs/_internal/__init__.py", line 562, in emit
logger.emit(self._translate(record))
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/opentelemetry/sdk/_logs/_internal/__init__.py", line 541, in _translate
return LogRecord(
^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/opentelemetry/sdk/_logs/_internal/__init__.py", line 198, in __init__
"attributes": BoundedAttributes(
^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/opentelemetry/attributes/__init__.py", line 170, in __init__
self[key] = value
~~~~^^^^^
File "/usr/local/lib/python3.12/site-packages/opentelemetry/attributes/__init__.py", line 187, in __setitem__
value = _clean_attribute(key, value, self.max_value_len) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/opentelemetry/attributes/__init__.py", line 111, in _clean_attribute
_logger.warning(
File "/usr/local/lib/python3.12/logging/__init__.py", line 1551, in warning
self._log(WARNING, msg, args, **kwargs)
File "/usr/local/lib/python3.12/logging/__init__.py", line 1684, in _log
self.handle(record)
File "/usr/local/lib/python3.12/logging/__init__.py", line 1700, in handle
self.callHandlers(record)
File "/usr/local/lib/python3.12/logging/__init__.py", line 1762, in callHandlers
hdlr.handle(record)
File "/usr/local/lib/python3.12/logging/__init__.py", line 1028, in handle
self.emit(record)
File "/usr/local/lib/python3.12/site-packages/opentelemetry/sdk/_logs/_internal/__init__.py", line 562, in emit
logger.emit(self._translate(record))
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/opentelemetry/sdk/_logs/_internal/__init__.py", line 541, in _translate
return LogRecord(
^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/opentelemetry/sdk/_logs/_internal/__init__.py", line 198, in __init__
"attributes": BoundedAttributes(
^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/opentelemetry/attributes/__init__.py", line 170, in __init__
self[key] = value
~~~~^^^^^
File "/usr/local/lib/python3.12/site-packages/opentelemetry/attributes/__init__.py", line 187, in __setitem__
value = _clean_attribute(key, value, self.max_value_len) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/opentelemetry/attributes/__init__.py", line 111, in _clean_attribute
_logger.warning(
Having said all that, I do not see any reason to keep this held up. Just....don't turn it on yet 😀
(Should probably get another opinion tho, just in case my eyes got crossed somewhere)
4b5eb93
to
e2601ff
Compare
I have fixed the problem by not setting None attributes in e2601ff. I still don't know who is wrong here: Either synapse by setting None attributes on LogRecord, or opentelemetry.attributes by expecting that LogRecord attributes are not None. https://docs.python.org/3/library/logging.html#logging.Logger.debug and https://docs.python.org/3/library/logging.html#logrecord-attributes specify nothing about the allowed types in LogRecord attributes, so I'd assume that any type can be used. I don't have read the entire documentation though. https://docs.python.org/3/library/logging.html#logging.Logger.debug suggests that LogRecord should always have the same keys present. Therefore, setting these attributes to |
e2601ff
to
cfde1df
Compare
It was opentelemetry: open-telemetry/opentelemetry-python#4342 With the current main of opentelemetry, None attributes work fine. I have verified that the warning no longer appears with this version and replaced my custom fix with a version bump. Therefore, we have to wait for another release until we can switch to a released version of opentelemetry. |
cfde1df
to
41f6083
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you squash this down before I approve it please? :)
ce4eba0
to
b624ff0
Compare
b624ff0
to
6197776
Compare
Pull Request Checklist
EventStore
toEventWorkerStore
.".code blocks
.(run the linters)