[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`
This commit is contained in:
dbf
2023-02-06 13:20:20 +01:00
committed by GitHub
parent 66ceef5fe1
commit 7af87e1bec
2 changed files with 9 additions and 2 deletions

View File

@ -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.

View File

@ -291,14 +291,19 @@ class TortoiseORMInstrumentor(BaseInstrumentor):
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