Skip to content

Commit

Permalink
Merge pull request #25 from xhdnoah/master
Browse files Browse the repository at this point in the history
feat: add otel tracing
  • Loading branch information
nicholasxuu authored Apr 29, 2024
2 parents 65ff0e3 + 26f8fed commit 48c38c0
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

---

## [1.2.0] - 2024-04-29

### Added:

- Redis OpenTelemetry Instrument

## [1.2.0] - 2022-07-26

### Added:
Expand Down
2 changes: 1 addition & 1 deletion cachext/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.2.0'
__version__ = '1.2.1'
2 changes: 2 additions & 0 deletions cachext/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ class Redis(BaseBackend):

def __init__(self, prefix=None, default_ttl=600, **kwargs):
import redis
from opentelemetry.instrumentation.redis import RedisInstrumentor
RedisInstrumentor().instrument()
self._client = redis.StrictRedis(**kwargs)
self.prefix = prefix
self.default_ttl = default_ttl
Expand Down
2 changes: 2 additions & 0 deletions cachext/exts.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def __init__(self, ns='REDIS_'):

def init_app(self, app):
import redis
from opentelemetry.instrumentation.redis import RedisInstrumentor
RedisInstrumentor().instrument()
opts = app.config.get_namespace(self.ns)
self._pool = redis.ConnectionPool(**opts)
self._client = redis.StrictRedis(connection_pool=self._pool)
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
opentelemetry.instrumentation.redis

0 comments on commit 48c38c0

Please sign in to comment.