This repository has been archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #104 from lzchen/v0.4b.x
- Loading branch information
Showing
37 changed files
with
1,417 additions
and
593 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,34 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
from opentelemetry import metrics | ||
from opentelemetry import metrics, trace | ||
from opentelemetry.sdk.metrics import MeterProvider | ||
from opentelemetry.sdk.metrics.export.controller import PushController | ||
from opentelemetry.sdk.trace import TracerProvider | ||
|
||
from azure_monitor import AzureMonitorMetricsExporter | ||
from azure_monitor.sdk.auto_collection import AutoCollection | ||
from azure_monitor.sdk.auto_collection import ( | ||
AutoCollection, | ||
AzureMetricsSpanProcessor, | ||
) | ||
|
||
# Add Span Processor to get metrics about traces | ||
trace.set_tracer_provider(TracerProvider()) | ||
tracer = trace.get_tracer_provider().get_tracer(__name__) | ||
span_processor = AzureMetricsSpanProcessor() | ||
trace.get_tracer_provider().add_span_processor(span_processor) | ||
|
||
metrics.set_meter_provider(MeterProvider()) | ||
meter = metrics.get_meter(__name__) | ||
exporter = AzureMonitorMetricsExporter( | ||
connection_string="InstrumentationKey=<INSTRUMENTATION KEY HERE>" | ||
) | ||
controller = PushController(meter, exporter, 5) | ||
|
||
testing_label_set = {"environment": "testing"} | ||
|
||
# Automatically collect standard metrics | ||
auto_collection = AutoCollection(meter=meter, labels=testing_label_set) | ||
auto_collection = AutoCollection( | ||
meter=meter, labels=testing_label_set, span_processor=span_processor | ||
) | ||
|
||
# To configure a separate export interval specific for standard metrics | ||
# meter_standard = metrics.get_meter(__name__ + "_standard") | ||
# controller _standard = PushController(meter_standard, exporter, 30) | ||
# _auto_collection = AutoCollection(meter=meter_standard, label_set=testing_label_set) | ||
metrics.get_meter_provider().start_pipeline(meter, exporter, 2) | ||
|
||
input("Press any key to exit...") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.