Skip to content

Commit

Permalink
Merge branch 'main' into munir/deprecate-otel-datadog-exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
mabdinur committed Mar 9, 2022
2 parents e115c81 + c60a7e4 commit a5f6ec9
Show file tree
Hide file tree
Showing 82 changed files with 1,151 additions and 321 deletions.
29 changes: 28 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,38 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased](https://github.com/open-telemetry/opentelemetry-python/compare/v1.9.1-0.28b1...HEAD)

## [1.9.1-0.28b1](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.9.1-0.28b1) - 2022-01-29
- `opentelemetry-instrumentation-wsgi` Capture custom request/response headers in span attributes
([#925])(https://github.com/open-telemetry/opentelemetry-python-contrib/pull/925)

- `opentelemetry-instrumentation-flask` Flask: Capture custom request/response headers in span attributes
([#952])(https://github.com/open-telemetry/opentelemetry-python-contrib/pull/952)

### Added

- `opentelemetry-instrumentation-sqlalchemy` added experimental sql commenter capability
([#924](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/924))
- `opentelemetry-instrumentation-dbapi` add experimental sql commenter capability
([#908](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/908))
- `opentelemetry-instrumentation-requests` make span attribute available to samplers
([#931](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/931))

### Fixed

- `opentelemetry-instrumentation-logging` retrieves service name defensively.
([#890](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/890))
- `opentelemetry-instrumentation-wsgi` WSGI: Conditionally create SERVER spans
([#903](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/903))
- `opentelemetry-instrumentation-falcon` Safer patching mechanism
([#895](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/895))

## [1.9.1-0.28b1](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.9.1-0.28b1) - 2022-01-29

### Fixed

- `opentelemetry-instrumentation-pika` requires `packaging` dependency

- `opentelemetry-instrumentation-tornado` Tornado: Conditionally create SERVER spans
([#889](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/889))

## [1.9.0-0.28b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.9.0-0.28b0) - 2022-01-26

Expand All @@ -34,6 +58,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `opentelemetry-instrumentation-pymongo` now supports `pymongo v4`
([#876](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/876))

- `opentelemetry-instrumentation-httpx` now supports versions higher than `0.19.0`.
([#866](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/866))

### Fixed

- `opentelemetry-instrumentation-django` Django: Conditionally create SERVER spans
Expand Down
3 changes: 2 additions & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pylint<2.10
pylint==2.12.2
flake8~=3.7
isort~=5.6
black>=22.1.0
Expand All @@ -13,3 +13,4 @@ readme-renderer~=24.0
grpcio-tools==1.29.0
mypy-protobuf>=1.23
protobuf>=3.13.0
markupsafe==2.0.1
4 changes: 3 additions & 1 deletion docs-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ redis>=2.6
sqlalchemy>=1.0
tornado>=5.1.1
ddtrace>=0.34.0
httpx~=0.18.0
httpx>=0.18.0
markupsafe==2.0.1
itsdangerous==2.0.1
1 change: 1 addition & 0 deletions docs/nitpick-exceptions.ini
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class_references=
httpx.AsyncBaseTransport
httpx.SyncByteStream
httpx.AsyncByteStream
httpx.Response
yarl.URL

anys=
Expand Down
2 changes: 1 addition & 1 deletion exporter/opentelemetry-exporter-richconsole/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
BASE_DIR, "src", "opentelemetry", "exporter", "richconsole", "version.py"
)
PACKAGE_INFO = {}
with open(VERSION_FILENAME) as f:
with open(VERSION_FILENAME, encoding="utf-8") as f:
exec(f.read(), PACKAGE_INFO)

setuptools.setup(version=PACKAGE_INFO["__version__"])
1 change: 1 addition & 0 deletions gen-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
-c dev-requirements.txt
astor==0.8.1
jinja2~=2.7
markupsafe==2.0.1
isort
black
requests
2 changes: 1 addition & 1 deletion instrumentation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
| [opentelemetry-instrumentation-fastapi](./opentelemetry-instrumentation-fastapi) | fastapi ~= 0.58 |
| [opentelemetry-instrumentation-flask](./opentelemetry-instrumentation-flask) | flask >= 1.0, < 3.0 |
| [opentelemetry-instrumentation-grpc](./opentelemetry-instrumentation-grpc) | grpcio ~= 1.27 |
| [opentelemetry-instrumentation-httpx](./opentelemetry-instrumentation-httpx) | httpx >= 0.18.0, < 0.19.0 |
| [opentelemetry-instrumentation-httpx](./opentelemetry-instrumentation-httpx) | httpx >= 0.18.0 |
| [opentelemetry-instrumentation-jinja2](./opentelemetry-instrumentation-jinja2) | jinja2 >= 2.7, < 4.0 |
| [opentelemetry-instrumentation-kafka-python](./opentelemetry-instrumentation-kafka-python) | kafka-python >= 2.0 |
| [opentelemetry-instrumentation-logging](./opentelemetry-instrumentation-logging) | logging |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
config.read("setup.cfg")

# We provide extras_require parameter to setuptools.setup later which
# overwrites the extra_require section from setup.cfg. To support extra_require
# secion in setup.cfg, we load it here and merge it with the extra_require param.
# overwrites the extras_require section from setup.cfg. To support extras_require
# section in setup.cfg, we load it here and merge it with the extras_require param.
extras_require = {}
if "options.extras_require" in config:
for key, value in config["options.extras_require"].items():
Expand Down
4 changes: 2 additions & 2 deletions instrumentation/opentelemetry-instrumentation-aiopg/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
config.read("setup.cfg")

# We provide extras_require parameter to setuptools.setup later which
# overwrites the extra_require section from setup.cfg. To support extra_require
# secion in setup.cfg, we load it here and merge it with the extra_require param.
# overwrites the extras_require section from setup.cfg. To support extras_require
# section in setup.cfg, we load it here and merge it with the extras_require param.
extras_require = {}
if "options.extras_require" in config:
for key, value in config["options.extras_require"].items():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ def __init__(self, database, server_port, server_host, user):
self.server_host = server_host
self.user = user

# pylint: disable=no-self-use
async def release(self, conn):
return conn

Expand Down Expand Up @@ -542,11 +543,11 @@ def __init__(self, database, server_port, server_host, user):
database, server_port, server_host, user
)

# pylint: disable=no-self-use
def cursor(self):
coro = self._cursor()
return _ContextManager(coro) # pylint: disable=no-value-for-parameter

# pylint: disable=no-self-use
async def _cursor(self):
return MockCursor()

Expand Down Expand Up @@ -585,13 +586,15 @@ async def __aenter__(self):


class AiopgPoolMock:
# pylint: disable=no-self-use
async def release(self, conn):
return conn

def acquire(self):
coro = self._acquire()
return _PoolAcquireContextManager(coro, self)

# pylint: disable=no-self-use
async def _acquire(self):
return AiopgConnectionMock()

Expand Down
4 changes: 2 additions & 2 deletions instrumentation/opentelemetry-instrumentation-asgi/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
config.read("setup.cfg")

# We provide extras_require parameter to setuptools.setup later which
# overwrites the extra_require section from setup.cfg. To support extra_require
# secion in setup.cfg, we load it here and merge it with the extra_require param.
# overwrites the extras_require section from setup.cfg. To support extras_require
# section in setup.cfg, we load it here and merge it with the extras_require param.
extras_require = {}
if "options.extras_require" in config:
for key, value in config["options.extras_require"].items():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,13 @@ def client_response_hook(span: Span, message: dict):
from opentelemetry.instrumentation.propagators import (
get_global_response_propagator,
)
from opentelemetry.instrumentation.utils import http_status_to_status_code
from opentelemetry.propagate import extract
from opentelemetry.instrumentation.utils import (
_start_internal_or_server_span,
http_status_to_status_code,
)
from opentelemetry.propagators.textmap import Getter, Setter
from opentelemetry.semconv.trace import SpanAttributes
from opentelemetry.trace import (
INVALID_SPAN,
Span,
SpanKind,
set_span_in_context,
)
from opentelemetry.trace import Span, set_span_in_context
from opentelemetry.trace.status import Status, StatusCode
from opentelemetry.util.http import remove_url_credentials

Expand Down Expand Up @@ -327,24 +324,18 @@ async def __call__(self, scope, receive, send):
if self.excluded_urls and self.excluded_urls.url_disabled(url):
return await self.app(scope, receive, send)

token = ctx = span_kind = None

if trace.get_current_span() is INVALID_SPAN:
ctx = extract(scope, getter=asgi_getter)
token = context.attach(ctx)
span_kind = SpanKind.SERVER
else:
ctx = context.get_current()
span_kind = SpanKind.INTERNAL

span_name, additional_attributes = self.default_span_details(scope)

span, token = _start_internal_or_server_span(
tracer=self.tracer,
span_name=span_name,
start_time=None,
context_carrier=scope,
context_getter=asgi_getter,
)

try:
with self.tracer.start_as_current_span(
span_name,
context=ctx,
kind=span_kind,
) as current_span:
with trace.use_span(span, end_on_exit=True) as current_span:
if current_span.is_recording():
attributes = collect_request_attributes(scope)
attributes.update(additional_attributes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
setup_testing_defaults,
)
from opentelemetry.test.test_base import TestBase
from opentelemetry.trace import format_span_id, format_trace_id
from opentelemetry.trace import SpanKind, format_span_id, format_trace_id


async def http_app(scope, receive, send):
Expand Down Expand Up @@ -310,10 +310,10 @@ def test_traceresponse_header(self):
self.assertEqual(response_body["body"], b"*")
self.assertEqual(response_start["status"], 200)

traceresponse = "00-{0}-{1}-01".format(
format_trace_id(span.get_span_context().trace_id),
format_span_id(span.get_span_context().span_id),
)
trace_id = format_trace_id(span.get_span_context().trace_id)
span_id = format_span_id(span.get_span_context().span_id)
traceresponse = f"00-{trace_id}-{span_id}-01"

self.assertListEqual(
response_start["headers"],
[
Expand Down Expand Up @@ -423,10 +423,10 @@ def test_websocket_traceresponse_header(self):
span = self.memory_exporter.get_finished_spans()[-1]
self.assertEqual(trace_api.SpanKind.SERVER, span.kind)

traceresponse = "00-{0}-{1}-01".format(
format_trace_id(span.get_span_context().trace_id),
format_span_id(span.get_span_context().span_id),
)
trace_id = format_trace_id(span.get_span_context().trace_id)
span_id = format_span_id(span.get_span_context().span_id)
traceresponse = f"00-{trace_id}-{span_id}-01"

self.assertListEqual(
socket_send["headers"],
[
Expand Down Expand Up @@ -550,5 +550,38 @@ def test_credential_removal(self):
)


class TestWrappedApplication(AsgiTestBase):
def test_mark_span_internal_in_presence_of_span_from_other_framework(self):
tracer_provider, exporter = TestBase.create_tracer_provider()
tracer = tracer_provider.get_tracer(__name__)
app = otel_asgi.OpenTelemetryMiddleware(
simple_asgi, tracer_provider=tracer_provider
)

# Wrapping the otel intercepted app with server span
async def wrapped_app(scope, receive, send):
with tracer.start_as_current_span(
"test", kind=SpanKind.SERVER
) as _:
await app(scope, receive, send)

self.seed_app(wrapped_app)
self.send_default_request()
span_list = exporter.get_finished_spans()

self.assertEqual(SpanKind.INTERNAL, span_list[0].kind)
self.assertEqual(SpanKind.INTERNAL, span_list[1].kind)
self.assertEqual(SpanKind.INTERNAL, span_list[2].kind)
self.assertEqual(trace_api.SpanKind.INTERNAL, span_list[3].kind)

# SERVER "test"
self.assertEqual(SpanKind.SERVER, span_list[4].kind)

# internal span should be child of the test span we have provided
self.assertEqual(
span_list[4].context.span_id, span_list[3].parent.span_id
)


if __name__ == "__main__":
unittest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
config.read("setup.cfg")

# We provide extras_require parameter to setuptools.setup later which
# overwrites the extra_require section from setup.cfg. To support extra_require
# secion in setup.cfg, we load it here and merge it with the extra_require param.
# overwrites the extras_require section from setup.cfg. To support extras_require
# section in setup.cfg, we load it here and merge it with the extras_require param.
extras_require = {}
if "options.extras_require" in config:
for key, value in config["options.extras_require"].items():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
config.read("setup.cfg")

# We provide extras_require parameter to setuptools.setup later which
# overwrites the extra_require section from setup.cfg. To support extra_require
# secion in setup.cfg, we load it here and merge it with the extra_require param.
# overwrites the extras_require section from setup.cfg. To support extras_require
# section in setup.cfg, we load it here and merge it with the extras_require param.
extras_require = {}
if "options.extras_require" in config:
for key, value in config["options.extras_require"].items():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ install_requires =
test =
moto~=2.0
opentelemetry-test-utils == 0.28b1
markupsafe==2.0.1

[options.packages.find]
where = src
Expand Down
4 changes: 2 additions & 2 deletions instrumentation/opentelemetry-instrumentation-boto/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
config.read("setup.cfg")

# We provide extras_require parameter to setuptools.setup later which
# overwrites the extra_require section from setup.cfg. To support extra_require
# secion in setup.cfg, we load it here and merge it with the extra_require param.
# overwrites the extras_require section from setup.cfg. To support extras_require
# section in setup.cfg, we load it here and merge it with the extras_require param.
extras_require = {}
if "options.extras_require" in config:
for key, value in config["options.extras_require"].items():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ install_requires =
test =
moto[all] ~= 2.2.6
opentelemetry-test-utils == 0.28b1
markupsafe==2.0.1

[options.packages.find]
where = src
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
config.read("setup.cfg")

# We provide extras_require parameter to setuptools.setup later which
# overwrites the extra_require section from setup.cfg. To support extra_require
# secion in setup.cfg, we load it here and merge it with the extra_require param.
# overwrites the extras_require section from setup.cfg. To support extras_require
# section in setup.cfg, we load it here and merge it with the extras_require param.
extras_require = {}
if "options.extras_require" in config:
for key, value in config["options.extras_require"].items():
Expand Down
4 changes: 2 additions & 2 deletions instrumentation/opentelemetry-instrumentation-celery/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
config.read("setup.cfg")

# We provide extras_require parameter to setuptools.setup later which
# overwrites the extra_require section from setup.cfg. To support extra_require
# secion in setup.cfg, we load it here and merge it with the extra_require param.
# overwrites the extras_require section from setup.cfg. To support extras_require
# section in setup.cfg, we load it here and merge it with the extras_require param.
extras_require = {}
if "options.extras_require" in config:
for key, value in config["options.extras_require"].items():
Expand Down
4 changes: 2 additions & 2 deletions instrumentation/opentelemetry-instrumentation-dbapi/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
config.read("setup.cfg")

# We provide extras_require parameter to setuptools.setup later which
# overwrites the extra_require section from setup.cfg. To support extra_require
# secion in setup.cfg, we load it here and merge it with the extra_require param.
# overwrites the extras_require section from setup.cfg. To support extras_require
# section in setup.cfg, we load it here and merge it with the extras_require param.
extras_require = {}
if "options.extras_require" in config:
for key, value in config["options.extras_require"].items():
Expand Down
Loading

0 comments on commit a5f6ec9

Please sign in to comment.