MCPcopy Create free account
hub / github.com/AgentOps-AI/agentops / record_interaction

Function record_interaction

app/api/agentops/common/rate_limit.py:24–33  ·  view source on GitHub ↗

Record an interaction from the given IP address. Uses a sliding window approach with sorted sets in Redis.

(ip: str)

Source from the content-addressed store, hash-verified

22
23
24def record_interaction(ip: str) -> None:
25 """
26 Record an interaction from the given IP address.
27 Uses a sliding window approach with sorted sets in Redis.
28 """
29 key, now = _key(ip), _now_us()
30
31 cache.zremrangebyscore(key, 0, now - WINDOW_US)
32 cache.zadd(key, {str(now): now})
33 cache.expire(key, RATE_LIMIT_EXPIRY)
34
35
36def is_blocked(ip: str) -> bool:

Callers

nothing calls this directly

Calls 5

_keyFunction · 0.85
_now_usFunction · 0.85
zremrangebyscoreMethod · 0.80
zaddMethod · 0.80
expireMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…