Skip to content

Commit 7c28436

Browse files
authored
Remove the osemgrep sarif metrics (#317)
Not used anymore. test plan: make in semgrep - [x] I ran `make setup && make` to update the generated code after editing a `.atd` file (TODO: have a CI check) - [x] I made sure we're still backward compatible with old versions of the CLI. For example, the Semgrep backend need to still be able to *consume* data generated by Semgrep 1.17.0. See https://atd.readthedocs.io/en/latest/atdgen-tutorial.html#smooth-protocol-upgrades
1 parent b1f7b29 commit 7c28436

File tree

2 files changed

+2
-122
lines changed

2 files changed

+2
-122
lines changed

semgrep_metrics.atd

+2-36
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
* `pysemgrep`. Currently, we try to fit the tests and don't update the
1414
* JSON output.
1515
* - specify the schema for the answer from https://metrics.semgrep.dev
16+
* - document also what we send via open telemetry in our traces when
17+
* using --trace?
1618
*)
1719

1820
<python text="from dataclasses import field">
@@ -71,12 +73,6 @@ type payload = {
7173
errors: errors;
7274
value: value;
7375
extension: extension;
74-
75-
(* Metrics related to osemgrep migration. It's intentionally made optional
76-
* so that it's easier to remove the field without breaking backward
77-
* compatibility once the migration is complete.
78-
*)
79-
?osemgrep <ocaml mutable>: osemgrep_metrics option;
8076
}
8177

8278
(*****************************************************************************)
@@ -272,36 +268,6 @@ type extension = {
272268
?ignoreCount <ocaml mutable>: int option;
273269
}
274270

275-
(*****************************************************************************)
276-
(* Osemgrep specific metrics *)
277-
(*****************************************************************************)
278-
279-
type osemgrep_metrics = {
280-
?format_output: osemgrep_format_output option;
281-
}
282-
283-
type osemgrep_format_output = {
284-
(* Whether the RPC succeeded. *)
285-
?succeeded: bool option;
286-
(* Name of the output format. *)
287-
?format: string option;
288-
(* Time in seconds to call osemgrep through RPC and get its result back. *)
289-
?osemgrep_rpc_response_time_seconds: float option;
290-
(* Time in seconds for osemgrep to format the output, excluding RPC. *)
291-
?osemgrep_format_time_seconds: float option;
292-
293-
(* We also validate whether osemgrep and pysemgrep return the same output or not.
294-
* The fields below help us keep track of this information.
295-
*)
296-
297-
(* Time in seconds for pysemgrep to format the output. *)
298-
?pysemgrep_format_time_seconds: float option;
299-
(* Time in seconds to validate whether the output from osemgrep matches pysemgrep. *)
300-
?validation_time_seconds: float option;
301-
(* Whether the osemgrep output matched the pysemgrep output. *)
302-
?is_match: bool option;
303-
}
304-
305271
(*****************************************************************************)
306272
(* TODO Response by metrics.semgrep.dev *)
307273
(*****************************************************************************)

semgrep_metrics.py

-86
Original file line numberDiff line numberDiff line change
@@ -864,88 +864,6 @@ def to_json_string(self, **kw: Any) -> str:
864864
return json.dumps(self.to_json(), **kw)
865865

866866

867-
@dataclass
868-
class OsemgrepFormatOutput:
869-
"""Original type: osemgrep_format_output = { ... }"""
870-
871-
succeeded: Optional[bool] = None
872-
format: Optional[str] = None
873-
osemgrep_rpc_response_time_seconds: Optional[float] = None
874-
osemgrep_format_time_seconds: Optional[float] = None
875-
pysemgrep_format_time_seconds: Optional[float] = None
876-
validation_time_seconds: Optional[float] = None
877-
is_match: Optional[bool] = None
878-
879-
@classmethod
880-
def from_json(cls, x: Any) -> 'OsemgrepFormatOutput':
881-
if isinstance(x, dict):
882-
return cls(
883-
succeeded=_atd_read_bool(x['succeeded']) if 'succeeded' in x else None,
884-
format=_atd_read_string(x['format']) if 'format' in x else None,
885-
osemgrep_rpc_response_time_seconds=_atd_read_float(x['osemgrep_rpc_response_time_seconds']) if 'osemgrep_rpc_response_time_seconds' in x else None,
886-
osemgrep_format_time_seconds=_atd_read_float(x['osemgrep_format_time_seconds']) if 'osemgrep_format_time_seconds' in x else None,
887-
pysemgrep_format_time_seconds=_atd_read_float(x['pysemgrep_format_time_seconds']) if 'pysemgrep_format_time_seconds' in x else None,
888-
validation_time_seconds=_atd_read_float(x['validation_time_seconds']) if 'validation_time_seconds' in x else None,
889-
is_match=_atd_read_bool(x['is_match']) if 'is_match' in x else None,
890-
)
891-
else:
892-
_atd_bad_json('OsemgrepFormatOutput', x)
893-
894-
def to_json(self) -> Any:
895-
res: Dict[str, Any] = {}
896-
if self.succeeded is not None:
897-
res['succeeded'] = _atd_write_bool(self.succeeded)
898-
if self.format is not None:
899-
res['format'] = _atd_write_string(self.format)
900-
if self.osemgrep_rpc_response_time_seconds is not None:
901-
res['osemgrep_rpc_response_time_seconds'] = _atd_write_float(self.osemgrep_rpc_response_time_seconds)
902-
if self.osemgrep_format_time_seconds is not None:
903-
res['osemgrep_format_time_seconds'] = _atd_write_float(self.osemgrep_format_time_seconds)
904-
if self.pysemgrep_format_time_seconds is not None:
905-
res['pysemgrep_format_time_seconds'] = _atd_write_float(self.pysemgrep_format_time_seconds)
906-
if self.validation_time_seconds is not None:
907-
res['validation_time_seconds'] = _atd_write_float(self.validation_time_seconds)
908-
if self.is_match is not None:
909-
res['is_match'] = _atd_write_bool(self.is_match)
910-
return res
911-
912-
@classmethod
913-
def from_json_string(cls, x: str) -> 'OsemgrepFormatOutput':
914-
return cls.from_json(json.loads(x))
915-
916-
def to_json_string(self, **kw: Any) -> str:
917-
return json.dumps(self.to_json(), **kw)
918-
919-
920-
@dataclass
921-
class OsemgrepMetrics:
922-
"""Original type: osemgrep_metrics = { ... }"""
923-
924-
format_output: Optional[OsemgrepFormatOutput] = None
925-
926-
@classmethod
927-
def from_json(cls, x: Any) -> 'OsemgrepMetrics':
928-
if isinstance(x, dict):
929-
return cls(
930-
format_output=OsemgrepFormatOutput.from_json(x['format_output']) if 'format_output' in x else None,
931-
)
932-
else:
933-
_atd_bad_json('OsemgrepMetrics', x)
934-
935-
def to_json(self) -> Any:
936-
res: Dict[str, Any] = {}
937-
if self.format_output is not None:
938-
res['format_output'] = (lambda x: x.to_json())(self.format_output)
939-
return res
940-
941-
@classmethod
942-
def from_json_string(cls, x: str) -> 'OsemgrepMetrics':
943-
return cls.from_json(json.loads(x))
944-
945-
def to_json_string(self, **kw: Any) -> str:
946-
return json.dumps(self.to_json(), **kw)
947-
948-
949867
@dataclass
950868
class Extension:
951869
"""Original type: extension = { ... }"""
@@ -1149,7 +1067,6 @@ class Payload:
11491067
value: Value
11501068
extension: Extension
11511069
parse_rate: List[Tuple[str, ParseStat]] = field(default_factory=lambda: [])
1152-
osemgrep: Optional[OsemgrepMetrics] = None
11531070

11541071
@classmethod
11551072
def from_json(cls, x: Any) -> 'Payload':
@@ -1165,7 +1082,6 @@ def from_json(cls, x: Any) -> 'Payload':
11651082
value=Value.from_json(x['value']) if 'value' in x else _atd_missing_json_field('Payload', 'value'),
11661083
extension=Extension.from_json(x['extension']) if 'extension' in x else _atd_missing_json_field('Payload', 'extension'),
11671084
parse_rate=_atd_read_assoc_object_into_list(ParseStat.from_json)(x['parse_rate']) if 'parse_rate' in x else [],
1168-
osemgrep=OsemgrepMetrics.from_json(x['osemgrep']) if 'osemgrep' in x else None,
11691085
)
11701086
else:
11711087
_atd_bad_json('Payload', x)
@@ -1182,8 +1098,6 @@ def to_json(self) -> Any:
11821098
res['value'] = (lambda x: x.to_json())(self.value)
11831099
res['extension'] = (lambda x: x.to_json())(self.extension)
11841100
res['parse_rate'] = _atd_write_assoc_list_to_object((lambda x: x.to_json()))(self.parse_rate)
1185-
if self.osemgrep is not None:
1186-
res['osemgrep'] = (lambda x: x.to_json())(self.osemgrep)
11871101
return res
11881102

11891103
@classmethod

0 commit comments

Comments
 (0)