-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Network Error Logging: backend part (#55135)
Sentry backend part of the NEL ([Network Error Logging](https://developer.mozilla.org/en-US/docs/Web/HTTP/Network_Error_Logging)) implementation. * Added a new `nel` event type and interface * Special logic for metadata and culprit generation To be deployed after merging Relay part (getsentry/relay#2421) and releasing `sentry-relay` python package. --------- Co-authored-by: mdtro <matthew.trostel@sentry.io> Co-authored-by: Joris Bayer <joris.bayer@sentry.io>
- Loading branch information
1 parent
d593b51
commit 685d98c
Showing
13 changed files
with
137 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from .base import DefaultEvent | ||
|
||
|
||
class NelEvent(DefaultEvent): | ||
key = "nel" | ||
|
||
def extract_metadata(self, data): | ||
metadata = super().extract_metadata(data) | ||
metadata["uri"] = data.get("request").get("url") | ||
return metadata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
__all__ = "Nel" | ||
|
||
from sentry.interfaces.base import Interface | ||
|
||
|
||
class Nel(Interface): | ||
""" | ||
A browser NEL report. | ||
""" | ||
|
||
title = "NEL report" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from sentry.eventtypes.nel import NelEvent | ||
from sentry.testutils.cases import TestCase | ||
from sentry.testutils.silo import region_silo_test | ||
|
||
|
||
@region_silo_test(stable=True) | ||
class NelEventTest(TestCase): | ||
def test_get_metadata(self): | ||
inst = NelEvent() | ||
data = { | ||
"logentry": {"formatted": "connection / tcp.refused"}, | ||
"request": {"url": "https://example.com/"}, | ||
} | ||
assert inst.get_metadata(data) == { | ||
"title": "connection / tcp.refused", | ||
"uri": "https://example.com/", | ||
} |