python123能监视电脑桌面_监视 Azure Monitor 的 Python 应用程序 - Azure Monitor | Microsoft Docs...

本文介绍了如何使用OpenCensus Python SDK将分布式跟踪、日志记录和指标收集数据发送到Azure Monitor。通过安装OpenCensus Azure Monitor导出程序并配置应用程序,您可以监视Python应用的性能和日志数据。文章提供了设置过程、先决条件、日志和异常的示例,以及如何查看和分析在Azure Monitor中收集的数据。
摘要由CSDN通过智能技术生成

您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

为 Python 应用程序设置 Azure MonitorSet up Azure Monitor for your Python application

09/24/2020

本文内容

通过与 OpenCensus 集成,Azure Monitor 支持对 Python 应用程序进行分布式跟踪、指标收集和日志记录。Azure Monitor supports distributed tracing, metric collection, and logging of Python applications through integration with OpenCensus. 本文将指导你完成为 Python 设置 OpenCensus 并将监视数据发送到 Azure Monitor 的过程。This article walks you through the process of setting up OpenCensus for Python and sending your monitoring data to Azure Monitor.

先决条件Prerequisites

Azure 订阅。An Azure subscription. 如果没有 Azure 订阅,请在开始之前创建一个免费帐户。If you don't have an Azure subscription, create a free account before you begin.

Python 安装。Python installation. 本文使用 Python 3.7.0,但其他版本可能会使用细微的更改。This article uses Python 3.7.0, although other versions will likely work with minor changes. SDK 仅支持 Python 版本2.7 和 v2.0 3.7。The SDK only supports Python v2.7 and v3.4-v3.7.

创建 Application Insights 资源。Create an Application Insights resource. 你将为你的资源分配自己的检测密钥 (ikey) 。You'll be assigned your own instrumentation key (ikey) for your resource.

检测适用于 Azure Monitor 的 OpenCensus Python SDKInstrument with OpenCensus Python SDK for Azure Monitor

安装 OpenCensus Azure Monitor 导出程序:Install the OpenCensus Azure Monitor exporters:

python -m pip install opencensus-ext-azure

备注

python -m pip install opencensus-ext-azure 命令假定你已为 Python 安装设置了 PATH 环境变量。The python -m pip install opencensus-ext-azure command assumes that you have a PATH environment variable set for your Python installation. 如果尚未配置此变量,则需要提供 Python 可执行文件所在位置的完整目录路径。If you haven't configured this variable, you need to give the full directory path to where your Python executable is located. 结果为如下所示的命令:C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\python.exe -m pip install opencensus-ext-azure。The result is a command like this: C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\python.exe -m pip install opencensus-ext-azure.

SDK 使用三个 Azure Monitor 导出程序将不同类型的遥测发送到 Azure Monitor。The SDK uses three Azure Monitor exporters to send different types of telemetry to Azure Monitor. 它们是跟踪、指标和日志。They're trace, metrics, and logs. 有关这些遥测类型的详细信息,请参阅数据平台概述。For more information on these telemetry types, see the data platform overview. 按照以下说明通过三个导出程序发送这些遥测类型。Use the following instructions to send these telemetry types via the three exporters.

遥测类型映射Telemetry type mappings

OpenCensus 提供的导出程序映射到 Azure Monitor 中看到的遥测类型。Here are the exporters that OpenCensus provides mapped to the types of telemetry that you see in Azure Monitor.

可观察性的支柱Pillar of observability

Azure Monitor 中的遥测类型Telemetry type in Azure Monitor

说明Explanation

日志Logs

跟踪,异常,customEventsTraces, exceptions, customEvents

日志遥测,异常遥测,事件遥测Log telemetry, exception telemetry, event telemetry

指标Metrics

customMetrics、performanceCounterscustomMetrics, performanceCounters

自定义指标性能计数器Custom metrics performance counters

跟踪Tracing

请求依赖项Requests dependencies

传入请求,传出请求Incoming requests, outgoing requests

日志Logs

首先,让我们生成一些本地日志数据。First, let's generate some local log data.

import logging

logger = logging.getLogger(__name__)

def valuePrompt():

line = input("Enter a value: ")

logger.warning(line)

def main():

while True:

valuePrompt()

if __name__ == "__main__":

main()

代码持续要求输入值。The code continuously asks for a value to be entered. 对于输入的每个值,将发出一个日志条目。A log entry is emitted for every entered value.

Enter a value: 24

24

Enter a value: 55

55

Enter a value: 123

123

Enter a value: 90

90

尽管输入值有助于演示,但最终我们希望向 Azure Monitor 发出日志数据。Although entering values is helpful for demonstration purposes, ultimately we want to emit the log data to Azure Monitor. 将连接字符串直接传递到导出程序。Pass your connection string directly into the exporter. 或者,可以在环境变量中指定它 APPLICATIONINSIGHTS_CONNECTION_STRING 。Or, you can specify it in an environment variable, APPLICATIONINSIGHTS_CONNECTION_STRING. 根据以下代码示例,修改上一步中的代码:Modify your code from the previous step based on the following code sample:

import logging

from opencensus.ext.azure.log_exporter import AzureLogHandler

logger = logging.getLogger(__name__)

# TODO: replace the all-zero GUID with your instrumentation key.

logger.addHandler(AzureLogHandler(

connection_string='InstrumentationKey=00000000-0000-0000-0000-000000000000')

)

def valuePrompt():

line = input("Enter a value: ")

logger.warning(line)

def main():

while True:

valuePrompt()

if __name__ == "__main__":

main()

导出程序会将日志数据发送到 Azure Monitor。The exporter sends log data to Azure Monitor. 可在 traces 下找到数据。You can find the data under traces.

备注

在此上下文中, traces 与不同 tracing 。In this context, traces isn't the same as tracing. 此处, traces 是指在使用时将在 Azure Monitor 中看到的遥测类型 AzureLogHandler 。Here, traces refers to the type of telemetry that you'll see in Azure Monitor when you utilize AzureLogHandler. 但 tracing 涉及到 OpenCensus 中的概念,并与 分布式跟踪相关。But tracing refers to a concept in OpenCensus and relates to distributed tracing.

备注

根记录器配置了警告级别。The root logger is configured with the level of WARNING. 这意味着,将忽略发送的严重性较低的任何日志,而不会将其发送到 Azure Monitor。That means any logs that you send that have less of a severity are ignored, and in turn, won't be sent to Azure Monitor. 有关详细信息,请参阅这篇文档。For more information, see documentation.

还可以通过使用 "custom_dimensions" 字段,将自定义属性添加到 额外 关键字参数中的日志消息。You can also add custom properties to your log messages in the extra keyword argument by using the custom_dimensions field. 这些属性在 Azure Monitor 中显示为中的键值对 customDimensions 。These properties appear as key-value pairs in customDimensions in Azure Monitor.

备注

若要使此功能正常运行,需要将字典传递给 custom_dimensions 字段。For this feature to work, you need to pass a dictionary to the custom_dimensions field. 如果传递任何其他类型的参数,记录器会将其忽略。If you pass arguments of any other type, the logger ignores them.

import logging

from opencensus.ext.azure.log_exporter import AzureLogHandler

logger = logging.getLogger(__name__)

# TODO: replace the all-zero GUID with your instrumentation key.

logger.addHandler(AzureLogHandler(

connection_string='InstrumentationKey=00000000-0000-0000-0000-000000000000')

)

properties = {'custom_dimensions': {'key_1': 'value_1', 'key_2': 'value_2'}}

# Use properties in logging statements

logger.warning('action', extra=properties)

为 Django 应用程序配置日志记录Configure logging for Django applications

可以按照上文所述在应用程序代码中为 Django 应用程序显式配置日志记录,也可以在 Django 的日志记录配置中指定日志记录。You can configure logging explicitly in your application code like above for your Django applications, or you can specify it in Django's logging configuration. 此代码可以包含在用于 Django 设置配置的任何文件中。This code can go into whatever file you use for Django settings configuration. 有关如何配置 Django 设置的详细说明,请参阅 Django 设置。For how to configure Django settings, see Django settings. 有关配置日志记录的详细信息,请参阅 Django 日志记录。For more information on configuring logging, see Django logging.

LOGGING = {

"handlers": {

"azure": {

"level": "DEBUG",

"class": "opencensus.ext.azure.log_exporter.AzureLogHandler",

"instrumentation_key": "",

},

"console": {

"level": "DEBUG",

"class": "logging.StreamHandler",

"stream": sys.stdout,

},

},

"loggers": {

"logger_name": {"handlers": ["azure", "console"]},

},

}

请确保使用的记录器的名称与配置中指定的相同。Be sure you use the logger with the same name as the one specified in your configuration.

import logging

logger = logging.getLogger("logger_name")

logger.warning("this will be tracked")

发送异常Send exceptions

OpenCensus Python 不会自动跟踪和发送 exception 遥测数据。OpenCensus Python doesn't automatically track and send exception telemetry. 通过 AzureLogHandler Python 日志记录库通过使用异常来发送。They're sent through AzureLogHandler by using exceptions through the Python logging library. 可以像使用普通日志记录时一样添加自定义属性。You can add custom properties just like with normal logging.

import logging

from opencensus.ext.azure.log_exporter import AzureLogHandler

logger = logging.getLogger(__name__)

# TODO: replace the all-zero GUID with your instrumentation key.

logger.addHandler(AzureLogHandler(

connection_string='InstrumentationKey=00000000-0000-0000-0000-000000000000')

)

properties = {'custom_dimensions': {'key_1': 'value_1', 'key_2': 'value_2'}}

# Use properties in exception logs

try:

result = 1 / 0 # generate a ZeroDivisionError

except Exception:

logger.exception('Captured an exception.', extra=properties)

因为你必须显式记录异常,所以用户需要如何记录未经处理的异常。Because you must log exceptions explicitly, it's up to the user how they want to log unhandled exceptions. OpenCensus 不会对用户希望执行此操作的方式施加限制,只要它们显式记录异常遥测。OpenCensus doesn't place restrictions on how a user wants to do this, as long as they explicitly log an exception telemetry.

发送事件Send events

可以采用与 customEvent 发送遥测数据完全相同的方式发送遥测数据, trace AzureEventHandler 而不是使用。You can send customEvent telemetry in exactly the same way that you send trace telemetry except by using AzureEventHandler instead.

import logging

from opencensus.ext.azure.log_exporter import AzureEventHandler

logger = logging.getLogger(__name__)

logger.addHandler(AzureEventHandler(connection_string='InstrumentationKey='))

logger.setLevel(logging.INFO)

logger.info('Hello, World!')

采样Sampling

有关在 OpenCensus 中采样的信息,请查看 OpenCensus 中的采样。For information on sampling in OpenCensus, take a look at sampling in OpenCensus.

日志关联Log correlation

有关如何使用跟踪上下文数据扩充日志的详细信息,请参阅 OpenCensus Python 日志集成。For details on how to enrich your logs with trace context data, see OpenCensus Python logs integration.

修改遥测Modify telemetry

有关如何在将跟踪的遥测发送到 Azure Monitor 之前修改它们的详细信息,请参阅 OpenCensus Python 遥测处理器。For details on how to modify tracked telemetry before it's sent to Azure Monitor, see OpenCensus Python telemetry processors.

指标Metrics

首先,让我们生成一些本地指标数据。First, let's generate some local metric data. 我们将创建一个简单的度量值,用于跟踪用户选择 Enter 键的次数。We'll create a simple metric to track the number of times the user selects the Enter key.

from datetime import datetime

from opencensus.stats import aggregation as aggregation_module

from opencensus.stats import measure as measure_module

from opencensus.stats import stats as stats_module

from opencensus.stats import view as view_module

from opencensus.tags import tag_map as tag_map_module

stats = stats_module.stats

view_manager = stats.view_manager

stats_recorder = stats.stats_recorder

prompt_measure = measure_module.MeasureInt("prompts",

"number of prompts",

"prompts")

prompt_view = view_module.View("prompt view",

"number of prompts",

[],

prompt_measure,

aggregation_module.CountAggregation())

view_manager.register_view(prompt_view)

mmap = stats_recorder.new_measurement_map()

tmap = tag_map_module.TagMap()

def prompt():

input("Press enter.")

mmap.measure_int_put(prompt_measure, 1)

mmap.record(tmap)

metrics = list(mmap.measure_to_view_map.get_metrics(datetime.utcnow()))

print(metrics[0].time_series[0].points[0])

def main():

while True:

prompt()

if __name__ == "__main__":

main()

重复运行代码会提示你选择 Enter。Running the code repeatedly prompts you to select Enter. 将创建一个度量值,以跟踪选择 输入 的次数。A metric is created to track the number of times Enter is selected. 对于每个条目,该值会递增,指标信息将显示在控制台中。With each entry, the value is incremented and the metric information appears in the console. 该信息包括指标更新时的当前值和当前时间戳。The information includes the current value and the current time stamp when the metric was updated.

Press enter.

Point(value=ValueLong(5), timestamp=2019-10-09 20:58:04.930426)

Press enter.

Point(value=ValueLong(6), timestamp=2019-10-09 20:58:06.570167)

Press enter.

Point(value=ValueLong(7), timestamp=2019-10-09 20:58:07.138614)

尽管输入值有助于演示,但最终我们希望向 Azure Monitor 发出指标数据。Although entering values is helpful for demonstration purposes, ultimately we want to emit the metric data to Azure Monitor. 将连接字符串直接传递到导出程序。Pass your connection string directly into the exporter. 或者,可以在环境变量中指定它 APPLICATIONINSIGHTS_CONNECTION_STRING 。Or, you can specify it in an environment variable, APPLICATIONINSIGHTS_CONNECTION_STRING. 根据以下代码示例,修改上一步中的代码:Modify your code from the previous step based on the following code sample:

from datetime import datetime

from opencensus.ext.azure import metrics_exporter

from opencensus.stats import aggregation as aggregation_module

from opencensus.stats import measure as measure_module

from opencensus.stats import stats as stats_module

from opencensus.stats import view as view_module

from opencensus.tags import tag_map as tag_map_module

stats = stats_module.stats

view_manager = stats.view_manager

stats_recorder = stats.stats_recorder

prompt_measure = measure_module.MeasureInt("prompts",

"number of prompts",

"prompts")

prompt_view = view_module.View("prompt view",

"number of prompts",

[],

prompt_measure,

aggregation_module.CountAggregation())

view_manager.register_view(prompt_view)

mmap = stats_recorder.new_measurement_map()

tmap = tag_map_module.TagMap()

# TODO: replace the all-zero GUID with your instrumentation key.

exporter = metrics_exporter.new_metrics_exporter(

connection_string='InstrumentationKey=00000000-0000-0000-0000-000000000000')

view_manager.register_exporter(exporter)

def prompt():

input("Press enter.")

mmap.measure_int_put(prompt_measure, 1)

mmap.record(tmap)

metrics = list(mmap.measure_to_view_map.get_metrics(datetime.utcnow()))

print(metrics[0].time_series[0].points[0])

def main():

while True:

prompt()

if __name__ == "__main__":

main()

导出程序会按固定的时间间隔将指标数据发送到 Azure Monitor。The exporter sends metric data to Azure Monitor at a fixed interval. 默认值为每 15 秒。The default is every 15 seconds. 我们正在跟踪单个度量值,因此,每个间隔将发送此指标数据,其中包含其包含的任何值和时间戳。We're tracking a single metric, so this metric data, with whatever value and time stamp it contains, is sent every interval. 可在 customMetrics 下找到数据。You can find the data under customMetrics.

性能计数器Performance counters

默认情况下,度量值导出程序会将一组性能计数器发送到 Azure Monitor。By default, the metrics exporter sends a set of performance counters to Azure Monitor. 可以通过在指标导出程序的构造函数中将 enable_standard_metrics 标志设为 False 来禁用此功能。You can disable this by setting the enable_standard_metrics flag to False in the constructor of the metrics exporter.

...

exporter = metrics_exporter.new_metrics_exporter(

enable_standard_metrics=False,

connection_string='InstrumentationKey=')

...

当前已发送这些性能计数器:These performance counters are currently sent:

可用内存(字节)Available Memory (bytes)

CPU 处理器时间(百分比)CPU Processor Time (percentage)

传入请求速率(每秒)Incoming Request Rate (per second)

传入请求平均执行时间(毫秒)Incoming Request Average Execution Time (milliseconds)

进程 CPU 使用率(百分比)Process CPU Usage (percentage)

进程专用字节数(字节)Process Private Bytes (bytes)

你应该能够在 performanceCounters 中看到这些指标。You should be able to see these metrics in performanceCounters. 有关详细信息,请参阅性能计时器。For more information, see performance counters.

修改遥测Modify telemetry

有关如何在将跟踪的遥测发送到 Azure Monitor 之前修改它们的信息,请参阅 OpenCensus Python 遥测处理器。For information on how to modify tracked telemetry before it's sent to Azure Monitor, see OpenCensus Python telemetry processors.

跟踪Tracing

备注

在 OpenCensus 中, tracing 是指 分布式跟踪。In OpenCensus, tracing refers to distributed tracing. AzureExporter 将 requests 和 dependency 遥测发送到 Azure Monitor。The AzureExporter sends requests and dependency telemetry to Azure Monitor.

首先,让我们在本地生成一些跟踪数据。First, let's generate some trace data locally. 在 Python IDLE 或所选编辑器中,输入以下代码:In Python IDLE, or your editor of choice, enter the following code:

from opencensus.trace.samplers import ProbabilitySampler

from opencensus.trace.tracer import Tracer

tracer = Tracer(sampler=ProbabilitySampler(1.0))

def valuePrompt():

with tracer.span(name="test") as span:

line = input("Enter a value: ")

print(line)

def main():

while True:

valuePrompt()

if __name__ == "__main__":

main()

重复运行代码会提示输入值。Running the code repeatedly prompts you to enter a value. 对于每个条目,将值输出到 shell。With each entry, the value is printed to the shell. OpenCensus Python 模块将生成相应的部分 SpanData 。The OpenCensus Python Module generates a corresponding piece of SpanData. OpenCensus 项目将跟踪定义为 span 树。The OpenCensus project defines a trace as a tree of spans.

Enter a value: 4

4

[SpanData(name='test', context=SpanContext(trace_id=8aa41bc469f1a705aed1bdb20c342603, span_id=None, trace_options=TraceOptions(enabled=True), tracestate=None), span_id='15ac5123ac1f6847', parent_span_id=None, attributes=BoundedDict({}, maxlen=32), start_time='2019-06-27T18:21:22.805429Z', end_time='2019-06-27T18:21:44.933405Z', child_span_count=0, stack_trace=None, annotations=BoundedList([], maxlen=32), message_events=BoundedList([], maxlen=128), links=BoundedList([], maxlen=32), status=None, same_process_as_parent_span=None, span_kind=0)]

Enter a value: 25

25

[SpanData(name='test', context=SpanContext(trace_id=8aa41bc469f1a705aed1bdb20c342603, span_id=None, trace_options=TraceOptions(enabled=True), tracestate=None), span_id='2e512f846ba342de', parent_span_id=None, attributes=BoundedDict({}, maxlen=32), start_time='2019-06-27T18:21:44.933405Z', end_time='2019-06-27T18:21:46.156787Z', child_span_count=0, stack_trace=None, annotations=BoundedList([], maxlen=32), message_events=BoundedList([], maxlen=128), links=BoundedList([], maxlen=32), status=None, same_process_as_parent_span=None, span_kind=0)]

Enter a value: 100

100

[SpanData(name='test', context=SpanContext(trace_id=8aa41bc469f1a705aed1bdb20c342603, span_id=None, trace_options=TraceOptions(enabled=True), tracestate=None), span_id='f3f9f9ee6db4740a', parent_span_id=None, attributes=BoundedDict({}, maxlen=32), start_time='2019-06-27T18:21:46.157732Z', end_time='2019-06-27T18:21:47.269583Z', child_span_count=0, stack_trace=None, annotations=BoundedList([], maxlen=32), message_events=BoundedList([], maxlen=128), links=BoundedList([], maxlen=32), status=None, same_process_as_parent_span=None, span_kind=0)]

尽管输入值有助于演示,但最终我们想要 SpanData Azure Monitor。Although entering values is helpful for demonstration purposes, ultimately we want to emit SpanData to Azure Monitor. 将连接字符串直接传递到导出程序。Pass your connection string directly into the exporter. 或者,可以在环境变量中指定它 APPLICATIONINSIGHTS_CONNECTION_STRING 。Or, you can specify it in an environment variable, APPLICATIONINSIGHTS_CONNECTION_STRING. 根据以下代码示例,修改上一步中的代码:Modify your code from the previous step based on the following code sample:

from opencensus.ext.azure.trace_exporter import AzureExporter

from opencensus.trace.samplers import ProbabilitySampler

from opencensus.trace.tracer import Tracer

# TODO: replace the all-zero GUID with your instrumentation key.

tracer = Tracer(

exporter=AzureExporter(

connection_string='InstrumentationKey=00000000-0000-0000-0000-000000000000'),

sampler=ProbabilitySampler(1.0),

)

def valuePrompt():

with tracer.span(name="test") as span:

line = input("Enter a value: ")

print(line)

def main():

while True:

valuePrompt()

if __name__ == "__main__":

main()

现在,当你运行 Python 脚本时,系统仍会提示你输入值,但只有该值输出到 shell 中。Now when you run the Python script, you should still be prompted to enter values, but only the value is being printed in the shell. 创建的 SpanData 将发送到 Azure Monitor。The created SpanData is sent to Azure Monitor. 可在 dependencies 下找到发出的 span 数据。You can find the emitted span data under dependencies. 有关传出请求的详细信息,请参阅 OpenCensus Python 依赖项。For more information about outgoing requests, see OpenCensus Python dependencies.

有关传入请求的详细信息,请参阅 OpenCensus Python 请求。For more information on incoming requests, see OpenCensus Python requests.

采样Sampling

有关在 OpenCensus 中采样的信息,请查看 OpenCensus 中的采样。For information on sampling in OpenCensus, take a look at sampling in OpenCensus.

跟踪关联Trace correlation

有关跟踪数据中遥测关联的详细信息,请参阅 OpenCensus Python 遥测关联。For more information on telemetry correlation in your trace data, take a look at OpenCensus Python telemetry correlation.

修改遥测Modify telemetry

有关如何在将跟踪的遥测发送到 Azure Monitor 之前修改它们的详细信息,请参阅 OpenCensus Python 遥测处理器。For more information on how to modify tracked telemetry before it's sent to Azure Monitor, see OpenCensus Python telemetry processors.

配置 Azure Monitor 导出程序Configure Azure Monitor exporters

如图所示,有三种不同的 Azure Monitor 导出程序支持 OpenCensus。As shown, there are three different Azure Monitor exporters that support OpenCensus. 每种类型都将不同类型的遥测发送到 Azure Monitor。Each one sends different types of telemetry to Azure Monitor. 若要查看每个导出程序发送的遥测类型,请参阅下表。To see what types of telemetry each exporter sends, see the following list.

每个导出程序都接受通过构造函数传递的相同配置参数。Each exporter accepts the same arguments for configuration, passed through the constructors. 可在此处查看每个相关的详细信息:You can see details about each one here:

connection_string:用于连接到 Azure Monitor 资源的连接字符串。connection_string: The connection string used to connect to your Azure Monitor resource. 其优先级高于 instrumentation_key。Takes priority over instrumentation_key.

enable_standard_metrics:用于 AzureMetricsExporter 。enable_standard_metrics: Used for AzureMetricsExporter. 指示导出程序将性能计数器指标自动发送到 Azure Monitor。Signals the exporter to send performance counter metrics automatically to Azure Monitor. 默认为 True。Defaults to True.

export_interval:用于指定导出频率(以秒为单位)。export_interval: Used to specify the frequency in seconds of exporting.

instrumentation_key:用于连接到 Azure Monitor 资源的检测密钥。instrumentation_key: The instrumentation key used to connect to your Azure Monitor resource.

logging_sampling_rate:用于 AzureLogHandler 。logging_sampling_rate: Used for AzureLogHandler. 为导出日志提供采样率 [0,1.0]。Provides a sampling rate [0,1.0] for exporting logs. 默认值为 1.0。Defaults to 1.0.

max_batch_size:指定一次导出的最大遥测大小。max_batch_size: Specifies the maximum size of telemetry that's exported at once.

proxies:指定用于将数据发送到 Azure Monitor 的代理的序列。proxies: Specifies a sequence of proxies to use for sending data to Azure Monitor. 有关详细信息,请参阅 代理。For more information, see proxies.

storage_path:本地存储文件夹所在位置的路径 (未发送的遥测) 。storage_path: A path to where the local storage folder exists (unsent telemetry). opencensus-ext-azure从 v 1.0.3,默认路径是 OS temp 目录 + opencensus-python + your-ikey 。As of opencensus-ext-azure v1.0.3, the default path is the OS temp directory + opencensus-python + your-ikey. 在 v 1.0.3 之前,默认路径为 $USER + .opencensus + .azure + python-file-name 。Prior to v1.0.3, the default path is $USER + .opencensus + .azure + python-file-name.

使用查询查看数据View your data with queries

可以通过“日志(分析)”选项卡查看从应用程序发送的遥测数据。You can view the telemetry data that was sent from your application through the Logs (Analytics) tab.

在“活动”下的列表中:In the list under Active:

对于使用 Azure Monitor 跟踪导出程序发送的遥测,传入请求在 requests 下显示。For telemetry sent with the Azure Monitor trace exporter, incoming requests appear under requests. 传出或进程内请求在 dependencies 下显示。Outgoing or in-process requests appear under dependencies.

对于使用 Azure Monitor 指标导出程序发送的遥测,发送的指标在 customMetrics 下显示。For telemetry sent with the Azure Monitor metrics exporter, sent metrics appear under customMetrics.

对于使用 Azure Monitor 日志导出程序发送的遥测,日志在 traces 下显示。For telemetry sent with the Azure Monitor logs exporter, logs appear under traces. 异常在 exceptions 下显示。Exceptions appear under exceptions.

有关如何使用查询和日志的更多详细信息,请参阅 Azure Monitor 中的日志。For more detailed information about how to use queries and logs, see Logs in Azure Monitor.

了解有关 OpenCensus for Python 的详细信息Learn more about OpenCensus for Python

后续步骤Next steps

警报Alerts

可用性测试:创建测试来确保站点在 Web 上可见。Availability tests: Create tests to make sure your site is visible on the web.

智能诊断:这些测试可自动运行,因此不需要进行任何设置。Smart diagnostics: These tests run automatically, so you don't have to do anything to set them up. 它们会告诉你应用是否具有异常的失败请求速率。They tell you if your app has an unusual rate of failed requests.

指标警报:设置警报以在某个指标超过阈值时发出警告。Metric alerts: Set alerts to warn you if a metric crosses a threshold. 可以在编码到应用中的自定义指标中设置它们。You can set them on custom metrics that you code into your app.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
本考试系统由前台考生考试部分和后台系统管理部分组成。 一、前台部分 1、 选择课程: (1)、考试部分 考试权限模式有两种:   1、课程管理员后台设定:由课程管理员在考生考试之前预先设定好每个的试卷 。   2、考生自己选择:考生在第一次登陆考试平台的时候,自己选择要参加的课程和试卷。 考试权限模式由最高管理员在后台设置。 考生要参加考试,必须满足几个前提: a.考生所在的有权限参加该试卷的考试。 b.该试卷呈“打开”状态。 c.该试卷所在课程呈“打开”状态。 d.该试卷所涉及的章节呈“打开”状态。 e.正好在试卷规定的时间内参加考试。 考生在考试过程中,应注意保存答案。试卷内每一种题型的后面都有一个保存按钮,只要考生做完此类型试题,应点击保存按钮。 试卷用倒计时方式扣减时间,如果考生在考试过程中不小心关闭窗口,可以重新进入考试系统,继续刚才的考试,以前保存的答案仍旧存在。 操作题一般来说用于信息化的考试,比如制作Word文档、Excel表格、网页制作等,考生在做完这些文件后上传到服务器上,等待管理员批改。具体上传参数,由最高管理员在后台设定。 在考试结束前一分钟和最后10秒种,系统会提示 考生保存答案,并提交试卷。    考试的次数由管理员或课程管理员设定。考生可以反复参加考试 (2)、竞赛部分 竞赛试卷可以由管理员出题,也可以由考生自由出题。考生在“练习部分”出“模拟试卷”的时候,可以把试卷类型设置为“竞赛”,让其他考生参加这份“模拟试卷”,进行竞赛。 (2)、练习部分 练习分两种:“分项练习”和“模拟试卷” “分项练习”:主要是针对各个章节,不同的题型进行练习。考生要参加练习,管理员或课程管理员必须首先在后台的“课程管理”——“练习管理”中设置好要练习章节的时间、状态。 练习时,以章为单位,按题型类别反复练习。只有在点击“本章已经练习完”之后,考生才可以在“查询成绩”中看到此章练习的标准答案和自己的答案。如果想再练习一次,请点击“重新练习”。       “模拟试卷”:考生可以按自己的想法出试卷,先设置试卷的属性,再设置各种题型的题量与分值,最后生成试卷。考生练习完即可查看成绩。 2、 成绩查询: (1)、考试部分 考生进入已经考过的试卷,可以了解每一种题型的得分情况。而且还可以深入了解到自己的答案与标准答案之间的差距。 因为试卷中的主观题需要课程管理员批改,可能需要一段时间才能查询到成绩。但如果试卷是由客观题型组成的,管理员或课程管理员就可以在后台的“试卷管理”——“查询方式”中,选择“考完查询”。这样,考生就可以在考试结束后立即看到自己的成绩了。 考生可以浏览整张试卷,并打印已经考过的试卷。 (3)、竞赛部分 和考试部分一样。 (2)、练习部分 “分项练习”只有在点击“本章已经练习完”之后,考生才可以在“查询成绩”中看到此章练习的标准答案和自己的答案。 3、 考试新闻  考生可以了解考试的相关信息,还可以看到公布的成绩。 二、后台管理部分 (一)、课程管理 1、课程管理: 课程分“专业课”、“公共课”和“基础课”。出试卷时,范围可以跨“公共课”。当本课程中如果有试卷呈“打开”状态时,请将此课程“打开”。 2、练习管理(章节管理): 用于设定练习的时间和状态,使用时必须为“打开”状态。如果想把题目录入到相应的章节,请在此添加章节序号。添加章节时必须输入数字,以防出错。“现有题量”显示了本章节所储存的“考试题”和“练习题”的总量。 3、试卷管理: 试卷类型分两类,随机试卷和人工出卷。随机试卷必须在“题型管理”中添加“题量”和“分值”。而人工出题的试卷在添加过程中需要从题库中选择试题,使试题呈“选中”状态,且在“题型管理”中只需填写“分值”即可,系统会自动计算“题量”。 使用试卷时,务必把试卷“打开”。  “题型管理”中的“分值”,除阅读理解外,都是指每道题目的分值。因为阅读理解是以大题为单位选题或是抽题,而每个大题都有不确定个小题,所以大题的总分值无法统计,只能输入小题的“分值”。注意:一旦修改试卷的“题量”和“分值”,将会清空已经考过此试卷的考生数据。 课程管理员最好在考试之前设定好试卷的“题量”和“分值”。 答案的保存方式有两种:整体保存和分部保存。整体保存是考试过程中一次性保存所有题型的试题答案。分部保存是仅
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值