-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cap max string length to 512 characters
This is the limit for most Sentry attributes (the server will discard everything past this), and this should help us stay under the 200 KB event size limit. See #20
- Loading branch information
1 parent
faa9231
commit 9075d59
Showing
6 changed files
with
96 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
open Base | ||
open Sexplib.Conv | ||
|
||
type t = string [@@deriving sexp_of] | ||
|
||
let unwrap t = | ||
Util.cap_string_length t | ||
|
||
let wrap t = t | ||
|
||
let%test_unit "round-trip" = | ||
let expect = "adsfasdfsdsd131" in | ||
expect | ||
|> wrap | ||
|> unwrap | ||
|> [%test_result: string] ~expect | ||
|
||
let%test_unit "long string round trip" = | ||
let input = String.init 1000 ~f:(Fn.const 'a') in | ||
let expect = String.sub ~pos:0 ~len:512 input in | ||
input | ||
|> wrap | ||
|> unwrap | ||
|> [%test_result: string] ~expect |
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,8 @@ | ||
(** The Sentry API discards anything after the first 512 characters of most | ||
string attributes, so avoid sending them in the first place, so we can | ||
also avoid sending events that are too big. | ||
https://docs.sentry.io/accounts/quotas/#attributes-limits *) | ||
type t = string [@@deriving sexp_of] | ||
|
||
val wrap : string -> t | ||
val unwrap : t -> string |
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