-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
891 additions
and
201 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,4 +33,4 @@ | |
except Exception: | ||
logger.exception('Captured an exception.', extra=properties) | ||
|
||
input("...") | ||
input("...") |
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 |
---|---|---|
|
@@ -23,4 +23,4 @@ | |
logger.addHandler(AzureLogHandler()) | ||
logger.warning('Hello, World!') | ||
|
||
input("...") | ||
input("...") |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -23,3 +23,4 @@ | |
|
||
with tracer.span(name='foo'): | ||
print('Hello, World!') | ||
input(...) |
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
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
55 changes: 55 additions & 0 deletions
55
.../opencensus-ext-azure/opencensus/ext/azure/metrics_exporter/heartbeat_metrics/__init__.py
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Copyright 2020, OpenCensus Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import threading | ||
|
||
from opencensus.ext.azure.metrics_exporter import MetricsExporter | ||
from opencensus.ext.azure.metrics_exporter.heartbeat_metrics.heartbeat import ( | ||
HeartbeatMetric, | ||
) | ||
from opencensus.metrics import transport | ||
from opencensus.metrics.export.metric_producer import MetricProducer | ||
|
||
_HEARTBEAT_METRICS = None | ||
_HEARTBEAT_LOCK = threading.Lock() | ||
|
||
|
||
def enable_heartbeat_metrics(connection_string, ikey): | ||
with _HEARTBEAT_LOCK: | ||
# Only start heartbeat if did not exist before | ||
global _HEARTBEAT_METRICS # pylint: disable=global-statement | ||
if _HEARTBEAT_METRICS is None: | ||
exporter = MetricsExporter( | ||
connection_string=connection_string, | ||
instrumentation_key=ikey, | ||
export_interval=900.0, # Send every 15 minutes | ||
) | ||
producer = AzureHeartbeatMetricsProducer() | ||
_HEARTBEAT_METRICS = producer | ||
exporter.exporter_thread = \ | ||
transport.get_exporter_thread([_HEARTBEAT_METRICS], | ||
exporter, | ||
exporter.options.export_interval) | ||
|
||
|
||
class AzureHeartbeatMetricsProducer(MetricProducer): | ||
"""Implementation of the producer of heartbeat metrics. | ||
Includes Azure attach rate metrics, implemented using gauges. | ||
""" | ||
def __init__(self): | ||
self._heartbeat = HeartbeatMetric() | ||
|
||
def get_metrics(self): | ||
return self._heartbeat.get_metrics() |
Oops, something went wrong.