Skip to content

Commit c9cc690

Browse files
authored
Merge pull request #200 from solarwinds/NH-113148-docs
NH-113148 docs
2 parents 5ff6ab0 + 36c60a6 commit c9cc690

File tree

7 files changed

+50
-24
lines changed

7 files changed

+50
-24
lines changed

CONFIGURATION.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ ENV['OTEL_RUBY_INSTRUMENTATION_MYSQL2_CONFIG_OPTS'] = 'db_statement=include;'
7070

7171
## Programmatic Configuration
7272

73-
Many OpenTelemetry instrumentation library configurations can be set within the `SolarWindsAPM::OTelConfig.initialize_with_config ... end` block, please consult the individual [instrumentation](https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation) README pages for the options available. Note this takes lower precedence than the [environment varable](#instrumentation-libraries) settings.
73+
Many OpenTelemetry instrumentation library configurations can be set within the `SolarWindsAPM::OTelNativeConfig.initialize_with_config ... end` block, please consult the individual [instrumentation](https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation) README pages for the options available. Note this takes lower precedence than the [environment varable](#instrumentation-libraries) settings.
7474

7575
> [!IMPORTANT]
7676
> this feature is only enabled if auto-config is disabled via `SW_APM_AUTO_CONFIGURE=false`.
@@ -159,7 +159,7 @@ SELECT * FROM SAMPLE_TABLE WHERE user_id = 1; /* traceparent=7435a9fe510ae453341
159159

160160
#### Limitation
161161

162-
> [!NOTE]
162+
> [!NOTE]
163163
> This feature currently does not support prepared statements. For `mysql2` the `query` operation is supported, for `pg` the "[exec-ish](https://github.com/solarwinds/apm-ruby/blob/main/lib/solarwinds_apm/patch/tag_sql/sw_pg_patch.rb#L15)" operations like `exec` and `query` are supported.
164164
165165
### Background Jobs
@@ -180,4 +180,14 @@ Explanation:
180180

181181
* `RUN_AT_EXIT_HOOKS`: This option, provided by Resque, ensures that the forked processes shut down gracefully (i.e., no immediate `exit!`). This allows the background processes that handle signal (trace, metrics, etc.) transmission to complete their tasks.
182182

183-
Additionally, you need to configure the Resque initializer in your Rails application by adding the following code to `config/initializers/resque.rb`. It's recommended to have a upper bound time (e.g. 8 seconds) to avoid infinited loop if something wrong with `solarwinds_apm` initialization.
183+
### Proxy
184+
185+
Starting with version 7.0.0, the environment variable `SW_APM_PROXY` and configuration file option `:http_proxy` are deprecated since telemetry is exported with standard OTLP exporters. These exporters use Ruby's `Net::HTTP`, which supports configuring an [HTTP proxy](https://docs.ruby-lang.org/en/master/Net/HTTP.html#class-Net::HTTPSession-label-Proxy+Server). The examples below set the `http_proxy` environment variable for the Ruby process to configure the proxy:
186+
187+
```bash
188+
# proxy server with no authentication
189+
http_proxy=http://<proxyHost>:<proxyPort> ruby my.app
190+
191+
# proxy server that requires basic authentication
192+
http_proxy=http://<username>:<password>@<proxyHost>:<proxyPort> ruby my.app
193+
```

README.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
The `solarwinds_apm` gem starting from version 6.0.0 is an [OpenTelemetry Ruby](https://opentelemetry.io/docs/instrumentation/ruby/) distribution. It provides automatic instrumentation and custom SolarWinds Observability features for Ruby applications.
44

55
## Requirements
6+
> [!NOTE]
7+
> Versions before 7.0.0 only support Linux and will go into no-op mode on other platforms.
68
7-
Only Linux is supported, the gem will go into no-op mode on other platforms. MRI Ruby version 3 or above is required. The [SolarWinds Observability documentation website](https://documentation.solarwinds.com/en/success_center/observability/content/configure/services/ruby/install.htm) has details on the supported platforms and system dependencies.
9+
MRI Ruby version 3 or above is required. The [SolarWinds Observability documentation website](https://documentation.solarwinds.com/en/success_center/observability/content/configure/services/ruby/install.htm) has details on the supported platforms and system dependencies.
810

911
See [CONTRIBUTING.md](CONTRIBUTING.md) for how to build for development.
1012

@@ -32,7 +34,7 @@ The only required configuration is the service key, which can be set in the `SW_
3234

3335
## Custom Instrumentation
3436

35-
`solarwinds_apm` supports the standard OpenTelemetry API for tracing and includes a helper to ease its use in manual instrumentation. Additionally, a set of SolarWindsAPM APIs are provided for features specific to SolarWinds Observability.
37+
`solarwinds_apm` supports the standard OpenTelemetry API and includes a few convenience methods for manual instrumentation. Additionally, a set of SolarWindsAPM APIs are provided for features specific to SolarWinds Observability.
3638

3739
### Using the OpenTelemetry API
3840

@@ -60,6 +62,25 @@ current_span = ::OpenTelemetry::Trace.current_span
6062

6163
Note that if `OpenTelemetry::SDK.configure` is used to set up a `TracerProvider`, it will not be configured with our distribution's customizations and manual instrumentation made with its `Tracer` object will not be reported to SolarWinds Observability.
6264

65+
This gem also initializes a global `MeterProvider`, so your application can create Meters and Metric Instruments as follows to collect custom metrics, which will be exported every 60 seconds.
66+
67+
```ruby
68+
# set up meter and create a counter instrument
69+
MyAppMeter = ::OpenTelemetry.meter_provider.meter('myapp')
70+
counter = MyAppMeter.create_counter('password.resets',
71+
description: 'Count of password reset requests to myapp',
72+
unit: '{request}'
73+
)
74+
75+
# increment counter
76+
def reset
77+
counter.add(1, attributes: {'user.id' => user_id})
78+
# do things
79+
end
80+
```
81+
82+
See the [OTel Ruby Metrics README](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/metrics_api/README.md) for more information on the API and links to examples.
83+
6384
### Using the SolarWindsAPM API
6485

6586
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).
@@ -158,7 +179,10 @@ By default, transaction names are constructed based on attributes such as the re
158179
result = SolarWindsAPM::API.set_transaction_name('my-custom-trace-name')
159180
```
160181

161-
#### Send Custom Metrics (Depreciated)
182+
#### Send Custom Metrics (Deprecated)
183+
184+
> [!NOTE]
185+
> Starting from version 7.0.0 these are no-op, standard OTel API should be used instead.
162186
163187
Service metrics are automatically collected by this library. In addition, the following methods support sending two types of custom metrics:
164188

lambda/otel/layer/Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ source 'https://rubygems.org'
66
# source 'https://rubygems.pkg.github.com/solarwinds' do
77
# end
88

9-
gem 'solarwinds_apm', '7.0.0.prev1'
9+
gem 'solarwinds_apm'

lib/rails/generators/solarwinds_apm/templates/solarwinds_apm_initializer.rb

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,12 @@
3535
# It sets the log level and takes the following values:
3636
# -1 disabled, 0 fatal, 1 error, 2 warning, 3 info (the default), 4 debug low, 5 debug medium, 6 debug high.
3737
# Values out of range (< -1 or > 6) are ignored and the log level is set to the default (info).
38-
#
39-
SolarWindsAPM::Config[:debug_level] = 3
40-
4138
#
4239
# :debug_level will map the Ruby logger as DISABLED, FATAL, ERROR, WARN, INFO, or DEBUG
4340
# The Ruby logger can afterwards be changed to a different level, e.g:
4441
# SolarWindsAPM.logger.level = Logger::INFO
42+
#
43+
SolarWindsAPM::Config[:debug_level] = 3
4544

4645
#
4746
# Turn Tracing on or off
@@ -101,16 +100,6 @@
101100
# }
102101
]
103102

104-
#
105-
# EC2 Metadata Fetching Timeout
106-
#
107-
# The timeout can be in the range 0 - 3000 (milliseconds)
108-
# Setting to 0 milliseconds effectively disables fetching from
109-
# the metadata URL (not waiting), and should only be used if
110-
# not running on EC2 / Openstack to minimize agent start up time.
111-
#
112-
SolarWindsAPM::Config[:ec2_metadata_timeout] = 1000
113-
114103
#
115104
# Trigger Trace Mode
116105
#

lib/solarwinds_apm/api/custom_metrics.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module CustomMetrics
3333
# * Boolean
3434
#
3535
def increment_metric(_name, _count = 1, _with_hostname = false, _tags_kvs = {}) # rubocop:disable Style/OptionalBooleanParameter
36-
SolarWindsAPM.logger.warn { 'increment_metric have been deprecated. Please use opentelemetry metrics-sdk to log metrics data.' }
36+
SolarWindsAPM.logger.warn { 'increment_metric is deprecated, please use the OpenTelemetry API instead.' }
3737
false
3838
end
3939

@@ -64,7 +64,7 @@ def increment_metric(_name, _count = 1, _with_hostname = false, _tags_kvs = {})
6464
# * Boolean
6565
#
6666
def summary_metric(_name, _value, _count = 1, _with_hostname = false, _tags_kvs = {}) # rubocop:disable Style/OptionalBooleanParameter
67-
SolarWindsAPM.logger.warn { 'summary_metric have been deprecated. Please use opentelemetry metrics-sdk to log metrics data.' }
67+
SolarWindsAPM.logger.warn { 'summary_metric is deprecated, please use the OpenTelemetry API instead.' }
6868
false
6969
end
7070

lib/solarwinds_apm/config.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ def self.[]=(key, value)
226226
when :tag_sql
227227
enable_disable_config('SW_APM_TAG_SQL', key, value, false, bool: true)
228228

229+
when :ec2_metadata_timeout
230+
SolarWindsAPM.logger.warn { ':ec2_metadata_timeout is deprecated' }
231+
229232
when :http_proxy
230233
SolarWindsAPM.logger.warn { ':http_proxy is deprecated' }
231234

lib/solarwinds_apm/noop/api.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ def hash_for_log
5656
# CustomMetrics
5757
module CustomMetrics
5858
def increment_metric(*)
59-
SolarWindsAPM.logger.warn { 'increment_metric have been deprecated. Please use opentelemetry metrics-sdk to log metrics data.' }
59+
SolarWindsAPM.logger.warn { 'increment_metric is deprecated, please use the OpenTelemetry API instead.' }
6060
false
6161
end
6262

6363
def summary_metric(*)
64-
SolarWindsAPM.logger.warn { 'summary_metric have been deprecated. Please use opentelemetry metrics-sdk to log metrics data.' }
64+
SolarWindsAPM.logger.warn { 'summary_metric is deprecated, please use the OpenTelemetry API instead.' }
6565
false
6666
end
6767
end

0 commit comments

Comments
 (0)