本文整理汇总了Python中applicationinsights.TelemetryClient方法的典型用法代码示例。如果您正苦于以下问题:Python applicationinsights.TelemetryClient方法的具体用法?Python applicationinsights.TelemetryClient怎么用?Python applicationinsights.TelemetryClient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类applicationinsights
的用法示例。
在下文中一共展示了applicationinsights.TelemetryClient方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_telemetry_client_with_processor
# 需要导入模块: import applicationinsights [as 别名]
# 或者: from applicationinsights import TelemetryClient [as 别名]
def get_telemetry_client_with_processor(
key: str, channel: TelemetryChannel, telemetry_processor: TelemetryProcessor = None
) -> TelemetryClient:
"""Gets a telemetry client instance with a telemetry processor.
:param key: instrumentation key
:type key: str
:param channel: Telemetry channel
:type channel: TelemetryChannel
:param telemetry_processor: use an existing telemetry processor from caller.
:type telemetry_processor: TelemetryProcessor
:return: a telemetry client with telemetry processor.
:rtype: TelemetryClient
"""
client = TelemetryClient(key, channel)
processor = (
telemetry_processor
if telemetry_processor is not None
else DjangoTelemetryProcessor()
)
client.add_telemetry_processor(processor)
return client
示例2: __init__
# 需要导入模块: import applicationinsights [as 别名]
# 或者: from applicationinsights import TelemetryClient [as 别名]
def __init__(self):
try:
self.telemetry = TelemetryClient(IKEY)
if os.path.exists("telemetry.config"):
config_file = open("telemetry.config", "r")
if config_file.read() == "1":
self.enable_telemetry = True
else:
self.enable_telemetry = False
else:
self.enable_telemetry = self._query_yes_no(PROMPT_TEXT)
config_file = open("telemetry.config", "w")
if self.enable_telemetry:
config_file.write("1")
self.telemetry.track_event("yes", {"device": DEVICE, "language": LANGUAGE})
else:
config_file.write("0")
self.telemetry.context.location.ip = "0.0.0.0"
self.telemetry.track_event("no", {"device": DEVICE, "language": LANGUAGE})
self.telemetry.flush()
except:
pass
示例3: _telemetry
# 需要导入模块: import applicationinsights [as 别名]
# 或者: from applicationinsights import TelemetryClient [as 别名]
def _telemetry(self) -> TelemetryClient:
"""Create the telemetry client."""
if not self.ikey:
sender = NullSender()
else:
sender = AsynchronousSender(self.endpoint)
ikey = self.ikey or '00000000-0000-0000-0000-000000000000'
queue = AsynchronousQueue(sender)
context = TelemetryContext()
context.instrumentation_key = ikey
channel = TelemetryChannel(context, queue)
return TelemetryClient(ikey, telemetry_channel=channel)
示例4: build_vortex_telemetry_client
# 需要导入模块: import applicationinsights [as 别名]
# 或者: from applicationinsights import TelemetryClient [as 别名]
def build_vortex_telemetry_client(service_endpoint_uri):
"""
Build vortex telemetry client.
"""
vortex_sender = VortexSynchronousSender(service_endpoint_uri)
sync_queue = SynchronousQueue(vortex_sender)
channel = VortexTelemetryChannel(None, queue=sync_queue)
client = TelemetryClient(INSTRUMENTATION_KEY, channel)
enable(INSTRUMENTATION_KEY)
return client