Created
February 15, 2019 20:09
-
-
Save ealsur/966c3d6fc1d865204332b739f749d885 to your computer and use it in GitHub Desktop.
Azure Cosmos DB + Functions Cookbook - monitoring
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
[FunctionName("Monitor")] | |
public static async Task Monitor( | |
[TimerTrigger("*/1 * * * * *", RunOnStartup = true)] TimerInfo timer, // Timer will trigger every 1 second, adjust CRON expression | |
[CosmosDB("%MonitoredDatabase%", "%MonitoredCollection%", ConnectionStringSetting = "CosmosDB")] DocumentClient monitoredCollectionClient, | |
[CosmosDB("%MonitoredDatabase%", "leases", ConnectionStringSetting = "CosmosDB")] DocumentClient leaseCollectionClient, | |
ILogger log) | |
{ | |
var estimator = GetRemainingWorkEstimator(monitoredCollectionClient, leaseCollectionClient); | |
var remainingWork = await estimator.GetEstimatedRemainingWork(); | |
// Send custom metric to App Insight | |
log.LogInformation(remainingWork.ToString()); | |
log.LogMetric("RemainingWork", remainingWork); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment