-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged PR 693228: Forward rocksdb logs to Kusto
This is a manual rollback of [this rollback](https://dev.azure.com/mseng/Domino/_git/BuildXL.Internal/pullrequest/689216).
- Loading branch information
1 parent
7bc194b
commit e1e04f9
Showing
8 changed files
with
133 additions
and
26 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
55 changes: 55 additions & 0 deletions
55
Public/Src/Cache/ContentStore/Distributed/RocksDbUtilities.cs
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 (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using BuildXL.Cache.ContentStore.Distributed.NuCache; | ||
using BuildXL.Cache.ContentStore.Tracing; | ||
using BuildXL.Cache.ContentStore.Tracing.Internal; | ||
using BuildXL.Engine.Cache.KeyValueStores; | ||
using RocksDbSharp; | ||
|
||
namespace BuildXL.Cache.ContentStore.Distributed.MetadataService | ||
{ | ||
internal static class RocksDbUtilities | ||
{ | ||
public static void ConfigureRocksDbTracingIfNeeded( | ||
OperationContext context, | ||
RocksDbContentLocationDatabaseConfiguration configuration, | ||
RocksDbStoreConfiguration settings, | ||
Tracer tracer, | ||
string componentName) | ||
{ | ||
if (!configuration.OpenReadOnly && configuration.RocksDbTracingLevel is { } tracingLevel) | ||
{ | ||
// Tracing operations only for non-readonly database. | ||
// We don't know if the current instance will be on a master machine, but the configuration is happening | ||
// before such decision is made. | ||
var traceLineHandler = CreateLogLineCallback(context, tracer, componentName: componentName); | ||
settings.LogLevel = tracingLevel; | ||
settings.HandleLogMessage = traceLineHandler; | ||
} | ||
} | ||
|
||
public static LogLineCallback CreateLogLineCallback(OperationContext context, Tracer tracer, string componentName) | ||
{ | ||
const string operation = "RocksDbTrace"; | ||
var rocksDbContext = context.CreateNested(componentName, caller: operation).TracingContext; | ||
return (logLevel, message) => | ||
{ | ||
Action<string> targetMethod = logLevel switch | ||
{ | ||
LogLevel.Debug => (string msg) => tracer.Debug(rocksDbContext, msg, operation: operation), | ||
LogLevel.Info => (string msg) => tracer.Info(rocksDbContext, msg, operation: operation), | ||
LogLevel.Warn => (string msg) => tracer.Warning(rocksDbContext, msg, operation: operation), | ||
LogLevel.Error => (string msg) => tracer.Error(rocksDbContext, msg, operation: operation), | ||
LogLevel.Fatal => (string msg) => tracer.Error(rocksDbContext, msg, operation: operation), | ||
LogLevel.Header => (string msg) => tracer.Info(rocksDbContext, msg, operation: operation), | ||
// Do nothing in case of an error | ||
_ => (string msg) => { } | ||
}; | ||
|
||
targetMethod(message); | ||
}; | ||
} | ||
} | ||
} |
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