solarwinds_apm 6.1.1 → 6.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ab7453d8ca9dc042ac880b99dd8cd11d6344e3372bb84b2fab1e6b4fa3d65ab
4
- data.tar.gz: '009803a9d3ad0f678824c57dca3031ef3b9f79989c00fecb16946962cb641f1e'
3
+ metadata.gz: 73f2befcea2c555995f79719d36c68d2448ae31f56656741d5c6e8d49e61963b
4
+ data.tar.gz: 4ba3986285dcda8adc5629c2e08b5221638928d06733dd6fc0c009379b97ab4b
5
5
  SHA512:
6
- metadata.gz: d80d9759f1050927d249d9ac1264eb6bd5407603cf2fee8c09ce27137c6b39773ea3f7b57dd7e5c428890a9ee27f7ba1cc02d20672bef43cfb0470f04de0b70c
7
- data.tar.gz: 664ade107e0f49a1709d0d5b87012ea6766094d469b3942afb10100a63c066735f512bb7d2aafae5925b99f4a305f4d2f2a31101090f3bddeee68e722e6efafd
6
+ metadata.gz: 777aebc61cfb1f6776f0640f9b0cbd6005c5c375989a046809ce4f97551a8f2925154496eeef798726ac2242641646bb590c48d23caf71165473b0ac0cfa6b52
7
+ data.tar.gz: c244cb0d3c1252cbcb85f3381cc82195ca8d59bf0ea4991f2c41f89a49d29a92efcf089ee35ae6274614493bd7e89d7ecb5851ec876a572d24fc5015ec7d5625
data/README.md CHANGED
@@ -64,9 +64,11 @@ Note that if `OpenTelemetry::SDK.configure` is used to set up a `TracerProvider`
64
64
 
65
65
  Several convenience and vendor-specific APIs are availabe to an application where `solarwinds_apm` has been loaded, below is a quick overview of the features provided. The full reference can be found at the [RubyDoc page for this gem](https://rubydoc.info/github/solarwinds/apm-ruby).
66
66
 
67
- #### Convenience Method for in_span
67
+ #### Convenience Method: `in_span` and `add_tracer`
68
68
 
69
- This method acquires the correct `Tracer` so a new span can be created in a single call, below is a simple Rails controller example:
69
+ `in_span` acquires the correct `Tracer` so a new span can be created in a single call.
70
+
71
+ For example, using it in a Rails controller:
70
72
 
71
73
  ```ruby
72
74
  class StaticController < ApplicationController
@@ -78,6 +80,51 @@ class StaticController < ApplicationController
78
80
  end
79
81
  ```
80
82
 
83
+ `add_tracer` can add a custom span to the specified instance or class method that is already defined. It can optionally set the span kind and additional attributes provided in hash format:
84
+
85
+ ```ruby
86
+ add_tracer :method_name, 'custom_span_name', { attributes: { 'any' => 'attributes' }, kind: :span_kind }
87
+ ```
88
+
89
+ For example, if you want to instrument class or instance method `create_session` inside an application controller:
90
+
91
+ To instrument instance method
92
+ ```ruby
93
+ class SessionsController < ApplicationController
94
+ include SolarWindsAPM::API::Tracer
95
+
96
+ def create
97
+ user = User.find_by(email: params[:session][:email].downcase)
98
+ create_session(user)
99
+ end
100
+
101
+ def create_session(user)
102
+ end
103
+
104
+ # instrument instance method create_session
105
+ add_tracer :create_session, 'custom_name', { attributes: { 'foo' => 'bar' }, kind: :consumer }
106
+ end
107
+ ```
108
+
109
+ To instrument class method
110
+ ```ruby
111
+ class SessionsController < ApplicationController
112
+ def create
113
+ user = User.find_by(email: params[:session][:email].downcase)
114
+ create_session(user)
115
+ end
116
+
117
+ def self.create_session(user)
118
+ end
119
+
120
+ # instrument class method create_session
121
+ class << self
122
+ include SolarWindsAPM::API::Tracer
123
+ add_tracer :create_session, 'custom_name', { attributes: { 'foo' => 'bar' }, kind: :consumer }
124
+ end
125
+ end
126
+ ```
127
+
81
128
  #### Get Curent Trace Context Information
82
129
 
83
130
  The `current_trace_info` method returns a `TraceInfo` object containing string representations of the current trace context that can be used in logging or manual propagation of context. This is a convenience method that wraps the OTel API `::OpenTelemetry::Trace.current_span`.