Skip to content

Commit

Permalink
ext to instrumentation naming
Browse files Browse the repository at this point in the history
  • Loading branch information
cnnradams committed Jun 4, 2020
1 parent 94783ea commit 6aa911d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ def hello():
import wsgiref.util as wsgiref_util

from opentelemetry import context, propagators, trace
from opentelemetry.instrumentation.utils import http_status_to_canonical_code
from opentelemetry.ext.wsgi.version import __version__
from opentelemetry.instrumentation.utils import http_status_to_canonical_code
from opentelemetry.trace.propagation import get_span_from_context
from opentelemetry.trace.status import Status, StatusCanonicalCode

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
from opentelemetry.trace.status import Status, StatusCanonicalCode


def http_status_to_canonical_code(status: int) -> StatusCanonicalCode:
def http_status_to_canonical_code(
status: int, allow_redirect: bool = True
) -> StatusCanonicalCode:
"""Converts an HTTP status code to an OpenTelemetry canonical status code
Args:
Expand All @@ -30,8 +32,12 @@ def http_status_to_canonical_code(status: int) -> StatusCanonicalCode:
# pylint:disable=too-many-branches,too-many-return-statements
if status < 100:
return StatusCanonicalCode.UNKNOWN
if status <= 399:
if status <= 299:
return StatusCanonicalCode.OK
if status <= 399:
if allow_redirect:
return StatusCanonicalCode.OK
return StatusCanonicalCode.DEADLINE_EXCEEDED
if status <= 499:
if status == 401: # HTTPStatus.UNAUTHORIZED:
return StatusCanonicalCode.UNAUTHENTICATED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = "0.8.dev0"
__version__ = "0.9.dev0"
8 changes: 4 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ envlist =
pypy3-test-ext-sqlite3

; opentelemetry-instrumentation-utils
py3{5,6,7,8}-test-ext-utils
pypy3-test-ext-utils
py3{5,6,7,8}-test-instrumentation-utils
pypy3-test-instrumentation-utils

; opentelemetry-ext-wsgi
py3{4,5,6,7,8}-test-ext-wsgi
Expand Down Expand Up @@ -168,7 +168,7 @@ changedir =
test-ext-pymysql: ext/opentelemetry-ext-pymysql/tests
test-ext-asgi: ext/opentelemetry-ext-asgi/tests
test-ext-sqlite3: ext/opentelemetry-ext-sqlite3/tests
test-ext-utils: ext/opentelemetry-instrumentation-utils/tests
test-instrumentation-utils: ext/opentelemetry-instrumentation-utils/tests
test-ext-wsgi: ext/opentelemetry-ext-wsgi/tests
test-ext-zipkin: ext/opentelemetry-ext-zipkin/tests
test-ext-boto: ext/opentelemetry-ext-boto/tests
Expand All @@ -187,7 +187,7 @@ commands_pre =
; cases but it saves a lot of boilerplate in this file.
test: pip install {toxinidir}/opentelemetry-api {toxinidir}/opentelemetry-sdk {toxinidir}/tests/util
; Install common utils package for all ext/ tests
ext: pip install {toxinidir}/ext/opentelemetry-instrumentation-utils
ext,instrumentation: pip install {toxinidir}/ext/opentelemetry-instrumentation-utils

test-auto-instrumentation: pip install {toxinidir}/opentelemetry-auto-instrumentation

Expand Down

0 comments on commit 6aa911d

Please sign in to comment.