本文整理匯總了Python中apache_beam.metrics.execution.MetricsContainer.to_runner_api_monitoring_infos方法的典型用法代碼示例。如果您正苦於以下問題:Python MetricsContainer.to_runner_api_monitoring_infos方法的具體用法?Python MetricsContainer.to_runner_api_monitoring_infos怎麽用?Python MetricsContainer.to_runner_api_monitoring_infos使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類apache_beam.metrics.execution.MetricsContainer
的用法示例。
在下文中一共展示了MetricsContainer.to_runner_api_monitoring_infos方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Operation
# 需要導入模塊: from apache_beam.metrics.execution import MetricsContainer [as 別名]
# 或者: from apache_beam.metrics.execution.MetricsContainer import to_runner_api_monitoring_infos [as 別名]
#.........這裏部分代碼省略.........
# fix its name later, which we do.
# TODO(robertwb): Plumb the actual name here.
{'ONLY_OUTPUT': self.receivers[0].opcounter
.element_counter.value()}
if len(self.receivers) == 1
else None))),
user=self.metrics_container.to_runner_api())
def monitoring_infos(self, transform_id):
"""Returns the list of MonitoringInfos collected by this operation."""
all_monitoring_infos = self.execution_time_monitoring_infos(transform_id)
all_monitoring_infos.update(
self.element_count_monitoring_infos(transform_id))
all_monitoring_infos.update(self.user_monitoring_infos(transform_id))
return all_monitoring_infos
def element_count_monitoring_infos(self, transform_id):
"""Returns the element count MonitoringInfo collected by this operation."""
if len(self.receivers) == 1:
# If there is exactly one output, we can unambiguously
# fix its name later, which we do.
# TODO(robertwb): Plumb the actual name here.
mi = monitoring_infos.int64_counter(
monitoring_infos.ELEMENT_COUNT_URN,
self.receivers[0].opcounter.element_counter.value(),
ptransform=transform_id,
tag='ONLY_OUTPUT' if len(self.receivers) == 1 else str(None),
)
return {monitoring_infos.to_key(mi) : mi}
return {}
def user_monitoring_infos(self, transform_id):
"""Returns the user MonitoringInfos collected by this operation."""
return self.metrics_container.to_runner_api_monitoring_infos(transform_id)
def execution_time_monitoring_infos(self, transform_id):
total_time_spent_msecs = (
self.scoped_start_state.sampled_msecs_int()
+ self.scoped_process_state.sampled_msecs_int()
+ self.scoped_finish_state.sampled_msecs_int())
mis = [
monitoring_infos.int64_counter(
monitoring_infos.START_BUNDLE_MSECS_URN,
self.scoped_start_state.sampled_msecs_int(),
ptransform=transform_id
),
monitoring_infos.int64_counter(
monitoring_infos.PROCESS_BUNDLE_MSECS_URN,
self.scoped_process_state.sampled_msecs_int(),
ptransform=transform_id
),
monitoring_infos.int64_counter(
monitoring_infos.FINISH_BUNDLE_MSECS_URN,
self.scoped_finish_state.sampled_msecs_int(),
ptransform=transform_id
),
monitoring_infos.int64_counter(
monitoring_infos.TOTAL_MSECS_URN,
total_time_spent_msecs,
ptransform=transform_id
),
]
return {monitoring_infos.to_key(mi) : mi for mi in mis}
def __str__(self):
"""Generates a useful string for this object.