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

Use sent_at instead of sentry_timestamp to reduce clock skew #1690

Merged
merged 18 commits into from Jul 22, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -6,7 +6,8 @@

- Improve timestamp precision of transactions and spans ([#1680](https://github.com/getsentry/sentry-dotnet/pull/1680))
- Flatten AggregateException ([#1672](https://github.com/getsentry/sentry-dotnet/pull/1672))
- NOTE: This can affect grouping. You can keep the original behavior by setting the option `KeepAggregateException` to `true`.
- NOTE: This can affect grouping. You can keep the original behavior by setting the option `KeepAggregateException` to `true`.
- Add sent_at to event ([#1690](https://github.com/getsentry/sentry-dotnet/pull/1690))

### Features

Expand Down
1 change: 1 addition & 0 deletions src/Sentry/SentryEvent.cs
Expand Up @@ -229,6 +229,7 @@ public void WriteTo(Utf8JsonWriter writer, IDiagnosticLogger? logger)
writer.WriteStringDictionaryIfNotEmpty("modules", _modules!);
writer.WriteSerializable("event_id", EventId, logger);
writer.WriteString("timestamp", Timestamp);
writer.WriteString("sent_at", DateTimeOffset.UtcNow);
writer.WriteSerializableIfNotNull("logentry", Message, logger);
writer.WriteStringIfNotWhiteSpace("logger", Logger);
writer.WriteString("platform", Constants.Platform);
Expand Down
@@ -0,0 +1,90 @@
{
breadcrumbs: [
{
message: crumb,
timestamp: Date_MaxValue
},
{
category: category,
data: {
data-key: data-value
},
level: warning,
message: message,
timestamp: Date_MaxValue,
type: type
}
],
contexts: {
.NET Framework: {
.NET Framework: "v2.0.50727", "v3.0", "v3.5",
.NET Framework Client: "v4.8", "v4.0.0.0",
.NET Framework Full: "v4.8"
},
context_key: context_value
},
debug_meta: {
images: [
{
debug_id: Guid_1,
type: wasm
}
]
},
environment: environment,
event_id: Guid_2,
exception: {
values: [
{
value: exception_value
}
]
},
extra: {
extra_key: extra_value
},
fingerprint: [
fingerprint
],
level: fatal,
logentry: {
formatted: structured_message,
message: message
},
logger: logger,
modules: {
module_key: module_value
},
platform: csharp,
release: release,
request: {
method: POST
},
sdk: {
name: SDK-test,
packages: [
{
name: name,
version: version
}
],
version: 1.1.1
},
sent_at: DateTime_1,
server_name: server_name,
tags: {
tag_key: tag_value
},
threads: {
values: [
{
crashed: true
}
]
},
timestamp: Date_MaxValue,
transaction: transaction,
user: {
id: user-id
}
}
5 changes: 4 additions & 1 deletion test/Sentry.Tests/Protocol/SentryEventTests.cs
@@ -1,9 +1,10 @@
namespace Sentry.Tests.Protocol;

[UsesVerify]
public class SentryEventTests
{
[Fact]
public void SerializeObject_AllPropertiesSetToNonDefault_SerializesValidObject()
public async Task SerializeObject_AllPropertiesSetToNonDefault_SerializesValidObject()
{
var ex = new Exception("exception message");
var timestamp = DateTimeOffset.MaxValue;
Expand Down Expand Up @@ -59,6 +60,8 @@ public void SerializeObject_AllPropertiesSetToNonDefault_SerializesValidObject()

var actualString = sut.ToJsonString();

await VerifyJson(actualString);

actualString.Should().Contain(
"\"debug_meta\":{\"images\":[" +
"{\"type\":\"wasm\",\"debug_id\":\"900f7d1b868432939de4457478f34720\"}" +
Expand Down