sentry-native.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include "sentry-native.h"
  2. #include "daemon/common.h"
  3. #include "sentry.h"
  4. void sentry_native_init(void)
  5. {
  6. sentry_options_t *options = sentry_options_new();
  7. // we should get this from CI (SENTRY_DSN)
  8. sentry_options_set_dsn(options, NETDATA_SENTRY_DSN);
  9. // where to save sentry files
  10. char path[FILENAME_MAX];
  11. snprintfz(path, FILENAME_MAX - 1, "%s/%s", netdata_configured_cache_dir, ".sentry-native");
  12. sentry_options_set_database_path(options, path);
  13. sentry_options_set_auto_session_tracking(options, false);
  14. // TODO: we should get this from CI (SENTRY_ENVIRONMENT)
  15. sentry_options_set_environment(options, NETDATA_SENTRY_ENVIRONMENT);
  16. // TODO: we should get this from CI (SENTRY_RELEASE)
  17. sentry_options_set_release(options, NETDATA_SENTRY_RELEASE);
  18. sentry_options_set_dist(options, NETDATA_SENTRY_DIST);
  19. // TODO: use config_get() to (un)set this
  20. sentry_options_set_debug(options, 1);
  21. // TODO: ask @ktsaou/@stelfrag if we want to attach something, eg.
  22. // sentry_options_add_attachment(options, "/path/to/file");
  23. sentry_init(options);
  24. time_t now;
  25. time(&now);
  26. char message[1024];
  27. snprintfz(message, 1024 - 1, "GVD: generated at %s", ctime(&now));
  28. sentry_capture_event(sentry_value_new_message_event(
  29. SENTRY_LEVEL_INFO,
  30. "custom",
  31. message
  32. ));
  33. }
  34. void sentry_native_fini(void)
  35. {
  36. sentry_close();
  37. }