Skip to content

Commit

Permalink
Changing direction on trace.
Browse files Browse the repository at this point in the history
  • Loading branch information
NTDLS committed Jan 4, 2025
1 parent 61d6aed commit 722fb65
Show file tree
Hide file tree
Showing 10 changed files with 1 addition and 132 deletions.
5 changes: 0 additions & 5 deletions NTDLS.Katzebase.Engine/EngineCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using NTDLS.Katzebase.Engine.Health;
using NTDLS.Katzebase.Engine.Interactions.Management;
using NTDLS.Katzebase.Engine.Threading;
using NTDLS.Katzebase.Engine.Trace;
using NTDLS.Katzebase.Shared;
using NTDLS.Semaphore;
using System.Diagnostics;
Expand All @@ -19,7 +18,6 @@ public class EngineCore
internal CacheManager Cache;
internal HeartbeatManager Heartbeat;
internal KatzebaseSettings Settings;
internal TraceManager Trace;

public PolicyManager Policy;
public SchemaManager Schemas;
Expand Down Expand Up @@ -106,9 +104,6 @@ public EngineCore(KatzebaseSettings settings)
LogManager.Information("Initializing heartbeat manager.");
Heartbeat = new HeartbeatManager(this);

LogManager.Information("Initializing trace manager.");
Trace = new TraceManager(this);

Schemas.PostInitialization();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ public DocumentAPIHandlers(EngineCore core)

public KbQueryDocumentSampleReply DocumentSample(RmContext context, KbQueryDocumentSample param)
{
using var trace = _core.Trace.CreateTracker(TraceType.DocumentSample, context.ConnectionId);
var session = _core.Sessions.GetSession(context.ConnectionId);
trace.SetSession(session);

#if DEBUG
Thread.CurrentThread.Name = $"KbAPI:{session.ProcessId}:{param.GetType().Name}";
Expand Down Expand Up @@ -75,9 +73,7 @@ public KbQueryDocumentSampleReply DocumentSample(RmContext context, KbQueryDocum
/// <returns></returns>
public KbQueryDocumentListReply DocumentList(RmContext context, KbQueryDocumentList param)
{
using var trace = _core.Trace.CreateTracker(TraceType.DocumentList, context.ConnectionId);
var session = _core.Sessions.GetSession(context.ConnectionId);
trace.SetSession(session);

#if DEBUG
Thread.CurrentThread.Name = $"KbAPI:{session.ProcessId}:{param.GetType().Name}";
Expand Down Expand Up @@ -121,9 +117,7 @@ public KbQueryDocumentListReply DocumentList(RmContext context, KbQueryDocumentL
/// <exception cref="KbObjectNotFoundException"></exception>
public KbQueryDocumentStoreReply DocumentStore(RmContext context, KbQueryDocumentStore param)
{
using var trace = _core.Trace.CreateTracker(TraceType.DocumentStore, context.ConnectionId);
var session = _core.Sessions.GetSession(context.ConnectionId);
trace.SetSession(session);

#if DEBUG
Thread.CurrentThread.Name = $"KbAPI:{session.ProcessId}:{param.GetType().Name}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ public IndexAPIHandlers(EngineCore core)

public KbQueryIndexGetReply IndexGet(RmContext context, KbQueryIndexGet param)
{
using var trace = _core.Trace.CreateTracker(TraceType.IndexGet, context.ConnectionId);
var session = _core.Sessions.GetSession(context.ConnectionId);
trace.SetSession(session);

#if DEBUG
Thread.CurrentThread.Name = $"KbAPI:{session.ProcessId}:{param.GetType().Name}";
Expand Down Expand Up @@ -68,9 +66,7 @@ public KbQueryIndexGetReply IndexGet(RmContext context, KbQueryIndexGet param)

public KbQueryIndexListReply IndexList(RmContext context, KbQueryIndexList param)
{
using var trace = _core.Trace.CreateTracker(TraceType.IndexList, context.ConnectionId);
var session = _core.Sessions.GetSession(context.ConnectionId);
trace.SetSession(session);

#if DEBUG
Thread.CurrentThread.Name = $"KbAPI:{session.ProcessId}:{param.GetType().Name}";
Expand Down Expand Up @@ -109,9 +105,7 @@ public KbQueryIndexListReply IndexList(RmContext context, KbQueryIndexList param

public KbQueryIndexExistsReply IndexExist(RmContext context, KbQueryIndexExists param)
{
using var trace = _core.Trace.CreateTracker(TraceType.IndexExist, context.ConnectionId);
var session = _core.Sessions.GetSession(context.ConnectionId);
trace.SetSession(session);

#if DEBUG
Thread.CurrentThread.Name = $"KbAPI:{session.ProcessId}:{param.GetType().Name}";
Expand Down Expand Up @@ -144,9 +138,7 @@ public KbQueryIndexExistsReply IndexExist(RmContext context, KbQueryIndexExists

public KbQueryIndexCreateReply IndexCreate(RmContext context, KbQueryIndexCreate param)
{
using var trace = _core.Trace.CreateTracker(TraceType.IndexCreate, context.ConnectionId);
var session = _core.Sessions.GetSession(context.ConnectionId);
trace.SetSession(session);

#if DEBUG
Thread.CurrentThread.Name = $"KbAPI:{session.ProcessId}:{param.GetType().Name}";
Expand Down Expand Up @@ -177,9 +169,7 @@ public KbQueryIndexCreateReply IndexCreate(RmContext context, KbQueryIndexCreate

public KbQueryIndexRebuildReply IndexRebuild(RmContext context, KbQueryIndexRebuild param)
{
using var trace = _core.Trace.CreateTracker(TraceType.IndexRebuild, context.ConnectionId);
var session = _core.Sessions.GetSession(context.ConnectionId);
trace.SetSession(session);

#if DEBUG
Thread.CurrentThread.Name = $"KbAPI:{session.ProcessId}:{param.GetType().Name}";
Expand Down Expand Up @@ -208,9 +198,7 @@ public KbQueryIndexRebuildReply IndexRebuild(RmContext context, KbQueryIndexRebu

public KbQueryIndexDropReply IndexDrop(RmContext context, KbQueryIndexDrop param)
{
using var trace = _core.Trace.CreateTracker(TraceType.IndexDrop, context.ConnectionId);
var session = _core.Sessions.GetSession(context.ConnectionId);
trace.SetSession(session);

#if DEBUG
Thread.CurrentThread.Name = $"KbAPI:{session.ProcessId}:{param.GetType().Name}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ public QueryAPIHandlers(EngineCore core)

public KbQueryQueryExplainPlanReply ExecuteExplainPlan(RmContext context, KbQueryQueryExplainPlan param)
{
using var trace = _core.Trace.CreateTracker(TraceType.ExecuteExplainPlan, context.ConnectionId);
var session = _core.Sessions.GetSession(context.ConnectionId);
trace.SetSession(session);

#if DEBUG
Thread.CurrentThread.Name = $"KbAPI:{session.ProcessId}:{param.GetType().Name}";
Expand Down Expand Up @@ -65,9 +63,7 @@ public KbQueryQueryExplainPlanReply ExecuteExplainPlan(RmContext context, KbQuer

public KbQueryQueryExplainOperationReply ExecuteExplainOperation(RmContext context, KbQueryQueryExplainOperation param)
{
using var trace = _core.Trace.CreateTracker(TraceType.ExecuteExplainOperation, context.ConnectionId);
var session = _core.Sessions.GetSession(context.ConnectionId);
trace.SetSession(session);

#if DEBUG
Thread.CurrentThread.Name = $"KbAPI:{session.ProcessId}:{param.GetType().Name}";
Expand Down Expand Up @@ -99,9 +95,7 @@ public KbQueryQueryExplainOperationReply ExecuteExplainOperation(RmContext conte

public KbQueryProcedureExecuteReply ExecuteStatementProcedure(RmContext context, KbQueryProcedureExecute param)
{
using var trace = _core.Trace.CreateTracker(TraceType.ExecuteStatementProcedure, context.ConnectionId);
var session = _core.Sessions.GetSession(context.ConnectionId);
trace.SetSession(session);

#if DEBUG
Thread.CurrentThread.Name = $"KbAPI:{session.ProcessId}:{param.GetType().Name}";
Expand All @@ -124,9 +118,7 @@ public KbQueryProcedureExecuteReply ExecuteStatementProcedure(RmContext context,

public KbQueryQueryExecuteQueryReply ExecuteStatementQuery(RmContext context, KbQueryQueryExecuteQuery param)
{
using var trace = _core.Trace.CreateTracker(TraceType.ExecuteStatementQuery, context.ConnectionId);
var session = _core.Sessions.GetSession(context.ConnectionId);
trace.SetSession(session);

#if DEBUG
Thread.CurrentThread.Name = $"KbAPI:{session.ProcessId}:{param.GetType().Name}";
Expand Down Expand Up @@ -158,9 +150,7 @@ public KbQueryQueryExecuteQueryReply ExecuteStatementQuery(RmContext context, Kb

public KbQueryQueryExecuteNonQueryReply ExecuteStatementNonQuery(RmContext context, KbQueryQueryExecuteNonQuery param)
{
using var trace = _core.Trace.CreateTracker(TraceType.ExecuteStatementNonQuery, context.ConnectionId);
var session = _core.Sessions.GetSession(context.ConnectionId);
trace.SetSession(session);

#if DEBUG
Thread.CurrentThread.Name = $"KbAPI:{session.ProcessId}:{param.GetType().Name}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ public SchemaAPIHandlers(EngineCore core)

public KbQuerySchemaListReply ListSchemas(RmContext context, KbQuerySchemaList param)
{
using var trace = _core.Trace.CreateTracker(TraceType.ListSchemas, context.ConnectionId);
var session = _core.Sessions.GetSession(context.ConnectionId);
trace.SetSession(session);

#if DEBUG
Thread.CurrentThread.Name = $"KbAPI:{session.ProcessId}:{param.GetType().Name}";
Expand Down Expand Up @@ -79,9 +77,7 @@ public KbQuerySchemaListReply ListSchemas(RmContext context, KbQuerySchemaList p

public KbQuerySchemaFieldSampleReply SchemaFieldSample(RmContext context, KbQuerySchemaFieldSample param)
{
using var trace = _core.Trace.CreateTracker(TraceType.SchemaFieldSample, context.ConnectionId);
var session = _core.Sessions.GetSession(context.ConnectionId);
trace.SetSession(session);

#if DEBUG
Thread.CurrentThread.Name = $"KbAPI:{session.ProcessId}:{param.GetType().Name}";
Expand Down Expand Up @@ -128,9 +124,7 @@ public KbQuerySchemaFieldSampleReply SchemaFieldSample(RmContext context, KbQuer
/// <param name="schemaPath"></param>
public KbQuerySchemaCreateReply CreateSchema(RmContext context, KbQuerySchemaCreate param)
{
using var trace = _core.Trace.CreateTracker(TraceType.CreateSchema, context.ConnectionId);
var session = _core.Sessions.GetSession(context.ConnectionId);
trace.SetSession(session);

#if DEBUG
Thread.CurrentThread.Name = $"KbAPI:{session.ProcessId}:{param.GetType().Name}";
Expand Down Expand Up @@ -173,9 +167,7 @@ public KbQuerySchemaCreateReply CreateSchema(RmContext context, KbQuerySchemaCre
/// <param name="schemaPath"></param>
public KbQuerySchemaExistsReply DoesSchemaExist(RmContext context, KbQuerySchemaExists param)
{
using var trace = _core.Trace.CreateTracker(TraceType.DoesSchemaExist, context.ConnectionId);
var session = _core.Sessions.GetSession(context.ConnectionId);
trace.SetSession(session);

#if DEBUG
Thread.CurrentThread.Name = $"KbAPI:{session.ProcessId}:{param.GetType().Name}";
Expand Down Expand Up @@ -226,9 +218,7 @@ public KbQuerySchemaExistsReply DoesSchemaExist(RmContext context, KbQuerySchema
/// <param name="schema"></param>
public KbQuerySchemaDropReply DropSchema(RmContext context, KbQuerySchemaDrop param)
{
using var trace = _core.Trace.CreateTracker(TraceType.DropSchema, context.ConnectionId);
var session = _core.Sessions.GetSession(context.ConnectionId);
trace.SetSession(session);

#if DEBUG
Thread.CurrentThread.Name = $"KbAPI:{session.ProcessId}:{param.GetType().Name}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ public KbQueryServerStartSessionReply StartSession(RmContext context, KbQuerySer
{
SessionState? session = null;

using var trace = _core.Trace.CreateTracker(TraceType.SessionStart, context.ConnectionId);

#if DEBUG
Thread.CurrentThread.Name = $"KbAPI:{param.GetType().Name}";
LogManager.Debug(Thread.CurrentThread.Name);
Expand Down Expand Up @@ -65,9 +63,6 @@ public KbQueryServerStartSessionReply StartSession(RmContext context, KbQuerySer
ServerTimeUTC = DateTime.UtcNow
};

trace.SetSession(session);
trace.Result = TraceResult.Success;

return apiResults;
}
#endif
Expand All @@ -85,7 +80,6 @@ public KbQueryServerStartSessionReply StartSession(RmContext context, KbQuerySer
LogManager.Debug($"Logged in user [{param.Username}].");

session = _core.Sessions.CreateSession(context.ConnectionId, param.Username, param.ClientName);
trace.SetSession(session);
#if DEBUG
Thread.CurrentThread.Name = $"KbAPI:{session.ProcessId}:{param.GetType().Name}";
LogManager.Debug(Thread.CurrentThread.Name);
Expand All @@ -97,8 +91,6 @@ public KbQueryServerStartSessionReply StartSession(RmContext context, KbQuerySer
ServerTimeUTC = DateTime.UtcNow
};

trace.Result = TraceResult.Success;

return apiResults;
}

Expand All @@ -113,10 +105,7 @@ public KbQueryServerStartSessionReply StartSession(RmContext context, KbQuerySer

public KbQueryServerCloseSessionReply CloseSession(RmContext context, KbQueryServerCloseSession param)
{
using var trace = _core.Trace.CreateTracker(TraceType.SessionClose, context.ConnectionId);

var session = _core.Sessions.GetSession(context.ConnectionId);
trace.SetSession(session);

#if DEBUG
Thread.CurrentThread.Name = $"KbAPI:{session.ProcessId}:{param.GetType().Name}";
Expand All @@ -128,8 +117,6 @@ public KbQueryServerCloseSessionReply CloseSession(RmContext context, KbQuerySer

var apiResults = new KbQueryServerCloseSessionReply();

trace.Result = TraceResult.Success;

return apiResults;
}
catch (Exception ex)
Expand All @@ -147,10 +134,8 @@ public void Heartbeat(RmContext context, KbNotifySessionHeartbeat param)

public KbQueryServerTerminateProcessReply TerminateSession(RmContext context, KbQueryServerTerminateProcess param)
{
using var trace = _core.Trace.CreateTracker(TraceType.SessionTerminate, context.ConnectionId);

var session = _core.Sessions.GetSession(context.ConnectionId);
trace.SetSession(session);

#if DEBUG
Thread.CurrentThread.Name = $"KbAPI:{session.ProcessId}:{param.GetType().Name}";
LogManager.Debug(Thread.CurrentThread.Name);
Expand All @@ -161,8 +146,6 @@ public KbQueryServerTerminateProcessReply TerminateSession(RmContext context, Kb

var apiResult = new KbQueryServerTerminateProcessReply();

trace.Result = TraceResult.Success;

return apiResult;
}
catch (Exception ex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ public TransactionAPIHandlers(EngineCore core)

public KbQueryTransactionBeginReply Begin(RmContext context, KbQueryTransactionBegin param)
{
using var trace = _core.Trace.CreateTracker(TraceType.TransactionBegin, context.ConnectionId);
var session = _core.Sessions.GetSession(context.ConnectionId);
trace.SetSession(session);

#if DEBUG
Thread.CurrentThread.Name = $"KbAPI:{session.ProcessId}:{param.GetType().Name}";
Expand All @@ -52,9 +50,7 @@ public KbQueryTransactionBeginReply Begin(RmContext context, KbQueryTransactionB

public KbQueryTransactionCommitReply Commit(RmContext context, KbQueryTransactionCommit param)
{
using var trace = _core.Trace.CreateTracker(TraceType.TransactionCommit, context.ConnectionId);
var session = _core.Sessions.GetSession(context.ConnectionId);
trace.SetSession(session);

#if DEBUG
Thread.CurrentThread.Name = $"KbAPI:{session.ProcessId}:{param.GetType().Name}";
Expand All @@ -76,9 +72,7 @@ public KbQueryTransactionCommitReply Commit(RmContext context, KbQueryTransactio

public KbQueryTransactionRollbackReply Rollback(RmContext context, KbQueryTransactionRollback param)
{
using var trace = _core.Trace.CreateTracker(TraceType.TransactionRollback, context.ConnectionId);
var session = _core.Sessions.GetSession(context.ConnectionId);
trace.SetSession(session);

#if DEBUG
Thread.CurrentThread.Name = $"KbAPI:{session.ProcessId}:{param.GetType().Name}";
Expand Down
3 changes: 0 additions & 3 deletions NTDLS.Katzebase.Engine/NTDLS.Katzebase.Engine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@
<EmbeddedResource Include="Scripts\CreateRole.kbs" />
<EmbeddedResource Include="Scripts\CreateAccount.kbs" />
</ItemGroup>
<ItemGroup>
<None Include="Trace\TraceTracker.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CoreCLR-NCalc" Version="3.1.253" />
<PackageReference Include="NTDLS.DelegateThreadPooling" Version="1.5.10" />
Expand Down
24 changes: 0 additions & 24 deletions NTDLS.Katzebase.Engine/Trace/TraceManager.cs

This file was deleted.

38 changes: 0 additions & 38 deletions NTDLS.Katzebase.Engine/Trace/TraceTracker.cs

This file was deleted.

0 comments on commit 722fb65

Please sign in to comment.