-
Notifications
You must be signed in to change notification settings - Fork 1
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
using system diagnostics for logging #59
base: main
Are you sure you want to change the base?
Changes from 1 commit
0219976
0f4845e
247ec3d
79bcbcb
afb7ea1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
|
@@ -52,6 +53,11 @@ public Client CreateClient() | |
{ | ||
httpClient.DefaultRequestHeaders.Add(header.Key, header.Value); | ||
} | ||
|
||
// system diagnostics logging configuration | ||
testClient.TraceSource.Listeners.Add(new ConsoleTraceListener()); | ||
testClient.TraceSource.Switch.ShouldTrace(TraceEventType.Verbose); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note to think about: How should we parameterize the verbosity.. here we hardcode it to verbose which is fine to start, but is that always useful |
||
|
||
return testClient; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Net.Http; | ||
using System.Text; | ||
|
@@ -37,11 +38,13 @@ public class Client | |
private const string PathOAuthClients = "/oauth-clients"; | ||
private readonly Rest _rest; | ||
private readonly Context _context; | ||
private readonly TraceSource _traceSource; | ||
|
||
public Client(Context context) | ||
{ | ||
_context = context; | ||
_rest = new Rest(context); | ||
_traceSource = new TraceSource("RAI", SourceLevels.All); | ||
_rest = new Rest(context, _traceSource); | ||
} | ||
|
||
public HttpClient HttpClient | ||
|
@@ -50,13 +53,19 @@ public HttpClient HttpClient | |
set { _rest.HttpClient = value; } | ||
} | ||
|
||
public TraceSource TraceSource | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to research - right now we think we can only do file-based configuration in .NET framework, but we need it in .NET core, how should we resolve this so programmatic configuration is not required? Possibilities: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. People complains about the missing ability to configure diagnostics traces using app.config or a similar configuration file, dotnet/runtime#23937 |
||
{ | ||
get { return _traceSource; } | ||
} | ||
|
||
public Task<Database> CreateDatabaseAsync(string database, string engine) | ||
{ | ||
return CreateDatabaseAsync(database, engine, false); | ||
} | ||
|
||
public async Task<Database> CreateDatabaseAsync(string database, string engine, bool overwrite) | ||
{ | ||
_traceSource.TraceEvent(TraceEventType.Verbose, 0, $"creating database {database}"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can just use some 100-offset number for now There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
var mode = CreateMode(null, overwrite); | ||
var transaction = new Transaction(_context.Region, database, engine, mode); | ||
await _rest.PostAsync(MakeUrl(PathTransaction), transaction.Payload(null), null, transaction.QueryParams()); | ||
|
@@ -111,6 +120,7 @@ public async Task<DeleteDatabaseResponse> DeleteDatabaseAsync(string database) | |
|
||
public async Task<Engine> CreateEngineAsync(string engine, string size = "XS") | ||
{ | ||
_traceSource.TraceEvent(TraceEventType.Verbose, 0, $"creating engine {engine} with size {size}"); | ||
var data = new Dictionary<string, string> | ||
{ | ||
{ "region", _context.Region }, | ||
|
@@ -532,6 +542,7 @@ public async Task<TransactionAsyncResult> ExecuteAsync( | |
if (rsp is string s) | ||
{ | ||
var txn = Json<TransactionAsyncCompactResponse>.Deserialize(s); | ||
_traceSource.TraceEvent(TraceEventType.Verbose, 0, $"transaction id {txn.Id}"); | ||
return new TransactionAsyncResult(txn, new List<ArrowRelation>(), null, new List<object>()); | ||
} | ||
|
||
|
@@ -741,6 +752,7 @@ private TransactionAsyncResult ReadTransactionAsyncResults(List<TransactionAsync | |
} | ||
|
||
var transactionResult = Json<TransactionAsyncCompactResponse>.Deserialize(_rest.ReadString(transaction.Data)); | ||
_traceSource.TraceEvent(TraceEventType.Verbose, 0, $"transaction id {transactionResult.Id}"); | ||
var metadataProto = _rest.ReadMetadataProtobuf(metadata.Data); | ||
|
||
List<object> problemsResult = null; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with this in principle, if we want to conform the logs with XUnit's logger (might be good for timing data and conforming format) we can create a new trace listener here, take the ITestOutputHelper in the ctor and use that to log out trace events
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done