Skip to content

Commit

Permalink
Merge branch 'main' into issue_852
Browse files Browse the repository at this point in the history
  • Loading branch information
ocelotl authored Jun 16, 2022
2 parents 18614c3 + 4ba6214 commit 0b6d9a5
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 9 deletions.
12 changes: 8 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased](https://github.com/open-telemetry/opentelemetry-python/compare/v1.12.0rc1-0.31b0...HEAD)
- Pyramid: Only categorize 400s and 500s exceptions as errors
([#1037](https://github.com/open-telemetry/opentelemetry-python-contrib/issues/1037))

### Fixed
- Fix bug in system metrics by checking their configuration
([#1129](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1129))
- Adding escape call to fix [auto-instrumentation not producing spans on Windows](https://github.com/open-telemetry/opentelemetry-python/issues/2703).
([#1100](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1100))
- `opentelemetry-instrumentation-grpc` narrow protobuf dependency to exclude protobuf >= 4
([1109](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1109))
([#1109](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1109))
- cleanup type hints for textmap `Getter` and `Setter` classes
([1106](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1106))

([#1106](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1106))
- fixed typo in `system.network.io` metric configuration
([#1135](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1135))


### Added
- `opentelemetry-instrumentation-logging` add log hook support
Expand All @@ -33,7 +37,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
- `opentelemetry-instrumentation-aiohttp-client` make span attributes available to sampler
([1072](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1072))
([#1072](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1072))
- `opentelemetry-instrumentation-aws-lambda` Fixed an issue - in some rare cases (API GW proxy integration test)
headers are set to None, breaking context propagators.
([#1055](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1055))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from logging import getLogger

from pyramid.events import BeforeTraversal
from pyramid.httpexceptions import HTTPException
from pyramid.httpexceptions import HTTPError, HTTPException
from pyramid.settings import asbool
from pyramid.tweens import EXCVIEW

Expand Down Expand Up @@ -198,7 +198,9 @@ def trace_tween(request):

activation = request.environ.get(_ENVIRON_ACTIVATION_KEY)

if isinstance(response, HTTPException):
# Only considering HTTPClientError and HTTPServerError
# to make sure HTTPRedirection is not reported as error
if isinstance(response, HTTPError):
activation.__exit__(
type(response),
response,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ def _hello_endpoint(request):
helloid = int(request.matchdict["helloid"])
if helloid == 500:
raise exc.HTTPInternalServerError()
if helloid == 302:
raise exc.HTTPFound()
if helloid == 204:
raise exc.HTTPNoContent()
if helloid == 900:
raise NotImplementedError()
return Response("Hello: " + str(helloid))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
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.util.http import (
OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_REQUEST,
OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_RESPONSE,
Expand Down Expand Up @@ -93,6 +94,48 @@ def test_registry_name_is_this_module(self):
config.registry.__name__, __name__.rsplit(".", maxsplit=1)[0]
)

def test_redirect_response_is_not_an_error(self):
tween_list = "pyramid.tweens.excview_tween_factory"
config = Configurator(settings={"pyramid.tweens": tween_list})
self._common_initialization(config)
resp = self.client.get("/hello/302")
self.assertEqual(302, resp.status_code)
span_list = self.memory_exporter.get_finished_spans()
self.assertEqual(len(span_list), 1)
self.assertEqual(span_list[0].status.status_code, StatusCode.UNSET)

PyramidInstrumentor().uninstrument()

self.config = Configurator()

self._common_initialization(self.config)

resp = self.client.get("/hello/302")
self.assertEqual(302, resp.status_code)
span_list = self.memory_exporter.get_finished_spans()
self.assertEqual(len(span_list), 1)

def test_204_empty_response_is_not_an_error(self):
tween_list = "pyramid.tweens.excview_tween_factory"
config = Configurator(settings={"pyramid.tweens": tween_list})
self._common_initialization(config)
resp = self.client.get("/hello/204")
self.assertEqual(204, resp.status_code)
span_list = self.memory_exporter.get_finished_spans()
self.assertEqual(len(span_list), 1)
self.assertEqual(span_list[0].status.status_code, StatusCode.UNSET)

PyramidInstrumentor().uninstrument()

self.config = Configurator()

self._common_initialization(self.config)

resp = self.client.get("/hello/204")
self.assertEqual(204, resp.status_code)
span_list = self.memory_exporter.get_finished_spans()
self.assertEqual(len(span_list), 1)


class TestWrappedWithOtherFramework(
InstrumentationTest, TestBase, WsgiTestBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"system.network.dropped.packets": ["transmit", "receive"],
"system.network.packets": ["transmit", "receive"],
"system.network.errors": ["transmit", "receive"],
"system.network.io": ["trasmit", "receive"],
"system.network.io": ["transmit", "receive"],
"system.network.connections": ["family", "type"],
"runtime.memory": ["rss", "vms"],
"runtime.cpu.time": ["user", "system"],
Expand Down Expand Up @@ -59,7 +59,7 @@
configuration = {
"system.memory.usage": ["used", "free", "cached"],
"system.cpu.time": ["idle", "user", "system", "irq"],
"system.network.io": ["trasmit", "receive"],
"system.network.io": ["transmit", "receive"],
"runtime.memory": ["rss", "vms"],
"runtime.cpu.time": ["user", "system"],
}
Expand Down Expand Up @@ -97,7 +97,7 @@
"system.network.dropped.packets": ["transmit", "receive"],
"system.network.packets": ["transmit", "receive"],
"system.network.errors": ["transmit", "receive"],
"system.network.io": ["trasmit", "receive"],
"system.network.io": ["transmit", "receive"],
"system.network.connections": ["family", "type"],
"runtime.memory": ["rss", "vms"],
"runtime.cpu.time": ["user", "system"],
Expand Down

0 comments on commit 0b6d9a5

Please sign in to comment.