Skip to content

Commit

Permalink
[TortoiseORM instrumentation] Fix `AttributeError: type object 'Confi…
Browse files Browse the repository at this point in the history
…g' has no attribute 'title'` (#1575)

* Use pydantic model name as default `title` value

* Update `CHANGELOG.md`

* Format with black

* Lint with `black`
  • Loading branch information
fullonic authored Feb 6, 2023
1 parent 66ceef5 commit 7af87e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Fix TortoiseORM instrumentation `AttributeError: type object 'Config' has no attribute 'title'`
([#1575](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1575))
- Fix SQLAlchemy uninstrumentation
([#1581](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1581))
- `opentelemetry-instrumentation-grpc` Fix code()/details() of _OpentelemetryServicerContext.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,19 @@ async def _from_queryset(self, func, modelcls, args, kwargs):
name = f"pydantic.{func.__name__}"

with self._tracer.start_as_current_span(
name, kind=SpanKind.INTERNAL
name,
kind=SpanKind.INTERNAL,
) as span:
if span.is_recording():
span_attributes = {}

model_config = getattr(modelcls, "Config", None)
if model_config:
model_title = getattr(modelcls.Config, "title")
model_title = getattr(
modelcls.Config,
"title",
modelcls.__name__,
)
if model_title:
span_attributes["pydantic.model"] = model_title

Expand Down

0 comments on commit 7af87e1

Please sign in to comment.