opentelemetry-instrumentation-memorysync
OpenTelemetry instrumentation for the MemorySync Python SDK — memory operations become first-class spans in AgentOps, Respan, and any other OpenTelemetry backend.
The first SDK-level tracing instrumentor shipped by any memory vendor.
pip install opentelemetry-instrumentation-memorysync
With AgentOps
agentops.init() registers AgentOps as the global OpenTelemetry tracer
provider, so MemorySync spans land in your AgentOps traces automatically:
import agentops
from opentelemetry.instrumentation.memorysync import instrument_memorysync
from memorysync import MemorySyncClient
agentops.init() # before or after instrument_memorysync() — both work
instrument_memorysync()
client = MemorySyncClient(api_key="ms_...", base_url="https://api.memorysync.io")
client.add("Prefers window seats", source="chat") # → span: memorysync.add
client.query("seating preferences", k=5) # → span: memorysync.query
With Respan (formerly Keywords AI)
Route your LLM calls through the Respan gateway and instrument MemorySync — every step of the loop is a first-class span:
from openai import OpenAI
from opentelemetry.instrumentation.memorysync import instrument_memorysync
instrument_memorysync()
llm = OpenAI(api_key=RESPAN_API_KEY, base_url="https://api.respan.ai/api/")
context = ms.recall(tenant_id=t, user_id=u, prompt=question, k=6) # span 1
reply = llm.chat.completions.create(...) # gateway-traced
ms.add_turn(tenant_id=t, user_id=u, text=..., sync_embed=False) # span 2
With plain OpenTelemetry / auto-instrumentation
The package registers the standard opentelemetry_instrumentor entry
point, so the OTel CLI picks it up with zero code changes:
opentelemetry-instrument python app.py
What gets traced
memorysync.{operation} CLIENT spans for both MemorySyncClient and
AsyncMemorySyncClient (full sync/async parity): add, add_turn,
bulk_add, query, retrieve, recall, search_routed, get,
update, forget, summarize, history, feedback, list_memories.
Attributes always include the operation, sync/async client kind,
server address, project/tenant/user identifiers, result counts, score
min/max/avg, already_exists idempotency signals, and error type +
HTTP status on failure. A memorysync.client.operation.duration
histogram is recorded per call.
Privacy: content capture is OFF by default
Memory content is customer data. By default no memory text, query text, or recalled context is recorded — only counts, identifiers, scores, and latencies. Opt in explicitly:
instrument_memorysync(capture_content=True)
# or: MEMORYSYNC_OTEL_CAPTURE_CONTENT=true
Even opted in, input is truncated to 500 characters and at most 5 result texts of 200 characters each are recorded.
Engineering guarantees
- Instrumentation can never break the app. Attribute extraction is fully guarded; return values and exceptions pass through untouched; spans are always ended.
- Zero stdout pollution — the instrumentation never prints (the test suite asserts stdout stays empty during instrumented calls).
- Idempotent —
instrument_memorysync()twice is safe;uninstrument_memorysync()restores the original methods. - Order independent — OTel's proxy tracer late-binds, so instrumenting before your platform initializes still works.
- Zero changes to the
memorysyncpackage — methods are wrapped at runtime; nothing in the SDK itself is modified on disk.
Docs
- AgentOps guide: https://docs.memorysync.io/guides/agentops
- Respan guide: https://docs.memorysync.io/guides/respan
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file opentelemetry_instrumentation_memorysync-1.0.0.tar.gz.
File metadata
- Download URL: opentelemetry_instrumentation_memorysync-1.0.0.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec0178966c3297d03849120d67ff70a1d7d184c759084b6f8b1dfc12d1ae88e5
|
|
| MD5 |
da2f206ded67e45859baa597bdba9b3a
|
|
| BLAKE2b-256 |
0080898224c77089120e030f0e595b8d5db45d146f4d15d21e6e2a03c3eb6401
|
File details
Details for the file opentelemetry_instrumentation_memorysync-1.0.0-py3-none-any.whl.
File metadata
- Download URL: opentelemetry_instrumentation_memorysync-1.0.0-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4bb41447b013064b32025173ad810d6495c9be8b42007f4019be9f44a618d6b
|
|
| MD5 |
5c51be6302b6546d0c6b851c45ee0261
|
|
| BLAKE2b-256 |
8e5becd394a3eac48c8ad231a25692e75dc20bbe3a7aeee05bc55e8e58678844
|