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

sdk: Span.resource will now default to an empty resource #724

Merged
merged 4 commits into from
May 23, 2020
Merged

sdk: Span.resource will now default to an empty resource #724

merged 4 commits into from
May 23, 2020

Conversation

yashmehrotra
Copy link
Contributor

Fixes #702

@yashmehrotra yashmehrotra requested a review from a team as a code owner May 22, 2020 02:34
@yashmehrotra
Copy link
Contributor Author

In Travis CI, the error I am getting is

sphinx.errors.SphinxWarning: /home/travis/build/open-telemetry/opentelemetry-python/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py:docstring of opentelemetry.sdk.trace.Span:17:py:class reference target not found: opentelemetry.sdk.resources.Resource

Warning, treated as error:

/home/travis/build/open-telemetry/opentelemetry-python/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py:docstring of opentelemetry.sdk.trace.Span:17:py:class reference target not found: opentelemetry.sdk.resources.Resource

ERROR: InvocationError for command /home/travis/build/open-telemetry/opentelemetry-python/.tox/docs/bin/sphinx-build -E -a -W -b html -T . _build/html (exited with code 2)

Do you know what could be the issue ?

@toumorokoshi
Copy link
Member

Having some trouble pushing some fixes, but this is occurring because the sphinx document needs to resolve a reference to the Resource object in the docs itself, and no sphinx automodule sphinx.

Here's a patch that would fix it:

diff --git a/docs/sdk/resources.rst b/docs/sdk/resources.rst
new file mode 100644
index 0000000..08732ac
--- /dev/null
+++ b/docs/sdk/resources.rst
@@ -0,0 +1,7 @@
+opentelemetry.sdk.resources package
+==========================================
+
+.. automodule:: opentelemetry.sdk.resources
+    :members:
+    :undoc-members:
+    :show-inheritance:
diff --git a/docs/sdk/sdk.rst b/docs/sdk/sdk.rst
index 27e9d44..d6ca098 100644
--- a/docs/sdk/sdk.rst
+++ b/docs/sdk/sdk.rst
@@ -7,4 +7,5 @@ OpenTelemetry Python SDK
     :maxdepth: 1
 
     metrics
+    resources
     trace

@yashmehrotra
Copy link
Contributor Author

Thanks @toumorokoshi , its all green now 😄

@yashmehrotra
Copy link
Contributor Author

yashmehrotra commented May 22, 2020

Should I also remove the None check in ext/opentelemetry-ext-jaeger/src/opentelemetry/ext/jaeger/__init__.py file ?

-        if span.resource:
-           tags.extend(_extract_tags(span.resource.labels))
+        tags.extend(_extract_tags(span.resource.labels))

@toumorokoshi
Copy link
Member

Great, thank you! can you take a look around and see if there's any references that we should update? I believe the jaeger / zipkin integrations are defensively handling for a None resource object. That code should be cleaned up to reduce confusion.

@toumorokoshi
Copy link
Member

Should I also remove the None check in ext/opentelemetry-ext-jaeger/src/opentelemetry/ext/jaeger/__init__.py file ?

-        if span.resource:
-           tags.extend(_extract_tags(span.resource.labels))
+        tags.extend(_extract_tags(span.resource.labels))

yes! that'd be great, along with any other places where this was handled defensively.

@yashmehrotra
Copy link
Contributor Author

@toumorokoshi Could only find 1 instance where this was happening

Copy link
Member

@toumorokoshi toumorokoshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thank you!

Copy link
Contributor

@ocelotl ocelotl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@toumorokoshi toumorokoshi merged commit 0e9a8e4 into open-telemetry:master May 23, 2020
@yashmehrotra yashmehrotra deleted the fix-702 branch May 24, 2020 02:17
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.

sdk: Span.resource should default to an empty resource
3 participants