Skip to content

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

Merged
toumorokoshi merged 4 commits intoopen-telemetry:masterfrom
yashmehrotra:fix-702
May 23, 2020
Merged

sdk: Span.resource will now default to an empty resource#724
toumorokoshi merged 4 commits intoopen-telemetry:masterfrom
yashmehrotra:fix-702

Conversation

@yashmehrotra
Copy link
Copy Markdown
Contributor

Fixes #702

@yashmehrotra yashmehrotra requested a review from a team May 22, 2020 02:34
@yashmehrotra
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

Thanks @toumorokoshi , its all green now 😄

@yashmehrotra
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

@toumorokoshi Could only find 1 instance where this was happening

Copy link
Copy Markdown
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
Copy Markdown
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