Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

U/eojeah/otel-semantic-attributes-http #129

Merged
merged 9 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.8']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ dist/
venv
tags
*.swp
.idea/
.vscode/
11 changes: 5 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v0.9.1
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: autopep8-wrapper
- id: check-json
files: \.(bowerrc|jshintrc|json)$
- id: check-yaml
- id: debug-statements
- id: name-tests-test
exclude: tests/acceptance/test_helper.py
- id: requirements-txt-fixer
- repo: https://gitlab.com/pycqa/flake8
rev: 5.0.4
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
args:
Expand All @@ -23,9 +22,9 @@ repos:
rev: v0.3.5
hooks:
- id: reorder-python-imports
language_version: python3.7
language_version: python3.8
- repo: https://github.com/asottile/pyupgrade
rev: v2.38.2
hooks:
- id: pyupgrade
args: ['--py37-plus']
args: ['--py38-plus']
35 changes: 0 additions & 35 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[mypy]
python_version = 3.7
python_version = 3.8
pretty = true
show_error_codes = true
show_error_context = true
Expand Down
1 change: 1 addition & 0 deletions pyramid_zipkin/request_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ def get_binary_annotations(
}
if response:
annotations['response_status_code'] = str(response.status_code)
annotations['http.response.status_code'] = str(response.status_code)

settings = request.registry.settings
if 'zipkin.set_extra_binary_annotations' in settings:
Expand Down
3 changes: 2 additions & 1 deletion pyramid_zipkin/tween.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ def tween(request: Request) -> Response:
except Exception as e:
zipkin_context.update_binary_annotations({
'error.type': type(e).__name__,
'response_status_code': '500'
'response_status_code': '500',
'http.response.status_code': '500',
Rob-Johnson marked this conversation as resolved.
Show resolved Hide resolved
})
raise e
finally:
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ coverage
mypy
ordereddict
pytest
tox
webtest
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
"Topic :: Software Development :: Libraries :: Python Modules",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
],
python_requires=">=3.7",
python_requires=">=3.8",
)
1 change: 1 addition & 0 deletions tests/acceptance/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def get_span():
'http.uri.qs': '/sample',
'http.route': '/sample',
'response_status_code': '200',
'http.response.status_code': '200',
},
'name': 'GET /sample',
'traceId': '17133d482ba4f605',
Expand Down
2 changes: 2 additions & 0 deletions tests/acceptance/server_span_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def set_extra_binary_annotations(dummy_request, response):
'http.uri.qs': '/pet/123?test=1',
'http.route': '/pet/{petId}',
'response_status_code': '200',
'http.response.status_code': '200',
'other': '42',
}

Expand All @@ -196,6 +197,7 @@ def test_binary_annotations_404(default_trace_id_generator):
'http.uri.qs': '/abcd?test=1',
'http.route': '',
'response_status_code': '404',
'http.response.status_code': '404',
}


Expand Down
5 changes: 4 additions & 1 deletion tests/tween_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ def test_zipkin_tween_exception(
called,
):
"""
If request processing has an exception set response_status_code to 500
If request processing has an exception set
response_status_code and http.response.status_code to 500
"""

mock_post_handler_hook = mock.Mock()
Expand All @@ -116,6 +117,7 @@ def test_zipkin_tween_exception(
assert len(spans) == 1
span = json.loads(spans[0])[0]
span['tags']['response_status_code'] = '500'
span['tags']['http.response.status_code'] = '500'
span['tags']['error.type'] = 'Exception'

assert handler.call_count == 1
Expand Down Expand Up @@ -149,6 +151,7 @@ def test_zipkin_tween_no_exception(
assert len(spans) == 1
span = json.loads(spans[0])[0]
span['tags']['response_status_code'] = '200'
span['tags']['http.response.status_code'] = '200'

assert handler.call_count == 1
assert mock_post_handler_hook.call_count == called
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = pre-commit, py37, py38, flake8, pre-commit
envlist = pre-commit, py38, py39, py310, py311, py312, flake8, pre-commit

[testenv]
deps = -rrequirements-dev.txt
Expand Down
Loading