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

Commit fd064f4

Browse files
authored
Update metrics docs to specify setting export_interval to 60s (#1193)
1 parent b85e476 commit fd064f4

File tree

5 files changed

+34
-61
lines changed

5 files changed

+34
-61
lines changed

contrib/opencensus-ext-azure/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
## Unreleased
44

5-
- Fix export of exception information in traces
5+
- Fix export of exception information in traces
66
([#1187](https://github.com/census-instrumentation/opencensus-python/pull/1187))
7+
- Modify metrics exporter to include setting export interval to 60s
8+
([#1193](https://github.com/census-instrumentation/opencensus-python/pull/1193))
79

810
## 1.1.8
911

contrib/opencensus-ext-azure/README.rst

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,11 @@ The **Azure Monitor Metrics Exporter** allows you to export metrics to `Azure Mo
166166
167167
def main():
168168
# Enable metrics
169-
# Set the interval in seconds in which you want to send metrics
170-
exporter = metrics_exporter.new_metrics_exporter(connection_string='InstrumentationKey=<your-instrumentation-key-here>')
169+
# Set the interval in seconds to 60s, which is the time interval application insights
170+
# aggregates your metrics
171+
exporter = metrics_exporter.new_metrics_exporter(
172+
connection_string='InstrumentationKey=<your-instrumentation-key-here>'
173+
)
171174
view_manager.register_exporter(exporter)
172175
173176
view_manager.register_view(CARROTS_VIEW)
@@ -176,7 +179,6 @@ The **Azure Monitor Metrics Exporter** allows you to export metrics to `Azure Mo
176179
177180
mmap.measure_int_put(CARROTS_MEASURE, 1000)
178181
mmap.record(tmap)
179-
# Default export interval is every 15.0s
180182
181183
print("Done recording metrics")
182184
@@ -196,10 +198,13 @@ The exporter also includes a set of performance counters that are exported to Az
196198
from opencensus.ext.azure import metrics_exporter
197199
198200
def main():
199-
# All you need is the next line. You can disable performance counters by
201+
# Performance counters are sent by default. You can disable performance counters by
200202
# passing in enable_standard_metrics=False into the constructor of
201203
# new_metrics_exporter()
202-
_exporter = metrics_exporter.new_metrics_exporter(connection_string='InstrumentationKey=<your-instrumentation-key-here>')
204+
_exporter = metrics_exporter.new_metrics_exporter(
205+
connection_string='InstrumentationKey=<your-instrumentation-key-here>',
206+
export_interval=60,
207+
)
203208
204209
for i in range(100):
205210
print(psutil.virtual_memory())
@@ -256,8 +261,12 @@ Modifying Metrics
256261
257262
def main():
258263
# Enable metrics
259-
# Set the interval in seconds in which you want to send metrics
260-
exporter = metrics_exporter.new_metrics_exporter(connection_string='InstrumentationKey=<your-instrumentation-key-here>')
264+
# Set the interval in seconds to 60s, which is the time interval application insights
265+
# aggregates your metrics
266+
exporter = metrics_exporter.new_metrics_exporter(
267+
connection_string='InstrumentationKey=<your-instrumentation-key-here>',
268+
export_interval=60,
269+
)
261270
exporter.add_telemetry_processor(callback_function)
262271
view_manager.register_exporter(exporter)
263272
@@ -267,7 +276,6 @@ Modifying Metrics
267276
268277
mmap.measure_int_put(CARROTS_MEASURE, 1000)
269278
mmap.record(tmap)
270-
# Default export interval is every 15.0s
271279
272280
print("Done recording metrics")
273281

contrib/opencensus-ext-azure/examples/metrics/simple.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import os
16+
1517
from opencensus.ext.azure import metrics_exporter
1618
from opencensus.stats import aggregation as aggregation_module
1719
from opencensus.stats import measure as measure_module
@@ -34,12 +36,12 @@
3436

3537

3638
def main():
37-
# Enable metrics
38-
# Set the interval in seconds in which you want to send metrics
39-
# TODO: you need to specify the instrumentation key in a connection string
40-
# and place it in the APPLICATIONINSIGHTS_CONNECTION_STRING
41-
# environment variable.
42-
exporter = metrics_exporter.new_metrics_exporter()
39+
# Enable metrics. Set the interval in seconds to 60s, which is the time
40+
# interval application insights aggregates your metrics
41+
exporter = metrics_exporter.new_metrics_exporter(
42+
connection_string=os.environ["APPLICATIONINSIGHTS_CONNECTION_STRING"],
43+
export_interval=60,
44+
)
4345
view_manager.register_exporter(exporter)
4446

4547
view_manager.register_view(CARROTS_VIEW)

contrib/opencensus-ext-azure/examples/metrics/standard.py

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

contrib/opencensus-ext-azure/examples/metrics/sum.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import os
1516
import time
1617

1718
from opencensus.ext.azure import metrics_exporter
@@ -36,12 +37,12 @@
3637

3738

3839
def main():
39-
# Enable metrics
40-
# Set the interval in seconds in which you want to send metrics
41-
# TODO: you need to specify the instrumentation key in a connection string
42-
# and place it in the APPLICATIONINSIGHTS_CONNECTION_STRING
43-
# environment variable.
44-
exporter = metrics_exporter.new_metrics_exporter()
40+
# Enable metrics. Set the interval in seconds to 60s, which is the time
41+
# interval application insights aggregates your metrics
42+
exporter = metrics_exporter.new_metrics_exporter(
43+
connection_string=os.environ["APPLICATIONINSIGHTS_CONNECTION_STRING"],
44+
export_interval=60,
45+
)
4546
view_manager.register_exporter(exporter)
4647

4748
view_manager.register_view(NUM_REQUESTS_VIEW)

0 commit comments

Comments
 (0)