|
50 | 50 | common_urns.monitoring_info_specs.USER_DISTRIBUTION_INT64.spec.urn) |
51 | 51 | USER_GAUGE_URN = common_urns.monitoring_info_specs.USER_LATEST_INT64.spec.urn |
52 | 52 | USER_STRING_SET_URN = common_urns.monitoring_info_specs.USER_SET_STRING.spec.urn |
| 53 | +USER_BOUNDED_TRIE_URN = ( |
| 54 | + common_urns.monitoring_info_specs.USER_BOUNDED_TRIE.spec.urn) |
53 | 55 | USER_METRIC_URNS = set([ |
54 | 56 | USER_COUNTER_URN, |
55 | 57 | USER_DISTRIBUTION_URN, |
56 | 58 | USER_GAUGE_URN, |
57 | | - USER_STRING_SET_URN |
| 59 | + USER_STRING_SET_URN, |
| 60 | + USER_BOUNDED_TRIE_URN, |
58 | 61 | ]) |
59 | 62 | WORK_REMAINING_URN = common_urns.monitoring_info_specs.WORK_REMAINING.spec.urn |
60 | 63 | WORK_COMPLETED_URN = common_urns.monitoring_info_specs.WORK_COMPLETED.spec.urn |
|
72 | 75 | LATEST_INT64_TYPE = common_urns.monitoring_info_types.LATEST_INT64_TYPE.urn |
73 | 76 | PROGRESS_TYPE = common_urns.monitoring_info_types.PROGRESS_TYPE.urn |
74 | 77 | STRING_SET_TYPE = common_urns.monitoring_info_types.SET_STRING_TYPE.urn |
| 78 | +BOUNDED_TRIE_TYPE = common_urns.monitoring_info_types.BOUNDED_TRIE_TYPE.urn |
75 | 79 |
|
76 | 80 | COUNTER_TYPES = set([SUM_INT64_TYPE]) |
77 | 81 | DISTRIBUTION_TYPES = set([DISTRIBUTION_INT64_TYPE]) |
78 | 82 | GAUGE_TYPES = set([LATEST_INT64_TYPE]) |
79 | 83 | STRING_SET_TYPES = set([STRING_SET_TYPE]) |
| 84 | +BOUNDED_TRIE_TYPES = set([BOUNDED_TRIE_TYPE]) |
80 | 85 |
|
81 | 86 | # TODO(migryz) extract values from beam_fn_api.proto::MonitoringInfoLabels |
82 | 87 | PCOLLECTION_LABEL = ( |
@@ -320,6 +325,23 @@ def user_set_string(namespace, name, metric, ptransform=None): |
320 | 325 | USER_STRING_SET_URN, STRING_SET_TYPE, metric, labels) |
321 | 326 |
|
322 | 327 |
|
| 328 | +def user_bounded_trie(namespace, name, metric, ptransform=None): |
| 329 | + """Return the string set monitoring info for the URN, metric and labels. |
| 330 | +
|
| 331 | + Args: |
| 332 | + namespace: User-defined namespace of BoundedTrie. |
| 333 | + name: Name of BoundedTrie. |
| 334 | + metric: The BoundedTrieData representing the metrics. |
| 335 | + ptransform: The ptransform id used as a label. |
| 336 | + """ |
| 337 | + labels = create_labels(ptransform=ptransform, namespace=namespace, name=name) |
| 338 | + return create_monitoring_info( |
| 339 | + USER_BOUNDED_TRIE_URN, |
| 340 | + BOUNDED_TRIE_TYPE, |
| 341 | + metric.to_proto().SerializeToString(), |
| 342 | + labels) |
| 343 | + |
| 344 | + |
323 | 345 | def create_monitoring_info( |
324 | 346 | urn, type_urn, payload, labels=None) -> metrics_pb2.MonitoringInfo: |
325 | 347 | """Return the gauge monitoring info for the URN, type, metric and labels. |
|
0 commit comments