Skip to content

Commit

Permalink
Merge branch 'main' into fix-psycopg2-instrument-connection
Browse files Browse the repository at this point in the history
  • Loading branch information
tammy-baylis-swi authored Jan 8, 2025
2 parents b3b3888 + 147e3f7 commit 238746e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- `opentelemetry-instrumentation-httpx` Fix `RequestInfo`/`ResponseInfo` type hints
([#3105](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3105))
- `opentelemetry-instrumentation` Fix `get_dist_dependency_conflicts` if no distribution requires
([#3168](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3168))


## Version 1.29.0/0.50b0 (2024-12-11)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@ def get_dist_dependency_conflicts(
extra = "extra"
instruments = "instruments"
instruments_marker = {extra: instruments}
for dep in dist.requires:
if extra not in dep or instruments not in dep:
continue

req = Requirement(dep)
if req.marker.evaluate(instruments_marker):
instrumentation_deps.append(req)
if dist.requires:
for dep in dist.requires:
if extra not in dep or instruments not in dep:
continue

req = Requirement(dep)
if req.marker.evaluate(instruments_marker):
instrumentation_deps.append(req)

return get_dependency_conflicts(instrumentation_deps)

Expand Down
16 changes: 16 additions & 0 deletions opentelemetry-instrumentation/tests/test_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,19 @@ def requires(self):
str(conflict),
'DependencyConflict: requested: "test-pkg~=1.0; extra == "instruments"" but found: "None"',
)

def test_get_dist_dependency_conflicts_requires_none(self):
class MockDistribution(Distribution):
def locate_file(self, path):
pass

def read_text(self, filename):
pass

@property
def requires(self):
return None

dist = MockDistribution()
conflict = get_dist_dependency_conflicts(dist)
self.assertTrue(conflict is None)

0 comments on commit 238746e

Please sign in to comment.