Skip to content

Commit

Permalink
Modify the configuration file structure and add parameter fields for …
Browse files Browse the repository at this point in the history
…subscription events

Signed-off-by: yaofighting <siyao@zju.edu.cn>
  • Loading branch information
yaofighting committed Nov 23, 2022
1 parent d4e2652 commit eb04934
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
-
-
- 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))


### Enhancements
Expand Down
5 changes: 5 additions & 0 deletions collector/pkg/component/receiver/cgoreceiver/cgo_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 11 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,22 @@ 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
var paramsList []CEventParamsForSubscribe
var temp CEventParamsForSubscribe
temp.name = C.CString("none")
temp.value = C.CString("none")
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"`
}
4 changes: 2 additions & 2 deletions probe/src/cgo/cgo_func.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ int getKindlingEvent(void **kindlingEvent){
}


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

int startProfile() {
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 @@ -62,7 +62,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()) {
Expand Down
6 changes: 5 additions & 1 deletion probe/src/cgo/kindling.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ uint16_t get_kindling_category(sinsp_evt *sEvt);

void init_sub_label();

void sub_event(char *eventName, char *category);
void sub_event(char* eventName, char* category, event_params_for_subscribe params[]);

int start_profile();

Expand All @@ -51,6 +51,10 @@ struct event {
string event_name;
ppm_event_type event_type;
};
struct event_params_for_subscribe {
char *name;
char *value;
};
struct kindling_event_t_for_go{
uint64_t timestamp;
char *name;
Expand Down

0 comments on commit eb04934

Please sign in to comment.