Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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: 2 additions & 0 deletions sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
## 1.8.10 (Unreleased)

### Features Added
- Add support for the `httpx2` OpenTelemetry instrumentation entry point
([#48899](https://github.com/Azure/azure-sdk-for-python/pull/48899))
- Add httpx instrumentation support
([#47953](https://github.com/Azure/azure-sdk-for-python/pull/47953))

Expand Down
3 changes: 2 additions & 1 deletion sdk/monitor/azure-monitor-opentelemetry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ OpenTelemetry instrumentations allow automatic collection of requests sent from
| [OpenTelemetry Django Instrumentation][ot_instrumentation_django] | [django][pypi_django] | [link][ot_instrumentation_django_version]
| [OpenTelemetry FastApi Instrumentation][ot_instrumentation_fastapi] | [fastapi][pypi_fastapi] | [link][ot_instrumentation_fastapi_version]
| [OpenTelemetry Flask Instrumentation][ot_instrumentation_flask] | [flask][pypi_flask] | [link][ot_instrumentation_flask_version]
| [OpenTelemetry Httpx Instrumentation][ot_instrumentation_httpx] | [httpx][pypi_httpx] | [link][ot_instrumentation_httpx_version]
| [OpenTelemetry Httpx Instrumentation][ot_instrumentation_httpx] | [httpx][pypi_httpx], [httpx2][pypi_httpx2] | [link][ot_instrumentation_httpx_version]
| [OpenTelemetry Psycopg2 Instrumentation][ot_instrumentation_psycopg2] | [psycopg2][pypi_psycopg2] | [link][ot_instrumentation_psycopg2_version]
| [OpenTelemetry Requests Instrumentation][ot_instrumentation_requests] | [requests][pypi_requests] | [link][ot_instrumentation_requests_version]
| [OpenTelemetry UrlLib Instrumentation][ot_instrumentation_urllib] | [urllib][pypi_urllib] | All
Expand Down Expand Up @@ -264,6 +264,7 @@ contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additio
[pypi_fastapi]: https://pypi.org/project/fastapi/
[pypi_flask]: https://pypi.org/project/Flask/
[pypi_httpx]: https://pypi.org/project/httpx/
[pypi_httpx2]: https://pypi.org/project/httpx2/
[pypi_psycopg2]: https://pypi.org/project/psycopg2/
[pypi_requests]: https://pypi.org/project/requests/
[pypi_urllib]: https://docs.python.org/3/library/urllib.html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"fastapi",
"flask",
"httpx",
"httpx2",
"psycopg2",
"requests",
"urllib",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ psycopg2-binary
requests
urllib3
httpx
httpx2
brotli
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
"urllib": {"enabled": False},
"urllib3": {"enabled": True},
"httpx": {"enabled": True},
"httpx2": {"enabled": True},
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@

from opentelemetry.instrumentation.httpx import (
HTTPXClientInstrumentor,
HTTPX2ClientInstrumentor,
)


class TestHttpxInstrumentation(unittest.TestCase):
def test_instrument(self):
self._instrument(HTTPXClientInstrumentor)
self._instrument(HTTPX2ClientInstrumentor)

def _instrument(self, instrumentor):
try:
HTTPXClientInstrumentor().instrument()
instrumentor().instrument()
except Exception as ex: # pylint: disable=broad-except
print(ex)
self.fail(f"Unexpected exception raised when instrumenting {HTTPXClientInstrumentor.__name__}")
self.fail(f"Unexpected exception raised when instrumenting {instrumentor.__name__}")
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def test_get_configurations(self, resource_create_mock):
"urllib": {"enabled": True},
"urllib3": {"enabled": True},
"httpx": {"enabled": True},
"httpx2": {"enabled": True},
"previewlib1": {"enabled": False},
"previewlib2": {"enabled": False},
},
Expand Down Expand Up @@ -147,6 +148,7 @@ def test_get_configurations_defaults(self, resource_create_mock):
"urllib": {"enabled": True},
"urllib3": {"enabled": True},
"httpx": {"enabled": True},
"httpx2": {"enabled": True},
},
)
self.assertEqual(configurations["resource"].attributes, TEST_DEFAULT_RESOURCE.attributes)
Expand Down Expand Up @@ -196,6 +198,7 @@ def test_get_configurations_env_vars(self, resource_create_mock):
"urllib": {"enabled": True},
"urllib3": {"enabled": True},
"httpx": {"enabled": True},
"httpx2": {"enabled": True},
},
)
self.assertEqual(configurations["resource"].attributes, TEST_DEFAULT_RESOURCE.attributes)
Expand Down Expand Up @@ -280,6 +283,7 @@ def test_merge_instrumentation_options_conflict(self, resource_create_mock):
"urllib": {"enabled": True},
"urllib3": {"enabled": False},
"httpx": {"enabled": True},
"httpx2": {"enabled": True},
},
)

Expand Down Expand Up @@ -315,6 +319,7 @@ def test_merge_instrumentation_options_extra_args(self, resource_create_mock):
"urllib": {"enabled": True},
"urllib3": {"enabled": True},
"httpx": {"enabled": True},
"httpx2": {"enabled": True},
},
)

Expand Down Expand Up @@ -461,6 +466,7 @@ def test_get_configurations_env_vars_rate_limited(self, resource_create_mock):
"urllib": {"enabled": True},
"urllib3": {"enabled": True},
"httpx": {"enabled": True},
"httpx2": {"enabled": True},
},
)
self.assertEqual(configurations["resource"].attributes, TEST_DEFAULT_RESOURCE.attributes)
Expand Down Expand Up @@ -489,6 +495,7 @@ def test_get_configurations_rate_limited_sampler_param(self, resource_create_moc
"urllib": {"enabled": True},
"urllib3": {"enabled": True},
"httpx": {"enabled": True},
"httpx2": {"enabled": True},
},
)
self.assertEqual(configurations["resource"].attributes, TEST_DEFAULT_RESOURCE.attributes)
Expand Down Expand Up @@ -528,6 +535,7 @@ def test_get_configurations_env_vars_no_preference(self, resource_create_mock):
"urllib": {"enabled": True},
"urllib3": {"enabled": True},
"httpx": {"enabled": True},
"httpx2": {"enabled": True},
},
)
self.assertEqual(configurations["resource"].attributes, TEST_DEFAULT_RESOURCE.attributes)
Expand Down Expand Up @@ -567,6 +575,7 @@ def test_get_configurations_env_vars_check_default(self, resource_create_mock):
"urllib": {"enabled": True},
"urllib3": {"enabled": True},
"httpx": {"enabled": True},
"httpx2": {"enabled": True},
},
)
self.assertEqual(configurations["resource"].attributes, TEST_DEFAULT_RESOURCE.attributes)
Expand Down Expand Up @@ -607,6 +616,7 @@ def test_get_configurations_env_vars_fixed_percentage(self, resource_create_mock
"urllib": {"enabled": True},
"urllib3": {"enabled": True},
"httpx": {"enabled": True},
"httpx2": {"enabled": True},
},
)
self.assertEqual(configurations["resource"].attributes, TEST_DEFAULT_RESOURCE.attributes)
Expand Down Expand Up @@ -646,6 +656,7 @@ def test_get_configurations_env_vars_always_on(self, resource_create_mock):
"urllib": {"enabled": True},
"urllib3": {"enabled": True},
"httpx": {"enabled": True},
"httpx2": {"enabled": True},
},
)
self.assertEqual(configurations["resource"].attributes, TEST_DEFAULT_RESOURCE.attributes)
Expand Down