Closed Yafaa closed 1 year ago
I am using Azure function to send metric to Azure Application Insights , after running a request opencensus-ext-azure keep sending the same metric
Steps to reproduce. Running this piece of code inside an azure function and send a request
from opencensus.ext.azure import metrics_exporter from opencensus.stats import aggregation as aggregation_module from opencensus.stats import measure as measure_module from opencensus.stats import stats as stats_module from opencensus.stats import view as view_module from opencensus.tags import tag_map as tag_map_module import os def build_sum_aggregation_metric(measure_name, measure_description, measure_unit, view_name, view_description, metric_value): stats = stats_module.stats view_manager = stats.view_manager stats_recorder = stats.stats_recorder MEASURE = measure_module.MeasureInt(measure_name, measure_description, measure_unit) VIEW = view_module.View(view_name, view_description, [], MEASURE, aggregation_module.SumAggregation()) instrumentation_key = os.getenv("APP_INSIGHTS_KEY") exporter = metrics_exporter.new_metrics_exporter( connection_string=instrumentation_key ) view_manager.register_exporter(exporter) view_manager.register_view(VIEW) mmap = stats_recorder.new_measurement_map() tmap = tag_map_module.TagMap() mmap.measure_int_put(MEASURE, metric_value) mmap.record(tmap) build_sum_aggregation_metric("metric 1", "metric 1", "metric 1", "metric 1", "metric 1", 30)
What is the expected behavior? The metric should be sent only 1 time.
What is the actual behavior? The metric are sent infinite time until I stop the function.
@Yafaa
This is by design. Metrics are meant to track and collect values over a period of time. After every export interval (default 15s), the current metric value will be exported.
I am using Azure function to send metric to Azure Application Insights , after running a request opencensus-ext-azure keep sending the same metric
Steps to reproduce. Running this piece of code inside an azure function and send a request
What is the expected behavior? The metric should be sent only 1 time.
What is the actual behavior? The metric are sent infinite time until I stop the function.