Skip to content

Commit 703f85c

Browse files
committed
Update pymemcache instrumentation to support pymemcache version > 1.3.x
1 parent 59ca95d commit 703f85c

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5454
- `opentelemetry-instrumentation-kafka-python` Fix topic extraction
5555
([#949](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/949))
5656

57+
### Changed
58+
59+
- `opentelemetry-instrumentation-pymemcache` should run against newer versions of pymemcache.
60+
([#935](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/935))
61+
5762
## [1.9.1-0.28b1](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.9.1-0.28b1) - 2022-01-29
5863

5964
### Fixed

instrumentation/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
| [opentelemetry-instrumentation-mysql](./opentelemetry-instrumentation-mysql) | mysql-connector-python ~= 8.0 |
2424
| [opentelemetry-instrumentation-pika](./opentelemetry-instrumentation-pika) | pika >= 0.12.0 |
2525
| [opentelemetry-instrumentation-psycopg2](./opentelemetry-instrumentation-psycopg2) | psycopg2 >= 2.7.3.1 |
26-
| [opentelemetry-instrumentation-pymemcache](./opentelemetry-instrumentation-pymemcache) | pymemcache ~= 1.3 |
26+
| [opentelemetry-instrumentation-pymemcache](./opentelemetry-instrumentation-pymemcache) | pymemcache > 2, < 4 |
2727
| [opentelemetry-instrumentation-pymongo](./opentelemetry-instrumentation-pymongo) | pymongo >= 3.1, < 5.0 |
2828
| [opentelemetry-instrumentation-pymysql](./opentelemetry-instrumentation-pymysql) | PyMySQL < 2 |
2929
| [opentelemetry-instrumentation-pyramid](./opentelemetry-instrumentation-pyramid) | pyramid >= 1.7 |

instrumentation/opentelemetry-instrumentation-pymemcache/src/opentelemetry/instrumentation/pymemcache/package.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# limitations under the License.
1414

1515

16-
_instruments = ("pymemcache ~= 1.3",)
16+
_instruments = ("pymemcache > 2, < 4",)

instrumentation/opentelemetry-instrumentation-pymemcache/tests/test_pymemcache.py

+9-11
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,11 @@ def test_set_multi_success(self):
126126
client = self.make_client([b"STORED\r\n"])
127127
# Alias for set_many, a convienance function that calls set for every key
128128
result = client.set_multi({b"key": b"value"}, noreply=False)
129-
self.assertTrue(result)
129+
assert len(result) == 0
130130

131131
spans = self.memory_exporter.get_finished_spans()
132132

133-
self.check_spans(spans, 2, ["set key", "set_multi key"])
133+
self.check_spans(spans, 1, ["set_multi key"])
134134

135135
def test_delete_not_found(self):
136136
client = self.make_client([b"NOT_FOUND\r\n"])
@@ -191,19 +191,17 @@ def test_delete_many_found(self):
191191

192192
spans = self.memory_exporter.get_finished_spans()
193193

194-
self.check_spans(
195-
spans, 3, ["add key", "delete key", "delete_many key"]
196-
)
194+
self.check_spans(spans, 2, ["add key", "delete_many key"])
197195

198196
def test_set_many_success(self):
199197
client = self.make_client([b"STORED\r\n"])
200198
# a convienance function that calls set for every key
201199
result = client.set_many({b"key": b"value"}, noreply=False)
202-
self.assertTrue(result)
200+
assert len(result) == 0
203201

204202
spans = self.memory_exporter.get_finished_spans()
205203

206-
self.check_spans(spans, 2, ["set key", "set_many key"])
204+
self.check_spans(spans, 1, ["set_many key"])
207205

208206
def test_set_get(self):
209207
client = self.make_client(
@@ -243,7 +241,7 @@ def test_prepend_stored(self):
243241

244242
def test_cas_stored(self):
245243
client = self.make_client([b"STORED\r\n"])
246-
result = client.cas(b"key", b"value", b"cas", noreply=False)
244+
result = client.cas(b"key", b"value", 1, noreply=False)
247245
self.assertTrue(result)
248246

249247
spans = self.memory_exporter.get_finished_spans()
@@ -252,7 +250,7 @@ def test_cas_stored(self):
252250

253251
def test_cas_exists(self):
254252
client = self.make_client([b"EXISTS\r\n"])
255-
result = client.cas(b"key", b"value", b"cas", noreply=False)
253+
result = client.cas(b"key", b"value", 1, noreply=False)
256254
assert result is False
257255

258256
spans = self.memory_exporter.get_finished_spans()
@@ -261,7 +259,7 @@ def test_cas_exists(self):
261259

262260
def test_cas_not_found(self):
263261
client = self.make_client([b"NOT_FOUND\r\n"])
264-
result = client.cas(b"key", b"value", b"cas", noreply=False)
262+
result = client.cas(b"key", b"value", 1, noreply=False)
265263
assert result is None
266264

267265
spans = self.memory_exporter.get_finished_spans()
@@ -445,7 +443,7 @@ def test_version_success(self):
445443
def test_stats(self):
446444
client = self.make_client([b"STAT fake_stats 1\r\n", b"END\r\n"])
447445
result = client.stats()
448-
assert client.sock.send_bufs == [b"stats \r\n"]
446+
assert client.sock.send_bufs == [b"stats\r\n"]
449447
assert result == {b"fake_stats": 1}
450448

451449
spans = self.memory_exporter.get_finished_spans()

opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
"instrumentation": "opentelemetry-instrumentation-psycopg2==0.29b0",
9494
},
9595
"pymemcache": {
96-
"library": "pymemcache ~= 1.3",
96+
"library": "pymemcache > 2, < 4",
9797
"instrumentation": "opentelemetry-instrumentation-pymemcache==0.29b0",
9898
},
9999
"pymongo": {

0 commit comments

Comments
 (0)