自从将App Insights添加到我的应用程序后,我就遇到了与this question类似的问题。它可能也与this other question有关,但它们都与App Insights没有直接关系,也没有解决方案。
这是django-tasks.log文件中的错误
Data drop 400: 100: Field 'url' on type 'RequestData' is too long. Expected: 2048 characters, Actual: 3701 {'iKey': <uuid>, 'tags': {'ai.cloud.role': 'manage.py', 'ai.cloud.roleInstance': <instance>, 'ai.device.id': <device>, 'ai.device.locale': 'en_US', 'ai.device.osVersion': '#1 SMP Tue Aug 25 17:23:54 UTC 2020', 'ai.device.type': 'Other', 'ai.internal.sdkVersion': 'py3.6.12:oc0.7.11:ext1.0.4', 'ai.operation.id': 'fcbe18bf6ca9036aa4546af171f3e877', 'ai.operation.name': 'GET /<my_url>/'}, 'time': '2020-12-15T17:58:36.498868Z', 'name': 'Microsoft.ApplicationInsights.Request', 'data': {'baseData': {'id': '116a0658b513bdb9', 'duration': '0.00:00:00.096', 'responseCode': '200', 'success': True, 'properties': {'request.name': 'GET /<my_url>/', 'request.url': 'https://<my host>/<my_url>/?<my very long query string>', 'django.user.id': '90', 'django.user.name': '100044505'}, 'ver': 2, 'name': 'GET /<my_url>/', 'url': 'https://<my host>/<my_url>/?<my very long query string>', 'source': None, 'measurements': None}, 'baseType': 'RequestData'}, 'ver': 1, 'sampleRate': None, 'seq': None, 'flags': None}.我们在日志中也看到了重复的情况。
Queue is full. Dropping telemetry.
Queue is full. Dropping telemetry.
Queue is full. Dropping telemetry.
Queue is full. Dropping telemetry.
Queue is full. Dropping telemetry.
Queue is full. Dropping telemetry.我可以重写应用程序来使用更短的查询,但这似乎是错误的答案。有没有办法将django配置为支持长URL?
发布于 2021-01-10 06:51:21
缓冲区不能更改,但您可以使用筛选器限制URL的大小。为了定制导出的跟踪,必须单独实例化它。
def shorten_url(envelope):
if 25 < len(envelope.data.baseData.url):
envelope.data.baseData["url"] = envelope.data.baseData.url[:25]+"..."
return True
from opencensus.ext.azure.trace_exporter import AzureExporter
exporter = AzureExporter(service_name='mysite')
exporter.add_telemetry_processor(shorten_url)
OPENCENSUS = {
'TRACE': {
'SAMPLER': 'opencensus.trace.samplers.ProbabilitySampler(rate=1)',
'EXPORTER': exporter
#Assumes Environmental Variable 'APPINSIGHTS_INSTRUMENTATIONKEY'
}
}完整的工作示例:https://github.com/Gamecock/Django-appinsights-example
https://stackoverflow.com/questions/65313480
复制相似问题