Module: Pyroscope

Defined in:
lib/pyroscope.rb,
lib/pyroscope/version.rb,
ext/pyroscope/pyroscope.c

Defined Under Namespace

Classes: Config

Constant Summary collapse

VALID_LOG_LEVELS =
%i[none error info debug]
VERSION =
"0.0.23".freeze

Class Method Summary collapse

Class Method Details

._build_summaryObject



77
78
79
80
81
82
83
# File 'ext/pyroscope/pyroscope.c', line 77

static VALUE
pyroscope_build_summary(VALUE self) {
  char *c_summary = BuildSummary();
  VALUE r_summary = rb_str_new_cstr(c_summary);
  free(c_summary);
  return r_summary;
}

._change_name(appName) ⇒ Object



45
46
47
48
49
50
51
52
# File 'ext/pyroscope/pyroscope.c', line 45

static VALUE
pyroscope_change_name(VALUE self, VALUE appName) {
  VALUE r_appName = StringValue(appName);
  char *c_appName = RSTRING_PTR(r_appName);

  int res = ChangeName(c_appName);
  return INT2FIX(res);
}

._set_logger_level(level) ⇒ Object



71
72
73
74
75
# File 'ext/pyroscope/pyroscope.c', line 71

static VALUE
pyroscope_set_logger_level(VALUE self, VALUE level) {
  int res = SetLoggerLevel(FIX2INT(level));
  return INT2FIX(res);
}

._set_tag(key, val) ⇒ Object



54
55
56
57
58
59
60
61
62
63
# File 'ext/pyroscope/pyroscope.c', line 54

static VALUE
pyroscope_set_tag(VALUE self, VALUE key, VALUE val) {
  VALUE r_key = StringValue(key);
  char *c_key = RSTRING_PTR(r_key);
  VALUE r_val = StringValue(val);
  char *c_val = RSTRING_PTR(r_val);

  int res = SetTag(c_key, c_val);
  return INT2FIX(res);
}

._start(appName, serverAddress, authToken, sampleRate, withSubprocesses, logLevel) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'ext/pyroscope/pyroscope.c', line 17

static VALUE
pyroscope_start(VALUE self, VALUE appName, VALUE serverAddress, VALUE authToken, VALUE sampleRate, VALUE withSubprocesses, VALUE logLevel) {
  VALUE r_appName = StringValue(appName);
  char *c_appName = RSTRING_PTR(r_appName);

  int c_sampleRate = FIX2INT(sampleRate);
  int c_withSubprocesses = FIX2INT(withSubprocesses);

  VALUE r_serverAddress = StringValue(serverAddress);
  char *c_serverAddress = RSTRING_PTR(r_serverAddress);

  VALUE r_authToken = StringValue(authToken);
  char *c_authToken = RSTRING_PTR(r_authToken);

  VALUE r_logLevel = StringValue(logLevel);
  char *c_logLevel = RSTRING_PTR(r_logLevel);

  int res = Start(c_appName, "rbspy", c_serverAddress, c_authToken, c_sampleRate, c_withSubprocesses, c_logLevel);

  return INT2FIX(res);
}

._stopObject



39
40
41
42
43
# File 'ext/pyroscope/pyroscope.c', line 39

static VALUE
pyroscope_stop(VALUE self) {
  int res = Stop();
  return INT2FIX(res);
}

._test_loggerObject



65
66
67
68
69
# File 'ext/pyroscope/pyroscope.c', line 65

static VALUE
pyroscope_test_logger(VALUE self) {
  int res = TestLogger();
  return INT2FIX(res);
}

.build_summaryObject



46
47
48
# File 'lib/pyroscope.rb', line 46

def build_summary
  _build_summary
end

.change_name(new_name) ⇒ Object



25
26
27
# File 'lib/pyroscope.rb', line 25

def change_name(new_name)
  _change_name(new_name)
end

.configure {|@configuration| ... } ⇒ Object

Yields:

  • (@configuration)


8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/pyroscope.rb', line 8

def configure
  @configuration = Config.new
  yield @configuration
  _start(
    @configuration.app_name,
    @configuration.server_address,
    @configuration.auth_token || "",
    @configuration.sample_rate || 100,
    @configuration.with_subprocesses || 0,
    @configuration.log_level || "error",
  )
end

.set_logger_level(level) ⇒ Object



39
40
41
42
43
44
# File 'lib/pyroscope.rb', line 39

def set_logger_level(level)
  i = VALID_LOG_LEVELS.index(level)
  raise "Unknown log level (#{level.inspect}), valid values are #{VALID_LOG_LEVELS.inspect}" unless i

  _set_logger_level(i - 1)
end

.set_tag(key, val) ⇒ Object



29
30
31
# File 'lib/pyroscope.rb', line 29

def set_tag(key, val)
  _set_tag(key, val)
end

.stopObject



21
22
23
# File 'lib/pyroscope.rb', line 21

def stop
  _stop
end

.test_loggerObject



33
34
35
# File 'lib/pyroscope.rb', line 33

def test_logger()
  _test_logger
end