NH-32409 Fix failed ASGI version lookup logs #108
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes a framework lookup at
Python.*.Version
span KV calculation and removes excessive warning logs as reported by customer, which are logging once per span, 3 spans per trace created by a very simple FastAPI app (their code attached to ticket, similar in testbed PR here):[ solarwinds_apm.exporter WARNING p#1.140549948016384] Version lookup of asgi failed, so skipping: No module named 'asgi'
This is a bit of an odd approach but all of
SolarWindsSpanExporter._add_info_instrumented_framework
is a little odd. The exceptions were being raised (and caught to log) because we can'timport asgi
to get its version. Instead, ASGI design is implemented by several frameworks listed here and added to new_ASGI_APP_IMPLEMENTATIONS
and_ASGI_SERVER_IMPLEMENTATIONS
. There are two new loops depending on ifSpanKind.SERVER
or any other kind (e.g.INTERNAL
,CLIENT
). Each loop goes through one implementations list and stops when it can set e.g.Python.Fastapi.Version
as0.89.1
orPython.Uvicorn.Version
as0.20.0
. It won't try to setPython.Asgi.Version
anymore.Caveat: The new loops stop at the first framework they're able to import. We're making these "estimates" right now as a placeholder until there is more demand for this feature. Then we'd address the
TODO
and find how to be more precise than relying only onspan.instrumentation_scope.name
(opentelemetry.instrumentation.asgi
) and SpanKind for settingPython.*.Version
.Example trace from simple ASGI app, with two
Python.Fastapi.Version
spans and onePython.Uvicorn.Version
span: https://my.na-01.cloud.solarwinds.com/140638900734749696/traces/42280A9C6F489D8603D60B14FE80A322/54CD29BC456800EF/detailsCompared trace from
main
, which is missingPython.*.Version
KVs on all spans: https://my.na-01.cloud.solarwinds.com/140638900734749696/traces/B5A4F6F225065B391F7896B9EFD5810C/D6D2B18C2CABF10C/details. This is the actual bug. 🙂