Skip to content

Commit

Permalink
chore: namespace observe c api (#164)
Browse files Browse the repository at this point in the history
* fix: go adapter, apply span tags and memory grow to current span instead of last subspan

* chore: namespace c/c++ observe api
  • Loading branch information
G4Vi authored Mar 25, 2024
1 parent 2993baa commit 4f1734a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
8 changes: 4 additions & 4 deletions observe-api/c/observe_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
#include <stdlib.h>
#include <string.h>

void span_enter(const char *name) {
void observe_api_span_enter(const char *name) {
const uint32_t uint32_ptr = (uint32_t)name;
const uint32_t uint32_length = strlen(name);
_span_enter(uint32_ptr, uint32_length);
}

void span_exit(void) { _span_exit(); }
void observe_api_span_exit(void) { _span_exit(); }

void metric(const char *metric) {
void observe_api_metric(const char *metric) {
const uint32_t uint32_ptr = (uint32_t)metric;
const uint32_t uint32_length = strlen(metric);
_metric(1, uint32_ptr, uint32_length);
}

void write_log(const enum DO_LOG_LEVEL level, const char *msg) {
void observe_api_write_log(const enum DO_LOG_LEVEL level, const char *msg) {
const uint32_t uint32_ptr = (uint32_t)msg;
const uint32_t uint32_length = strlen(msg);
const uint32_t uint32_level = level;
Expand Down
16 changes: 12 additions & 4 deletions observe-api/c/observe_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,17 @@ enum DO_LOG_LEVEL {
DO_LL_TRACE = 4
};

void span_enter(const char *name);
void span_exit(void);
void metric(const char *metric);
void write_log(const enum DO_LOG_LEVEL level, const char *msg);
#ifdef __cplusplus
extern "C" {
#endif

void observe_api_span_enter(const char *name);
void observe_api_span_exit(void);
void observe_api_metric(const char *metric);
void observe_api_write_log(const enum DO_LOG_LEVEL level, const char *msg);

#ifdef __cplusplus
}
#endif

#endif
8 changes: 4 additions & 4 deletions observe-api/test/c/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
#include <stdlib.h>

void run() {
span_enter("printf");
observe_api_span_enter("printf");
printf("Hello from Wasm!\n");
span_exit();
observe_api_span_exit();
}

int main(int argc, char *argv[]) {
span_enter("run");
observe_api_span_enter("run");
run();
span_exit();
observe_api_span_exit();

return 0;
}
Binary file modified observe-api/test/c_guest.wasm
Binary file not shown.
Binary file modified observe-api/test/cxx_guest.wasm
Binary file not shown.

0 comments on commit 4f1734a

Please sign in to comment.