From 95b9e8b1865567a20eadf7205a314213fdc97372 Mon Sep 17 00:00:00 2001 From: mattiasdrp Date: Mon, 16 Sep 2024 23:20:25 +0200 Subject: [PATCH 1/6] Ppx profiler: Raise an error when a ppx has a wrong action If `[@profiler.action]` is encountered but `action` is unknown, instead of silently doing nothing, raise an error --- src/lib_ppx_profiler/error.ml | 9 +++++++++ src/lib_ppx_profiler/error.mli | 1 + src/lib_ppx_profiler/rewriter.ml | 18 ++++++++++++++---- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/lib_ppx_profiler/error.ml b/src/lib_ppx_profiler/error.ml index 4b504ccaa3b1..e0378bc0b3ff 100644 --- a/src/lib_ppx_profiler/error.ml +++ b/src/lib_ppx_profiler/error.ml @@ -6,6 +6,7 @@ (*****************************************************************************) type error = + | Invalid_action of string | Invalid_payload of Parsetree.payload | Invalid_aggregate of Key.t | Invalid_mark of Key.t @@ -18,6 +19,14 @@ type error = let error loc err = let msg, hint = match err with + | Invalid_action action -> + ( "Invalid action.", + Format.asprintf + "@[Accepted actions are aggregate, aggregate_s, aggregate_f, \ + mark, record, record_f, record_s, reset_block_section, span, \ + span_f, span_s, stamp and stop]@,\ + Found: %s@." + action ) | Invalid_payload payload -> ( "Invalid or empty attribute payload.", Format.asprintf diff --git a/src/lib_ppx_profiler/error.mli b/src/lib_ppx_profiler/error.mli index 14389119d665..d18055822e7a 100644 --- a/src/lib_ppx_profiler/error.mli +++ b/src/lib_ppx_profiler/error.mli @@ -6,6 +6,7 @@ (*****************************************************************************) type error = + | Invalid_action of string | Invalid_payload of Parsetree.payload | Invalid_aggregate of Key.t | Invalid_mark of Key.t diff --git a/src/lib_ppx_profiler/rewriter.ml b/src/lib_ppx_profiler/rewriter.ml index 3419c1110206..992118690197 100644 --- a/src/lib_ppx_profiler/rewriter.ml +++ b/src/lib_ppx_profiler/rewriter.ml @@ -42,7 +42,7 @@ module rec Constants : sig val filter_out_all_handled_attributes : Parsetree.attribute list -> Parsetree.attribute list end = struct - (* This rewriter handles ppxes starting with profiling. *) + (* This rewriter handles ppxes starting with profiler. *) let namespace = "profiler" type t = {action : string; attribute_name : string} @@ -240,12 +240,22 @@ end = struct ] |> List.map (fun (const, fn) -> (Constants.get_attribute const, fn)) - let of_string = + let of_string loc = let module StringMap = Map.Make (String) in let association_constant_rewriter = association_constant_rewriter |> List.to_seq |> StringMap.of_seq in - fun attribute -> StringMap.find_opt attribute association_constant_rewriter + fun attribute -> + match StringMap.find_opt attribute association_constant_rewriter with + | Some res -> Some res + | None -> + (* Raise an Error if the ppx starts with [@profiler.action ...] + but action is not handled by this ppx *) + if String.starts_with ~prefix:"profiler." attribute then + match String.split_on_char '.' attribute with + | [_; action] -> Error.error loc Error.(Invalid_action action) + | _ -> None + else None (** Transforms a rewriter in an OCaml function call: - [@profiler.aggregate_s ...] will create a proper @@ -331,7 +341,7 @@ end = struct | _ -> Error.error loc (Invalid_payload payload) let of_attribute ({Ppxlib.attr_payload; attr_loc; _} as attribute) = - match Ppxlib_helper.get_attribute_name attribute |> of_string with + match Ppxlib_helper.get_attribute_name attribute |> of_string attr_loc with | Some rewriter -> let key = extract_key_from_payload attr_loc attr_payload in Some (rewriter key attr_loc) -- GitLab From aa2d9269b7f3906623a62457a4dc3c974cbaa1c2 Mon Sep 17 00:00:00 2001 From: mattiasdrp Date: Mon, 16 Sep 2024 23:21:45 +0200 Subject: [PATCH 2/6] Ppx_profiler: Fix some attributes not accepting all possible keys --- src/lib_ppx_profiler/rewriter.ml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/lib_ppx_profiler/rewriter.ml b/src/lib_ppx_profiler/rewriter.ml index 992118690197..5eeee458809a 100644 --- a/src/lib_ppx_profiler/rewriter.ml +++ b/src/lib_ppx_profiler/rewriter.ml @@ -158,44 +158,43 @@ end = struct let aggregate_s key location = match Key.content key with - | Key.Ident _ | Key.String _ | Key.Apply _ -> Aggregate_s {key; location} + | Key.Apply _ | Key.Ident _ | Key.String _ -> Aggregate_s {key; location} | _ -> Error.error location (Error.Invalid_aggregate key) let aggregate_f key location = match Key.content key with - | Key.Ident _ | Key.String _ | Key.Apply _ -> Aggregate_f {key; location} + | Key.Apply _ | Key.Ident _ | Key.String _ -> Aggregate_f {key; location} | _ -> Error.error location (Error.Invalid_aggregate key) let mark key location = match Key.content key with - | Key.List _ -> Mark {key; location} + | Key.Apply _ | Key.Ident _ | Key.List _ -> Mark {key; location} | _ -> Error.error location (Error.Invalid_mark key) let record key location = match Key.content key with - | Key.Ident _ | Key.String _ | Key.Apply _ -> Record {key; location} + | Key.Apply _ | Key.Ident _ | Key.String _ -> Record {key; location} | _ -> Error.error location (Error.Invalid_record key) let record_f key location = match Key.content key with - | Key.Ident _ | Key.String _ | Key.Apply _ -> Record_f {key; location} + | Key.Apply _ | Key.Ident _ | Key.String _ -> Record_f {key; location} | _ -> Error.error location (Error.Invalid_record key) let record_s key location = match Key.content key with - | Key.Ident _ | Key.String _ | Key.Apply _ -> Record_s {key; location} + | Key.Apply _ | Key.Ident _ | Key.String _ -> Record_s {key; location} | _ -> Error.error location (Error.Invalid_record key) let reset_block_section key location = match Key.content key with - | Key.Ident _ | Key.String _ | Key.Apply _ -> + | Key.Apply _ | Key.Ident _ | Key.String _ -> Reset_block_section {key; location} | _ -> Error.error location (Error.Invalid_record key) let span_s key location = match Key.content key with - | Key.List _ -> Span_s {key; location} - | Key.Apply _ -> Span_s {key; location} + | Key.Apply _ | Key.Ident _ | Key.List _ -> Span_s {key; location} | _ -> Error.error location (Error.Invalid_span key) let stop key location = -- GitLab From 221a65a2d2468c2eaa4299622dcfe88f0e3bfbbb Mon Sep 17 00:00:00 2001 From: mattiasdrp Date: Mon, 16 Sep 2024 23:22:11 +0200 Subject: [PATCH 3/6] Ppx_profiler: Add the span_f action needed for profiling the environment --- src/lib_ppx_profiler/expression.ml | 1 + src/lib_ppx_profiler/rewriter.ml | 18 ++++++++++++++++++ src/lib_ppx_profiler/rewriter.mli | 1 + 3 files changed, 20 insertions(+) diff --git a/src/lib_ppx_profiler/expression.ml b/src/lib_ppx_profiler/expression.ml index d13fdce30428..3ca7d61fab9f 100644 --- a/src/lib_ppx_profiler/expression.ml +++ b/src/lib_ppx_profiler/expression.ml @@ -46,6 +46,7 @@ let rewrite rewriters t = | Rewriter.Aggregate_f content | Rewriter.Record_f content | Rewriter.Record_s content + | Rewriter.Span_f content | Rewriter.Span_s content -> add_wrapping_function expr diff --git a/src/lib_ppx_profiler/rewriter.ml b/src/lib_ppx_profiler/rewriter.ml index 5eeee458809a..e4547b121b4f 100644 --- a/src/lib_ppx_profiler/rewriter.ml +++ b/src/lib_ppx_profiler/rewriter.ml @@ -29,6 +29,9 @@ module rec Constants : sig (** Constant representing [@profiler.reset_block_section] *) val reset_block_section_constant : t + (** Constant representing [@profiler.span_f] *) + val span_f_constant : t + (** Constant representing [@profiler.span_s] *) val span_s_constant : t @@ -72,6 +75,9 @@ end = struct (* [@profiler.reset_block_section] *) let reset_block_section_constant = create_constant "reset_block_section" + (* [@profiler.span_s] *) + let span_f_constant = create_constant "span_f" + (* [@profiler.span_s] *) let span_s_constant = create_constant "span_s" @@ -93,6 +99,7 @@ end = struct record_f_constant; record_s_constant; reset_block_section_constant; + span_f_constant; span_s_constant; stop_constant; ] @@ -129,6 +136,7 @@ and Rewriter : sig | Record_f of content | Record_s of content | Reset_block_section of content + | Span_f of content | Span_s of content | Stop of content @@ -153,6 +161,7 @@ end = struct | Record_f of content | Record_s of content | Reset_block_section of content + | Span_f of content | Span_s of content | Stop of content @@ -192,6 +201,11 @@ end = struct Reset_block_section {key; location} | _ -> Error.error location (Error.Invalid_record key) + let span_f key location = + match Key.content key with + | Key.Apply _ | Key.Ident _ | Key.List _ -> Span_f {key; location} + | _ -> Error.error location (Error.Invalid_span key) + let span_s key location = match Key.content key with | Key.Apply _ | Key.Ident _ | Key.List _ -> Span_s {key; location} @@ -210,6 +224,7 @@ end = struct | Record_f c | Record_s c | Reset_block_section c + | Span_f c | Span_s c | Stop c -> c.location @@ -222,6 +237,7 @@ end = struct | Record_f _ -> Constants.record_f_constant | Record_s _ -> Constants.record_s_constant | Reset_block_section _ -> Constants.record_s_constant + | Span_f _ -> Constants.span_f_constant | Span_s _ -> Constants.span_s_constant | Stop _ -> Constants.stop_constant @@ -234,6 +250,7 @@ end = struct (Constants.record_f_constant, record_f); (Constants.record_s_constant, record_s); (Constants.reset_block_section_constant, reset_block_section); + (Constants.span_f_constant, span_f); (Constants.span_s_constant, span_s); (Constants.stop_constant, stop); ] @@ -273,6 +290,7 @@ end = struct | Record_f _ -> "record_f" | Record_s _ -> "record_s" | Reset_block_section _ -> "reset_block_section" + | Span_f _ -> "span_f" | Span_s _ -> "span_s" | Stop _ -> "stop" ) in diff --git a/src/lib_ppx_profiler/rewriter.mli b/src/lib_ppx_profiler/rewriter.mli index 715af1443508..c904a9246e4d 100644 --- a/src/lib_ppx_profiler/rewriter.mli +++ b/src/lib_ppx_profiler/rewriter.mli @@ -58,6 +58,7 @@ and Rewriter : sig | Record_f of content | Record_s of content | Reset_block_section of content + | Span_f of content | Span_s of content | Stop of content -- GitLab From 873627523291508243b81a3497776bc4e3b791df Mon Sep 17 00:00:00 2001 From: mattiasdrp Date: Tue, 17 Sep 2024 10:12:57 +0200 Subject: [PATCH 4/6] Ppx_profiler: Add aggregate --- src/lib_ppx_profiler/expression.ml | 3 ++- src/lib_ppx_profiler/rewriter.ml | 38 ++++++++++++++++++++++-------- src/lib_ppx_profiler/rewriter.mli | 3 ++- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/src/lib_ppx_profiler/expression.ml b/src/lib_ppx_profiler/expression.ml index 3ca7d61fab9f..37bd045da53d 100644 --- a/src/lib_ppx_profiler/expression.ml +++ b/src/lib_ppx_profiler/expression.ml @@ -42,8 +42,9 @@ let rewrite rewriters t = List.fold_left (fun expr rewriter -> match rewriter with - | Rewriter.Aggregate_s content + | Rewriter.Aggregate content | Rewriter.Aggregate_f content + | Rewriter.Aggregate_s content | Rewriter.Record_f content | Rewriter.Record_s content | Rewriter.Span_f content diff --git a/src/lib_ppx_profiler/rewriter.ml b/src/lib_ppx_profiler/rewriter.ml index e4547b121b4f..7f53f61a8ffd 100644 --- a/src/lib_ppx_profiler/rewriter.ml +++ b/src/lib_ppx_profiler/rewriter.ml @@ -8,12 +8,15 @@ module rec Constants : sig type t - (** Constant representing [@profiler.aggregate_s] *) - val aggregate_s_constant : t + (** Constant representing [@profiler.aggregate] *) + val aggregate_constant : t (** Constant representing [@profiler.aggregate_f] *) val aggregate_f_constant : t + (** Constant representing [@profiler.aggregate_s] *) + val aggregate_s_constant : t + (** Constant representing [@profiler.mark] *) val mark_constant : t @@ -54,12 +57,15 @@ end = struct let attribute_name = namespace ^ "." ^ action in {action; attribute_name} - (* [@profiler.aggregate_s] *) - let aggregate_s_constant = create_constant "aggregate_s" + (* [@profiler.aggregate] *) + let aggregate_constant = create_constant "aggregate" (* [@profiler.aggregate_f] *) let aggregate_f_constant = create_constant "aggregate_f" + (* [@profiler.aggregate_s] *) + let aggregate_s_constant = create_constant "aggregate_s" + (* [@profiler.mark] *) let mark_constant = create_constant "mark" @@ -92,8 +98,9 @@ end = struct defined above *) let constants = [ - aggregate_s_constant; + aggregate_constant; aggregate_f_constant; + aggregate_s_constant; mark_constant; record_constant; record_f_constant; @@ -129,8 +136,9 @@ and Rewriter : sig val get_key : content -> Key.t type t = - | Aggregate_s of content + | Aggregate of content | Aggregate_f of content + | Aggregate_s of content | Mark of content | Record of content | Record_f of content @@ -154,8 +162,9 @@ end = struct let get_key content = content.key type t = - | Aggregate_s of content + | Aggregate of content | Aggregate_f of content + | Aggregate_s of content | Mark of content | Record of content | Record_f of content @@ -165,9 +174,9 @@ end = struct | Span_s of content | Stop of content - let aggregate_s key location = + let aggregate key location = match Key.content key with - | Key.Apply _ | Key.Ident _ | Key.String _ -> Aggregate_s {key; location} + | Key.Apply _ | Key.Ident _ | Key.String _ -> Aggregate {key; location} | _ -> Error.error location (Error.Invalid_aggregate key) let aggregate_f key location = @@ -175,6 +184,11 @@ end = struct | Key.Apply _ | Key.Ident _ | Key.String _ -> Aggregate_f {key; location} | _ -> Error.error location (Error.Invalid_aggregate key) + let aggregate_s key location = + match Key.content key with + | Key.Apply _ | Key.Ident _ | Key.String _ -> Aggregate_s {key; location} + | _ -> Error.error location (Error.Invalid_aggregate key) + let mark key location = match Key.content key with | Key.Apply _ | Key.Ident _ | Key.List _ -> Mark {key; location} @@ -217,8 +231,9 @@ end = struct | _ -> Error.error location (Error.Invalid_stop key) let get_location = function - | Aggregate_s c + | Aggregate c | Aggregate_f c + | Aggregate_s c | Mark c | Record c | Record_f c @@ -230,6 +245,7 @@ end = struct c.location let to_constant = function + | Aggregate _ -> Constants.aggregate_constant | Aggregate_f _ -> Constants.aggregate_f_constant | Aggregate_s _ -> Constants.aggregate_s_constant | Mark _ -> Constants.mark_constant @@ -243,6 +259,7 @@ end = struct let association_constant_rewriter = [ + (Constants.aggregate_constant, aggregate); (Constants.aggregate_f_constant, aggregate_f); (Constants.aggregate_s_constant, aggregate_s); (Constants.mark_constant, mark); @@ -283,6 +300,7 @@ end = struct Ppxlib.Ldot ( profiler_module, match t with + | Aggregate _ -> "aggregate" | Aggregate_f _ -> "aggregate_f" | Aggregate_s _ -> "aggregate_s" | Mark _ -> "mark" diff --git a/src/lib_ppx_profiler/rewriter.mli b/src/lib_ppx_profiler/rewriter.mli index c904a9246e4d..6ca0e9bcc2fd 100644 --- a/src/lib_ppx_profiler/rewriter.mli +++ b/src/lib_ppx_profiler/rewriter.mli @@ -51,8 +51,9 @@ and Rewriter : sig (** Possible rewriters *) type t = - | Aggregate_s of content + | Aggregate of content | Aggregate_f of content + | Aggregate_s of content | Mark of content | Record of content | Record_f of content -- GitLab From cda9b446c94e02874399eb4a225c89ac38643810 Mon Sep 17 00:00:00 2001 From: mattiasdrp Date: Tue, 17 Sep 2024 10:16:13 +0200 Subject: [PATCH 5/6] Ppx_profiler: Add span --- src/lib_ppx_profiler/expression.ml | 1 + src/lib_ppx_profiler/rewriter.ml | 18 ++++++++++++++++++ src/lib_ppx_profiler/rewriter.mli | 1 + 3 files changed, 20 insertions(+) diff --git a/src/lib_ppx_profiler/expression.ml b/src/lib_ppx_profiler/expression.ml index 37bd045da53d..156aa507b8a6 100644 --- a/src/lib_ppx_profiler/expression.ml +++ b/src/lib_ppx_profiler/expression.ml @@ -47,6 +47,7 @@ let rewrite rewriters t = | Rewriter.Aggregate_s content | Rewriter.Record_f content | Rewriter.Record_s content + | Rewriter.Span content | Rewriter.Span_f content | Rewriter.Span_s content -> add_wrapping_function diff --git a/src/lib_ppx_profiler/rewriter.ml b/src/lib_ppx_profiler/rewriter.ml index 7f53f61a8ffd..784d22af8cca 100644 --- a/src/lib_ppx_profiler/rewriter.ml +++ b/src/lib_ppx_profiler/rewriter.ml @@ -32,6 +32,9 @@ module rec Constants : sig (** Constant representing [@profiler.reset_block_section] *) val reset_block_section_constant : t + (** Constant representing [@profiler.span] *) + val span_constant : t + (** Constant representing [@profiler.span_f] *) val span_f_constant : t @@ -81,6 +84,9 @@ end = struct (* [@profiler.reset_block_section] *) let reset_block_section_constant = create_constant "reset_block_section" + (* [@profiler.span] *) + let span_constant = create_constant "span" + (* [@profiler.span_s] *) let span_f_constant = create_constant "span_f" @@ -106,6 +112,7 @@ end = struct record_f_constant; record_s_constant; reset_block_section_constant; + span_constant; span_f_constant; span_s_constant; stop_constant; @@ -144,6 +151,7 @@ and Rewriter : sig | Record_f of content | Record_s of content | Reset_block_section of content + | Span of content | Span_f of content | Span_s of content | Stop of content @@ -170,6 +178,7 @@ end = struct | Record_f of content | Record_s of content | Reset_block_section of content + | Span of content | Span_f of content | Span_s of content | Stop of content @@ -215,6 +224,11 @@ end = struct Reset_block_section {key; location} | _ -> Error.error location (Error.Invalid_record key) + let span key location = + match Key.content key with + | Key.Apply _ | Key.Ident _ | Key.List _ -> Span {key; location} + | _ -> Error.error location (Error.Invalid_span key) + let span_f key location = match Key.content key with | Key.Apply _ | Key.Ident _ | Key.List _ -> Span_f {key; location} @@ -239,6 +253,7 @@ end = struct | Record_f c | Record_s c | Reset_block_section c + | Span c | Span_f c | Span_s c | Stop c -> @@ -253,6 +268,7 @@ end = struct | Record_f _ -> Constants.record_f_constant | Record_s _ -> Constants.record_s_constant | Reset_block_section _ -> Constants.record_s_constant + | Span _ -> Constants.span_constant | Span_f _ -> Constants.span_f_constant | Span_s _ -> Constants.span_s_constant | Stop _ -> Constants.stop_constant @@ -267,6 +283,7 @@ end = struct (Constants.record_f_constant, record_f); (Constants.record_s_constant, record_s); (Constants.reset_block_section_constant, reset_block_section); + (Constants.span_constant, span); (Constants.span_f_constant, span_f); (Constants.span_s_constant, span_s); (Constants.stop_constant, stop); @@ -308,6 +325,7 @@ end = struct | Record_f _ -> "record_f" | Record_s _ -> "record_s" | Reset_block_section _ -> "reset_block_section" + | Span _ -> "span" | Span_f _ -> "span_f" | Span_s _ -> "span_s" | Stop _ -> "stop" ) diff --git a/src/lib_ppx_profiler/rewriter.mli b/src/lib_ppx_profiler/rewriter.mli index 6ca0e9bcc2fd..aad33f82c672 100644 --- a/src/lib_ppx_profiler/rewriter.mli +++ b/src/lib_ppx_profiler/rewriter.mli @@ -59,6 +59,7 @@ and Rewriter : sig | Record_f of content | Record_s of content | Reset_block_section of content + | Span of content | Span_f of content | Span_s of content | Stop of content -- GitLab From afadf63ecf78693ff37fc67ceee1be9e937a0704 Mon Sep 17 00:00:00 2001 From: mattiasdrp Date: Tue, 17 Sep 2024 10:20:25 +0200 Subject: [PATCH 6/6] Ppx_profiler: Add stamp --- src/lib_ppx_profiler/expression.ml | 3 ++- src/lib_ppx_profiler/rewriter.ml | 17 +++++++++++++++++ src/lib_ppx_profiler/rewriter.mli | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/lib_ppx_profiler/expression.ml b/src/lib_ppx_profiler/expression.ml index 156aa507b8a6..f3208087c85a 100644 --- a/src/lib_ppx_profiler/expression.ml +++ b/src/lib_ppx_profiler/expression.ml @@ -56,7 +56,8 @@ let rewrite rewriters t = loc (Rewriter.get_key content) (* Functions that have a ~lod parameter *) - | Rewriter.Mark content | Rewriter.Record content -> + | Rewriter.Mark content | Rewriter.Record content | Rewriter.Stamp content + -> add_unit_function ~lod:true expr diff --git a/src/lib_ppx_profiler/rewriter.ml b/src/lib_ppx_profiler/rewriter.ml index 784d22af8cca..0873c5c8324b 100644 --- a/src/lib_ppx_profiler/rewriter.ml +++ b/src/lib_ppx_profiler/rewriter.ml @@ -41,6 +41,9 @@ module rec Constants : sig (** Constant representing [@profiler.span_s] *) val span_s_constant : t + (** Constant representing [@profiler.stamp] *) + val stamp_constant : t + (** Constant representing [@profiler.stop] *) val stop_constant : t @@ -93,6 +96,9 @@ end = struct (* [@profiler.span_s] *) let span_s_constant = create_constant "span_s" + (* [@profiler.stamp] *) + let stamp_constant = create_constant "stamp" + (* [@profiler.stop] *) let stop_constant = create_constant "stop" @@ -154,6 +160,7 @@ and Rewriter : sig | Span of content | Span_f of content | Span_s of content + | Stamp of content | Stop of content val to_constant : t -> Constants.t @@ -181,6 +188,7 @@ end = struct | Span of content | Span_f of content | Span_s of content + | Stamp of content | Stop of content let aggregate key location = @@ -239,6 +247,11 @@ end = struct | Key.Apply _ | Key.Ident _ | Key.List _ -> Span_s {key; location} | _ -> Error.error location (Error.Invalid_span key) + let stamp key location = + match Key.content key with + | Key.Apply _ | Key.Ident _ | Key.String _ -> Stamp {key; location} + | _ -> Error.error location (Error.Invalid_span key) + let stop key location = match Key.content key with | Key.Empty -> Stop {key; location} @@ -256,6 +269,7 @@ end = struct | Span c | Span_f c | Span_s c + | Stamp c | Stop c -> c.location @@ -271,6 +285,7 @@ end = struct | Span _ -> Constants.span_constant | Span_f _ -> Constants.span_f_constant | Span_s _ -> Constants.span_s_constant + | Stamp _ -> Constants.stamp_constant | Stop _ -> Constants.stop_constant let association_constant_rewriter = @@ -286,6 +301,7 @@ end = struct (Constants.span_constant, span); (Constants.span_f_constant, span_f); (Constants.span_s_constant, span_s); + (Constants.stamp_constant, stamp); (Constants.stop_constant, stop); ] |> List.map (fun (const, fn) -> (Constants.get_attribute const, fn)) @@ -328,6 +344,7 @@ end = struct | Span _ -> "span" | Span_f _ -> "span_f" | Span_s _ -> "span_s" + | Stamp _ -> "stamp" | Stop _ -> "stop" ) in Ppxlib.Ast_helper.Exp.ident {txt = lident; loc} diff --git a/src/lib_ppx_profiler/rewriter.mli b/src/lib_ppx_profiler/rewriter.mli index aad33f82c672..5a8417a54e1d 100644 --- a/src/lib_ppx_profiler/rewriter.mli +++ b/src/lib_ppx_profiler/rewriter.mli @@ -62,6 +62,7 @@ and Rewriter : sig | Span of content | Span_f of content | Span_s of content + | Stamp of content | Stop of content val to_constant : t -> Constants.t -- GitLab