Skip to content

Commit

Permalink
Fix invalid logging time (#472)
Browse files Browse the repository at this point in the history
* skyapm dotnet 对接日志记录

* feat : Remove MSLogger, implementation SkyApm.ILogger, Add Extension for AddPushSkyApmLogger

* feat : add a copyright header to all new files

* feat : add a copyright header to all new files

* feat :  Clean up code format

* feat : Modify log docking, separate the docking log item.

* feat : Fix invalid logging time

Co-authored-by: 吴晟 Wu Sheng <[email protected]>
  • Loading branch information
KawhiWei and wu-sheng authored May 4, 2022
1 parent 9da12cb commit 8cfe8e8
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/SkyApm.Abstractions/Tracing/Segments/LoggerContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*
*/

using System;
using System.Collections.Generic;

namespace SkyApm.Tracing.Segments
Expand All @@ -25,5 +26,7 @@ public class LoggerContext
public Dictionary<string, object> Logs { get; set; }

public SegmentContext SegmentContext { get; set; }

public long Date { get; set; }
}
}
2 changes: 2 additions & 0 deletions src/SkyApm.Abstractions/Transport/LoggerRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@ public class LoggerRequest
public Dictionary<string, object> Logs { get; set; }

public SegmentRequest SegmentRequest { get; set; }

public long Date { get; set; }
}
}
1 change: 1 addition & 0 deletions src/SkyApm.Core/Transport/LoggerContextContextMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public LoggerRequest Map(LoggerContext loggerContext)
{
Logs = loggerContext.Logs,
SegmentRequest = segmentRequest,
Date = loggerContext.Date,
};
}
}
Expand Down
1 change: 1 addition & 0 deletions src/SkyApm.Diagnostics.Logging/SkyApmLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ private void SendLog(string logLevel, string message)
{
Logs = logs,
SegmentContext = _entrySegmentContextAccessor.Context,
Date = DateTimeOffset.UtcNow.Offset.Ticks
};
_skyApmLogDispatcher.Dispatch(logContext);
}
Expand Down
2 changes: 1 addition & 1 deletion src/SkyApm.Transport.Grpc/V8/LoggerReporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public async Task ReportAsync(IReadOnlyCollection<LoggerRequest> loggerRequests,
TraceSegmentId = loggerRequest.SegmentRequest.Segment.SegmentId,
//SpanId=item.Segment
},
Timestamp = DateTimeOffset.UtcNow.Ticks,
Timestamp = loggerRequest.Date,
Service = loggerRequest.SegmentRequest.Segment.ServiceId,
ServiceInstance = loggerRequest.SegmentRequest.Segment.ServiceInstanceId,
Endpoint = "",
Expand Down

0 comments on commit 8cfe8e8

Please sign in to comment.