Skip to content

Commit

Permalink
adjust telemetry changes (#7)
Browse files Browse the repository at this point in the history
* adjust telemetry changes

* bump version

* clear poetry PyPI cache
  • Loading branch information
burak-upstash authored Jul 4, 2023
1 parent 351a994 commit 2ac3981
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 43 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ jobs:
run: curl -sSL https://install.python-poetry.org | python3 -

- name: Set up Poetry environment
run: poetry install --no-root
run: |
poetry cache clear PyPI --all
poetry install --no-root
- name: Run tests
run: |
Expand Down
14 changes: 7 additions & 7 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "upstash_ratelimit"
version = "0.4.0"
version = "0.4.2"
description = "Serverless ratelimiting package from Upstash"
authors = ["Upstash <support@upstash.com>", "Zgîmbău Tudor <tudor.zgimbau@gmail.com>"]
readme = "README.md"
Expand All @@ -10,7 +10,7 @@ packages = [{include = "upstash_ratelimit"}]
python = "^3.8"
pytest = "^7.3.0"
pytest-asyncio = "^0.21.0"
upstash-redis = "^0.14.4"
upstash-redis = "^0.14.5"

[build-system]
requires = ["poetry-core"]
Expand Down
1 change: 0 additions & 1 deletion upstash_ratelimit/algorithms/algorithm.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from abc import ABC, abstractmethod
from upstash_redis.asyncio import Redis
from upstash_redis.schema.telemetry import TelemetryData
from upstash_ratelimit.config import SDK, PREFIX
from upstash_ratelimit.schema.response import RateLimitResponse
from asyncio import sleep
Expand Down
5 changes: 1 addition & 4 deletions upstash_ratelimit/asyncio/fixed_window.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from distutils.sysconfig import PREFIX
from typing import Literal
from upstash_redis.asyncio import Redis
from upstash_redis.schema.telemetry import TelemetryData
from upstash_ratelimit.algorithms.fixed_window_core import FixedWindowCore
from upstash_ratelimit.config import SDK
from upstash_ratelimit.asyncio.async_blocker import AsyncBlocker
Expand Down Expand Up @@ -33,11 +32,9 @@ def __init__(
if redis is None:
redis = Redis.from_env()

redis._headers["Upstash-Telemetry-Sdk"] = "upstash_ratelimit@python"
self.redis = redis

if redis.allow_telemetry:
self.redis.telemetry_data = TelemetryData(sdk=SDK)

super().__init__(
max_number_of_requests=max_number_of_requests,
window=window,
Expand Down
5 changes: 1 addition & 4 deletions upstash_ratelimit/asyncio/limiter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from upstash_ratelimit.config import PREFIX
from upstash_redis.asyncio import Redis
from upstash_redis.schema.telemetry import TelemetryData
from upstash_ratelimit.config import SDK, PREFIX
from typing import Literal, Optional
from upstash_ratelimit.asyncio.fixed_window import FixedWindow
Expand All @@ -22,12 +21,10 @@ def __init__(self, redis: Optional[Redis] = None, prefix: str = PREFIX):
if redis is None:
redis = Redis.from_env()

redis._headers["Upstash-Telemetry-Sdk"] = "upstash_ratelimit@python"
self.redis = redis
self.prefix = prefix

if redis.allow_telemetry:
self.redis.telemetry_data = TelemetryData(sdk=SDK)

def fixed_window(
self,
max_number_of_requests: int,
Expand Down
5 changes: 1 addition & 4 deletions upstash_ratelimit/asyncio/sliding_window.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import ClassVar, Literal
from upstash_redis.asyncio import Redis
from upstash_redis.schema.telemetry import TelemetryData
from upstash_ratelimit.algorithms.sliding_window_core import SlidingWindowCore
from upstash_ratelimit.asyncio.async_blocker import AsyncBlocker
from upstash_ratelimit.utils.time import to_milliseconds
Expand Down Expand Up @@ -37,11 +36,9 @@ def __init__(
if redis is None:
redis = Redis.from_env()

redis._headers["Upstash-Telemetry-Sdk"] = "upstash_ratelimit@python"
self.redis = redis

if redis.allow_telemetry:
self.redis.telemetry_data = TelemetryData(sdk=SDK)

super().__init__(
max_number_of_requests=max_number_of_requests,
window=window,
Expand Down
5 changes: 1 addition & 4 deletions upstash_ratelimit/asyncio/token_bucket.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import Literal
from upstash_redis.asyncio import Redis
from upstash_redis.schema.telemetry import TelemetryData
from upstash_ratelimit.algorithms.token_bucket_core import TokenBucketCore
from upstash_ratelimit.asyncio.async_blocker import AsyncBlocker
from upstash_ratelimit.config import PREFIX, SDK
Expand Down Expand Up @@ -36,11 +35,9 @@ def __init__(
if redis is None:
redis = Redis.from_env()

redis._headers["Upstash-Telemetry-Sdk"] = "upstash_ratelimit@python"
self.redis = redis

if redis.allow_telemetry:
self.redis.telemetry_data = TelemetryData(sdk=SDK)

super().__init__(
max_number_of_tokens=max_number_of_tokens,
refill_rate=refill_rate,
Expand Down
5 changes: 1 addition & 4 deletions upstash_ratelimit/limiter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from upstash_ratelimit.config import PREFIX
from upstash_redis import Redis
from upstash_redis.schema.telemetry import TelemetryData
from upstash_ratelimit.config import SDK, PREFIX
from typing import Literal, Optional

Expand All @@ -23,12 +22,10 @@ def __init__(self, redis: Optional[Redis] = None, prefix: str = PREFIX):
if redis is None:
redis = Redis.from_env()

redis._headers["Upstash-Telemetry-Sdk"] = "upstash_ratelimit@python"
self.redis = redis
self.prefix = prefix

if redis.allow_telemetry:
self.redis.telemetry_data = TelemetryData(sdk=SDK)

def fixed_window(
self,
max_number_of_requests: int,
Expand Down
5 changes: 1 addition & 4 deletions upstash_ratelimit/sync/fixed_window.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from distutils.sysconfig import PREFIX
from typing import Literal
from upstash_redis import Redis
from upstash_redis.schema.telemetry import TelemetryData
from upstash_ratelimit.algorithms.fixed_window_core import FixedWindowCore
from upstash_ratelimit.config import SDK
from upstash_ratelimit.sync.sync_blocker import SyncBlocker
Expand Down Expand Up @@ -33,11 +32,9 @@ def __init__(
if redis is None:
redis = Redis.from_env()

redis._headers["Upstash-Telemetry-Sdk"] = "upstash_ratelimit@python"
self.redis = redis

if redis.allow_telemetry:
self.redis.telemetry_data = TelemetryData(sdk=SDK)

super().__init__(
max_number_of_requests=max_number_of_requests,
window=window,
Expand Down
5 changes: 1 addition & 4 deletions upstash_ratelimit/sync/sliding_window.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import Literal
from upstash_redis import Redis
from upstash_redis.schema.telemetry import TelemetryData
from upstash_ratelimit.algorithms.sliding_window_core import SlidingWindowCore
from upstash_ratelimit.config import PREFIX, SDK
from upstash_ratelimit.schema.response import RateLimitResponse
Expand Down Expand Up @@ -34,11 +33,9 @@ def __init__(
if redis is None:
redis = Redis.from_env()

redis._headers["Upstash-Telemetry-Sdk"] = "upstash_ratelimit@python"
self.redis = redis

if redis.allow_telemetry:
self.redis.telemetry_data = TelemetryData(sdk=SDK)

super().__init__(
max_number_of_requests=max_number_of_requests,
window=window,
Expand Down
5 changes: 1 addition & 4 deletions upstash_ratelimit/sync/token_bucket.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import Literal
from upstash_redis import Redis
from upstash_redis.schema.telemetry import TelemetryData
from upstash_ratelimit.algorithms.token_bucket_core import TokenBucketCore
from upstash_ratelimit.sync.sync_blocker import SyncBlocker
from upstash_ratelimit.config import PREFIX, SDK
Expand Down Expand Up @@ -35,11 +34,9 @@ def __init__(
if redis is None:
redis = Redis.from_env()

redis._headers["Upstash-Telemetry-Sdk"] = "upstash_ratelimit@python"
self.redis = redis

if redis.allow_telemetry:
self.redis.telemetry_data = TelemetryData(sdk=SDK)

super().__init__(
max_number_of_tokens=max_number_of_tokens,
refill_rate=refill_rate,
Expand Down

0 comments on commit 2ac3981

Please sign in to comment.