Skip to content
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

Fix invalid logging time #472

Merged
merged 9 commits into from
May 4, 2022
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