2 * Copyright (C) 2021 Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 * SPDX-License-Identifier: GPL-2.0-only
8 #include "event-notifier-error-accounting.h"
9 #include <lttng/error-query-internal.h>
10 #include <lttng/trigger/trigger-internal.h>
11 #include <lttng/action/action-internal.h>
14 enum lttng_trigger_status
lttng_trigger_add_error_results(
15 const struct lttng_trigger
*trigger
,
16 struct lttng_error_query_results
*results
)
18 enum lttng_trigger_status status
;
19 uint64_t discarded_tracer_messages_count
;
20 enum event_notifier_error_accounting_status error_accounting_status
;
21 struct lttng_error_query_result
*discarded_tracer_messages_counter
= NULL
;
22 const char *trigger_name
;
25 status
= lttng_trigger_get_name(trigger
, &trigger_name
);
26 trigger_name
= status
== LTTNG_TRIGGER_STATUS_OK
?
27 trigger_name
: "(unnamed)";
28 status
= lttng_trigger_get_owner_uid(trigger
,
30 assert(status
== LTTNG_TRIGGER_STATUS_OK
);
32 error_accounting_status
= event_notifier_error_accounting_get_count(
33 trigger
, &discarded_tracer_messages_count
);
34 if (error_accounting_status
!= EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK
) {
35 ERR("Failed to retrieve tracer discarded messages count for triger: triggger name = '%s', trigger owner uid = %d",
36 trigger_name
, (int) trigger_owner
);
37 status
= LTTNG_TRIGGER_STATUS_ERROR
;
41 discarded_tracer_messages_counter
= lttng_error_query_result_counter_create(
42 "discarded tracer messages",
43 "Count of messages discarded by the tracer due to a communication error with the session daemon",
44 discarded_tracer_messages_count
);
45 if (!discarded_tracer_messages_counter
) {
46 status
= LTTNG_TRIGGER_STATUS_ERROR
;
50 if (lttng_error_query_results_add_result(
51 results
, discarded_tracer_messages_counter
)) {
52 status
= LTTNG_TRIGGER_STATUS_ERROR
;
56 /* Ownership transferred to the results. */
57 discarded_tracer_messages_counter
= NULL
;
59 status
= LTTNG_TRIGGER_STATUS_OK
;
61 lttng_error_query_result_destroy(discarded_tracer_messages_counter
);
66 enum lttng_trigger_status
lttng_trigger_add_action_error_query_results(
67 struct lttng_trigger
*trigger
,
68 struct lttng_error_query_results
*results
)
70 enum lttng_trigger_status status
;
71 const char *trigger_name
;
73 enum lttng_action_status action_status
;
75 status
= lttng_trigger_get_name(trigger
, &trigger_name
);
76 trigger_name
= status
== LTTNG_TRIGGER_STATUS_OK
?
77 trigger_name
: "(unnamed)";
78 status
= lttng_trigger_get_owner_uid(trigger
,
80 assert(status
== LTTNG_TRIGGER_STATUS_OK
);
82 action_status
= lttng_action_add_error_query_results(
83 lttng_trigger_get_action(trigger
), results
);
84 switch (action_status
) {
85 case LTTNG_ACTION_STATUS_OK
:
86 status
= LTTNG_TRIGGER_STATUS_OK
;
89 status
= LTTNG_TRIGGER_STATUS_ERROR
;
93 status
= LTTNG_TRIGGER_STATUS_OK
;