docs: Add supported versions and fix-backport policy
[lttng-tools.git] / include / lttng / error-query.h
CommitLineData
b99a0cb3
JG
1/*
2 * error-query.h
3 *
4 * Copyright (C) 2021 Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 *
75f62e53 6 * SPDX-License-Identifier: LGPL-2.1-only
b99a0cb3
JG
7 *
8 */
9
10#ifndef LTTNG_ERROR_QUERY_H
11#define LTTNG_ERROR_QUERY_H
12
4bd69c5f 13#include <lttng/lttng-export.h>
28f23191 14#include <lttng/lttng.h>
b99a0cb3 15#include <lttng/trigger/trigger.h>
28f23191 16
b99a0cb3
JG
17#include <stdint.h>
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23/* An error query. */
24struct lttng_error_query;
25
26/*
27 * A collection of "lttng_error_query_result" returned after executing an error
28 * query against an endpoint.
29 */
30struct lttng_error_query_results;
31
32/* A 'result' is an opaque error type. */
33struct lttng_error_query_result;
34
35enum lttng_error_query_status {
36 LTTNG_ERROR_QUERY_STATUS_OK = 0,
37 /* An error occurred while querying for errors. */
38 LTTNG_ERROR_QUERY_STATUS_ERROR = -1,
39 /* The target of the query does not make sense for this endpoint. */
40 LTTNG_ERROR_QUERY_STATUS_INVALID_QUERY_TARGET = -2,
41 LTTNG_ERROR_QUERY_STATUS_INVALID_PARAMETER = -3,
42};
43
44enum lttng_error_query_result_type {
45 /* A count of errors provided as an unsigned integral value. */
46 LTTNG_ERROR_QUERY_RESULT_TYPE_COUNTER = 0,
47 LTTNG_ERROR_QUERY_RESULT_TYPE_UNKNOWN = -1,
48};
49
50enum lttng_error_query_result_status {
51 LTTNG_ERROR_QUERY_RESULT_STATUS_OK = 0,
52 LTTNG_ERROR_QUERY_RESULT_STATUS_ERROR = -1,
53 LTTNG_ERROR_QUERY_RESULT_STATUS_INVALID_PARAMETER = -2,
54};
55
56enum lttng_error_query_results_status {
57 LTTNG_ERROR_QUERY_RESULTS_STATUS_OK = 0,
58 LTTNG_ERROR_QUERY_RESULTS_STATUS_ERROR = -1,
59 LTTNG_ERROR_QUERY_RESULTS_STATUS_INVALID_PARAMETER = -2,
60};
61
62/* Create an error query targetting a trigger object. */
28f23191
JG
63LTTNG_EXPORT extern struct lttng_error_query *
64lttng_error_query_trigger_create(const struct lttng_trigger *trigger);
b99a0cb3 65
63dd3d7b 66/* Create an error query targetting a trigger's condition object. */
28f23191
JG
67LTTNG_EXPORT extern struct lttng_error_query *
68lttng_error_query_condition_create(const struct lttng_trigger *trigger);
63dd3d7b 69
cb9222ff
JG
70/*
71 * Create an error query targetting an action object.
72 *
73 * `action_path` is copied internally. The root of the `action_path` is the
74 * action of `trigger`.
75 */
28f23191
JG
76LTTNG_EXPORT extern struct lttng_error_query *
77lttng_error_query_action_create(const struct lttng_trigger *trigger,
78 const struct lttng_action_path *action_path);
b99a0cb3
JG
79
80/* Destroy an error query. */
4bd69c5f 81LTTNG_EXPORT extern void lttng_error_query_destroy(struct lttng_error_query *query);
b99a0cb3
JG
82
83/*
84 * Run an error query against an endpoint.
85 *
86 * Currently, only the `lttng_session_daemon_command_endpoint` is supported,
87 * see `lttng/endpoint.h`.
88 */
28f23191
JG
89LTTNG_EXPORT extern enum lttng_error_code
90lttng_error_query_execute(const struct lttng_error_query *query,
91 const struct lttng_endpoint *endpoint,
92 struct lttng_error_query_results **results);
b99a0cb3
JG
93
94/* Get the number of results in a result set. */
4bd69c5f 95LTTNG_EXPORT LTTNG_EXPORT extern enum lttng_error_query_results_status
28f23191
JG
96lttng_error_query_results_get_count(const struct lttng_error_query_results *results,
97 unsigned int *count);
b99a0cb3
JG
98
99/* Get a result from a result set by index. */
4bd69c5f 100LTTNG_EXPORT extern enum lttng_error_query_results_status
28f23191
JG
101lttng_error_query_results_get_result(const struct lttng_error_query_results *results,
102 const struct lttng_error_query_result **result,
103 unsigned int index);
b99a0cb3
JG
104
105/* Destroy an error query result set. */
28f23191
JG
106LTTNG_EXPORT extern void
107lttng_error_query_results_destroy(struct lttng_error_query_results *results);
b99a0cb3
JG
108
109/* Get the type of an error query result. */
28f23191
JG
110LTTNG_EXPORT extern enum lttng_error_query_result_type
111lttng_error_query_result_get_type(const struct lttng_error_query_result *result);
b99a0cb3
JG
112
113/* Get the name of result. */
28f23191
JG
114LTTNG_EXPORT extern enum lttng_error_query_result_status
115lttng_error_query_result_get_name(const struct lttng_error_query_result *result, const char **name);
b99a0cb3
JG
116
117/* Get the description of a result. */
4bd69c5f 118LTTNG_EXPORT extern enum lttng_error_query_result_status
28f23191
JG
119lttng_error_query_result_get_description(const struct lttng_error_query_result *result,
120 const char **description);
b99a0cb3
JG
121
122/* Get the value of an error counter. */
4bd69c5f 123LTTNG_EXPORT extern enum lttng_error_query_result_status
28f23191
JG
124lttng_error_query_result_counter_get_value(const struct lttng_error_query_result *result,
125 uint64_t *value);
b99a0cb3
JG
126
127#ifdef __cplusplus
128}
129#endif
130
131#endif /* LTTNG_ERROR_QUERY_H */
This page took 0.042795 seconds and 4 git commands to generate.