Merge pull request #94 from NathanielRN/move-instrumentation-aiopg
Move instrumentation aiopg
This commit is contained in:
commit
1a9576c0d0
|
|
@ -39,15 +39,15 @@ 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-dbapi == 0.15.dev0
|
opentelemetry-instrumentation-dbapi == 0.15b0
|
||||||
opentelemetry-instrumentation == 0.15.dev0
|
opentelemetry-instrumentation == 0.15b0
|
||||||
aiopg >= 0.13.0
|
aiopg >= 0.13.0
|
||||||
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
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ from opentelemetry.instrumentation.dbapi import (
|
||||||
TracedCursor,
|
TracedCursor,
|
||||||
)
|
)
|
||||||
from opentelemetry.trace import SpanKind
|
from opentelemetry.trace import SpanKind
|
||||||
from opentelemetry.trace.status import Status, StatusCanonicalCode
|
from opentelemetry.trace.status import Status, StatusCode
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=abstract-method
|
# pylint: disable=abstract-method
|
||||||
|
|
@ -108,14 +108,10 @@ class AsyncTracedCursor(TracedCursor):
|
||||||
self._populate_span(span, *args)
|
self._populate_span(span, *args)
|
||||||
try:
|
try:
|
||||||
result = await query_method(*args, **kwargs)
|
result = await 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"
|
||||||
|
|
|
||||||
|
|
@ -226,8 +226,7 @@ class TestAiopgIntegration(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):
|
||||||
|
|
@ -278,8 +277,7 @@ class TestAiopgIntegration(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")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue