mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-08-01 09:13:23 +08:00
Merge pull request #94 from NathanielRN/move-instrumentation-aiopg
Move instrumentation aiopg
This commit is contained in:
@ -39,15 +39,15 @@ package_dir=
|
||||
=src
|
||||
packages=find_namespace:
|
||||
install_requires =
|
||||
opentelemetry-api == 0.15.dev0
|
||||
opentelemetry-instrumentation-dbapi == 0.15.dev0
|
||||
opentelemetry-instrumentation == 0.15.dev0
|
||||
opentelemetry-api == 0.15b0
|
||||
opentelemetry-instrumentation-dbapi == 0.15b0
|
||||
opentelemetry-instrumentation == 0.15b0
|
||||
aiopg >= 0.13.0
|
||||
wrapt >= 1.0.0, < 2.0.0
|
||||
|
||||
[options.extras_require]
|
||||
test =
|
||||
opentelemetry-test == 0.15.dev0
|
||||
opentelemetry-test == 0.15b0
|
||||
|
||||
[options.packages.find]
|
||||
where = src
|
||||
|
@ -8,7 +8,7 @@ from opentelemetry.instrumentation.dbapi import (
|
||||
TracedCursor,
|
||||
)
|
||||
from opentelemetry.trace import SpanKind
|
||||
from opentelemetry.trace.status import Status, StatusCanonicalCode
|
||||
from opentelemetry.trace.status import Status, StatusCode
|
||||
|
||||
|
||||
# pylint: disable=abstract-method
|
||||
@ -108,14 +108,10 @@ class AsyncTracedCursor(TracedCursor):
|
||||
self._populate_span(span, *args)
|
||||
try:
|
||||
result = await query_method(*args, **kwargs)
|
||||
if span.is_recording():
|
||||
span.set_status(Status(StatusCanonicalCode.OK))
|
||||
return result
|
||||
except Exception as ex: # pylint: disable=broad-except
|
||||
if span.is_recording():
|
||||
span.set_status(
|
||||
Status(StatusCanonicalCode.UNKNOWN, str(ex))
|
||||
)
|
||||
span.set_status(Status(StatusCode.ERROR, str(ex)))
|
||||
raise ex
|
||||
|
||||
|
||||
|
@ -12,4 +12,4 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# 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.port"], 123)
|
||||
self.assertIs(
|
||||
span.status.canonical_code,
|
||||
trace_api.status.StatusCanonicalCode.OK,
|
||||
span.status.status_code, trace_api.status.StatusCode.UNSET,
|
||||
)
|
||||
|
||||
def test_span_not_recording(self):
|
||||
@ -278,8 +277,7 @@ class TestAiopgIntegration(TestBase):
|
||||
span = spans_list[0]
|
||||
self.assertEqual(span.attributes["db.statement"], "Test query")
|
||||
self.assertIs(
|
||||
span.status.canonical_code,
|
||||
trace_api.status.StatusCanonicalCode.UNKNOWN,
|
||||
span.status.status_code, trace_api.status.StatusCode.ERROR,
|
||||
)
|
||||
self.assertEqual(span.status.description, "Test Exception")
|
||||
|
||||
|
Reference in New Issue
Block a user