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 (#368)

Signed-off-by: yaofighting <siyao@zju.edu.cn>
  • Loading branch information
yaofighting committed Dec 2, 2022
1 parent 8164aea commit 10ca120
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 12 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

## Unreleased
### New features
-
- 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))

Expand All @@ -14,11 +13,11 @@
- Add no_response_threshold(120s) for No response requests. ([#376](https://github.com/KindlingProject/kindling/pull/376))
- Add payload for all protocols.([#375](https://github.com/KindlingProject/kindling/pull/375))
- Add a new clustering method "blank" that is used to reduce the cardinality of metrics as much as possible. ([#372](https://github.com/KindlingProject/kindling/pull/372))
- Modify the configuration file structure and add parameter fields for subscription events. ([#368](https://github.com/CloudDectective-Harmonycloud/kindling/pull/368))


### Bug fixes
- Fix the bug where the pod metadata with persistent IP in the map is deleted incorrectly due to the deleting mechanism with a delay. ([#374](https://github.com/KindlingProject/kindling/pull/374))
-
- Fix potential deadlock of exited thread delay queue. ([#373](https://github.com/CloudDectective-Harmonycloud/kindling/pull/373))
- Fix the bug that cpuEvent cache size continuously increases even if trace profiling is not enabled.([#362](https://github.com/CloudDectective-Harmonycloud/kindling/pull/362))
- Fix the bug that duplicate CPU events are indexed into Elasticsearch. ([#359](https://github.com/KindlingProject/kindling/pull/359))
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

0 comments on commit 10ca120

Please sign in to comment.