-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Introduce enable live metrics to distro #35566
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
6f33e54
add live metrics to distro
lzchen 33d7d22
docstring
lzchen 1fe4034
lint
lzchen 1bc37b7
lint
lzchen f3d8f10
Update _configure.py
lzchen 8367b8a
Update _configure.py
lzchen 0af2302
default
lzchen 0de60a9
Update _configure.py
lzchen a07de6c
typing
lzchen 04b1de1
lint
lzchen 6c06302
Update _configure.py
lzchen b2896ce
lint
lzchen 0392bc1
Update _configure.py
lzchen 2c2c35f
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-python …
lzchen 3a683e8
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-python …
lzchen 75fae7d
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-python …
lzchen 2480421
Update CHANGELOG.md
lzchen 58c0bff
default
lzchen df3088f
spell
lzchen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
37 changes: 37 additions & 0 deletions
37
sdk/monitor/azure-monitor-opentelemetry/samples/metrics/live.py
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. | ||
| """ | ||
| This example shows how configure live metrics to be enabled. It sets up a minimal example of sending dependency, | ||
| trace and exception telemetry to demonstrate the capabilities and collection set of live metrics. | ||
| """ | ||
| import logging | ||
| import requests | ||
| import time | ||
|
|
||
| from azure.monitor.opentelemetry import configure_azure_monitor | ||
| from opentelemetry import trace | ||
|
|
||
| from opentelemetry.sdk.resources import Resource | ||
|
|
||
| configure_azure_monitor( | ||
| resource=Resource.create({ | ||
| "service.name": "live_metrics_service", | ||
| "service.instance.id": "qp_instance_id", | ||
| }), | ||
| logger_name=__name__, | ||
| enable_live_metrics=True, # Enable live metrics configuration | ||
| ) | ||
|
|
||
| tracer = trace.get_tracer(__name__) | ||
| logger = logging.getLogger(__name__) | ||
|
|
||
| while True: | ||
|
lzchen marked this conversation as resolved.
|
||
| with tracer.start_as_current_span("parent"): | ||
| logger.warning("sending request") | ||
| response = requests.get("https://azure.microsoft.com/", timeout=5) | ||
| try: | ||
| val = 1 / 0 | ||
| print(val) | ||
| except ZeroDivisionError: | ||
| logger.error("Error: Division by zero", stack_info=True, exc_info=True) | ||
| time.sleep(2) | ||
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.