Class: Appsignal::Extension::Transaction

Inherits:
Object
  • Object
show all
Defined in:
ext/appsignal_extension.c

Instance Method Summary collapse

Instance Method Details

#completeObject



258
259
260
261
262
263
264
265
# File 'ext/appsignal_extension.c', line 258

static VALUE complete_transaction(VALUE self) {
  appsignal_transaction_t* transaction;

  Data_Get_Struct(self, appsignal_transaction_t, transaction);

  appsignal_complete_transaction(transaction);
  return Qnil;
}

#finish(gc_duration_ms) ⇒ Object



247
248
249
250
251
252
253
254
255
256
# File 'ext/appsignal_extension.c', line 247

static VALUE finish_transaction(VALUE self, VALUE gc_duration_ms) {
  appsignal_transaction_t* transaction;
  int sample;

  Check_Type(gc_duration_ms, T_FIXNUM);
  Data_Get_Struct(self, appsignal_transaction_t, transaction);

  sample = appsignal_finish_transaction(transaction, NUM2LONG(gc_duration_ms));
  return sample == 1 ? Qtrue : Qfalse;
}

#finish_event(name, title, body, body_format, gc_duration_ms) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'ext/appsignal_extension.c', line 80

static VALUE finish_event(VALUE self, VALUE name, VALUE title, VALUE body, VALUE body_format, VALUE gc_duration_ms) {
  appsignal_transaction_t* transaction;
  appsignal_data_t* body_data;
  int body_type;

  Check_Type(name, T_STRING);
  Check_Type(title, T_STRING);
  Check_Type(body_format, T_FIXNUM);

  Data_Get_Struct(self, appsignal_transaction_t, transaction);

  body_type = TYPE(body);
  if (body_type == T_STRING) {
    appsignal_finish_event(
        transaction,
        make_appsignal_string(name),
        make_appsignal_string(title),
        make_appsignal_string(body),
        FIX2INT(body_format),
        FIX2LONG(gc_duration_ms)
    );
  } else if (body_type == RUBY_T_DATA) {
    Data_Get_Struct(body, appsignal_data_t, body_data);
    appsignal_finish_event_data(
        transaction,
        make_appsignal_string(name),
        make_appsignal_string(title),
        body_data,
        FIX2INT(body_format),
        FIX2LONG(gc_duration_ms)
    );
  } else {
      rb_raise(rb_eTypeError, "body should be a String or Appsignal::Extension::Data");
  }

  return Qnil;
}

#record_event(name, title, body, duration, body_format, gc_duration_ms) ⇒ Object



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'ext/appsignal_extension.c', line 118

static VALUE record_event(VALUE self, VALUE name, VALUE title, VALUE body, VALUE duration, VALUE body_format, VALUE gc_duration_ms) {
  appsignal_transaction_t* transaction;
  appsignal_data_t* body_data;
  int body_type;
  int duration_type;

  Check_Type(name, T_STRING);
  Check_Type(title, T_STRING);
  duration_type = TYPE(duration);
  if (duration_type != T_FIXNUM && duration_type != T_BIGNUM) {
      rb_raise(rb_eTypeError, "duration should be a Fixnum or Bignum");
  }
  Check_Type(body_format, T_FIXNUM);

  Data_Get_Struct(self, appsignal_transaction_t, transaction);

  body_type = TYPE(body);
  if (body_type == T_STRING) {
    appsignal_record_event(
        transaction,
        make_appsignal_string(name),
        make_appsignal_string(title),
        make_appsignal_string(body),
        FIX2INT(body_format),
        NUM2LONG(duration),
        NUM2LONG(gc_duration_ms)
    );
  } else if (body_type == RUBY_T_DATA) {
    Data_Get_Struct(body, appsignal_data_t, body_data);
    appsignal_record_event_data(
        transaction,
        make_appsignal_string(name),
        make_appsignal_string(title),
        body_data,
        FIX2INT(body_format),
        NUM2LONG(duration),
        NUM2LONG(gc_duration_ms)
    );
  } else {
      rb_raise(rb_eTypeError, "body should be a String or Appsignal::Extension::Data");
  }

  return Qnil;
}

#set_action(action) ⇒ Object



201
202
203
204
205
206
207
208
209
210
211
212
# File 'ext/appsignal_extension.c', line 201

static VALUE set_transaction_action(VALUE self, VALUE action) {
  appsignal_transaction_t* transaction;

  Check_Type(action, T_STRING);
  Data_Get_Struct(self, appsignal_transaction_t, transaction);

  appsignal_set_transaction_action(
      transaction,
      make_appsignal_string(action)
  );
  return Qnil;
}

#set_error(name, message, backtrace) ⇒ Object



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'ext/appsignal_extension.c', line 163

static VALUE set_transaction_error(VALUE self, VALUE name, VALUE message, VALUE backtrace) {
  appsignal_transaction_t* transaction;
  appsignal_data_t* backtrace_data;

  Check_Type(name, T_STRING);
  Check_Type(message, T_STRING);
  Check_Type(backtrace, RUBY_T_DATA);

  Data_Get_Struct(self, appsignal_transaction_t, transaction);
  Data_Get_Struct(backtrace, appsignal_data_t, backtrace_data);

  appsignal_set_transaction_error(
      transaction,
      make_appsignal_string(name),
      make_appsignal_string(message),
      backtrace_data
  );
  return Qnil;
}

#set_metadata(key, value) ⇒ Object



232
233
234
235
236
237
238
239
240
241
242
243
244
245
# File 'ext/appsignal_extension.c', line 232

static VALUE set_transaction_metadata(VALUE self, VALUE key, VALUE value) {
  appsignal_transaction_t* transaction;

  Check_Type(key, T_STRING);
  Check_Type(value, T_STRING);
  Data_Get_Struct(self, appsignal_transaction_t, transaction);

  appsignal_set_transaction_metadata(
      transaction,
      make_appsignal_string(key),
      make_appsignal_string(value)
  );
  return Qnil;
}

#set_queue_start(queue_start) ⇒ Object



214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# File 'ext/appsignal_extension.c', line 214

static VALUE set_transaction_queue_start(VALUE self, VALUE queue_start) {
  appsignal_transaction_t* transaction;
  int queue_start_type;

  queue_start_type = TYPE(queue_start);
  if (queue_start_type != T_FIXNUM && queue_start_type != T_BIGNUM) {
      rb_raise(rb_eTypeError, "queue_start should be a Fixnum or Bignum");
  }

  Data_Get_Struct(self, appsignal_transaction_t, transaction);

  appsignal_set_transaction_queue_start(
      transaction,
      NUM2LONG(queue_start)
  );
  return Qnil;
}

#set_sample_data(key, payload) ⇒ Object



183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'ext/appsignal_extension.c', line 183

static VALUE set_transaction_sample_data(VALUE self, VALUE key, VALUE payload) {
  appsignal_transaction_t* transaction;
  appsignal_data_t* payload_data;

  Check_Type(key, T_STRING);
  Check_Type(payload, RUBY_T_DATA);

  Data_Get_Struct(self, appsignal_transaction_t, transaction);
  Data_Get_Struct(payload, appsignal_data_t, payload_data);

  appsignal_set_transaction_sample_data(
      transaction,
      make_appsignal_string(key),
      payload_data
  );
  return Qnil;
}

#start_event(gc_duration_ms) ⇒ Object

Transaction instance methods



68
69
70
71
72
73
74
75
76
77
78
# File 'ext/appsignal_extension.c', line 68

static VALUE start_event(VALUE self, VALUE gc_duration_ms) {
  appsignal_transaction_t* transaction;

  Check_Type(gc_duration_ms, T_FIXNUM);

  Data_Get_Struct(self, appsignal_transaction_t, transaction);

  appsignal_start_event(transaction, NUM2LONG(gc_duration_ms));

  return Qnil;
}