Class: Appsignal::Extension::Span
Class Method Summary collapse
-
.root(namespace) ⇒ Object
Create a span.
Instance Method Summary collapse
-
#add_error(name, message, backtrace) ⇒ Object
Set span error.
- #child ⇒ Object
-
#close ⇒ Object
Close span.
- #set_attribute_bool(key, value) ⇒ Object
- #set_attribute_double(key, value) ⇒ Object
- #set_attribute_int(key, value) ⇒ Object
-
#set_attribute_string(key, value) ⇒ Object
Set attributes on a span.
-
#set_name(name) ⇒ Object
Span name and namespace.
-
#set_sample_data(key, payload) ⇒ Object
Set span sample data.
-
#to_json ⇒ Object
Span to json.
Class Method Details
.root(namespace) ⇒ Object
Create a span
573 574 575 576 577 578 579 580 581 582 583 584 585 |
# File 'ext/appsignal_extension.c', line 573
static VALUE root_span_new(VALUE self, VALUE namespace) {
appsignal_span_t* span;
Check_Type(namespace, T_STRING);
span = appsignal_create_root_span(make_appsignal_string(namespace));
if (span) {
return Data_Wrap_Struct(Span, NULL, appsignal_free_span, span);
} else {
return Qnil;
}
}
|
Instance Method Details
#add_error(name, message, backtrace) ⇒ Object
Set span error
613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 |
# File 'ext/appsignal_extension.c', line 613
static VALUE add_span_error(VALUE self, VALUE name, VALUE message, VALUE backtrace) {
appsignal_span_t* span;
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_span_t, span);
Data_Get_Struct(backtrace, appsignal_data_t, backtrace_data);
appsignal_add_span_error(
span,
make_appsignal_string(name),
make_appsignal_string(message),
backtrace_data
);
return Qnil;
}
|
#child ⇒ Object
587 588 589 590 591 592 593 594 595 596 597 598 599 600 |
# File 'ext/appsignal_extension.c', line 587
static VALUE child_span_new(VALUE self) {
appsignal_span_t* parent;
appsignal_span_t* span;
Data_Get_Struct(self, appsignal_span_t, parent);
span = appsignal_create_child_span(parent);
if (span) {
return Data_Wrap_Struct(Span, NULL, appsignal_free_span, span);
} else {
return Qnil;
}
}
|
#close ⇒ Object
Close span
737 738 739 740 741 742 743 744 745 |
# File 'ext/appsignal_extension.c', line 737 static VALUE close_span(VALUE self) { appsignal_span_t* span; Data_Get_Struct(self, appsignal_span_t, span); appsignal_close_span(span); return Qnil; } |
#set_attribute_bool(key, value) ⇒ Object
689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 |
# File 'ext/appsignal_extension.c', line 689
static VALUE set_span_attribute_bool(VALUE self, VALUE key, VALUE value) {
appsignal_span_t* span;
Check_Type(key, T_STRING);
Data_Get_Struct(self, appsignal_span_t, span);
appsignal_set_span_attribute_bool(
span,
make_appsignal_string(key),
RTEST(value)
);
return Qnil;
}
|
#set_attribute_double(key, value) ⇒ Object
705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 |
# File 'ext/appsignal_extension.c', line 705
static VALUE set_span_attribute_double(VALUE self, VALUE key, VALUE value) {
appsignal_span_t* span;
Check_Type(key, T_STRING);
Check_Type(value, T_FLOAT);
Data_Get_Struct(self, appsignal_span_t, span);
appsignal_set_span_attribute_double(
span,
make_appsignal_string(key),
NUM2DBL(value)
);
return Qnil;
}
|
#set_attribute_int(key, value) ⇒ Object
668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 |
# File 'ext/appsignal_extension.c', line 668
static VALUE set_span_attribute_int(VALUE self, VALUE key, VALUE value) {
appsignal_span_t* span;
VALUE value_type = TYPE(value);
Check_Type(key, T_STRING);
if (value_type != T_FIXNUM && value_type != T_BIGNUM) {
rb_raise(rb_eTypeError, "wrong argument type %s (expected Integer)", rb_obj_classname(value));
}
Data_Get_Struct(self, appsignal_span_t, span);
appsignal_set_span_attribute_int(
span,
make_appsignal_string(key),
NUM2LONG(value)
);
return Qnil;
}
|
#set_attribute_string(key, value) ⇒ Object
Set attributes on a span
651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 |
# File 'ext/appsignal_extension.c', line 651
static VALUE set_span_attribute_string(VALUE self, VALUE key, VALUE value) {
appsignal_span_t* span;
Check_Type(key, T_STRING);
Check_Type(value, T_STRING);
Data_Get_Struct(self, appsignal_span_t, span);
appsignal_set_span_attribute_string(
span,
make_appsignal_string(key),
make_appsignal_string(value)
);
return Qnil;
}
|
#set_name(name) ⇒ Object
Span name and namespace
602 603 604 605 606 607 608 609 610 611 |
# File 'ext/appsignal_extension.c', line 602
static VALUE set_span_name(VALUE self, VALUE name) {
appsignal_span_t* span;
Check_Type(name, T_STRING);
Data_Get_Struct(self, appsignal_span_t, span);
appsignal_set_span_name(span, make_appsignal_string(name));
return Qnil;
}
|
#set_sample_data(key, payload) ⇒ Object
Set span sample data
633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 |
# File 'ext/appsignal_extension.c', line 633
static VALUE set_span_sample_data(VALUE self, VALUE key, VALUE payload) {
appsignal_span_t* span;
appsignal_data_t* payload_data;
Check_Type(key, T_STRING);
Check_Type(payload, RUBY_T_DATA);
Data_Get_Struct(self, appsignal_span_t, span);
Data_Get_Struct(payload, appsignal_data_t, payload_data);
appsignal_set_span_sample_data(
span,
make_appsignal_string(key),
payload_data
);
return Qnil;
}
|
#to_json ⇒ Object
Span to json
722 723 724 725 726 727 728 729 730 731 732 733 734 735 |
# File 'ext/appsignal_extension.c', line 722
static VALUE span_to_json(VALUE self) {
appsignal_span_t* span;
appsignal_string_t json;
Data_Get_Struct(self, appsignal_span_t, span);
json = appsignal_span_to_json(span);
if (json.len == 0) {
return Qnil;
} else {
return make_ruby_string(json);
}
}
|