Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Add BaseSpan interface to make Span and BlankSpan compatible#313

Merged
mayurkale22 merged 4 commits intocensus-instrumentation:masterfrom
mayurkale22:base_span_interface
Sep 19, 2018
Merged

Add BaseSpan interface to make Span and BlankSpan compatible#313
mayurkale22 merged 4 commits intocensus-instrumentation:masterfrom
mayurkale22:base_span_interface

Conversation

@mayurkale22
Copy link
Copy Markdown
Member

issue #312

@mayurkale22
Copy link
Copy Markdown
Member Author

/cc @tgermain FYI

span = BaseSpan()

with self.assertRaises(NotImplementedError):
list(iter(span))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

a test for __enter__ and __exit__ might be missing. Something like that for instance :

from unittest import mock

@mock.patch(BaseSpan, "__enter__")
@mock.patch(BaseSpan, "__exit__")
def test_context_manager(self, m_exit, m_enter)
    span = BaseSpan()
    with span:
        pass
    self.assertTrue(m_enter.called)
    self.assertTrue(m_exit.called)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done

Copy link
Copy Markdown
Contributor

@liyanhui1228 liyanhui1228 left a comment

Choose a reason for hiding this comment

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

LGTM with minor comments.

Comment thread opencensus/trace/blank_span.py Outdated
from opencensus.trace import time_event as time_event_module
from opencensus.trace.span_context import generate_span_id
from opencensus.trace.tracers import base
from opencensus.trace.base_span import BaseSpan
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sort the imports, and import module instead of class.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done

@mayurkale22
Copy link
Copy Markdown
Member Author

Fixes #312

@mayurkale22 mayurkale22 merged commit cac4305 into census-instrumentation:master Sep 19, 2018
@mayurkale22 mayurkale22 deleted the base_span_interface branch September 19, 2018 05:06
@davewalkexpel
Copy link
Copy Markdown

@liyanhui1228 Hi, can a release be cut that included this? It would really help me. Thanks!

@mayurkale22
Copy link
Copy Markdown
Member Author

@davewalkexpel Unfortunately no. But we might do a patch release soon.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants