Skip to content

Commit 7af87e1

Browse files
authored
[TortoiseORM instrumentation] Fix AttributeError: type object 'Config' has no attribute 'title' (#1575)
* Use pydantic model name as default `title` value * Update `CHANGELOG.md` * Format with black * Lint with `black`
1 parent 66ceef5 commit 7af87e1

File tree

2 files changed

+9
-2
lines changed
  • instrumentation/opentelemetry-instrumentation-tortoiseorm/src/opentelemetry/instrumentation/tortoiseorm

2 files changed

+9
-2
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2727

2828
### Fixed
2929

30+
- Fix TortoiseORM instrumentation `AttributeError: type object 'Config' has no attribute 'title'`
31+
([#1575](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1575))
3032
- Fix SQLAlchemy uninstrumentation
3133
([#1581](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1581))
3234
- `opentelemetry-instrumentation-grpc` Fix code()/details() of _OpentelemetryServicerContext.

instrumentation/opentelemetry-instrumentation-tortoiseorm/src/opentelemetry/instrumentation/tortoiseorm/__init__.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -291,14 +291,19 @@ async def _from_queryset(self, func, modelcls, args, kwargs):
291291
name = f"pydantic.{func.__name__}"
292292

293293
with self._tracer.start_as_current_span(
294-
name, kind=SpanKind.INTERNAL
294+
name,
295+
kind=SpanKind.INTERNAL,
295296
) as span:
296297
if span.is_recording():
297298
span_attributes = {}
298299

299300
model_config = getattr(modelcls, "Config", None)
300301
if model_config:
301-
model_title = getattr(modelcls.Config, "title")
302+
model_title = getattr(
303+
modelcls.Config,
304+
"title",
305+
modelcls.__name__,
306+
)
302307
if model_title:
303308
span_attributes["pydantic.model"] = model_title
304309

0 commit comments

Comments
 (0)