本文整理匯總了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