You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2021/09/21 20:44:52 UTC
[GitHub] [beam] ajamato commented on a change in pull request #15294: [BEAM-11986] Spanner write metric
ajamato commented on a change in pull request #15294:
URL: https://github.com/apache/beam/pull/15294#discussion_r713402051
##########
File path: sdks/python/apache_beam/io/gcp/experimental/spannerio.py
##########
@@ -320,6 +330,42 @@ def __init__(self, spanner_configuration):
self._spanner_configuration = spanner_configuration
self._snapshot = None
self._session = None
+ self.base_labels = {
+ monitoring_infos.SERVICE_LABEL: 'Spanner',
+ monitoring_infos.METHOD_LABEL: 'Read',
+ monitoring_infos.SPANNER_PROJECT_ID: self._spanner_configuration.
+ project,
+ monitoring_infos.SPANNER_DATABASE_ID: self._spanner_configuration.
+ database,
+ }
+
+ def _table_metric(self, table_id, status):
+ database_id = self._spanner_configuration.database
+ project_id = self._spanner_configuration.project
+ resource = resource_identifiers.SpannerTable(
+ project_id, database_id, table_id)
+ labels = {
+ **self.base_labels,
+ monitoring_infos.RESOURCE_LABEL: resource,
+ monitoring_infos.SPANNER_TABLE_ID: table_id
+ }
+ service_call_metric = ServiceCallMetric(
Review comment:
ServiceCallMetric by design must be instantiated before the IO(spanner) API call is made to the IO source/sink.
This is because we intened to use it to also time the IO(spanner) API calls.
Then the .call() should be made once the IO(spanner) API call returns
##########
File path: sdks/python/apache_beam/io/gcp/experimental/spannerio.py
##########
@@ -523,6 +585,42 @@ class _ReadFromPartitionFn(DoFn):
"""
def __init__(self, spanner_configuration):
self._spanner_configuration = spanner_configuration
+ self.base_labels = {
+ monitoring_infos.SERVICE_LABEL: 'Spanner',
+ monitoring_infos.METHOD_LABEL: 'Read',
+ monitoring_infos.SPANNER_PROJECT_ID: self._spanner_configuration.
Review comment:
Please use this style, avoid breaking the self._spanner_configuration.project into mutliple lines
monitoring_infos.SPANNER_PROJECT_ID: (
self._spanner_configuration.project),
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org