Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update metrics docs to specify setting export_interval to 60s #1193

Merged
merged 3 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion contrib/opencensus-ext-azure/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

## Unreleased

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

## 1.1.8

Expand Down
24 changes: 16 additions & 8 deletions contrib/opencensus-ext-azure/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,11 @@ The **Azure Monitor Metrics Exporter** allows you to export metrics to `Azure Mo

def main():
# Enable metrics
# Set the interval in seconds in which you want to send metrics
exporter = metrics_exporter.new_metrics_exporter(connection_string='InstrumentationKey=<your-instrumentation-key-here>')
# Set the interval in seconds to 60s, which is the time interval application insights
# aggregates your metrics
exporter = metrics_exporter.new_metrics_exporter(
connection_string='InstrumentationKey=<your-instrumentation-key-here>'
)
view_manager.register_exporter(exporter)

view_manager.register_view(CARROTS_VIEW)
Expand All @@ -176,7 +179,6 @@ The **Azure Monitor Metrics Exporter** allows you to export metrics to `Azure Mo

mmap.measure_int_put(CARROTS_MEASURE, 1000)
mmap.record(tmap)
# Default export interval is every 15.0s

print("Done recording metrics")

Expand All @@ -196,10 +198,13 @@ The exporter also includes a set of performance counters that are exported to Az
from opencensus.ext.azure import metrics_exporter

def main():
# All you need is the next line. You can disable performance counters by
# Performance counters are sent by default. You can disable performance counters by
# passing in enable_standard_metrics=False into the constructor of
# new_metrics_exporter()
_exporter = metrics_exporter.new_metrics_exporter(connection_string='InstrumentationKey=<your-instrumentation-key-here>')
_exporter = metrics_exporter.new_metrics_exporter(
connection_string='InstrumentationKey=<your-instrumentation-key-here>',
export_interval=60,
)

for i in range(100):
print(psutil.virtual_memory())
Expand Down Expand Up @@ -256,8 +261,12 @@ Modifying Metrics

def main():
# Enable metrics
# Set the interval in seconds in which you want to send metrics
exporter = metrics_exporter.new_metrics_exporter(connection_string='InstrumentationKey=<your-instrumentation-key-here>')
# Set the interval in seconds to 60s, which is the time interval application insights
# aggregates your metrics
exporter = metrics_exporter.new_metrics_exporter(
connection_string='InstrumentationKey=<your-instrumentation-key-here>',
export_interval=60,
)
exporter.add_telemetry_processor(callback_function)
view_manager.register_exporter(exporter)

Expand All @@ -267,7 +276,6 @@ Modifying Metrics

mmap.measure_int_put(CARROTS_MEASURE, 1000)
mmap.record(tmap)
# Default export interval is every 15.0s

print("Done recording metrics")

Expand Down
14 changes: 8 additions & 6 deletions contrib/opencensus-ext-azure/examples/metrics/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os

from opencensus.ext.azure import metrics_exporter
from opencensus.stats import aggregation as aggregation_module
from opencensus.stats import measure as measure_module
Expand All @@ -34,12 +36,12 @@


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

view_manager.register_view(CARROTS_VIEW)
Expand Down
40 changes: 0 additions & 40 deletions contrib/opencensus-ext-azure/examples/metrics/standard.py

This file was deleted.

13 changes: 7 additions & 6 deletions contrib/opencensus-ext-azure/examples/metrics/sum.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import time

from opencensus.ext.azure import metrics_exporter
Expand All @@ -36,12 +37,12 @@


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

view_manager.register_view(NUM_REQUESTS_VIEW)
Expand Down