Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Commit 86d5bd7

Browse files
authored
Remove dependencies/sec from performance counters for Azure (#922)
1 parent 07cb5f0 commit 86d5bd7

File tree

5 files changed

+10
-159
lines changed

5 files changed

+10
-159
lines changed

contrib/opencensus-ext-azure/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## Unreleased
44

5+
- Remove dependency rate from standard metrics
6+
([#903](https://github.com/census-instrumentation/opencensus-python/pull/903))
7+
58
## 1.0.3
69
Released 2020-06-17
710

contrib/opencensus-ext-azure/README.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,10 @@ The **Azure Monitor Metrics Exporter** allows you to export metrics to `Azure Mo
178178
if __name__ == "__main__":
179179
main()
180180
181-
Standard Metrics
182-
################
181+
Performance counters
182+
####################
183183

184-
The exporter also includes a set of standard metrics that are exported to Azure Monitor by default.
184+
The exporter also includes a set of performance counters that are exported to Azure Monitor by default.
185185

186186
.. code:: python
187187
@@ -191,7 +191,7 @@ The exporter also includes a set of standard metrics that are exported to Azure
191191
from opencensus.ext.azure import metrics_exporter
192192
193193
def main():
194-
# All you need is the next line. You can disable standard metrics by
194+
# All you need is the next line. You can disable performance counters by
195195
# passing in enable_standard_metrics=False into the constructor of
196196
# new_metrics_exporter()
197197
_exporter = metrics_exporter.new_metrics_exporter(connection_string='InstrumentationKey=<your-instrumentation-key-here>')
@@ -205,13 +205,12 @@ The exporter also includes a set of standard metrics that are exported to Azure
205205
if __name__ == "__main__":
206206
main()
207207
208-
Below is a list of standard metrics that are currently available:
208+
Below is a list of performance counters that are currently available:
209209

210210
- Available Memory (bytes)
211211
- CPU Processor Time (percentage)
212212
- Incoming Request Rate (per second)
213213
- Incoming Request Average Execution Time (milliseconds)
214-
- Outgoing Request Rate (per second)
215214
- Process CPU Usage (percentage)
216215
- Process Private Bytes (bytes)
217216

contrib/opencensus-ext-azure/opencensus/ext/azure/metrics_exporter/standard_metrics/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
from opencensus.ext.azure.metrics_exporter.standard_metrics.cpu import (
1616
ProcessorTimeMetric,
1717
)
18-
from opencensus.ext.azure.metrics_exporter.standard_metrics.http_dependency import ( # noqa E501
19-
DependencyRateMetric,
20-
)
2118
from opencensus.ext.azure.metrics_exporter.standard_metrics.http_requests import ( # noqa E501
2219
RequestsAvgExecutionMetric,
2320
RequestsRateMetric,
@@ -34,7 +31,6 @@
3431

3532
# List of standard metrics to track
3633
STANDARD_METRICS = [AvailableMemoryMetric,
37-
DependencyRateMetric,
3834
ProcessCPUMetric,
3935
ProcessMemoryMetric,
4036
ProcessorTimeMetric,

contrib/opencensus-ext-azure/opencensus/ext/azure/metrics_exporter/standard_metrics/http_dependency.py

Lines changed: 0 additions & 92 deletions
This file was deleted.

contrib/opencensus-ext-azure/tests/test_azure_standard_metrics.py

Lines changed: 2 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import requests
2121

2222
from opencensus.ext.azure.metrics_exporter import standard_metrics
23-
from opencensus.trace import execution_context
2423

2524
if sys.version_info < (3,):
2625
from BaseHTTPServer import HTTPServer
@@ -33,10 +32,8 @@
3332

3433
class TestStandardMetrics(unittest.TestCase):
3534
def setUp(self):
36-
standard_metrics.http_dependency.dependency_map.clear()
3735
standard_metrics.http_requests.requests_map.clear()
3836
requests.Session.request = ORIGINAL_FUNCTION
39-
standard_metrics.http_dependency.ORIGINAL_REQUEST = ORIGINAL_FUNCTION
4037
standard_metrics.http_requests.ORIGINAL_CONSTRUCTOR = ORIGINAL_CONS
4138

4239
@mock.patch('opencensus.ext.azure.metrics_exporter'
@@ -50,12 +47,12 @@ def test_producer_get_metrics(self):
5047
producer = standard_metrics.AzureStandardMetricsProducer()
5148
metrics = producer.get_metrics()
5249

53-
self.assertEqual(len(metrics), 7)
50+
self.assertEqual(len(metrics), 6)
5451

5552
def test_register_metrics(self):
5653
registry = standard_metrics.register_metrics()
5754

58-
self.assertEqual(len(registry.get_metrics()), 7)
55+
self.assertEqual(len(registry.get_metrics()), 6)
5956

6057
def test_get_available_memory_metric(self):
6158
metric = standard_metrics.AvailableMemoryMetric()
@@ -144,58 +141,6 @@ def test_get_process_cpu_usage_exception(self, logger_mock):
144141

145142
logger_mock.exception.assert_called()
146143

147-
def test_dependency_patch(self):
148-
map = standard_metrics.http_dependency.dependency_map
149-
standard_metrics.http_dependency.ORIGINAL_REQUEST = lambda x: None
150-
session = requests.Session()
151-
execution_context.set_is_exporter(False)
152-
result = standard_metrics.http_dependency.dependency_patch(session)
153-
154-
self.assertEqual(map['count'], 1)
155-
self.assertIsNone(result)
156-
157-
def test_dependency_patch_exporter_thread(self):
158-
map = standard_metrics.http_dependency.dependency_map
159-
standard_metrics.http_dependency.ORIGINAL_REQUEST = lambda x: None
160-
session = mock.Mock()
161-
execution_context.set_is_exporter(True)
162-
result = standard_metrics.http_dependency.dependency_patch(session)
163-
164-
self.assertIsNone(map.get('count'))
165-
self.assertIsNone(result)
166-
167-
def test_get_dependency_rate_metric(self):
168-
metric = standard_metrics.DependencyRateMetric()
169-
gauge = metric()
170-
171-
self.assertEqual(gauge.descriptor.name,
172-
'\\ApplicationInsights\\Dependency Calls/Sec')
173-
174-
def test_get_dependency_rate_first_time(self):
175-
rate = standard_metrics.DependencyRateMetric.get_value()
176-
177-
self.assertEqual(rate, 0)
178-
179-
@mock.patch('opencensus.ext.azure.metrics_exporter'
180-
'.standard_metrics.http_dependency.time')
181-
def test_get_dependency_rate(self, time_mock):
182-
time_mock.time.return_value = 100
183-
standard_metrics.http_dependency.dependency_map['last_time'] = 98
184-
standard_metrics.http_dependency.dependency_map['count'] = 4
185-
rate = standard_metrics.DependencyRateMetric.get_value()
186-
187-
self.assertEqual(rate, 2)
188-
189-
@mock.patch('opencensus.ext.azure.metrics_exporter'
190-
'.standard_metrics.http_dependency.time')
191-
def test_get_dependency_rate_error(self, time_mock):
192-
time_mock.time.return_value = 100
193-
standard_metrics.http_dependency.dependency_map['last_result'] = 5
194-
standard_metrics.http_dependency.dependency_map['last_time'] = 100
195-
result = standard_metrics.DependencyRateMetric.get_value()
196-
197-
self.assertEqual(result, 5)
198-
199144
def test_request_patch(self):
200145
map = standard_metrics.http_requests.requests_map
201146
func = mock.Mock()

0 commit comments

Comments
 (0)