Commit 75c8a39
feat: add span flags support for isRemote property (#1917)
* feat(otlp-exporter): add span flags support for isRemote property
This commit implements the missing isRemote flag functionality in the Ruby
OpenTelemetry SDK's OTLP exporter, bringing it to feature parity with Go,
Python, PHP, and JavaScript SDKs.
Changes:
- Add span flags constants matching OTLP specification (0x100, 0x200)
- Implement build_span_flags method following OTLP spec
- Extend SpanData to include parent_span_context field
- Update span creation to store parent span context
- Modify OTLP exporter to set flags for both spans and links
- Update protobuf definitions to include flags field
- Add comprehensive test coverage for all scenarios
The implementation follows the exact same pattern as other OpenTelemetry
SDKs, ensuring consistency across language implementations.
Flag values:
- Local context: 0x100 (SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK)
- Remote context: 0x300 (HAS_IS_REMOTE_MASK | IS_REMOTE_MASK)
Fixes: Missing span flags support in OTLP exporter
Resolves: Feature parity with other OpenTelemetry SDKs
* chore: updated changelog PR number
* chore: added passing of parent_span_is_remote boolean in place of parent_span_context
* fix: move isRemote implementation to correct production exporter
- Revert changes from exporter/otlp-common (incomplete refactoring)
- Remove span_flags.rb and tests from otlp-common
- Add span_flags.rb to correct location in exporter/otlp
- Implementation now in production exporter/otlp/lib/opentelemetry/exporter/otlp/exporter.rb
This addresses reviewer feedback that the common.rb file was not the production version.
* refactor: improve build_span_flags function based on reviewer feedback
- Remove default value for base_flags parameter (make it required)
- Combine flag initialization into single line for better conciseness
- Maintains same functionality while improving code clarity
Addresses reviewer suggestion for cleaner, more explicit function signature.
* refactor: remove intermediate variable assignment in as_otlp_span
- Remove span variable assignment and use .tap method instead
- More concise code while maintaining same functionality
- Addresses reviewer suggestion for cleaner code structure
The .tap method allows us to set the flags field and return the span
object in a single expression, eliminating the need for an intermediate variable.
* refactor: pass flags directly as named argument to Span.new
- Remove .tap method and pass flags: as named argument to Span.new constructor
- More concise and cleaner code structure
- Addresses reviewer suggestion for direct parameter passing
This eliminates the need for separate span.flags assignment and makes
the code more readable by setting all span properties in one place.
* refactor: pass flags directly as named argument to Link.new
- Remove intermediate link_proto variable assignment
- Pass flags: as named argument directly to Link.new constructor
- Apply same pattern as span creation for consistency
- More concise and cleaner code structure
This completes the refactoring to pass flags directly in constructors
for both spans and links, eliminating separate assignment steps.
* chore: implemented changes in expected file and improved code post review
* fix: fix for failing test cases
* fix: moved constants to a suitable location
* failing test changes
* chore: delete manual constants for span_flags and use the latest from the protobuf updates for the SDK
* fix: added fix for workflow failing tests
* fix: failing workflows
* fix: replace magic number with SAMPLED constant
* fix: all robocop offenses
* fix: update base_flags_int and test objects
* fix: do not pass integers to build_span_flags
* chore: removed changelog
---------
Co-authored-by: Kayla Reopelle <[email protected]>1 parent 90ae798 commit 75c8a39
File tree
4 files changed
+187
-6
lines changed- exporter/otlp
- lib/opentelemetry/exporter/otlp
- test/opentelemetry/exporter/otlp
- sdk/lib/opentelemetry/sdk/trace
4 files changed
+187
-6
lines changedLines changed: 24 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
106 | 126 | | |
107 | 127 | | |
108 | 128 | | |
| |||
336 | 356 | | |
337 | 357 | | |
338 | 358 | | |
339 | | - | |
| 359 | + | |
340 | 360 | | |
| 361 | + | |
341 | 362 | | |
342 | 363 | | |
343 | 364 | | |
| |||
346 | 367 | | |
347 | 368 | | |
348 | 369 | | |
349 | | - | |
| 370 | + | |
| 371 | + | |
350 | 372 | | |
351 | 373 | | |
352 | 374 | | |
| |||
Lines changed: 157 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
672 | 672 | | |
673 | 673 | | |
674 | 674 | | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
675 | 679 | | |
676 | 680 | | |
677 | 681 | | |
| |||
684 | 688 | | |
685 | 689 | | |
686 | 690 | | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
687 | 695 | | |
688 | 696 | | |
689 | 697 | | |
| |||
696 | 704 | | |
697 | 705 | | |
698 | 706 | | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
699 | 711 | | |
700 | 712 | | |
701 | 713 | | |
| |||
740 | 752 | | |
741 | 753 | | |
742 | 754 | | |
743 | | - | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
744 | 760 | | |
745 | 761 | | |
746 | 762 | | |
747 | 763 | | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
748 | 768 | | |
749 | 769 | | |
750 | 770 | | |
| |||
762 | 782 | | |
763 | 783 | | |
764 | 784 | | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
765 | 789 | | |
766 | 790 | | |
767 | 791 | | |
| |||
779 | 803 | | |
780 | 804 | | |
781 | 805 | | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
782 | 938 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
312 | 312 | | |
313 | 313 | | |
314 | 314 | | |
315 | | - | |
| 315 | + | |
| 316 | + | |
316 | 317 | | |
317 | 318 | | |
318 | 319 | | |
319 | 320 | | |
320 | | - | |
| 321 | + | |
321 | 322 | | |
322 | 323 | | |
323 | 324 | | |
324 | 325 | | |
325 | 326 | | |
| 327 | + | |
326 | 328 | | |
327 | 329 | | |
328 | 330 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
0 commit comments