Skip to content
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

fix NonRecordSpan.attributes access #1377

Merged
merged 13 commits into from
Oct 21, 2022
Merged

Conversation

adriangb
Copy link
Contributor

@adriangb adriangb commented Oct 6, 2022

I'm seeing this fail in my test suite:

            duration_attrs[
                SpanAttributes.HTTP_STATUS_CODE
>           ] = span.attributes.get(SpanAttributes.HTTP_STATUS_CODE)
E           AttributeError: 'NonRecordingSpan' object has no attribute 'attributes'

And I can tell that NotRecordingSpan does not have attributes and it seems like that would be checked for. I tried to add a test but with all of the mocking and lack of typing I can't tell what is actually being tested where.

@adriangb adriangb requested a review from a team October 6, 2022 00:27
@adriangb
Copy link
Contributor Author

adriangb commented Oct 6, 2022

Seems like this was added in #1230, any thoughts @TheAnshul756?

@srikanthccv
Copy link
Member

You are correct, this throws an error in the absence of SDK. Please use span.is_recording() instead.

@adriangb
Copy link
Contributor Author

adriangb commented Oct 6, 2022

I tried that locally and it made some other test fail, we'll see what CI says

@adriangb
Copy link
Contributor Author

adriangb commented Oct 6, 2022

@TheAnshul756
Copy link
Contributor

TheAnshul756 commented Oct 6, 2022

Looks like the issue is in the tests. span.is_recording() is false in case of the failed tests. I'm looking into it.

Upd: Span detach was done in patched start_response method and we were trying to access span.is_recordin() after that.

@TheAnshul756
Copy link
Contributor

Hello @adriangb
I've added the fix and want to commit. So should I create a PR on your fork?

@adriangb
Copy link
Contributor Author

adriangb commented Oct 6, 2022

Sure or just merge that and I’ll rebase, either way

@TheAnshul756
Copy link
Contributor

TheAnshul756 commented Oct 6, 2022

Please merge this PR.

@adriangb
Copy link
Contributor Author

adriangb commented Oct 6, 2022

Please merge this PR.

Done

@adriangb
Copy link
Contributor Author

Hi is there anything missing to push this forward?

@TheAnshul756
Copy link
Contributor

I think just lint fix and changelog are remaining.

@srikanthccv srikanthccv enabled auto-merge (squash) October 21, 2022 15:23
@srikanthccv srikanthccv merged commit 99f29b4 into open-telemetry:main Oct 21, 2022
saartochner-lumigo pushed a commit to lumigo-io/opentelemetry-python-contrib that referenced this pull request Nov 13, 2022
saartochner-lumigo pushed a commit to lumigo-io/opentelemetry-python-contrib that referenced this pull request Nov 13, 2022
saartochner-lumigo pushed a commit to lumigo-io/opentelemetry-python-contrib that referenced this pull request Nov 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants