From e0cd2624653e16c5bebd20977d0d5f4a409b1b6b Mon Sep 17 00:00:00 2001 From: Aasiyah Feisal Date: Thu, 30 Apr 2020 15:15:04 -0400 Subject: [PATCH 01/11] Added RPC constants files only --- opencensus/grpc/__init__.py | 18 ++ opencensus/grpc/rpc_m_c_test.py | 93 +++++++++ opencensus/grpc/rpc_measure_constants.py | 171 +++++++++++++++++ opencensus/grpc/rpc_v_c_test.py | 101 ++++++++++ opencensus/grpc/rpc_view_constants.py | 228 +++++++++++++++++++++++ 5 files changed, 611 insertions(+) create mode 100755 opencensus/grpc/__init__.py create mode 100644 opencensus/grpc/rpc_m_c_test.py create mode 100644 opencensus/grpc/rpc_measure_constants.py create mode 100644 opencensus/grpc/rpc_v_c_test.py create mode 100644 opencensus/grpc/rpc_view_constants.py diff --git a/opencensus/grpc/__init__.py b/opencensus/grpc/__init__.py new file mode 100755 index 000000000..03f05ce36 --- /dev/null +++ b/opencensus/grpc/__init__.py @@ -0,0 +1,18 @@ +# Copyright 2017, OpenCensus Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# import rpc_measure_constants +# import rpc_view_constants + diff --git a/opencensus/grpc/rpc_m_c_test.py b/opencensus/grpc/rpc_m_c_test.py new file mode 100644 index 000000000..73310de55 --- /dev/null +++ b/opencensus/grpc/rpc_m_c_test.py @@ -0,0 +1,93 @@ +import unittest +# import rpc_measure_constants +from opencensus.grpc import rpc_measure_constants + + +class RPCMCTest(unittest.TestCase): + """ + RPCMTest tests the rpc_measure_constants module + """ + + def setUp(self): + """ + sets up a test rpc_measure_constant instance + """ + self.rpc_measure = rpc_measure_constants.RPCMeasureConstants() + + def test_client_measures(self): + """ + tests the client measures + """ + self.assertEqual(self.rpc_measure.grpc_client_sent_messages_per_rpc.unit, + "1", + "grpc_client_sent_messages_per_rpc not set correctly on init") + self.assertEqual(self.rpc_measure.grpc_client_sent_bytes_per_rpc.description, + "Total bytes sent across all request messages per RPC", + "grpc_client_sent_bytes_per_rpc not set correctly on init") + self.assertEqual(self.rpc_measure.grpc_client_received_messages_per_rpc.name, + "grpc.io/client/received_messages_per_rpc", + "grpc_client_received_messages_per_rpc not set correctly on init") + self.assertEqual(self.rpc_measure.grpc_client_received_bytes_per_rpc.unit, + "by", + "grpc_client_received_bytes_per_rpc not set correctly upon init") + self.assertEqual(self.rpc_measure.grpc_client_roundtrip_latency.name, + "grpc.io/client/roundtrip_latency", + "grpc_client_roundtrip_latency not initialized correctly") + self.assertEqual(self.rpc_measure.grpc_client_server_latency.name, + "grpc.io/client/server_latency", + "grpc_client_server_latency not set properly") + self.assertEqual(self.rpc_measure.grpc_client_started_rpcs.description, + "Number of started client RPCs.", + "grpc_client_started_rpcs not set properly") + self.assertEqual(self.rpc_measure.grpc_client_sent_messages_per_method.unit, + "1", + "grpc_client_sent_messages_per_method not set properly") + self.assertEqual(self.rpc_measure.grpc_client_received_messages_per_method.name, + "grpc.io/client/received_messages_per_method", + "grpc_client_received_messages_per_method not set properly") + self.assertEqual(self.rpc_measure.grpc_client_sent_bytes_per_method.description, + "Total bytes sent per method, recorded real-time as bytes are sent.", + "grpc_client_sent_bytes_per_method not set properly") + self.assertEqual(self.rpc_measure.grpc_client_received_bytes_per_method.unit, + "by", + "grpc_client_received_bytes_per_method not set properly") + + def test_server_measures(self): + """ + tests the server measures + """ + self.assertEqual(self.rpc_measure.grpc_server_received_messages_per_rpc.name, + "grpc.io/server/received_messages_per_rpc", + "grpc_server_received_messages_per_rpc not set properly") + self.assertEqual(self.rpc_measure.grpc_server_received_bytes_per_rpc.description, + "Total bytes received across all messages per RPC", + "grpc_server_received_bytes_per_rpc not set properly") + self.assertEqual(self.rpc_measure.grpc_server_sent_messages_per_rpc.unit, + "1", + "grpc_server_sent_messages_per_rpc not set properly") + self.assertEqual(self.rpc_measure.grpc_server_sent_bytes_per_rpc.name, + "grpc.io/server/sent_bytes_per_rpc", + "grpc_server_sent_bytes_per_rpc not set properly") + self.assertEqual(self.rpc_measure.grpc_server_server_latency.description, + "Time between first byte of request received to" + " last byte of response sent or terminal error.", + "grpc_server_server_latency not set properly") + self.assertEqual(self.rpc_measure.grpc_server_started_rpcs.unit, + "1", + "grpc_server_started_rpcs not set correctly") + self.assertEqual(self.rpc_measure.grpc_server_sent_messages_per_method.name, + "grpc.io/server/sent_messages_per_method", + "grpc_server_sent_messages_per_method not set correctly") + self.assertEqual(self.rpc_measure.grpc_server_received_messages_per_method.description, + "Total messages received per method.", + "grpc_server_received_messages_per_method not set correctly") + self.assertEqual(self.rpc_measure.grpc_server_sent_bytes_per_method.unit, + "by", + "grpc_server_sent_bytes_per_method not set correctly") + self.assertEqual(self.rpc_measure.grpc_server_received_bytes_per_method.name, + "grpc.io/server/received_bytes_per_method", + "grpc_server_received_bytes_per_method not set correctly") + + +if __name__ == '__main__': + unittest.main() diff --git a/opencensus/grpc/rpc_measure_constants.py b/opencensus/grpc/rpc_measure_constants.py new file mode 100644 index 000000000..e3be2fb97 --- /dev/null +++ b/opencensus/grpc/rpc_measure_constants.py @@ -0,0 +1,171 @@ +from opencensus.tags import tag_key +from opencensus.stats.measure import MeasureInt +from opencensus.stats.measure import MeasureFloat + +""" +Defines constants for collecting rpc stats +""" +class RPCMeasureConstants: + """ + Define constants used to define Measures below + see specs in documentation for opencensus-python + """ + byte = "by" + count = "1" + millisecond = "ms" + + def __init__(self): + """ + Define client and server tags + """ + # Client Tags + # gRPC server status code received, e.g. OK, CANCELLED, DEADLINE_EXCEEDED + self.grpc_client_status = tag_key.TagKey("grpc_client_status") + + # Full gRPC method name, including package, service and method, + # e.g. google.bigtable.v2.Bigtable/CheckAndMutateRow + self.grpc_client_method = tag_key.TagKey("grpc_client_method") + + + # Server Tags + # gRPC server status code returned, e.g. OK, CANCELLED, DEADLINE_EXCEEDED + self.grpc_server_status = tag_key.TagKey("grpc_server_status") + + # Full gRPC method name, including package, service and method, + # e.g. com.exampleapi.v4.BookshelfService/Checkout + self.grpc_server_method = tag_key.TagKey("grpc_server_method") + + """ + Client Measures + """ + # Number of messages sent in the RPC (always 1 for non-streaming RPCs) + self.grpc_client_sent_messages_per_rpc = MeasureInt( + name="grpc.io/client/sent_messages_per_rpc", + description="Number of messages sent in the RPC", + unit=self.count) + + # Total bytes sent across all request messages per RPC + self.grpc_client_sent_bytes_per_rpc = MeasureFloat( + name="grpc.io/client/sent_bytes_per_rpc", + description="Total bytes sent across all request messages per RPC", + unit=self.byte) + + # Number of response messages received per RPC (always 1 for non-streaming RPCs) + self.grpc_client_received_messages_per_rpc = MeasureInt( + name="grpc.io/client/received_messages_per_rpc", + description="Number of response messages received per RPC", + unit=self.count) + + # Total bytes received across all response messages per RPC + self.grpc_client_received_bytes_per_rpc = MeasureFloat( + name="grpc.io/client/received_bytes_per_rpc", + description="Total bytes received across all response messages per RPC", + unit=self.byte) + + # Time between first byte of request sent to last byte of response received, or terminal error + self.grpc_client_roundtrip_latency = MeasureFloat( + name="grpc.io/client/roundtrip_latency", + description="Time between first byte of request sent to" + " last byte of response received or terminal error.", + unit=self.millisecond) + + # Propagated from the server and should have the same value as "grpc.io/server/latency" + self.grpc_client_server_latency = MeasureFloat( + name="grpc.io/client/server_latency", + description="Server latency in msecs", + unit=self.millisecond) + + # The total number of client RPCs ever opened, including those that have not completed + self.grpc_client_started_rpcs = MeasureInt( + name="grpc.io/client/started_rpcs", + description="Number of started client RPCs.", + unit=self.count) + + # Total messages sent per method + self.grpc_client_sent_messages_per_method = MeasureInt( + name="grpc.io/client/sent_messages_per_method", + description="Total messages sent per method.", + unit=self.count) + + # Total messages received per method + self.grpc_client_received_messages_per_method = MeasureInt( + name="grpc.io/client/received_messages_per_method", + description="Total messages received per method.", + unit=self.count) + + # Total bytes sent per method, recorded real-time as bytes are sent + self.grpc_client_sent_bytes_per_method = MeasureFloat( + name="grpc.io/client/sent_bytes_per_method", + description="Total bytes sent per method, recorded real-time as bytes are sent.", + unit=self.byte) + + # Total bytes received per method, recorded real-time as bytes are received + self.grpc_client_received_bytes_per_method = MeasureFloat( + name="grpc.io/client/received_bytes_per_method", + description="Total bytes received per method," + " recorded real-time as bytes are received.", + unit=self.byte) + + """ + Server Measures + """ + # Number of messages received in each RPC. Has value 1 for non-streaming RPCs + self.grpc_server_received_messages_per_rpc = MeasureInt( + name="grpc.io/server/received_messages_per_rpc", + description="Number of messages received in each RPC", + unit=self.count) + + # Total bytes received across all messages per RPC + self.grpc_server_received_bytes_per_rpc = MeasureFloat( + name="grpc.io/server/received_bytes_per_rpc", + description="Total bytes received across all messages per RPC", + unit=self.byte) + + # Number of messages sent in each RPC. Has value 1 for non-streaming RPCs + self.grpc_server_sent_messages_per_rpc = MeasureInt( + name="grpc.io/server/sent_messages_per_rpc", + description="Number of messages sent in each RPC", + unit=self.count) + + # Total bytes sent in across all response messages per RPC + self.grpc_server_sent_bytes_per_rpc = MeasureFloat( + name="grpc.io/server/sent_bytes_per_rpc", + description="Total bytes sent across all response messages per RPC", + unit=self.byte) + + # Time between first byte of request received to last byte of response sent, or terminal error + self.grpc_server_server_latency = MeasureFloat( + name="grpc.io/server/server_latency", + description="Time between first byte of request received" + " to last byte of response sent or terminal error.", + unit=self.millisecond) + + # The total number of server RPCs ever opened, including those that have not completed + self.grpc_server_started_rpcs = MeasureInt( + name="grpc.io/server/started_rpcs", + description="Number of started server RPCs.", + unit=self.count) + + # Total messages sent per method + self.grpc_server_sent_messages_per_method = MeasureInt( + name="grpc.io/server/sent_messages_per_method", + description="Total messages sent per method.", + unit=self.count) + + # Total messages received per method + self.grpc_server_received_messages_per_method = MeasureInt( + name="grpc.io/server/received_messages_per_method", + description="Total messages received per method.", + unit=self.count) + + # Total bytes sent per method, recorded real-time as bytes are sent + self.grpc_server_sent_bytes_per_method = MeasureFloat( + name="grpc.io/server/sent_bytes_per_method", + description="Total bytes sent per method, recorded real-time as bytes are sent.", + unit=self.byte) + + # Total bytes received per method, recorded real-time as bytes are received + self.grpc_server_received_bytes_per_method = MeasureFloat( + name="grpc.io/server/received_bytes_per_method", + description="Total bytes received per method, recorded real-time as bytes are received.", + unit=self.byte) diff --git a/opencensus/grpc/rpc_v_c_test.py b/opencensus/grpc/rpc_v_c_test.py new file mode 100644 index 000000000..c8e43e416 --- /dev/null +++ b/opencensus/grpc/rpc_v_c_test.py @@ -0,0 +1,101 @@ +import unittest +#import rpc_view_constants +from opencensus.grpc import rpc_view_constants + + +class RPCVCTests(unittest.TestCase): + """ + RPVMTest tests the rpc_view_constants module + """ + + def setUp(self): + self.rpc_view = rpc_view_constants.RPCViewConstants() + + def test_client_measures(self): + self.assertEqual(self.rpc_view.grpc_client_sent_bytes_per_rpc_view.name, + "grpc.io/client/sent_bytes_per_rpc", + "grpc_client_sent_bytes_per_rpc_view not set correctly") + self.assertEqual(self.rpc_view.grpc_client_received_bytes_per_rpc_view.description, + "Received bytes per RPC", + "grpc_client_received_bytes_per_rpc_view not set correctly") + self.assertEqual(self.rpc_view.grpc_client_roundtrip_latency_view.measure.name, + "grpc.io/client/roundtrip_latency", + "grpc_client_roundtrip_latency_view not set correctly") + self.assertEqual(self.rpc_view.grpc_client_completed_rpc_view.measure.name, + "grpc.io/client/roundtrip_latency", + "grpc_client_completed_rpc_view not set correctly") + self.assertEqual(self.rpc_view.grpc_client_started_rpc_view.description, + "Number of started client RPCs", + "grpc_client_started_rpc_view not set correctly") + self.assertEqual(self.rpc_view.grpc_client_sent_messages_per_rpc_view.name, + "grpc.io/client/sent_messages_per_rpc", + "grpc_client_sent_messages_per_rpc_view not set correctly") + self.assertEqual(self.rpc_view.grpc_client_received_messages_per_rpc_view.description, + "Number of response messages received per RPC", + "grpc_client_received_messages_per_rpc_view not set correctly") + self.assertEqual(self.rpc_view.grpc_client_server_latency_view.measure.unit, + "ms", + "grpc_client_server_latency_view not set correctly") + self.assertEqual(self.rpc_view.grpc_client_sent_messages_per_method_view.name, + "grpc.io/client/sent_messages_per_method", + "grpc_client_sent_messages_per_method_view not set correctly") + self.assertEqual(self.rpc_view.grpc_client_received_messages_per_method_view.description, + "Number of messages received", + "grpc_client_received_messages_per_method_view not set correctly") + self.assertEqual(self.rpc_view.grpc_client_sent_bytes_per_method_view.measure.unit, + "by", + "grpc_client_sent_bytes_per_method_view not set correctly") + self.assertEqual(self.rpc_view.grpc_client_received_bytes_per_method_view.name, + "grpc.io/client/received_bytes_per_method", + "grpc_client_received_bytes_per_method_view not set correctly") + + def test_server_measures(self): + # Test default server views + self.assertEqual(self.rpc_view.grpc_server_received_bytes_per_rpc.name, + "grpc.io/server/received_bytes_per_rpc", + "grpc_server_received_bytes_per_rpc view not set correctly") + + self.assertEqual(self.rpc_view.grpc_server_sent_bytes_per_rpc.name, + "grpc.io/server/sent_bytes_per_rpc", + "grpc_server_sent_bytes_per_rpc view not set correctly") + + self.assertEqual(self.rpc_view.grpc_server_server_latency.name, + "grpc.io/server/server_latency", + "grpc_server_server_latency view not set correctly") + + self.assertEqual(self.rpc_view.grpc_server_completed_rpcs.name, + "grpc.io/server/completed_rpcs", + "grpc_server_completed_rpcs view not set correctly") + + self.assertEqual(self.rpc_view.grpc_server_started_rpcs.name, + "grpc.io/server/started_rpcs", + "grpc_server_started_rpcs view not set correctly") + + # Test extra server views + self.assertEqual(self.rpc_view.grpc_server_received_messages_per_rpc.name, + "grpc.io/server/received_messages_per_rpc", + "grpc_server_received_messages_per_rpc view not set correctly") + + self.assertEqual(self.rpc_view.grpc_server_sent_messages_per_rpc.name, + "grpc.io/server/sent_messages_per_rpc", + "grpc_server_sent_messages_per_rpc view not set correctly") + + self.assertEqual(self.rpc_view.grpc_server_sent_messages_per_method.name, + "grpc.io/server/sent_messages_per_method", + "grpc_server_sent_messages_per_method view not set correctly") + + self.assertEqual(self.rpc_view.grpc_server_received_messages_per_method.name, + "grpc.io/server/received_messages_per_method", + "grpc_server_received_messages_per_method view not set correctly") + + self.assertEqual(self.rpc_view.grpc_server_sent_bytes_per_method.name, + "grpc.io/server/sent_bytes_per_method", + "grpc_server_sent_bytes_per_method view not set correctly") + + self.assertEqual(self.rpc_view.grpc_server_received_bytes_per_method.name, + "grpc.io/server/received_bytes_per_method", + "grpc_server_received_bytes_per_method view not set correctly") + + +if __name__ == '__main__': + unittest.main() diff --git a/opencensus/grpc/rpc_view_constants.py b/opencensus/grpc/rpc_view_constants.py new file mode 100644 index 000000000..95dbe170b --- /dev/null +++ b/opencensus/grpc/rpc_view_constants.py @@ -0,0 +1,228 @@ +from opencensus.stats.aggregation import CountAggregation +from opencensus.stats.aggregation import SumAggregation +from opencensus.stats.aggregation import DistributionAggregation +from opencensus.stats import bucket_boundaries +from opencensus.stats import view +from opencensus.grpc import rpc_measure_constants +# import rpc_measure_constants + +""" +Defines constants for exporting views on rpc stats +""" +class RPCViewConstants: + """ + Define variables used by constants below + """ + # Buckets for distributions in default views + # Common histogram bucket boundaries for bytes received/sets Views (in bytes). + rpc_bytes_bucket_boundaries = [0, 1024, 2048, 4096, 16384, 65536, 262144, 4194304, + 16777216, 67108864, 268435456, 1073741824, 4294967296] + + # Common histogram bucket boundaries for latency and elapsed-time Views (in milliseconds). + rpc_millis_bucket_boundaries = [0.0, 0.01, 0.05, 0.1, 0.3, 0.6, 0.8, 1.0, 2.0, 3.0, + 4.0, 5.0, 6.0, 8.0, 10.0, 13.0, 16.0, 20.0, 25.0, + 30.0, 40.0, 50.0, 65.0, 80.0, 100.0, 130.0, 160.0, + 200.0, 250.0, 300.0, 400.0, 500.0, 650.0, 800.0, + 1000.0, 2000.0, 5000.0, 10000.0, 20000.0, 50000.0, 100000.0] + + # Common histogram bucket boundaries for request/response count Views (no unit). + rpc_count_bucket_boundaries = [0.0, 1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0, 128.0, 256.0, + 512.0, 1024.0, 2048.0, 4096.0, 8192.0, 16384.0, 32768.0, 65536.0] + + # Record sum and count stats at the same time. + count = CountAggregation() + sum = SumAggregation() + + # Set up aggregation object for rpc_bytes_bucket_boundaries + bytes_bucket_boundaries = bucket_boundaries.BucketBoundaries(rpc_bytes_bucket_boundaries) + aggregation_with_bytes_histogram = DistributionAggregation(bytes_bucket_boundaries.boundaries) + + # Set up aggregation object for rpc_millis_bucket_boundaries + millis_bucket_boundaries = bucket_boundaries.BucketBoundaries(rpc_millis_bucket_boundaries) + aggregation_with_millis_histogram = DistributionAggregation(millis_bucket_boundaries.boundaries) + + # Set up aggregation object for rpc_count_bucket_boundaries + count_bucket_boundaries = bucket_boundaries.BucketBoundaries(rpc_count_bucket_boundaries) + aggregation_with_count_histogram = DistributionAggregation(count_bucket_boundaries.boundaries) + + # Initialize an instance of RPC Measure Constants + rpc_m_c = rpc_measure_constants.RPCMeasureConstants() + + """ + RPC Client Cumulative Views + """ + # Default Views + # The following set of views are considered minimum + # required to monitor client-side performance + grpc_client_sent_bytes_per_rpc_view = view.View( + name="grpc.io/client/sent_bytes_per_rpc", + description="Sent bytes per RPC", + columns=[rpc_m_c.grpc_client_method], + measure=rpc_m_c.grpc_client_sent_bytes_per_rpc, + aggregation=aggregation_with_bytes_histogram) + + grpc_client_received_bytes_per_rpc_view = view.View( + name="grpc.io/client/received_bytes_per_rpc", + description="Received bytes per RPC", + columns=[rpc_m_c.grpc_client_method], + measure=rpc_m_c.grpc_client_received_bytes_per_rpc, + aggregation=aggregation_with_bytes_histogram) + + grpc_client_roundtrip_latency_view = view.View( + name="grpc.io/client/roundtrip_latency", + description="Latency in msecs", + columns=[rpc_m_c.grpc_client_method], + measure=rpc_m_c.grpc_client_roundtrip_latency, + aggregation=aggregation_with_millis_histogram) + + grpc_client_completed_rpc_view = view.View( + name="grpc.io/client/completed_rpcs", + description="Number of completed client RPCs", + columns=[rpc_m_c.grpc_client_method, rpc_m_c.grpc_client_status], + measure=rpc_m_c.grpc_client_roundtrip_latency, + aggregation=count) + + grpc_client_started_rpc_view = view.View( + name="grpc.io/client/started_rpcs", + description="Number of started client RPCs", + columns=[rpc_m_c.grpc_client_method], + measure=rpc_m_c.grpc_client_started_rpcs, + aggregation=count) + + # Extra Views + # The following set of views are considered useful + # but not mandatory to monitor client side performance + grpc_client_sent_messages_per_rpc_view = view.View( + name="grpc.io/client/sent_messages_per_rpc", + description="Number of messages sent in the RPC", + columns=[rpc_m_c.grpc_client_method], + measure=rpc_m_c.grpc_client_sent_messages_per_rpc, + aggregation=aggregation_with_count_histogram) + + grpc_client_received_messages_per_rpc_view = view.View( + name="grpc.io/client/received_messages_per_rpc", + description="Number of response messages received per RPC", + columns=[rpc_m_c.grpc_client_method], + measure=rpc_m_c.grpc_client_received_messages_per_rpc, + aggregation=aggregation_with_count_histogram) + + grpc_client_server_latency_view = view.View( + name="grpc.io/client/server_latency", + description="Server latency in msecs", + columns=[rpc_m_c.grpc_client_method], + measure=rpc_m_c.grpc_client_server_latency, + aggregation=aggregation_with_millis_histogram) + + grpc_client_sent_messages_per_method_view = view.View( + name="grpc.io/client/sent_messages_per_method", + description="Number of messages sent", + columns=[rpc_m_c.grpc_client_method], + measure=rpc_m_c.grpc_client_sent_messages_per_method, + aggregation=count) + + grpc_client_received_messages_per_method_view = view.View( + name="grpc.io/client/received_messages_per_method", + description="Number of messages received", + columns=[rpc_m_c.grpc_client_method], + measure=rpc_m_c.grpc_client_received_messages_per_method, + aggregation=count) + grpc_client_sent_bytes_per_method_view = view.View( + name="grpc.io/client/sent_bytes_per_method", + description="Sent bytes per method", + columns=[rpc_m_c.grpc_client_method], + measure=rpc_m_c.grpc_client_sent_bytes_per_method, + aggregation=sum) + + grpc_client_received_bytes_per_method_view = view.View( + name="grpc.io/client/received_bytes_per_method", + description="Received bytes per method", + columns=[rpc_m_c.grpc_client_method], + measure=rpc_m_c.grpc_client_received_bytes_per_method, + aggregation=sum) + + """ + RPC Server Cumulative Views + """ + # Default Views + # The following set of views are considered minimum + # required to monitor server-side performance + grpc_server_received_bytes_per_rpc = view.View( + name="grpc.io/server/received_bytes_per_rpc", + description="Received bytes per RPC", + columns=[rpc_m_c.grpc_server_method], + measure=rpc_m_c.grpc_server_received_bytes_per_rpc, + aggregation=sum) + + grpc_server_sent_bytes_per_rpc = view.View( + name="grpc.io/server/sent_bytes_per_rpc", + description="Sent bytes per RPC", + columns=[rpc_m_c.grpc_server_method], + measure=rpc_m_c.grpc_server_sent_bytes_per_method, + aggregation=sum) + + grpc_server_server_latency = view.View( + name="grpc.io/server/server_latency", + description="Latency in msecs", + columns=[rpc_m_c.grpc_server_method], + measure=rpc_m_c.grpc_server_server_latency, + aggregation=aggregation_with_millis_histogram) + + grpc_server_completed_rpcs = view.View( + name="grpc.io/server/completed_rpcs", + description="Number of completed server RPCs", + columns=[rpc_m_c.grpc_server_method, rpc_m_c.grpc_server_status], + measure=rpc_m_c.grpc_server_server_latency, + aggregation=count) + + grpc_server_started_rpcs = view.View( + name="grpc.io/server/started_rpcs", + description="Number of started server RPCs", + columns=[rpc_m_c.grpc_server_method], + measure=rpc_m_c.grpc_server_started_rpcs, + aggregation=count) + + + # Extra Views + # The following set of views are considered useful + # but not mandatory to monitor server-side performance + grpc_server_received_messages_per_rpc = view.View( + name="grpc.io/server/received_messages_per_rpc", + description="Number of response messages received in each RPC", + columns=[rpc_m_c.grpc_server_method], + measure=rpc_m_c.grpc_server_received_messages_per_rpc, + aggregation=aggregation_with_count_histogram) + + grpc_server_sent_messages_per_rpc = view.View( + name="grpc.io/server/sent_messages_per_rpc", + description="Number of messages sent in each RPC", + columns=[rpc_m_c.grpc_server_method], + measure=rpc_m_c.grpc_server_sent_messages_per_rpc, + aggregation=aggregation_with_count_histogram) + + grpc_server_sent_messages_per_method = view.View( + name="grpc.io/server/sent_messages_per_method", + description="Number of messages sent", + columns=[rpc_m_c.grpc_server_method], + measure=rpc_m_c.grpc_server_sent_messages_per_method, + aggregation=count) + + grpc_server_received_messages_per_method = view.View( + name="grpc.io/server/received_messages_per_method", + description="Number of messages received", + columns=[rpc_m_c.grpc_server_method], + measure=rpc_m_c.grpc_server_received_messages_per_method, + aggregation=count) + + grpc_server_sent_bytes_per_method = view.View( + name="grpc.io/server/sent_bytes_per_method", + description="Sent bytes per method", + columns=[rpc_m_c.grpc_server_method], + measure=rpc_m_c.grpc_server_sent_bytes_per_method, + aggregation=sum) + + grpc_server_received_bytes_per_method = view.View( + name="grpc.io/server/received_bytes_per_method", + description="Received bytes per method", + columns=[rpc_m_c.grpc_server_method], + measure=rpc_m_c.grpc_server_received_bytes_per_method, + aggregation=sum) From e1c7f2c17ef9798219c69066d1088fd721eddeba Mon Sep 17 00:00:00 2001 From: Anam Navied Date: Thu, 30 Apr 2020 15:33:14 -0400 Subject: [PATCH 02/11] fixed rpc_view_constant.py pylint errors --- opencensus/grpc/rpc_view_constants.py | 60 +++++++++++++++++---------- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/opencensus/grpc/rpc_view_constants.py b/opencensus/grpc/rpc_view_constants.py index 95dbe170b..6d84a48aa 100644 --- a/opencensus/grpc/rpc_view_constants.py +++ b/opencensus/grpc/rpc_view_constants.py @@ -9,41 +9,58 @@ """ Defines constants for exporting views on rpc stats """ + + class RPCViewConstants: """ Define variables used by constants below """ - # Buckets for distributions in default views - # Common histogram bucket boundaries for bytes received/sets Views (in bytes). - rpc_bytes_bucket_boundaries = [0, 1024, 2048, 4096, 16384, 65536, 262144, 4194304, - 16777216, 67108864, 268435456, 1073741824, 4294967296] - - # Common histogram bucket boundaries for latency and elapsed-time Views (in milliseconds). - rpc_millis_bucket_boundaries = [0.0, 0.01, 0.05, 0.1, 0.3, 0.6, 0.8, 1.0, 2.0, 3.0, - 4.0, 5.0, 6.0, 8.0, 10.0, 13.0, 16.0, 20.0, 25.0, - 30.0, 40.0, 50.0, 65.0, 80.0, 100.0, 130.0, 160.0, - 200.0, 250.0, 300.0, 400.0, 500.0, 650.0, 800.0, - 1000.0, 2000.0, 5000.0, 10000.0, 20000.0, 50000.0, 100000.0] - - # Common histogram bucket boundaries for request/response count Views (no unit). - rpc_count_bucket_boundaries = [0.0, 1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0, 128.0, 256.0, - 512.0, 1024.0, 2048.0, 4096.0, 8192.0, 16384.0, 32768.0, 65536.0] + # Buckets for distributions in default views + # Common histogram bucket boundaries for bytes + # received/sets Views (in bytes). + rpc_bytes_bucket_boundaries = [0, 1024, 2048, 4096, 16384, 65536, + 262144, 4194304, 16777216, 67108864, + 268435456, 1073741824, 4294967296] + + # Common histogram bucket boundaries for latency and + # elapsed-time Views (in milliseconds). + rpc_millis_bucket_boundaries = [0.0, 0.01, 0.05, 0.1, 0.3, 0.6, + 0.8, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, + 8.0, 10.0, 13.0, 16.0, 20.0, 25.0, + 30.0, 40.0, 50.0, 65.0, 80.0, 100.0, + 130.0, 160.0, 200.0, 250.0, 300.0, + 400.0, 500.0, 650.0, 800.0, 1000.0, + 2000.0, 5000.0, 10000.0, 20000.0, + 50000.0, 100000.0] + + # Common histogram bucket boundaries for request/response + # count Views (no unit). + rpc_count_bucket_boundaries = [0.0, 1.0, 2.0, 4.0, 8.0, 16.0, 32.0, + 64.0, 128.0, 256.0, 512.0, 1024.0, + 2048.0, 4096.0, 8192.0, 16384.0, + 32768.0, 65536.0] # Record sum and count stats at the same time. count = CountAggregation() sum = SumAggregation() # Set up aggregation object for rpc_bytes_bucket_boundaries - bytes_bucket_boundaries = bucket_boundaries.BucketBoundaries(rpc_bytes_bucket_boundaries) - aggregation_with_bytes_histogram = DistributionAggregation(bytes_bucket_boundaries.boundaries) + bytes_bucket_boundaries = bucket_boundaries.BucketBoundaries( + rpc_bytes_bucket_boundaries) + aggregation_with_bytes_histogram = DistributionAggregation( + bytes_bucket_boundaries.boundaries) # Set up aggregation object for rpc_millis_bucket_boundaries - millis_bucket_boundaries = bucket_boundaries.BucketBoundaries(rpc_millis_bucket_boundaries) - aggregation_with_millis_histogram = DistributionAggregation(millis_bucket_boundaries.boundaries) + millis_bucket_boundaries = bucket_boundaries.BucketBoundaries( + rpc_millis_bucket_boundaries) + aggregation_with_millis_histogram = DistributionAggregation( + millis_bucket_boundaries.boundaries) # Set up aggregation object for rpc_count_bucket_boundaries - count_bucket_boundaries = bucket_boundaries.BucketBoundaries(rpc_count_bucket_boundaries) - aggregation_with_count_histogram = DistributionAggregation(count_bucket_boundaries.boundaries) + count_bucket_boundaries = bucket_boundaries.BucketBoundaries( + rpc_count_bucket_boundaries) + aggregation_with_count_histogram = DistributionAggregation( + count_bucket_boundaries.boundaries) # Initialize an instance of RPC Measure Constants rpc_m_c = rpc_measure_constants.RPCMeasureConstants() @@ -181,7 +198,6 @@ class RPCViewConstants: measure=rpc_m_c.grpc_server_started_rpcs, aggregation=count) - # Extra Views # The following set of views are considered useful # but not mandatory to monitor server-side performance From 60ff80c2955b62990d6b3371c3154107fbf27f14 Mon Sep 17 00:00:00 2001 From: Anam Navied Date: Thu, 30 Apr 2020 15:52:19 -0400 Subject: [PATCH 03/11] fixed rpc_v_c_test.py pylint errors --- opencensus/grpc/rpc_v_c_test.py | 192 +++++++++++++++++++------------- 1 file changed, 113 insertions(+), 79 deletions(-) diff --git a/opencensus/grpc/rpc_v_c_test.py b/opencensus/grpc/rpc_v_c_test.py index c8e43e416..874af7bb0 100644 --- a/opencensus/grpc/rpc_v_c_test.py +++ b/opencensus/grpc/rpc_v_c_test.py @@ -1,5 +1,4 @@ import unittest -#import rpc_view_constants from opencensus.grpc import rpc_view_constants @@ -12,89 +11,124 @@ def setUp(self): self.rpc_view = rpc_view_constants.RPCViewConstants() def test_client_measures(self): - self.assertEqual(self.rpc_view.grpc_client_sent_bytes_per_rpc_view.name, - "grpc.io/client/sent_bytes_per_rpc", - "grpc_client_sent_bytes_per_rpc_view not set correctly") - self.assertEqual(self.rpc_view.grpc_client_received_bytes_per_rpc_view.description, - "Received bytes per RPC", - "grpc_client_received_bytes_per_rpc_view not set correctly") - self.assertEqual(self.rpc_view.grpc_client_roundtrip_latency_view.measure.name, - "grpc.io/client/roundtrip_latency", - "grpc_client_roundtrip_latency_view not set correctly") - self.assertEqual(self.rpc_view.grpc_client_completed_rpc_view.measure.name, - "grpc.io/client/roundtrip_latency", - "grpc_client_completed_rpc_view not set correctly") - self.assertEqual(self.rpc_view.grpc_client_started_rpc_view.description, - "Number of started client RPCs", - "grpc_client_started_rpc_view not set correctly") - self.assertEqual(self.rpc_view.grpc_client_sent_messages_per_rpc_view.name, - "grpc.io/client/sent_messages_per_rpc", - "grpc_client_sent_messages_per_rpc_view not set correctly") - self.assertEqual(self.rpc_view.grpc_client_received_messages_per_rpc_view.description, - "Number of response messages received per RPC", - "grpc_client_received_messages_per_rpc_view not set correctly") - self.assertEqual(self.rpc_view.grpc_client_server_latency_view.measure.unit, - "ms", - "grpc_client_server_latency_view not set correctly") - self.assertEqual(self.rpc_view.grpc_client_sent_messages_per_method_view.name, - "grpc.io/client/sent_messages_per_method", - "grpc_client_sent_messages_per_method_view not set correctly") - self.assertEqual(self.rpc_view.grpc_client_received_messages_per_method_view.description, - "Number of messages received", - "grpc_client_received_messages_per_method_view not set correctly") - self.assertEqual(self.rpc_view.grpc_client_sent_bytes_per_method_view.measure.unit, - "by", - "grpc_client_sent_bytes_per_method_view not set correctly") - self.assertEqual(self.rpc_view.grpc_client_received_bytes_per_method_view.name, - "grpc.io/client/received_bytes_per_method", - "grpc_client_received_bytes_per_method_view not set correctly") + self.assertEqual( + self.rpc_view.grpc_client_sent_bytes_per_rpc_view.name, + "grpc.io/client/sent_bytes_per_rpc", + "grpc_client_sent_bytes_per_rpc_view not set correctly") + + self.assertEqual( + self.rpc_view.grpc_client_received_bytes_per_rpc_view.description, + "Received bytes per RPC", + "grpc_client_received_bytes_per_rpc_view not set correctly") + + self.assertEqual( + self.rpc_view.grpc_client_roundtrip_latency_view.measure.name, + "grpc.io/client/roundtrip_latency", + "grpc_client_roundtrip_latency_view not set correctly") + + self.assertEqual( + self.rpc_view.grpc_client_completed_rpc_view.measure.name, + "grpc.io/client/roundtrip_latency", + "grpc_client_completed_rpc_view not set correctly") + + self.assertEqual( + self.rpc_view.grpc_client_started_rpc_view.description, + "Number of started client RPCs", + "grpc_client_started_rpc_view not set correctly") + + self.assertEqual( + self.rpc_view.grpc_client_sent_messages_per_rpc_view.name, + "grpc.io/client/sent_messages_per_rpc", + "grpc_client_sent_messages_per_rpc_view not set correctly") + + self.assertEqual( + self.rpc_view.grpc_client_received_messages_per_rpc_view. + description, + "Number of response messages received per RPC", + "grpc_client_received_messages_per_rpc_view not set correctly") + + self.assertEqual( + self.rpc_view.grpc_client_server_latency_view.measure.unit, + "ms", + "grpc_client_server_latency_view not set correctly") + + self.assertEqual( + self.rpc_view.grpc_client_sent_messages_per_method_view.name, + "grpc.io/client/sent_messages_per_method", + "grpc_client_sent_messages_per_method_view not set correctly") + + self.assertEqual( + self.rpc_view.grpc_client_received_messages_per_method_view.description, + "Number of messages received", + "grpc_client_received_messages_per_method_view not set correctly") + + self.assertEqual( + self.rpc_view.grpc_client_sent_bytes_per_method_view.measure.unit, + "by", + "grpc_client_sent_bytes_per_method_view not set correctly") + + self.assertEqual( + self.rpc_view.grpc_client_received_bytes_per_method_view.name, + "grpc.io/client/received_bytes_per_method", + "grpc_client_received_bytes_per_method_view not set correctly") def test_server_measures(self): # Test default server views - self.assertEqual(self.rpc_view.grpc_server_received_bytes_per_rpc.name, - "grpc.io/server/received_bytes_per_rpc", - "grpc_server_received_bytes_per_rpc view not set correctly") - - self.assertEqual(self.rpc_view.grpc_server_sent_bytes_per_rpc.name, - "grpc.io/server/sent_bytes_per_rpc", - "grpc_server_sent_bytes_per_rpc view not set correctly") - - self.assertEqual(self.rpc_view.grpc_server_server_latency.name, - "grpc.io/server/server_latency", - "grpc_server_server_latency view not set correctly") - - self.assertEqual(self.rpc_view.grpc_server_completed_rpcs.name, - "grpc.io/server/completed_rpcs", - "grpc_server_completed_rpcs view not set correctly") - - self.assertEqual(self.rpc_view.grpc_server_started_rpcs.name, - "grpc.io/server/started_rpcs", - "grpc_server_started_rpcs view not set correctly") + self.assertEqual( + self.rpc_view.grpc_server_received_bytes_per_rpc.name, + "grpc.io/server/received_bytes_per_rpc", + "grpc_server_received_bytes_per_rpc view not set correctly") + + self.assertEqual( + self.rpc_view.grpc_server_sent_bytes_per_rpc.name, + "grpc.io/server/sent_bytes_per_rpc", + "grpc_server_sent_bytes_per_rpc view not set correctly") + + self.assertEqual( + self.rpc_view.grpc_server_server_latency.name, + "grpc.io/server/server_latency", + "grpc_server_server_latency view not set correctly") + + self.assertEqual( + self.rpc_view.grpc_server_completed_rpcs.name, + "grpc.io/server/completed_rpcs", + "grpc_server_completed_rpcs view not set correctly") + + self.assertEqual( + self.rpc_view.grpc_server_started_rpcs.name, + "grpc.io/server/started_rpcs", + "grpc_server_started_rpcs view not set correctly") # Test extra server views - self.assertEqual(self.rpc_view.grpc_server_received_messages_per_rpc.name, - "grpc.io/server/received_messages_per_rpc", - "grpc_server_received_messages_per_rpc view not set correctly") - - self.assertEqual(self.rpc_view.grpc_server_sent_messages_per_rpc.name, - "grpc.io/server/sent_messages_per_rpc", - "grpc_server_sent_messages_per_rpc view not set correctly") - - self.assertEqual(self.rpc_view.grpc_server_sent_messages_per_method.name, - "grpc.io/server/sent_messages_per_method", - "grpc_server_sent_messages_per_method view not set correctly") - - self.assertEqual(self.rpc_view.grpc_server_received_messages_per_method.name, - "grpc.io/server/received_messages_per_method", - "grpc_server_received_messages_per_method view not set correctly") - - self.assertEqual(self.rpc_view.grpc_server_sent_bytes_per_method.name, - "grpc.io/server/sent_bytes_per_method", - "grpc_server_sent_bytes_per_method view not set correctly") - - self.assertEqual(self.rpc_view.grpc_server_received_bytes_per_method.name, - "grpc.io/server/received_bytes_per_method", - "grpc_server_received_bytes_per_method view not set correctly") + self.assertEqual( + self.rpc_view.grpc_server_received_messages_per_rpc.name, + "grpc.io/server/received_messages_per_rpc", + "grpc_server_received_messages_per_rpc view not set correctly") + + self.assertEqual( + self.rpc_view.grpc_server_sent_messages_per_rpc.name, + "grpc.io/server/sent_messages_per_rpc", + "grpc_server_sent_messages_per_rpc view not set correctly") + + self.assertEqual( + self.rpc_view.grpc_server_sent_messages_per_method.name, + "grpc.io/server/sent_messages_per_method", + "grpc_server_sent_messages_per_method view not set correctly") + + self.assertEqual( + self.rpc_view.grpc_server_received_messages_per_method.name, + "grpc.io/server/received_messages_per_method", + "grpc_server_received_messages_per_method view not set correctly") + + self.assertEqual( + self.rpc_view.grpc_server_sent_bytes_per_method.name, + "grpc.io/server/sent_bytes_per_method", + "grpc_server_sent_bytes_per_method view not set correctly") + + self.assertEqual( + self.rpc_view.grpc_server_received_bytes_per_method.name, + "grpc.io/server/received_bytes_per_method", + "grpc_server_received_bytes_per_method view not set correctly") if __name__ == '__main__': From 0defc91a0db373b7f84d4a5331513fbedc88ef6d Mon Sep 17 00:00:00 2001 From: Anam Navied Date: Thu, 30 Apr 2020 16:01:59 -0400 Subject: [PATCH 04/11] fixed rpc_measure_constant.py pylint errors --- opencensus/grpc/rpc_measure_constants.py | 75 ++++++++++++++++-------- 1 file changed, 49 insertions(+), 26 deletions(-) diff --git a/opencensus/grpc/rpc_measure_constants.py b/opencensus/grpc/rpc_measure_constants.py index e3be2fb97..ddae43c47 100644 --- a/opencensus/grpc/rpc_measure_constants.py +++ b/opencensus/grpc/rpc_measure_constants.py @@ -5,6 +5,8 @@ """ Defines constants for collecting rpc stats """ + + class RPCMeasureConstants: """ Define constants used to define Measures below @@ -16,19 +18,20 @@ class RPCMeasureConstants: def __init__(self): """ - Define client and server tags + Define client and server tags """ # Client Tags - # gRPC server status code received, e.g. OK, CANCELLED, DEADLINE_EXCEEDED + # gRPC server status code received, + # e.g. OK, CANCELLED, DEADLINE_EXCEEDED self.grpc_client_status = tag_key.TagKey("grpc_client_status") # Full gRPC method name, including package, service and method, # e.g. google.bigtable.v2.Bigtable/CheckAndMutateRow self.grpc_client_method = tag_key.TagKey("grpc_client_method") - # Server Tags - # gRPC server status code returned, e.g. OK, CANCELLED, DEADLINE_EXCEEDED + # gRPC server status code returned, + # e.g. OK, CANCELLED, DEADLINE_EXCEEDED self.grpc_server_status = tag_key.TagKey("grpc_server_status") # Full gRPC method name, including package, service and method, @@ -36,9 +39,10 @@ def __init__(self): self.grpc_server_method = tag_key.TagKey("grpc_server_method") """ - Client Measures + Client Measures """ - # Number of messages sent in the RPC (always 1 for non-streaming RPCs) + # Number of messages sent in the RPC + # (always 1 for non-streaming RPCs) self.grpc_client_sent_messages_per_rpc = MeasureInt( name="grpc.io/client/sent_messages_per_rpc", description="Number of messages sent in the RPC", @@ -47,35 +51,42 @@ def __init__(self): # Total bytes sent across all request messages per RPC self.grpc_client_sent_bytes_per_rpc = MeasureFloat( name="grpc.io/client/sent_bytes_per_rpc", - description="Total bytes sent across all request messages per RPC", + description="Total bytes sent across all" + " request messages per RPC", unit=self.byte) - # Number of response messages received per RPC (always 1 for non-streaming RPCs) + # Number of response messages received + # per RPC (always 1 for non-streaming RPCs) self.grpc_client_received_messages_per_rpc = MeasureInt( name="grpc.io/client/received_messages_per_rpc", description="Number of response messages received per RPC", unit=self.count) - # Total bytes received across all response messages per RPC + # Total bytes received across all + # response messages per RPC self.grpc_client_received_bytes_per_rpc = MeasureFloat( name="grpc.io/client/received_bytes_per_rpc", - description="Total bytes received across all response messages per RPC", + description="Total bytes received across all" + " response messages per RPC", unit=self.byte) - # Time between first byte of request sent to last byte of response received, or terminal error + # Time between first byte of request sent to last + # byte of response received, or terminal error self.grpc_client_roundtrip_latency = MeasureFloat( name="grpc.io/client/roundtrip_latency", description="Time between first byte of request sent to" " last byte of response received or terminal error.", unit=self.millisecond) - # Propagated from the server and should have the same value as "grpc.io/server/latency" + # Propagated from the server and should + # have the same value as "grpc.io/server/latency" self.grpc_client_server_latency = MeasureFloat( name="grpc.io/client/server_latency", description="Server latency in msecs", unit=self.millisecond) - # The total number of client RPCs ever opened, including those that have not completed + # The total number of client RPCs ever opened, + # including those that have not completed self.grpc_client_started_rpcs = MeasureInt( name="grpc.io/client/started_rpcs", description="Number of started client RPCs.", @@ -93,13 +104,16 @@ def __init__(self): description="Total messages received per method.", unit=self.count) - # Total bytes sent per method, recorded real-time as bytes are sent + # Total bytes sent per method, + # recorded real-time as bytes are sent self.grpc_client_sent_bytes_per_method = MeasureFloat( name="grpc.io/client/sent_bytes_per_method", - description="Total bytes sent per method, recorded real-time as bytes are sent.", + description="Total bytes sent per method, recorded" + " real-time as bytes are sent.", unit=self.byte) - # Total bytes received per method, recorded real-time as bytes are received + # Total bytes received per method, recorded real-time + # as bytes are received self.grpc_client_received_bytes_per_method = MeasureFloat( name="grpc.io/client/received_bytes_per_method", description="Total bytes received per method," @@ -107,9 +121,10 @@ def __init__(self): unit=self.byte) """ - Server Measures + Server Measures """ - # Number of messages received in each RPC. Has value 1 for non-streaming RPCs + # Number of messages received in each RPC. + # Has value 1 for non-streaming RPCs self.grpc_server_received_messages_per_rpc = MeasureInt( name="grpc.io/server/received_messages_per_rpc", description="Number of messages received in each RPC", @@ -118,10 +133,12 @@ def __init__(self): # Total bytes received across all messages per RPC self.grpc_server_received_bytes_per_rpc = MeasureFloat( name="grpc.io/server/received_bytes_per_rpc", - description="Total bytes received across all messages per RPC", + description="Total bytes received across all" + " messages per RPC", unit=self.byte) - # Number of messages sent in each RPC. Has value 1 for non-streaming RPCs + # Number of messages sent in each RPC. + # Has value 1 for non-streaming RPCs self.grpc_server_sent_messages_per_rpc = MeasureInt( name="grpc.io/server/sent_messages_per_rpc", description="Number of messages sent in each RPC", @@ -130,17 +147,20 @@ def __init__(self): # Total bytes sent in across all response messages per RPC self.grpc_server_sent_bytes_per_rpc = MeasureFloat( name="grpc.io/server/sent_bytes_per_rpc", - description="Total bytes sent across all response messages per RPC", + description="Total bytes sent across all response" + " messages per RPC", unit=self.byte) - # Time between first byte of request received to last byte of response sent, or terminal error + # Time between first byte of request received to last byte of + # response sent, or terminal error self.grpc_server_server_latency = MeasureFloat( name="grpc.io/server/server_latency", description="Time between first byte of request received" " to last byte of response sent or terminal error.", unit=self.millisecond) - # The total number of server RPCs ever opened, including those that have not completed + # The total number of server RPCs ever opened, + # including those that have not completed self.grpc_server_started_rpcs = MeasureInt( name="grpc.io/server/started_rpcs", description="Number of started server RPCs.", @@ -161,11 +181,14 @@ def __init__(self): # Total bytes sent per method, recorded real-time as bytes are sent self.grpc_server_sent_bytes_per_method = MeasureFloat( name="grpc.io/server/sent_bytes_per_method", - description="Total bytes sent per method, recorded real-time as bytes are sent.", + description="Total bytes sent per method, recorded" + " real-time as bytes are sent.", unit=self.byte) - # Total bytes received per method, recorded real-time as bytes are received + # Total bytes received per method, recorded real-time as + # bytes are received self.grpc_server_received_bytes_per_method = MeasureFloat( name="grpc.io/server/received_bytes_per_method", - description="Total bytes received per method, recorded real-time as bytes are received.", + description="Total bytes received per method, recorded" + " real-time as bytes are received.", unit=self.byte) From f09e830831acdab4c0e08164665c16d74b2622b1 Mon Sep 17 00:00:00 2001 From: Anam Navied Date: Thu, 30 Apr 2020 16:02:45 -0400 Subject: [PATCH 05/11] fixed __init__.py pylint errors --- opencensus/grpc/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/opencensus/grpc/__init__.py b/opencensus/grpc/__init__.py index 03f05ce36..f5b0233a2 100755 --- a/opencensus/grpc/__init__.py +++ b/opencensus/grpc/__init__.py @@ -15,4 +15,3 @@ # import rpc_measure_constants # import rpc_view_constants - From 622dc7d8556448b57ae2571e31c6f6977df5ba88 Mon Sep 17 00:00:00 2001 From: Anam Navied Date: Thu, 30 Apr 2020 16:07:22 -0400 Subject: [PATCH 06/11] fixed rpc_m_c_test.py pylint errors --- opencensus/grpc/rpc_m_c_test.py | 83 ++++++++++++++++++++------------- 1 file changed, 51 insertions(+), 32 deletions(-) diff --git a/opencensus/grpc/rpc_m_c_test.py b/opencensus/grpc/rpc_m_c_test.py index 73310de55..3f8a37ea6 100644 --- a/opencensus/grpc/rpc_m_c_test.py +++ b/opencensus/grpc/rpc_m_c_test.py @@ -1,5 +1,4 @@ import unittest -# import rpc_measure_constants from opencensus.grpc import rpc_measure_constants @@ -56,38 +55,58 @@ def test_server_measures(self): """ tests the server measures """ - self.assertEqual(self.rpc_measure.grpc_server_received_messages_per_rpc.name, - "grpc.io/server/received_messages_per_rpc", - "grpc_server_received_messages_per_rpc not set properly") - self.assertEqual(self.rpc_measure.grpc_server_received_bytes_per_rpc.description, - "Total bytes received across all messages per RPC", - "grpc_server_received_bytes_per_rpc not set properly") - self.assertEqual(self.rpc_measure.grpc_server_sent_messages_per_rpc.unit, - "1", - "grpc_server_sent_messages_per_rpc not set properly") - self.assertEqual(self.rpc_measure.grpc_server_sent_bytes_per_rpc.name, - "grpc.io/server/sent_bytes_per_rpc", - "grpc_server_sent_bytes_per_rpc not set properly") - self.assertEqual(self.rpc_measure.grpc_server_server_latency.description, - "Time between first byte of request received to" - " last byte of response sent or terminal error.", - "grpc_server_server_latency not set properly") - self.assertEqual(self.rpc_measure.grpc_server_started_rpcs.unit, - "1", - "grpc_server_started_rpcs not set correctly") - self.assertEqual(self.rpc_measure.grpc_server_sent_messages_per_method.name, - "grpc.io/server/sent_messages_per_method", - "grpc_server_sent_messages_per_method not set correctly") - self.assertEqual(self.rpc_measure.grpc_server_received_messages_per_method.description, - "Total messages received per method.", - "grpc_server_received_messages_per_method not set correctly") - self.assertEqual(self.rpc_measure.grpc_server_sent_bytes_per_method.unit, - "by", - "grpc_server_sent_bytes_per_method not set correctly") - self.assertEqual(self.rpc_measure.grpc_server_received_bytes_per_method.name, - "grpc.io/server/received_bytes_per_method", - "grpc_server_received_bytes_per_method not set correctly") + self.assertEqual( + self.rpc_measure.grpc_server_received_messages_per_rpc.name, + "grpc.io/server/received_messages_per_rpc", + "grpc_server_received_messages_per_rpc not set properly") + + self.assertEqual( + self.rpc_measure.grpc_server_received_bytes_per_rpc.description, + "Total bytes received across all messages per RPC", + "grpc_server_received_bytes_per_rpc not set properly") + + self.assertEqual( + self.rpc_measure.grpc_server_sent_messages_per_rpc.unit, + "1", + "grpc_server_sent_messages_per_rpc not set properly") + + self.assertEqual( + self.rpc_measure.grpc_server_sent_bytes_per_rpc.name, + "grpc.io/server/sent_bytes_per_rpc", + "grpc_server_sent_bytes_per_rpc not set properly") + + self.assertEqual( + self.rpc_measure.grpc_server_server_latency.description, + "Time between first byte of request received to" + " last byte of response sent or terminal error.", + "grpc_server_server_latency not set properly") + + self.assertEqual( + self.rpc_measure.grpc_server_started_rpcs.unit, + "1", + "grpc_server_started_rpcs not set correctly") + + self.assertEqual( + self.rpc_measure.grpc_server_sent_messages_per_method.name, + "grpc.io/server/sent_messages_per_method", + "grpc_server_sent_messages_per_method not set correctly") + + self.assertEqual( + self.rpc_measure.grpc_server_received_messages_per_method. + description, + "Total messages received per method.", + "grpc_server_received_messages_per_method not set correctly") + + self.assertEqual( + self.rpc_measure.grpc_server_sent_bytes_per_method.unit, + "by", + "grpc_server_sent_bytes_per_method not set correctly") + self.assertEqual( + self.rpc_measure.grpc_server_received_bytes_per_method.name, + "grpc.io/server/received_bytes_per_method", + "grpc_server_received_bytes_per_method not set correctly") +TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT if __name__ == '__main__': unittest.main() From ea58ae2eed12960d0b530f653545d6d2b338ef37 Mon Sep 17 00:00:00 2001 From: Anam Navied Date: Thu, 30 Apr 2020 16:09:14 -0400 Subject: [PATCH 07/11] removed a typo --- opencensus/grpc/rpc_m_c_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opencensus/grpc/rpc_m_c_test.py b/opencensus/grpc/rpc_m_c_test.py index 3f8a37ea6..1ad920c7f 100644 --- a/opencensus/grpc/rpc_m_c_test.py +++ b/opencensus/grpc/rpc_m_c_test.py @@ -106,7 +106,7 @@ def test_server_measures(self): self.rpc_measure.grpc_server_received_bytes_per_method.name, "grpc.io/server/received_bytes_per_method", "grpc_server_received_bytes_per_method not set correctly") -TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT + if __name__ == '__main__': unittest.main() From e0d689fab4cbf45681f6669669819ffca3e6feec Mon Sep 17 00:00:00 2001 From: Anam Navied Date: Thu, 30 Apr 2020 16:48:37 -0400 Subject: [PATCH 08/11] fixed travis CI error --- opencensus/grpc/rpc_m_c_test.py | 1 + opencensus/grpc/rpc_measure_constants.py | 3 +-- opencensus/grpc/rpc_v_c_test.py | 1 + opencensus/grpc/rpc_view_constants.py | 12 ++++++------ 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/opencensus/grpc/rpc_m_c_test.py b/opencensus/grpc/rpc_m_c_test.py index 1ad920c7f..eb84ff99b 100644 --- a/opencensus/grpc/rpc_m_c_test.py +++ b/opencensus/grpc/rpc_m_c_test.py @@ -1,4 +1,5 @@ import unittest + from opencensus.grpc import rpc_measure_constants diff --git a/opencensus/grpc/rpc_measure_constants.py b/opencensus/grpc/rpc_measure_constants.py index ddae43c47..9e5177105 100644 --- a/opencensus/grpc/rpc_measure_constants.py +++ b/opencensus/grpc/rpc_measure_constants.py @@ -1,6 +1,5 @@ +from opencensus.stats.measure import MeasureFloat, MeasureInt from opencensus.tags import tag_key -from opencensus.stats.measure import MeasureInt -from opencensus.stats.measure import MeasureFloat """ Defines constants for collecting rpc stats diff --git a/opencensus/grpc/rpc_v_c_test.py b/opencensus/grpc/rpc_v_c_test.py index 874af7bb0..4f19c8e3e 100644 --- a/opencensus/grpc/rpc_v_c_test.py +++ b/opencensus/grpc/rpc_v_c_test.py @@ -1,4 +1,5 @@ import unittest + from opencensus.grpc import rpc_view_constants diff --git a/opencensus/grpc/rpc_view_constants.py b/opencensus/grpc/rpc_view_constants.py index 6d84a48aa..56f871017 100644 --- a/opencensus/grpc/rpc_view_constants.py +++ b/opencensus/grpc/rpc_view_constants.py @@ -1,10 +1,10 @@ -from opencensus.stats.aggregation import CountAggregation -from opencensus.stats.aggregation import SumAggregation -from opencensus.stats.aggregation import DistributionAggregation -from opencensus.stats import bucket_boundaries -from opencensus.stats import view from opencensus.grpc import rpc_measure_constants -# import rpc_measure_constants +from opencensus.stats import bucket_boundaries, view +from opencensus.stats.aggregation import ( + CountAggregation, + DistributionAggregation, + SumAggregation, +) """ Defines constants for exporting views on rpc stats From 7c0143ca29b08cf4cc9c64f3c69157caec0ff6d3 Mon Sep 17 00:00:00 2001 From: Anam Navied Date: Thu, 30 Apr 2020 17:26:15 -0400 Subject: [PATCH 09/11] fixed another travis CI error --- opencensus/grpc/rpc_measure_constants.py | 1 + opencensus/grpc/rpc_view_constants.py | 1 + 2 files changed, 2 insertions(+) diff --git a/opencensus/grpc/rpc_measure_constants.py b/opencensus/grpc/rpc_measure_constants.py index 9e5177105..5640c009e 100644 --- a/opencensus/grpc/rpc_measure_constants.py +++ b/opencensus/grpc/rpc_measure_constants.py @@ -1,6 +1,7 @@ from opencensus.stats.measure import MeasureFloat, MeasureInt from opencensus.tags import tag_key + """ Defines constants for collecting rpc stats """ diff --git a/opencensus/grpc/rpc_view_constants.py b/opencensus/grpc/rpc_view_constants.py index 56f871017..80fe12cc8 100644 --- a/opencensus/grpc/rpc_view_constants.py +++ b/opencensus/grpc/rpc_view_constants.py @@ -6,6 +6,7 @@ SumAggregation, ) + """ Defines constants for exporting views on rpc stats """ From 538be756f9432a22a64a8f46d8f1ba3f9a221444 Mon Sep 17 00:00:00 2001 From: Anam Navied Date: Fri, 1 May 2020 12:48:30 -0400 Subject: [PATCH 10/11] fixed rpc_m_c and rpc_v_c tests pylint errors --- opencensus/grpc/rpc_m_c_test.py | 87 ++++++++++++++++++++------------- opencensus/grpc/rpc_v_c_test.py | 3 +- 2 files changed, 56 insertions(+), 34 deletions(-) diff --git a/opencensus/grpc/rpc_m_c_test.py b/opencensus/grpc/rpc_m_c_test.py index eb84ff99b..42b22cc47 100644 --- a/opencensus/grpc/rpc_m_c_test.py +++ b/opencensus/grpc/rpc_m_c_test.py @@ -18,39 +18,60 @@ def test_client_measures(self): """ tests the client measures """ - self.assertEqual(self.rpc_measure.grpc_client_sent_messages_per_rpc.unit, - "1", - "grpc_client_sent_messages_per_rpc not set correctly on init") - self.assertEqual(self.rpc_measure.grpc_client_sent_bytes_per_rpc.description, - "Total bytes sent across all request messages per RPC", - "grpc_client_sent_bytes_per_rpc not set correctly on init") - self.assertEqual(self.rpc_measure.grpc_client_received_messages_per_rpc.name, - "grpc.io/client/received_messages_per_rpc", - "grpc_client_received_messages_per_rpc not set correctly on init") - self.assertEqual(self.rpc_measure.grpc_client_received_bytes_per_rpc.unit, - "by", - "grpc_client_received_bytes_per_rpc not set correctly upon init") - self.assertEqual(self.rpc_measure.grpc_client_roundtrip_latency.name, - "grpc.io/client/roundtrip_latency", - "grpc_client_roundtrip_latency not initialized correctly") - self.assertEqual(self.rpc_measure.grpc_client_server_latency.name, - "grpc.io/client/server_latency", - "grpc_client_server_latency not set properly") - self.assertEqual(self.rpc_measure.grpc_client_started_rpcs.description, - "Number of started client RPCs.", - "grpc_client_started_rpcs not set properly") - self.assertEqual(self.rpc_measure.grpc_client_sent_messages_per_method.unit, - "1", - "grpc_client_sent_messages_per_method not set properly") - self.assertEqual(self.rpc_measure.grpc_client_received_messages_per_method.name, - "grpc.io/client/received_messages_per_method", - "grpc_client_received_messages_per_method not set properly") - self.assertEqual(self.rpc_measure.grpc_client_sent_bytes_per_method.description, - "Total bytes sent per method, recorded real-time as bytes are sent.", - "grpc_client_sent_bytes_per_method not set properly") - self.assertEqual(self.rpc_measure.grpc_client_received_bytes_per_method.unit, - "by", - "grpc_client_received_bytes_per_method not set properly") + self.assertEqual( + self.rpc_measure.grpc_client_sent_messages_per_rpc.unit, + "1", + "grpc_client_sent_messages_per_rpc not set correctly on init") + + self.assertEqual( + self.rpc_measure.grpc_client_sent_bytes_per_rpc.description, + "Total bytes sent across all request messages per RPC", + "grpc_client_sent_bytes_per_rpc not set correctly on init") + + self.assertEqual( + self.rpc_measure.grpc_client_received_messages_per_rpc.name, + "grpc.io/client/received_messages_per_rpc", + "grpc_client_received_messages_per_rpc not set correctly on init") + + self.assertEqual( + self.rpc_measure.grpc_client_received_bytes_per_rpc.unit, + "by", + "grpc_client_received_bytes_per_rpc not set correctly upon init") + + self.assertEqual( + self.rpc_measure.grpc_client_roundtrip_latency.name, + "grpc.io/client/roundtrip_latency", + "grpc_client_roundtrip_latency not initialized correctly") + + self.assertEqual( + self.rpc_measure.grpc_client_server_latency.name, + "grpc.io/client/server_latency", + "grpc_client_server_latency not set properly") + + self.assertEqual( + self.rpc_measure.grpc_client_started_rpcs.description, + "Number of started client RPCs.", + "grpc_client_started_rpcs not set properly") + + self.assertEqual( + self.rpc_measure.grpc_client_sent_messages_per_method.unit, + "1", + "grpc_client_sent_messages_per_method not set properly") + + self.assertEqual( + self.rpc_measure.grpc_client_received_messages_per_method.name, + "grpc.io/client/received_messages_per_method", + "grpc_client_received_messages_per_method not set properly") + + self.assertEqual( + self.rpc_measure.grpc_client_sent_bytes_per_method.description, + "Total bytes sent per method, recorded real-time as bytes are sent.", + "grpc_client_sent_bytes_per_method not set properly") + + self.assertEqual( + self.rpc_measure.grpc_client_received_bytes_per_method.unit, + "by", + "grpc_client_received_bytes_per_method not set properly") def test_server_measures(self): """ diff --git a/opencensus/grpc/rpc_v_c_test.py b/opencensus/grpc/rpc_v_c_test.py index 4f19c8e3e..efab8a34b 100644 --- a/opencensus/grpc/rpc_v_c_test.py +++ b/opencensus/grpc/rpc_v_c_test.py @@ -59,7 +59,8 @@ def test_client_measures(self): "grpc_client_sent_messages_per_method_view not set correctly") self.assertEqual( - self.rpc_view.grpc_client_received_messages_per_method_view.description, + self.rpc_view.grpc_client_received_messages_per_method_view. + description, "Number of messages received", "grpc_client_received_messages_per_method_view not set correctly") From b22d3dcde48b881ef71b2abde44b3557ad26a756 Mon Sep 17 00:00:00 2001 From: Anam Navied Date: Fri, 1 May 2020 13:43:50 -0400 Subject: [PATCH 11/11] fixed last issue in rpc_m_c_test pylint --- opencensus/grpc/rpc_m_c_test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/opencensus/grpc/rpc_m_c_test.py b/opencensus/grpc/rpc_m_c_test.py index 42b22cc47..0688cd313 100644 --- a/opencensus/grpc/rpc_m_c_test.py +++ b/opencensus/grpc/rpc_m_c_test.py @@ -65,7 +65,8 @@ def test_client_measures(self): self.assertEqual( self.rpc_measure.grpc_client_sent_bytes_per_method.description, - "Total bytes sent per method, recorded real-time as bytes are sent.", + "Total bytes sent per method," + " recorded real-time as bytes are sent.", "grpc_client_sent_bytes_per_method not set properly") self.assertEqual(