-
Notifications
You must be signed in to change notification settings - Fork 650
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
Change status codes from grpc status codes, remove setting status in instrumentations except on ERROR #1282
Conversation
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.
Looks good on first pass. I see comments about removing status setting code from instrumentations. Spec says instrumentation should set status in case of errors. Is the idea that instrumenation should not catch exceptions and let tracer/span context handle the exeptions and record status? That sounds good but it should be a general guideline and not a hard rule as in some cases, it might make sense for instrumentation to set status anyway.
@@ -159,8 +160,12 @@ def _translate_links(self, sdk_span: SDKSpan) -> None: | |||
|
|||
def _translate_status(self, sdk_span: SDKSpan) -> None: | |||
if sdk_span.status is not None: | |||
# TODO: Update this when the proto definitions are updated to include UNSET and ERROR |
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.
Is this TODO required for GA? If so, may be create an issue and link it here?
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.
@@ -109,12 +109,13 @@ async def traced_execution( | |||
try: | |||
result = await query_method(*args, **kwargs) | |||
if span.is_recording(): | |||
span.set_status(Status(StatusCanonicalCode.OK)) | |||
# TODO: Remove setting status in instrumentation |
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.
# TODO: Remove setting status in instrumentation | |
# TODO: Remove setting OK status in instrumentation |
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.
That's not exactly accurate. The TODO is removing any set_status
in instrumentations that pertain to OK
or UNSET
. I should probably name it to remove setting non-ERROR status in instrumentation
.
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.
Update: I made the changes and will be just removing the TODOs.
...tation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py
Outdated
Show resolved
Hide resolved
...on/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery/__init__.py
Outdated
Show resolved
Hide resolved
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.
Thanks! I think the one blocker for me is the field "canonical_code" still being in the codebase. Or let me know if that's intended.
...tation/opentelemetry-instrumentation-aiohttp-client/tests/test_aiohttp_client_integration.py
Show resolved
Hide resolved
...telemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/aiopg_integration.py
Outdated
Show resolved
Hide resolved
...tation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py
Outdated
Show resolved
Hide resolved
...ry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/__init__.py
Outdated
Show resolved
Hide resolved
...pentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py
Outdated
Show resolved
Hide resolved
No that comment about instrumentations not recording status is few lines of code cleanup left to do for the instrumentations that I left so to not bloat up the PR (like here: https://github.com/open-telemetry/opentelemetry-python/pull/1282/files#r513361923). The general idea is: instrumentations should not set status ever unless if an error happens. Span api/sdk should not set status either, so the only time that the span status is set to OK is by the user. I updated the description to address this. |
Update: I made the changes and will be just removing the TODOs. |
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.
Thanks! I'd not the one change to eachdist that may be worth reverting.
tox.ini
Outdated
@@ -369,7 +369,7 @@ commands_pre = | |||
python scripts/eachdist.py install --editable --with-test-deps | |||
|
|||
commands = | |||
python scripts/eachdist.py lint --check-only | |||
python scripts/eachdist.py lint |
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.
will this command still fail on fixing styling commands? I think the reason this was --check-only was to use that tox command for CI, rather than for users trying to run lint / formatting rules.
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.
Sorry left it in by accident =p
"""Converts an HTTP status code to an OpenTelemetry canonical status code | ||
|
||
Args: | ||
status (int): HTTP status code | ||
""" | ||
# pylint:disable=too-many-branches,too-many-return-statements | ||
# See: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/http.md#status |
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.
I feel like this section could be refactored to a much simpler tree of conditions.
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.
Perhaps. I left it in there just to show the possible httpstatuses.
Fixes #1214
Changes status canonical codes to comply with spec changes. Also changes behavior for setting status within instrumentations. The general idea is: instrumentations should not set status ever unless if an error happens. Span api/sdk should not set status either, so the only time that the span status is set to OK is by the user.
UNSET
.UNKNOWN
toERROR
http_to_canonical_code
to follow https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/http.md#statusStatusCode.UNSET
. Do not set status toStatusCode.OK
upon span end if not set.TODO:
record_exception
option to span__exit__
set_status_on_exception
parameter tostart_as_current_span