Skip to content

Commit c988d98

Browse files
committed
Implemented policy profiler in cf-agent
Changelog: The policy profiling logic is now implemented natively within the cf-agent, replacing the previous reliance on cf-agent logs and the cf-profile.pl script for faster execution. Ticket: ENT-8096 Signed-off-by: Victor Moene <[email protected]>
1 parent 42ebd9f commit c988d98

File tree

6 files changed

+303
-37
lines changed

6 files changed

+303
-37
lines changed

cf-agent/cf-agent.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ static const struct option OPTIONS[] =
209209
{"color", optional_argument, 0, 'C'},
210210
{"no-extensions", no_argument, 0, 'E'},
211211
{"timestamp", no_argument, 0, 'l'},
212+
{"profile", no_argument, 0, 'p'},
212213
/* Only long option for the rest */
213214
{"ignore-preferred-augments", no_argument, 0, 0},
214215
{"log-modules", required_argument, 0, 0},
@@ -245,6 +246,7 @@ static const char *const HINTS[] =
245246
"Enable colorized output. Possible values: 'always', 'auto', 'never'. If option is used, the default value is 'auto'",
246247
"Disable extension loading (used while upgrading)",
247248
"Log timestamps on each line of log output",
249+
"Output diagnostic of bundle execution",
248250
"Ignore def_preferred.json file in favor of def.json",
249251
"Enable even more detailed debug logging for specific areas of the implementation. Use together with '-d'. Use --log-modules=help for a list of available modules",
250252
"Do not load augments (def.json)",
@@ -323,7 +325,9 @@ int main(int argc, char *argv[])
323325

324326
BeginAudit();
325327

328+
int64_t policy_event_start = EvalContextEventStart();
326329
KeepPromises(ctx, policy, config);
330+
EvalContextWriteEventTree(ctx, policy_event_start);
327331

328332
if (EvalAborted(ctx))
329333
{
@@ -523,7 +527,7 @@ static GenericAgentConfig *CheckOpts(int argc, char **argv)
523527
FreeFixedStringArray(argc_new, argv_tmp);
524528

525529
int longopt_idx;
526-
while ((c = getopt_long(argc_new, argv_new, "tdvnKIf:g:w:D:N:VxMB:b:hC::ElT::",
530+
while ((c = getopt_long(argc_new, argv_new, "tdvnKIf:g:w:D:N:VxMB:b:hC::ElT::p",
527531
OPTIONS, &longopt_idx))
528532
!= -1)
529533
{
@@ -689,6 +693,9 @@ static GenericAgentConfig *CheckOpts(int argc, char **argv)
689693
}
690694

691695
break;
696+
case 'p':
697+
config->profiling = true;
698+
break;
692699

693700
/* long options only */
694701
case 0:

0 commit comments

Comments
 (0)