Skip to content

Commit

Permalink
add EventSourceName override to durability provider, and rename event…
Browse files Browse the repository at this point in the history
…Id args in EtwSource to avoid clashes in linux logging (#37)
  • Loading branch information
sebastianburckhardt authored Apr 20, 2021
1 parent 3c5c586 commit 8be85ad
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 29 deletions.
2 changes: 2 additions & 0 deletions src/DurableTask.Netherite.AzureFunctions/NetheriteProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public NetheriteProvider(

public override TimeSpan MaximumDelayTime { get; set; } = TimeSpan.MaxValue;

public override string EventSourceName => "DurableTask-Netherite";

/// <inheritdoc/>
public async override Task<string> RetrieveSerializedEntityState(EntityId entityId, JsonSerializerSettings serializerSettings)
{
Expand Down
8 changes: 4 additions & 4 deletions src/DurableTask.Netherite/OrchestrationService/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ Task<ClientEvent> PerformRequestWithTimeoutAndCancellation(CancellationToken tok
internal class PendingRequest : TransportAbstraction.IDurabilityOrExceptionListener
{
readonly long requestId;
readonly EventId eventId;
readonly EventId partitionEventId;
readonly uint partitionId;
readonly Client client;
readonly (DateTime due, int id) timeoutKey;
Expand All @@ -158,11 +158,11 @@ internal class PendingRequest : TransportAbstraction.IDurabilityOrExceptionListe

public string RequestId => $"{Client.GetShortId(this.client.ClientId)}-{this.requestId}"; // matches EventId

public PendingRequest(long requestId, EventId eventId, uint partitionId, Client client, DateTime due, int timeoutId)
public PendingRequest(long requestId, EventId partitionEventId, uint partitionId, Client client, DateTime due, int timeoutId)
{
this.requestId = requestId;
this.partitionId = partitionId;
this.eventId = eventId;
this.partitionEventId = partitionEventId;
this.client = client;
this.timeoutKey = (due, timeoutId);
this.continuation = new TaskCompletionSource<ClientEvent>();
Expand Down Expand Up @@ -252,7 +252,7 @@ public void TryTimeout()
this.client.traceHelper.TraceTimerProgress($"firing ({this.timeoutKey.due:o},{this.timeoutKey.id})");
if (this.client.ResponseWaiters.TryRemove(this.requestId, out var pendingRequest))
{
this.client.traceHelper.TraceRequestTimeout(pendingRequest.eventId, pendingRequest.partitionId);
this.client.traceHelper.TraceRequestTimeout(pendingRequest.partitionEventId, pendingRequest.partitionId);
this.continuation.TrySetException(timeoutException);
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/DurableTask.Netherite/Tracing/ClientTraceHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,22 @@ public void TraceTimerProgress(string details)
}
}

public void TraceRequestTimeout(EventId eventId, uint partitionId)
public void TraceRequestTimeout(EventId partitionEventId, uint partitionId)
{
if (this.logLevelLimit <= LogLevel.Warning)
{
if (this.logger.IsEnabled(LogLevel.Warning))
{
this.logger.LogWarning("{client} Request {eventId} for partition {partitionId:D2} timed out", this.tracePrefix, eventId, partitionId);
this.logger.LogWarning("{client} Request {eventId} for partition {partitionId:D2} timed out", this.tracePrefix, partitionEventId, partitionId);
}
if (EtwSource.Log.IsEnabled())
{
EtwSource.Log.ClientRequestTimeout(this.account, this.taskHub, this.clientId, eventId.ToString(), (int) partitionId, TraceUtils.AppName, TraceUtils.ExtensionVersion);
EtwSource.Log.ClientRequestTimeout(this.account, this.taskHub, this.clientId, partitionEventId.ToString(), (int) partitionId, TraceUtils.AppName, TraceUtils.ExtensionVersion);
}
}
}

public void TraceSend(Event @event)
public void TraceSend(PartitionEvent @event)
{
if (this.logLevelLimit <= LogLevel.Debug)
{
Expand All @@ -97,12 +97,12 @@ public void TraceSend(Event @event)
}
if (EtwSource.Log.IsEnabled())
{
EtwSource.Log.ClientEventSent(this.account, this.taskHub, this.clientId, @event.EventIdString, @event.ToString(), TraceUtils.AppName, TraceUtils.ExtensionVersion);
EtwSource.Log.ClientSentEvent(this.account, this.taskHub, this.clientId, @event.EventIdString, @event.ToString(), TraceUtils.AppName, TraceUtils.ExtensionVersion);
}
}
}

public void TraceReceive(Event @event)
public void TraceReceive(ClientEvent @event)
{
if (this.logLevelLimit <= LogLevel.Debug)
{
Expand All @@ -112,7 +112,7 @@ public void TraceReceive(Event @event)
}
if (EtwSource.Log.IsEnabled())
{
EtwSource.Log.ClientEventReceived(this.account, this.taskHub, this.clientId, @event.EventIdString, @event.ToString(), TraceUtils.AppName, TraceUtils.ExtensionVersion);
EtwSource.Log.ClientReceivedEvent(this.account, this.taskHub, this.clientId, @event.EventIdString, @event.ToString(), TraceUtils.AppName, TraceUtils.ExtensionVersion);
}
}
}
Expand Down
36 changes: 18 additions & 18 deletions src/DurableTask.Netherite/Tracing/EtwSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ public void ClientTimerProgress(string Account, string TaskHub, Guid ClientId, s
}

[Event(217, Level = EventLevel.Warning, Version = 1)]
public void ClientRequestTimeout(string Account, string TaskHub, Guid ClientId, string EventId, int PartitionId, string AppName, string ExtensionVersion)
public void ClientRequestTimeout(string Account, string TaskHub, Guid ClientId, string PartitionEventId, int PartitionId, string AppName, string ExtensionVersion)
{
SetCurrentThreadActivityId(serviceInstanceId);
this.WriteEvent(217, Account, TaskHub, ClientId, EventId, PartitionId, AppName, ExtensionVersion);
this.WriteEvent(217, Account, TaskHub, ClientId, PartitionEventId, PartitionId, AppName, ExtensionVersion);
}

// ----- specific events relating to DurableTask concepts (TaskMessage, OrchestrationWorkItem, Instance)
Expand Down Expand Up @@ -170,61 +170,61 @@ public void InstanceUpdated(string Account, string TaskHub, int PartitionId, str
}

[Event(228, Level = EventLevel.Verbose, Version = 1)]
public void InstanceStatusFetched(string Account, string TaskHub, int PartitionId, string InstanceId, string ExecutionId, string status, string EventId, double LatencyMs, string AppName, string ExtensionVersion)
public void InstanceStatusFetched(string Account, string TaskHub, int PartitionId, string InstanceId, string ExecutionId, string status, string PartitionEventId, double LatencyMs, string AppName, string ExtensionVersion)
{
SetCurrentThreadActivityId(serviceInstanceId);
this.WriteEvent(228, Account, TaskHub, PartitionId, InstanceId, ExecutionId, status, EventId, LatencyMs, AppName, ExtensionVersion);
this.WriteEvent(228, Account, TaskHub, PartitionId, InstanceId, ExecutionId, status, PartitionEventId, LatencyMs, AppName, ExtensionVersion);
}

[Event(229, Level = EventLevel.Verbose, Version = 1)]
public void InstanceHistoryFetched(string Account, string TaskHub, int PartitionId, string InstanceId, string ExecutionId, int EventCount, int Episode, string EventId, double LatencyMs, string AppName, string ExtensionVersion)
public void InstanceHistoryFetched(string Account, string TaskHub, int PartitionId, string InstanceId, string ExecutionId, int EventCount, int Episode, string PartitionEventId, double LatencyMs, string AppName, string ExtensionVersion)
{
SetCurrentThreadActivityId(serviceInstanceId);
this.WriteEvent(229, Account, TaskHub, PartitionId, InstanceId, ExecutionId, EventCount, Episode, EventId, LatencyMs, AppName, ExtensionVersion);
this.WriteEvent(229, Account, TaskHub, PartitionId, InstanceId, ExecutionId, EventCount, Episode, PartitionEventId, LatencyMs, AppName, ExtensionVersion);
}

// ----- general event processing and statistics

[Event(240, Level = EventLevel.Informational, Version = 1)]
public void PartitionEventProcessed(string Account, string TaskHub, int PartitionId, long CommitLogPosition, string Category, string EventId, string EventInfo, long NextCommitLogPosition, long NextInputQueuePosition, double QueueLatencyMs, double FetchLatencyMs, double LatencyMs, bool IsReplaying, string AppName, string ExtensionVersion)
public void PartitionEventProcessed(string Account, string TaskHub, int PartitionId, long CommitLogPosition, string Category, string PartitionEventId, string EventInfo, long NextCommitLogPosition, long NextInputQueuePosition, double QueueLatencyMs, double FetchLatencyMs, double LatencyMs, bool IsReplaying, string AppName, string ExtensionVersion)
{
SetCurrentThreadActivityId(serviceInstanceId);
this.WriteEvent(240, Account, TaskHub, PartitionId, CommitLogPosition, Category, EventId, EventInfo, NextCommitLogPosition, NextInputQueuePosition, QueueLatencyMs, FetchLatencyMs, LatencyMs, IsReplaying, AppName, ExtensionVersion);
this.WriteEvent(240, Account, TaskHub, PartitionId, CommitLogPosition, Category, PartitionEventId, EventInfo, NextCommitLogPosition, NextInputQueuePosition, QueueLatencyMs, FetchLatencyMs, LatencyMs, IsReplaying, AppName, ExtensionVersion);
}

[Event(241, Level = EventLevel.Verbose, Version = 1)]
public void PartitionEventDetail(string Account, string TaskHub, int PartitionId, long CommitLogPosition, string EventId, string Details, string AppName, string ExtensionVersion)
public void PartitionEventDetail(string Account, string TaskHub, int PartitionId, long CommitLogPosition, string PartitionEventId, string Details, string AppName, string ExtensionVersion)
{
SetCurrentThreadActivityId(serviceInstanceId);
this.WriteEvent(241, Account, TaskHub, PartitionId, CommitLogPosition, EventId, Details, AppName, ExtensionVersion);
this.WriteEvent(241, Account, TaskHub, PartitionId, CommitLogPosition, PartitionEventId, Details, AppName, ExtensionVersion);
}

[Event(242, Level = EventLevel.Warning, Version = 1)]
public void PartitionEventWarning(string Account, string TaskHub, int PartitionId, long CommitLogPosition, string EventId, string Details, string AppName, string ExtensionVersion)
public void PartitionEventWarning(string Account, string TaskHub, int PartitionId, long CommitLogPosition, string PartitionEventId, string Details, string AppName, string ExtensionVersion)
{
SetCurrentThreadActivityId(serviceInstanceId);
this.WriteEvent(242, Account, TaskHub, PartitionId, CommitLogPosition, EventId, Details, AppName, ExtensionVersion);
this.WriteEvent(242, Account, TaskHub, PartitionId, CommitLogPosition, PartitionEventId, Details, AppName, ExtensionVersion);
}

[Event(243, Level = EventLevel.Verbose, Version = 1)]
public void ClientEventReceived(string Account, string TaskHub, Guid ClientId, string EventId, string EventInfo, string AppName, string ExtensionVersion)
public void ClientReceivedEvent(string Account, string TaskHub, Guid ClientId, string PartitionEventId, string EventInfo, string AppName, string ExtensionVersion)
{
SetCurrentThreadActivityId(serviceInstanceId);
this.WriteEvent(243, Account, TaskHub, ClientId, EventId, EventInfo, AppName, ExtensionVersion);
this.WriteEvent(243, Account, TaskHub, ClientId, PartitionEventId, EventInfo, AppName, ExtensionVersion);
}

[Event(244, Level = EventLevel.Verbose, Version = 1)]
public void ClientEventSent(string Account, string TaskHub, Guid ClientId, string EventId, string EventInfo, string AppName, string ExtensionVersion)
public void ClientSentEvent(string Account, string TaskHub, Guid ClientId, string PartitionEventId, string EventInfo, string AppName, string ExtensionVersion)
{
SetCurrentThreadActivityId(serviceInstanceId);
this.WriteEvent(244, Account, TaskHub, ClientId, EventId, EventInfo, AppName, ExtensionVersion);
this.WriteEvent(244, Account, TaskHub, ClientId, PartitionEventId, EventInfo, AppName, ExtensionVersion);
}

[Event(245, Level = EventLevel.Warning, Version = 1)]
public void PartitionOffloadDecision(string Account, string TaskHub, int PartitionId, long CommitLogPosition, string EventId, int ReportedLocalLoad, int Pending, int Backlog, int Remotes, string ReportedRemoteLoad, string AppName, string ExtensionVersion)
public void PartitionOffloadDecision(string Account, string TaskHub, int PartitionId, long CommitLogPosition, string PartitionEventId, int ReportedLocalLoad, int Pending, int Backlog, int Remotes, string ReportedRemoteLoad, string AppName, string ExtensionVersion)
{
SetCurrentThreadActivityId(serviceInstanceId);
this.WriteEvent(245, Account, TaskHub, PartitionId, CommitLogPosition, EventId, ReportedLocalLoad, Pending, Backlog, Remotes, ReportedRemoteLoad, AppName, ExtensionVersion);
this.WriteEvent(245, Account, TaskHub, PartitionId, CommitLogPosition, PartitionEventId, ReportedLocalLoad, Pending, Backlog, Remotes, ReportedRemoteLoad, AppName, ExtensionVersion);
}

[Event(246, Level = EventLevel.Informational, Version = 1)]
Expand Down

0 comments on commit 8be85ad

Please sign in to comment.