mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-07-30 21:56:07 +08:00
Merge pull request #100 from NathanielRN/move-instrumentation-dbapi
Move instrumentation dbapi
This commit is contained in:
@ -39,13 +39,13 @@ package_dir=
|
|||||||
=src
|
=src
|
||||||
packages=find_namespace:
|
packages=find_namespace:
|
||||||
install_requires =
|
install_requires =
|
||||||
opentelemetry-api == 0.15.dev0
|
opentelemetry-api == 0.15b0
|
||||||
opentelemetry-instrumentation == 0.15.dev0
|
opentelemetry-instrumentation == 0.15b0
|
||||||
wrapt >= 1.0.0, < 2.0.0
|
wrapt >= 1.0.0, < 2.0.0
|
||||||
|
|
||||||
[options.extras_require]
|
[options.extras_require]
|
||||||
test =
|
test =
|
||||||
opentelemetry-test == 0.15.dev0
|
opentelemetry-test == 0.15b0
|
||||||
|
|
||||||
[options.packages.find]
|
[options.packages.find]
|
||||||
where = src
|
where = src
|
||||||
|
@ -50,7 +50,7 @@ from opentelemetry import trace as trace_api
|
|||||||
from opentelemetry.instrumentation.dbapi.version import __version__
|
from opentelemetry.instrumentation.dbapi.version import __version__
|
||||||
from opentelemetry.instrumentation.utils import unwrap
|
from opentelemetry.instrumentation.utils import unwrap
|
||||||
from opentelemetry.trace import SpanKind, TracerProvider, get_tracer
|
from opentelemetry.trace import SpanKind, TracerProvider, get_tracer
|
||||||
from opentelemetry.trace.status import Status, StatusCanonicalCode
|
from opentelemetry.trace.status import Status, StatusCode
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -343,14 +343,10 @@ class TracedCursor:
|
|||||||
self._populate_span(span, *args)
|
self._populate_span(span, *args)
|
||||||
try:
|
try:
|
||||||
result = query_method(*args, **kwargs)
|
result = query_method(*args, **kwargs)
|
||||||
if span.is_recording():
|
|
||||||
span.set_status(Status(StatusCanonicalCode.OK))
|
|
||||||
return result
|
return result
|
||||||
except Exception as ex: # pylint: disable=broad-except
|
except Exception as ex: # pylint: disable=broad-except
|
||||||
if span.is_recording():
|
if span.is_recording():
|
||||||
span.set_status(
|
span.set_status(Status(StatusCode.ERROR, str(ex)))
|
||||||
Status(StatusCanonicalCode.UNKNOWN, str(ex))
|
|
||||||
)
|
|
||||||
raise ex
|
raise ex
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,4 +12,4 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
__version__ = "0.15.dev0"
|
__version__ = "0.15b0"
|
||||||
|
@ -65,8 +65,7 @@ class TestDBApiIntegration(TestBase):
|
|||||||
self.assertEqual(span.attributes["net.peer.name"], "testhost")
|
self.assertEqual(span.attributes["net.peer.name"], "testhost")
|
||||||
self.assertEqual(span.attributes["net.peer.port"], 123)
|
self.assertEqual(span.attributes["net.peer.port"], 123)
|
||||||
self.assertIs(
|
self.assertIs(
|
||||||
span.status.canonical_code,
|
span.status.status_code, trace_api.status.StatusCode.UNSET,
|
||||||
trace_api.status.StatusCanonicalCode.OK,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_span_not_recording(self):
|
def test_span_not_recording(self):
|
||||||
@ -117,8 +116,7 @@ class TestDBApiIntegration(TestBase):
|
|||||||
span = spans_list[0]
|
span = spans_list[0]
|
||||||
self.assertEqual(span.attributes["db.statement"], "Test query")
|
self.assertEqual(span.attributes["db.statement"], "Test query")
|
||||||
self.assertIs(
|
self.assertIs(
|
||||||
span.status.canonical_code,
|
span.status.status_code, trace_api.status.StatusCode.ERROR,
|
||||||
trace_api.status.StatusCanonicalCode.UNKNOWN,
|
|
||||||
)
|
)
|
||||||
self.assertEqual(span.status.description, "Test Exception")
|
self.assertEqual(span.status.description, "Test Exception")
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user