本文整理汇总了C#中DocumentDatabase.CreateMetrics方法的典型用法代码示例。如果您正苦于以下问题:C# DocumentDatabase.CreateMetrics方法的具体用法?C# DocumentDatabase.CreateMetrics怎么用?C# DocumentDatabase.CreateMetrics使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DocumentDatabase
的用法示例。
在下文中一共展示了DocumentDatabase.CreateMetrics方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateInfoPackageForDatabase
public static void CreateInfoPackageForDatabase(ZipArchive package, DocumentDatabase database, RequestManager requestManager, string zipEntryPrefix = null)
{
zipEntryPrefix = zipEntryPrefix ?? string.Empty;
var databaseName = database.Name;
if (string.IsNullOrWhiteSpace(databaseName))
databaseName = Constants.SystemDatabase;
var jsonSerializer = JsonExtensions.CreateDefaultJsonSerializer();
jsonSerializer.Formatting=Formatting.Indented;
if (database.StartupTasks.OfType<ReplicationTask>().Any())
{
var replication = package.CreateEntry(zipEntryPrefix + "replication.json", compressionLevel);
using (var statsStream = replication.Open())
using (var streamWriter = new StreamWriter(statsStream))
{
jsonSerializer.Serialize(streamWriter, ReplicationUtils.GetReplicationInformation(database));
streamWriter.Flush();
}
}
var sqlReplicationTask = database.StartupTasks.OfType<SqlReplicationTask>().FirstOrDefault();
if (sqlReplicationTask != null)
{
var replication = package.CreateEntry(zipEntryPrefix + "sql_replication.json", compressionLevel);
using (var statsStream = replication.Open())
using (var streamWriter = new StreamWriter(statsStream))
{
jsonSerializer.Serialize(streamWriter, sqlReplicationTask.Statistics);
streamWriter.Flush();
}
}
var stats = package.CreateEntry(zipEntryPrefix + "stats.json", compressionLevel);
using (var statsStream = stats.Open())
using (var streamWriter = new StreamWriter(statsStream))
{
jsonSerializer.Serialize(streamWriter, database.Statistics);
streamWriter.Flush();
}
var metrics = package.CreateEntry(zipEntryPrefix + "metrics.json", compressionLevel);
using (var metricsStream = metrics.Open())
using (var streamWriter = new StreamWriter(metricsStream))
{
jsonSerializer.Serialize(streamWriter, database.CreateMetrics());
streamWriter.Flush();
}
var logs = package.CreateEntry(zipEntryPrefix + "logs.csv", compressionLevel);
using (var logsStream = logs.Open())
using (var streamWriter = new StreamWriter(logsStream))
{
var target = LogManager.GetTarget<DatabaseMemoryTarget>();
if (target == null) streamWriter.WriteLine("DatabaseMemoryTarget was not registered in the log manager, logs are not available");
else
{
var boundedMemoryTarget = target[databaseName];
var log = boundedMemoryTarget.GeneralLog;
streamWriter.WriteLine("time,logger,level,message,exception");
foreach (var logEvent in log)
{
streamWriter.WriteLine("{0:O},{1},{2},{3},{4}", logEvent.TimeStamp, logEvent.LoggerName, logEvent.Level, logEvent.FormattedMessage, logEvent.Exception);
}
}
streamWriter.Flush();
}
var config = package.CreateEntry(zipEntryPrefix + "config.json", compressionLevel);
using (var configStream = config.Open())
using (var streamWriter = new StreamWriter(configStream))
using (var jsonWriter = new JsonTextWriter(streamWriter) { Formatting = Formatting.Indented })
{
GetConfigForDebug(database).WriteTo(jsonWriter, new EtagJsonConverter());
jsonWriter.Flush();
}
var indexes = package.CreateEntry(zipEntryPrefix + "indexes.json", compressionLevel);
using (var indexesStream = indexes.Open())
using (var streamWriter = new StreamWriter(indexesStream))
{
jsonSerializer.Serialize(streamWriter, database.IndexDefinitionStorage.IndexDefinitions.ToDictionary(x => x.Key, x => x.Value));
streamWriter.Flush();
}
var currentlyIndexing = package.CreateEntry(zipEntryPrefix + "currently-indexing.json", compressionLevel);
using (var currentlyIndexingStream = currentlyIndexing.Open())
//.........这里部分代码省略.........