Skip to content

Commit

Permalink
Merge branch 'main' into logging-correlation
Browse files Browse the repository at this point in the history
  • Loading branch information
alrex authored Mar 9, 2021
2 parents 7e4ea53 + 9315eb0 commit ef671cf
Show file tree
Hide file tree
Showing 22 changed files with 36 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- 'release/*'
pull_request:
env:
CORE_REPO_SHA: ddff32ac77e2e22b3193b71f1e71a590a99d1eda
CORE_REPO_SHA: 10dc3a8bc031d5b355f62a698094a03eedb2a8ee

jobs:
build:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
AioHttpClientInstrumentor,
)
from opentelemetry.test.test_base import TestBase
from opentelemetry.trace.status import StatusCode
from opentelemetry.trace import StatusCode


def run_with_test_server(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,7 @@ def test_span_succeeded(self):
self.assertEqual(span.attributes["db.user"], "testuser")
self.assertEqual(span.attributes["net.peer.name"], "testhost")
self.assertEqual(span.attributes["net.peer.port"], 123)
self.assertIs(
span.status.status_code, trace_api.status.StatusCode.UNSET
)
self.assertIs(span.status.status_code, trace_api.StatusCode.UNSET)

def test_span_not_recording(self):
connection_props = {
Expand Down Expand Up @@ -317,9 +315,7 @@ def test_span_failed(self):
self.assertEqual(len(spans_list), 1)
span = spans_list[0]
self.assertEqual(span.attributes["db.statement"], "Test query")
self.assertIs(
span.status.status_code, trace_api.status.StatusCode.ERROR
)
self.assertIs(span.status.status_code, trace_api.StatusCode.ERROR)
self.assertEqual(span.status.description, "Exception: Test Exception")

def test_executemany(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def test_s3_client(self):
},
)
self.assertIs(
span.status.status_code, trace_api.status.StatusCode.ERROR,
span.status.status_code, trace_api.StatusCode.ERROR,
)

# Comment test for issue 1088
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ def test_span_succeeded(self):
self.assertEqual(span.attributes["db.user"], "testuser")
self.assertEqual(span.attributes["net.peer.name"], "testhost")
self.assertEqual(span.attributes["net.peer.port"], 123)
self.assertIs(
span.status.status_code, trace_api.status.StatusCode.UNSET
)
self.assertIs(span.status.status_code, trace_api.StatusCode.UNSET)

def test_span_name(self):
db_integration = dbapi.DatabaseApiIntegration(
Expand Down Expand Up @@ -125,9 +123,7 @@ def test_span_succeeded_with_capture_of_statement_parameters(self):
self.assertEqual(span.attributes["db.user"], "testuser")
self.assertEqual(span.attributes["net.peer.name"], "testhost")
self.assertEqual(span.attributes["net.peer.port"], 123)
self.assertIs(
span.status.status_code, trace_api.status.StatusCode.UNSET
)
self.assertIs(span.status.status_code, trace_api.StatusCode.UNSET)

def test_span_not_recording(self):
connection_props = {
Expand Down Expand Up @@ -174,9 +170,7 @@ def test_span_failed(self):
self.assertEqual(len(spans_list), 1)
span = spans_list[0]
self.assertEqual(span.attributes["db.statement"], "Test query")
self.assertIs(
span.status.status_code, trace_api.status.StatusCode.ERROR
)
self.assertIs(span.status.status_code, trace_api.StatusCode.ERROR)
self.assertEqual(span.status.description, "Exception: Test Exception")

def test_executemany(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
from opentelemetry.instrumentation.django import DjangoInstrumentor
from opentelemetry.test.test_base import TestBase
from opentelemetry.test.wsgitestutil import WsgiTestBase
from opentelemetry.trace import SpanKind
from opentelemetry.trace.status import StatusCode
from opentelemetry.trace import SpanKind, StatusCode
from opentelemetry.util.http import get_excluded_urls, get_traced_request_attrs

# pylint: disable=import-error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
ElasticsearchInstrumentor,
)
from opentelemetry.test.test_base import TestBase
from opentelemetry.trace.status import StatusCode
from opentelemetry.trace import StatusCode

major_version = elasticsearch.VERSION[0]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from opentelemetry.instrumentation.falcon import FalconInstrumentor
from opentelemetry.test.test_base import TestBase
from opentelemetry.trace.status import StatusCode
from opentelemetry.trace import StatusCode
from opentelemetry.util.http import get_excluded_urls, get_traced_request_attrs

from .app import make_app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def test_error_simple(self):
self.assertEqual(len(spans), 1)
span = spans[0]
self.assertIs(
span.status.status_code, trace.status.StatusCode.ERROR,
span.status.status_code, trace.StatusCode.ERROR,
)

def test_error_stream_unary(self):
Expand All @@ -163,7 +163,7 @@ def test_error_stream_unary(self):
self.assertEqual(len(spans), 1)
span = spans[0]
self.assertIs(
span.status.status_code, trace.status.StatusCode.ERROR,
span.status.status_code, trace.StatusCode.ERROR,
)

def test_error_unary_stream(self):
Expand All @@ -174,7 +174,7 @@ def test_error_unary_stream(self):
self.assertEqual(len(spans), 1)
span = spans[0]
self.assertIs(
span.status.status_code, trace.status.StatusCode.ERROR,
span.status.status_code, trace.StatusCode.ERROR,
)

def test_error_stream_stream(self):
Expand All @@ -185,5 +185,5 @@ def test_error_stream_stream(self):
self.assertEqual(len(spans), 1)
span = spans[0]
self.assertIs(
span.status.status_code, trace.status.StatusCode.ERROR,
span.status.status_code, trace.StatusCode.ERROR,
)
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
)
from opentelemetry.sdk import trace as trace_sdk
from opentelemetry.test.test_base import TestBase
from opentelemetry.trace.status import StatusCode
from opentelemetry.trace import StatusCode

from .protobuf.test_server_pb2 import Request, Response
from .protobuf.test_server_pb2_grpc import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ def test_succeeded(self):
spans_list = self.memory_exporter.get_finished_spans()
self.assertEqual(len(spans_list), 1)
span = spans_list[0]
self.assertIs(
span.status.status_code, trace_api.status.StatusCode.UNSET
)
self.assertIs(span.status.status_code, trace_api.StatusCode.UNSET)
self.assertIsNotNone(span.end_time)

def test_not_recording(self):
Expand Down Expand Up @@ -96,7 +94,7 @@ def test_failed(self):
span = spans_list[0]

self.assertIs(
span.status.status_code, trace_api.status.StatusCode.ERROR,
span.status.status_code, trace_api.StatusCode.ERROR,
)
self.assertEqual(span.status.description, "failure")
self.assertIsNotNone(span.end_time)
Expand All @@ -116,10 +114,10 @@ def test_multiple_commands(self):
second_span = spans_list[1]

self.assertIs(
first_span.status.status_code, trace_api.status.StatusCode.UNSET,
first_span.status.status_code, trace_api.StatusCode.UNSET,
)
self.assertIs(
second_span.status.status_code, trace_api.status.StatusCode.ERROR,
second_span.status.status_code, trace_api.StatusCode.ERROR,
)

def test_int_command(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from opentelemetry.sdk import resources
from opentelemetry.test.mock_textmap import MockTextMapPropagator
from opentelemetry.test.test_base import TestBase
from opentelemetry.trace.status import StatusCode
from opentelemetry.trace import StatusCode


class InvalidResponseObjectException(Exception):
Expand Down Expand Up @@ -86,7 +86,7 @@ def test_basic(self):
},
)

self.assertIs(span.status.status_code, trace.status.StatusCode.UNSET)
self.assertIs(span.status.status_code, trace.StatusCode.UNSET)

self.check_span_instrumentation_info(
span, opentelemetry.instrumentation.requests
Expand Down Expand Up @@ -130,7 +130,7 @@ def test_not_foundbasic(self):
self.assertEqual(span.attributes.get("http.status_text"), "Not Found")

self.assertIs(
span.status.status_code, trace.status.StatusCode.ERROR,
span.status.status_code, trace.StatusCode.ERROR,
)

def test_uninstrument(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from opentelemetry.sdk import resources
from opentelemetry.test.mock_textmap import MockTextMapPropagator
from opentelemetry.test.test_base import TestBase
from opentelemetry.trace.status import StatusCode
from opentelemetry.trace import StatusCode


class RequestsIntegrationTestBase(abc.ABC):
Expand Down Expand Up @@ -111,7 +111,7 @@ def test_basic(self):
},
)

self.assertIs(span.status.status_code, trace.status.StatusCode.UNSET)
self.assertIs(span.status.status_code, trace.StatusCode.UNSET)

self.check_span_instrumentation_info(
span, opentelemetry.instrumentation.urllib
Expand Down Expand Up @@ -161,7 +161,7 @@ def test_not_foundbasic(self):
self.assertEqual(span.attributes.get("http.status_text"), "Not Found")

self.assertIs(
span.status.status_code, trace.status.StatusCode.ERROR,
span.status.status_code, trace.StatusCode.ERROR,
)

def test_uninstrument(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import opentelemetry.instrumentation.wsgi as otel_wsgi
from opentelemetry import trace as trace_api
from opentelemetry.test.wsgitestutil import WsgiTestBase
from opentelemetry.trace.status import StatusCode
from opentelemetry.trace import StatusCode


class Response:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from opentelemetry.instrumentation.asyncpg import AsyncPGInstrumentor
from opentelemetry.test.test_base import TestBase
from opentelemetry.trace.status import StatusCode
from opentelemetry.trace import StatusCode

POSTGRES_HOST = os.getenv("POSTGRESQL_HOST", "localhost")
POSTGRES_PORT = int(os.getenv("POSTGRESQL_PORT", "5432"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from opentelemetry.instrumentation.celery import CeleryInstrumentor
from opentelemetry.sdk import resources
from opentelemetry.sdk.trace import TracerProvider, export
from opentelemetry.trace.status import StatusCode
from opentelemetry.trace import StatusCode

# set a high timeout for async executions due to issues in CI
ASYNC_GET_TIMEOUT = 120
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def tearDown(self):
def _check_span(self, span, name):
self.assertEqual(span.attributes["service"], self.test_service)
self.assertEqual(span.name, name)
self.assertIs(span.status.status_code, trace.status.StatusCode.UNSET)
self.assertIs(span.status.status_code, trace.StatusCode.UNSET)
self.assertEqual(span.attributes.get("db.name"), 0)
self.assertEqual(span.attributes["net.peer.name"], "localhost")
self.assertEqual(span.attributes["net.peer.ip"], 6379)
Expand Down Expand Up @@ -130,7 +130,7 @@ def tearDown(self):

def _check_span(self, span, name):
self.assertEqual(span.name, name)
self.assertIs(span.status.status_code, trace.status.StatusCode.UNSET)
self.assertIs(span.status.status_code, trace.StatusCode.UNSET)
self.assertEqual(span.attributes["net.peer.name"], "localhost")
self.assertEqual(span.attributes["net.peer.ip"], 6379)
self.assertEqual(span.attributes["db.redis.database_index"], 10)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def _check_span(self, span, name):
name = "{0} {1}".format(name, self.SQL_DB)
self.assertEqual(span.name, name)
self.assertEqual(span.attributes.get(_DB), self.SQL_DB)
self.assertIs(span.status.status_code, trace.status.StatusCode.UNSET)
self.assertIs(span.status.status_code, trace.StatusCode.UNSET)
self.assertGreater((span.end_time - span.start_time), 0)

def test_orm_insert(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ def test_engine_traced(self):
span = traces[0]
# check subset of span fields
self.assertEqual(span.name, "SELECT opentelemetry-tests")
self.assertIs(span.status.status_code, trace.status.StatusCode.UNSET)
self.assertIs(span.status.status_code, trace.StatusCode.UNSET)
self.assertGreater((span.end_time - span.start_time), 0)
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ def test_engine_execute_errors(self):
self.assertTrue(span.end_time - span.start_time > 0)
# check the error
self.assertIs(
span.status.status_code, trace.status.StatusCode.ERROR,
span.status.status_code, trace.StatusCode.ERROR,
)
self.assertIn("a_wrong_table", span.status.description)
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_engine_execute_errors(self):
self.assertTrue(span.end_time - span.start_time > 0)
# check the error
self.assertIs(
span.status.status_code, trace.status.StatusCode.ERROR,
span.status.status_code, trace.StatusCode.ERROR,
)
self.assertIn("a_wrong_table", span.status.description)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_engine_execute_errors(self):
self.assertTrue((span.end_time - span.start_time) > 0)
# check the error
self.assertIs(
span.status.status_code, trace.status.StatusCode.ERROR,
span.status.status_code, trace.StatusCode.ERROR,
)
self.assertEqual(
span.status.description, "no such table: a_wrong_table"
Expand Down

0 comments on commit ef671cf

Please sign in to comment.