apache_beam.metrics.monitoring_infos module

apache_beam.metrics.monitoring_infos.to_timestamp_proto(timestamp_secs)[source]

Converts seconds since epoch to a google.protobuf.Timestamp.

Parameters:timestamp_secs – The timestamp in seconds since epoch.
apache_beam.metrics.monitoring_infos.to_timestamp_secs(timestamp_proto)[source]

Converts a google.protobuf.Timestamp to seconds since epoch.

Parameters:timestamp_proto – The google.protobuf.Timestamp.
apache_beam.metrics.monitoring_infos.extract_counter_value(monitoring_info_proto)[source]

Returns the int coutner value of the monitoring info.

apache_beam.metrics.monitoring_infos.extract_distribution(monitoring_info_proto)[source]

Returns the relevant DistributionInt64 or DistributionDouble.

Parameters:monitoring_info_proto – The monitoring infor for the distribution.
apache_beam.metrics.monitoring_infos.create_labels(ptransform='', tag='')[source]

Create the label dictionary based on the provided tags.

Parameters:
  • ptransform – The ptransform/step name.
  • tag – he output tag name, used as a label.
apache_beam.metrics.monitoring_infos.int64_counter(urn, metric, ptransform='', tag='')[source]

Return the counter monitoring info for the specifed URN, metric and labels.

Parameters:
  • urn – The URN of the monitoring info/metric.
  • metric – The metric proto field to use in the monitoring info. Or an int value.
  • ptransform – The ptransform/step name used as a label.
  • tag – The output tag name, used as a label.
apache_beam.metrics.monitoring_infos.int64_distribution(urn, metric, ptransform='', tag='')[source]

Return the distribution monitoring info for the URN, metric and labels.

Parameters:
  • urn – The URN of the monitoring info/metric.
  • metric – The metric proto field to use in the monitoring info. Or an int value.
  • ptransform – The ptransform/step name used as a label.
  • tag – The output tag name, used as a label.
apache_beam.metrics.monitoring_infos.int64_gauge(urn, metric, ptransform='', tag='')[source]

Return the gauge monitoring info for the URN, metric and labels.

Parameters:
  • urn – The URN of the monitoring info/metric.
  • metric – The metric proto field to use in the monitoring info. Or an int value.
  • ptransform – The ptransform/step name used as a label.
  • tag – The output tag name, used as a label.
apache_beam.metrics.monitoring_infos.create_monitoring_info(urn, type_urn, metric_proto, labels=None)[source]

Return the gauge monitoring info for the URN, type, metric and labels.

Parameters:
  • urn – The URN of the monitoring info/metric.
  • type_urn – The URN of the type of the monitoring info/metric. i.e. beam:metrics:sum_int_64, beam:metrics:latest_int_64.
  • metric_proto – The metric proto field to use in the monitoring info. Or an int value.
  • labels – The label dictionary to use in the MonitoringInfo.
apache_beam.metrics.monitoring_infos.user_metric_urn(namespace, name)[source]

Returns the metric URN for a user metric, with a proper URN prefix.

Parameters:
  • namespace – The namespace of the metric.
  • name – The name of the metric.
apache_beam.metrics.monitoring_infos.is_counter(monitoring_info_proto)[source]

Returns true if the monitoring info is a coutner metric.

apache_beam.metrics.monitoring_infos.is_distribution(monitoring_info_proto)[source]

Returns true if the monitoring info is a distrbution metric.

apache_beam.metrics.monitoring_infos.is_gauge(monitoring_info_proto)[source]

Returns true if the monitoring info is a gauge metric.

apache_beam.metrics.monitoring_infos.is_user_monitoring_info(monitoring_info_proto)[source]

Returns true if the monitoring info is a user metric.

apache_beam.metrics.monitoring_infos.extract_metric_result_map_value(monitoring_info_proto)[source]

Returns the relevant GaugeResult, DistributionResult or int value.

These are the proper format for use in the MetricResult.query() result.

apache_beam.metrics.monitoring_infos.parse_namespace_and_name(monitoring_info_proto)[source]

Returns the (namespace, name) tuple of the URN in the monitoring info.

apache_beam.metrics.monitoring_infos.to_key(monitoring_info_proto)[source]

Returns a key based on the URN and labels.

This is useful in maps to prevent reporting the same MonitoringInfo twice.