Skip to content

Commit

Permalink
Merge pull request #63 from xhdnoah/master
Browse files Browse the repository at this point in the history
feat: add otel instrument
  • Loading branch information
nicholasxuu authored Apr 29, 2024
2 parents 8956201 + 9b74530 commit cff5de7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@ All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

## [1.2.7] - 2024-04-28

- Add MySQLClientInstrumentor used to automatic tracing the requests from mysqlClient, the `instrument()` method should be invoked before `connect()`.

## [1.2.6] - 2021-12-29

- Update `updated_at` field implicitly when updating with the `only` option.

```
some_record.a_field = "updatede a field"
# updated fields: a_field, updated_at
some_record.save(only=["a_field"])
```


## [1.2.3] - 2021-04-21

- ensure_ascii is provided in JSONCharField to support storing Chinese in non-ascii way
Expand Down
2 changes: 1 addition & 1 deletion peeweext/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.2.6'
__version__ = '1.2.7'
2 changes: 2 additions & 0 deletions peeweext/flask.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from werkzeug.local import LocalProxy
from werkzeug.utils import import_string, cached_property
from playhouse import db_url
from opentelemetry.instrumentation.mysqlclient import MySQLClientInstrumentor


class UninitializedException(Exception):
Expand All @@ -20,6 +21,7 @@ def init_app(self, app):
config.get('model', 'peeweext.model.Model'))
conn_params = config.get('conn_params', {})

MySQLClientInstrumentor().instrument()
# initialize private connection pool
self._database = db_url.connect(config['db_url'], **conn_params)

Expand Down
2 changes: 2 additions & 0 deletions peeweext/sea.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from playhouse import db_url
from peewee import DoesNotExist, DataError
import grpc
from opentelemetry.instrumentation.mysqlclient import MySQLClientInstrumentor

from .validation import ValidationError

Expand All @@ -18,6 +19,7 @@ def init_app(self, app):
self.model_class = import_string(
config.get('model', 'peeweext.model.Model'))
conn_params = config.get('conn_params', {})
MySQLClientInstrumentor().instrument()
self.database = db_url.connect(config['db_url'], **conn_params)
self._try_setup_celery()

Expand Down

0 comments on commit cff5de7

Please sign in to comment.