Django中的OpenTelemetry Python Auto Instrumentation出现错误



下面是我所做的设置:

export OTEL_TRACES_EXPORTER=otlp
export OTEL_RESOURCE_ATTRIBUTES=service.name=Communication
export OTEL_EXPORTER_OTLP_HEADERS=x-scope-orgid=XXXXX
export OTEL_PYTHON_LOG_CORRELATION=true
export OTEL_LOG_LEVEL=debug
export OTEL_PYTHON_LOG_LEVEL=debug
export DJANGO_SETTINGS_MODULE=nsl_vcs.settings.docker
export OTEL_PYTHON_DJANGO_TRACED_REQUEST_ATTRS='path_info,content_type'
export OTEL_PYTHON_TRACER_PROVIDER=sdk_tracer_provider
export OTEL_PYTHON_METER_PROVIDER=sdk_meter_provider
pip3 install opentelemetry-sdk
pip3 install opentelemetry-instrumentation-django
pip install opentelemetry-exporter-otlp
opentelemetry-bootstrap --action=install
opentelemetry-instrument python3 manage.py runserver --settings=nsl_vcs.settings.docker 0.0.0.0:7013 --noreload

所有的命令都是成功的,我没有看到任何错误。但当我启动REST调用时,它会给我以下错误。请注意,如果没有跟踪,我不会得到错误:

opentelemetry-instrument python3 manage.py runserver --settings=nsl_vcs.settings.docker 0.0.0.0:7013 --noreload
2021-07-13 10:38:55,169 DEBUG [/home/nsluser/.local/lib/python3.8/site-packages/opentelemetry/instrumentation/auto_instrumentation/sitecustomize.py] [sitecustomize.py:82] [trace_id=0 span_id=0 resource.service.name=Communication] - Instrumented logging
2021-07-13 10:38:55,197 DEBUG [/home/nsluser/.local/lib/python3.8/site-packages/opentelemetry/instrumentation/auto_instrumentation/sitecustomize.py] [sitecustomize.py:82] [trace_id=0 span_id=0 resource.service.name=Communication] - Instrumented grpc_client
2021-07-13 10:38:55,199 DEBUG [/home/nsluser/.local/lib/python3.8/site-packages/opentelemetry/instrumentation/auto_instrumentation/sitecustomize.py] [sitecustomize.py:82] [trace_id=0 span_id=0 resource.service.name=Communication] - Instrumented grpc_server
path2 /home/nsluser/base/code/communications/nsl_vcs/payment_gateways/templates
ENV docker
2021-07-13 16:08:55,303 DEBUG [/home/nsluser/.local/lib/python3.8/site-packages/opentelemetry/instrumentation/auto_instrumentation/sitecustomize.py] [sitecustomize.py:82] [trace_id=0 span_id=0 resource.service.name=Communication] - Instrumented django
Performing system checks...
ENV From base import docker
System check identified no issues (0 silenced).
July 13, 2021 - 16:08:55
Django version 2.1, using settings 'nsl_vcs.settings.docker'
Starting development server at http://0.0.0.0:7013/
Quit the server with CONTROL-C.
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/usr/local/lib/python3.8/dist-packages/django/core/handlers/base.py", line 117, in _get_response
response = middleware_method(request, callback, callback_args, callback_kwargs)
File "/home/nsluser/.local/lib/python3.8/site-packages/opentelemetry/instrumentation/django/middleware.py", line 174, in process_view
route = getattr(match, "route")
AttributeError: 'ResolverMatch' object has no attribute 'route'

这是一个开放遥测的问题,Django 2.1的一个例子:https://github.com/open-telemetry/opentelemetry-python-contrib/pull/581

最新更新