Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify the configuration file structure and add parameter fields for subscription events #368

Merged
merged 3 commits into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
-
- Support the protocol RocketMQ.([#328](https://github.com/KindlingProject/kindling/pull/328))
- Add a new tool: A debug tool for Trace Profiling is provided for developers to troubleshoot problems.([#363](https://github.com/CloudDectective-Harmonycloud/kindling/pull/363))
- Modify the configuration file structure and add parameter fields for subscription events. ([#368](https://github.com/CloudDectective-Harmonycloud/kindling/pull/368))
dxsup marked this conversation as resolved.
Show resolved Hide resolved


### Enhancements
Expand Down
7 changes: 6 additions & 1 deletion collector/pkg/component/receiver/cgoreceiver/cgo_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extern "C" {
#endif
int runForGo();
int getKindlingEvent(void **kindlingEvent);
int subEventForGo(char* eventName, char* category);
int subEventForGo(char* eventName, char* category, void *params);
int startProfile();
int stopProfile();
void startProfileDebug(int pid, int tid);
Expand All @@ -22,6 +22,11 @@ void stopProfileDebug();

#endif //SYSDIG_CGO_FUNC_H

struct event_params_for_subscribe {
char *name;
char *value;
};

struct kindling_event_t_for_go{
uint64_t timestamp;
char *name;
Expand Down
12 changes: 10 additions & 2 deletions collector/pkg/component/receiver/cgoreceiver/cgoreceiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ const (

type CKindlingEventForGo C.struct_kindling_event_t_for_go

type CEventParamsForSubscribe C.struct_event_params_for_subscribe

type CgoReceiver struct {
cfg *Config
analyzerManager *analyzerpackage.Manager
Expand Down Expand Up @@ -172,15 +174,21 @@ func (r *CgoReceiver) sendToNextConsumer(evt *model.KindlingEvent) error {
return nil
}

func (r *CgoReceiver) subEvent() {
func (r *CgoReceiver) subEvent() error {
if len(r.cfg.SubscribeInfo) == 0 {
r.telemetry.Logger.Warn("No events are subscribed by cgoreceiver. Please check your configuration.")
} else {
r.telemetry.Logger.Infof("The subscribed events are: %v", r.cfg.SubscribeInfo)
}
for _, value := range r.cfg.SubscribeInfo {
C.subEventForGo(C.CString(value.Name), C.CString(value.Category))
//to do. analyze params filed in the value
paramsList := make([]CEventParamsForSubscribe, 0)
var temp CEventParamsForSubscribe
temp.name = C.CString("terminator")
paramsList = append(paramsList, temp)
C.subEventForGo(C.CString(value.Name), C.CString(value.Category), (unsafe.Pointer)(&paramsList[0]))
}
return nil
}

func (r *CgoReceiver) StartProfile() error {
Expand Down
5 changes: 3 additions & 2 deletions collector/pkg/component/receiver/cgoreceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ type Config struct {
}

type SubEvent struct {
Category string `mapstructure:"category"`
Name string `mapstructure:"name"`
Category string `mapstructure:"category"`
Name string `mapstructure:"name"`
Params map[string]string `mapstructure:"params"`
}
2 changes: 1 addition & 1 deletion probe/src/cgo/cgo_func.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ int runForGo() { return init_probe(); }

int getKindlingEvent(void** kindlingEvent) { return getEvent(kindlingEvent); }

void subEventForGo(char* eventName, char* category) { sub_event(eventName, category); }

int startProfile() { return start_profile(); }
int stopProfile() { return stop_profile(); }

void subEventForGo(char* eventName, char* category, void *params) { sub_event(eventName, category, (event_params_for_subscribe *)params); }
void startProfileDebug(int pid, int tid) { start_profile_debug(pid, tid); }

void stopProfileDebug() { stop_profile_debug(); }
2 changes: 1 addition & 1 deletion probe/src/cgo/cgo_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extern "C" {
#endif
int runForGo();
int getKindlingEvent(void** kindlingEvent);
void subEventForGo(char* eventName, char* category);
void subEventForGo(char* eventName, char* category, void* params);
int startProfile();
int stopProfile();
void startProfileDebug(int pid, int tid);
Expand Down
2 changes: 1 addition & 1 deletion probe/src/cgo/kindling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void init_sub_label() {
}
}

void sub_event(char* eventName, char* category) {
void sub_event(char* eventName, char* category, event_params_for_subscribe params[]) {
auto it_type = m_events.find(eventName);
if (it_type == m_events.end()) {
cout << "failed to find event " << eventName << endl;
Expand Down
7 changes: 5 additions & 2 deletions probe/src/cgo/kindling.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ uint16_t get_kindling_category(sinsp_evt* sEvt);

void init_sub_label();

void sub_event(char* eventName, char* category);

int start_profile();

int stop_profile();
Expand All @@ -51,6 +49,11 @@ struct event {
string event_name;
ppm_event_type event_type;
};
struct event_params_for_subscribe {
char *name;
char *value;
};
void sub_event(char* eventName, char* category, event_params_for_subscribe params[]);
struct kindling_event_t_for_go {
uint64_t timestamp;
char* name;
Expand Down