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
594 595 596 597 598 599 600 601 602 603 604 605 606 |
# File 'ext/appsignal_extension.c', line 594
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 TypedData_Wrap_Struct(Span, &span_data_type, span);
} else {
return Qnil;
}
}
|
Instance Method Details
#add_error(name, message, backtrace) ⇒ Object
Set span error
634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 |
# File 'ext/appsignal_extension.c', line 634
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);
backtrace_data = rb_check_typeddata(backtrace, &data_data_type);
TypedData_Get_Struct(self, appsignal_span_t, &span_data_type, span);
appsignal_add_span_error(
span,
make_appsignal_string(name),
make_appsignal_string(message),
backtrace_data
);
return Qnil;
}
|
#child ⇒ Object
608 609 610 611 612 613 614 615 616 617 618 619 620 621 |
# File 'ext/appsignal_extension.c', line 608
static VALUE child_span_new(VALUE self) {
appsignal_span_t* parent;
appsignal_span_t* span;
TypedData_Get_Struct(self, appsignal_span_t, &span_data_type, parent);
span = appsignal_create_child_span(parent);
if (span) {
return TypedData_Wrap_Struct(Span, &span_data_type, span);
} else {
return Qnil;
}
}
|
#close ⇒ Object
Close span
758 759 760 761 762 763 764 765 766 |
# File 'ext/appsignal_extension.c', line 758
static VALUE close_span(VALUE self) {
appsignal_span_t* span;
TypedData_Get_Struct(self, appsignal_span_t, &span_data_type, span);
appsignal_close_span(span);
return Qnil;
}
|
#set_attribute_bool(key, value) ⇒ Object
710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 |
# File 'ext/appsignal_extension.c', line 710
static VALUE set_span_attribute_bool(VALUE self, VALUE key, VALUE value) {
appsignal_span_t* span;
Check_Type(key, T_STRING);
TypedData_Get_Struct(self, appsignal_span_t, &span_data_type, span);
appsignal_set_span_attribute_bool(
span,
make_appsignal_string(key),
RTEST(value)
);
return Qnil;
}
|
#set_attribute_double(key, value) ⇒ Object
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 |
# File 'ext/appsignal_extension.c', line 726
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);
TypedData_Get_Struct(self, appsignal_span_t, &span_data_type, span);
appsignal_set_span_attribute_double(
span,
make_appsignal_string(key),
NUM2DBL(value)
);
return Qnil;
}
|
#set_attribute_int(key, value) ⇒ Object
689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 |
# File 'ext/appsignal_extension.c', line 689
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));
}
TypedData_Get_Struct(self, appsignal_span_t, &span_data_type, 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
672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 |
# File 'ext/appsignal_extension.c', line 672
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);
TypedData_Get_Struct(self, appsignal_span_t, &span_data_type, 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
623 624 625 626 627 628 629 630 631 632 |
# File 'ext/appsignal_extension.c', line 623
static VALUE set_span_name(VALUE self, VALUE name) {
appsignal_span_t* span;
Check_Type(name, T_STRING);
TypedData_Get_Struct(self, appsignal_span_t, &span_data_type, span);
appsignal_set_span_name(span, make_appsignal_string(name));
return Qnil;
}
|
#set_sample_data(key, payload) ⇒ Object
Set span sample data
654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 |
# File 'ext/appsignal_extension.c', line 654
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);
payload_data = rb_check_typeddata(payload, &data_data_type);
TypedData_Get_Struct(self, appsignal_span_t, &span_data_type, span);
appsignal_set_span_sample_data(
span,
make_appsignal_string(key),
payload_data
);
return Qnil;
}
|
#to_json ⇒ Object
Span to json
743 744 745 746 747 748 749 750 751 752 753 754 755 756 |
# File 'ext/appsignal_extension.c', line 743
static VALUE span_to_json(VALUE self) {
appsignal_span_t* span;
appsignal_string_t json;
TypedData_Get_Struct(self, appsignal_span_t, &span_data_type, span);
json = appsignal_span_to_json(span);
if (json.len == 0) {
return Qnil;
} else {
return make_ruby_string(json);
}
}
|