splunk-otel 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b26ca5033148be9cca92f15da5226356a391db3d3f2da45b144b64381a321b69
4
- data.tar.gz: c6a6fbb2e6a784bb149654d77a1736f3aab4ba18827a25000561ea05271bf6a1
3
+ metadata.gz: fcafe2c8c9d5df1735256ab1d088eba1679b07c55f7790dc1b90f24cce3cfa34
4
+ data.tar.gz: a161059f434a56f484bb5b7e7c40da09c5333b067b18676bd6ac2c648ee5dbd4
5
5
  SHA512:
6
- metadata.gz: 9a6156c5569d2dd5a85cbff060c0def7d8fe4c35408b9545b5d1704306bbb945ef0c11273844d9c7ad7fff7079b8b95b3ee3d9101451e4c388bad7c5c0f46bd2
7
- data.tar.gz: 56b7fd62c64d001e9e60226e7a119f374734a59d984bf21e47056b19b7ee419a79c059059c5d7982175309654ccaed04694218858952eadb06f1249ba65a31ac
6
+ metadata.gz: 807de3ed7cd3135b07a65bfc296f6930dfb2904e9b01e5baae0b20aeb1e7a121b6a55064d1d38ab633644b6dcb68bb2f0f4e567ca95e9b27bc47d98dee6d59b0
7
+ data.tar.gz: b30aede6336990f2e73c4d525ec056fe37d63bf0191b865298cd01c89cfbe060f640c2a30645cf7c927702d32e8e4409475e4099a7b0c00b61a95921f241abd3
@@ -0,0 +1,17 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ open-pull-requests-limit: 10
8
+ - package-ecosystem: "github-actions"
9
+ directory: "/"
10
+ schedule:
11
+ interval: "weekly"
12
+ day: "friday"
13
+ - package-ecosystem: "docker"
14
+ directory: "/examples/rails-7-barebones/"
15
+ schedule:
16
+ interval: "weekly"
17
+ day: "friday"
@@ -15,7 +15,7 @@ jobs:
15
15
  ruby-version: [3.1, 3.0, 2.7, 2.6]
16
16
 
17
17
  steps:
18
- - uses: actions/checkout@v2
18
+ - uses: actions/checkout@v3
19
19
 
20
20
  - name: Run Collector
21
21
  run: docker-compose up -d
@@ -33,6 +33,8 @@ jobs:
33
33
  run: bundle exec rubocop
34
34
  - name: Run tests
35
35
  run: bundle exec rake test
36
+ - name: Upload coverage to Codecov
37
+ uses: codecov/codecov-action@v3
36
38
  - name: Run basic example e2e test
37
39
  run: ruby console.rb
38
40
  working-directory: ./examples/basic/
@@ -42,7 +44,16 @@ jobs:
42
44
  test-e2e-rails-7-barebones:
43
45
  runs-on: ubuntu-latest
44
46
  steps:
45
- - uses: actions/checkout@v2
47
+ - uses: actions/checkout@v3
46
48
  - name: Run e2e tests via Docker
47
49
  working-directory: ./examples/rails-7-barebones
48
50
  run: docker-compose up --build --exit-code-from tester
51
+
52
+ linkChecker:
53
+ runs-on: ubuntu-latest
54
+ steps:
55
+ - uses: actions/checkout@v3
56
+ - name: Link Checker
57
+ uses: lycheeverse/lychee-action@v1.5.0
58
+ with:
59
+ fail: true
data/.gitlab-ci.yml CHANGED
@@ -1,18 +1,31 @@
1
1
  image:
2
2
  name: "docker-hub.repo.splunkdev.net/ruby:3.1.2"
3
3
 
4
+ include:
5
+ - project: 'ci-cd/templates'
6
+ ref: master
7
+ file: '/prodsec/.oss-scan.yml'
8
+
4
9
  stages:
5
10
  - build
11
+ - scan
6
12
  - release
7
13
 
8
14
  build:
9
15
  stage: build
16
+ artifacts:
17
+ paths:
18
+ - Gemfile.lock
10
19
  script: |
11
20
  gem update --system
12
21
  bundle install
13
22
  bundle exec rubocop
14
23
  bundle exec rake test
15
24
 
25
+ oss-scan:
26
+ stage: scan
27
+ extends: .oss-scan
28
+
16
29
  release:
17
30
  stage: release
18
31
  rules:
data/.lycheeignore ADDED
@@ -0,0 +1,2 @@
1
+ https://docs.splunk.com/Observability/gdi/get-data-in/application/ruby/get-started.html
2
+ http://localhost:4318/
data/.rubocop.yml CHANGED
@@ -25,3 +25,6 @@ Metrics/AbcSize:
25
25
 
26
26
  Metrics/MethodLength:
27
27
  Max: 15
28
+
29
+ Metrics/ModuleLength:
30
+ Max: 105
data/CHANGELOG.md CHANGED
@@ -7,4 +7,26 @@ and this repository adheres to [Semantic Versioning](https://semver.org/spec/v2.
7
7
 
8
8
  ## Unreleased
9
9
 
10
+ ## v0.2.0 - 2022-09-06
10
11
 
12
+ ### Added
13
+
14
+ - OpenTelemetry Ruby SDK and API are updated to 1.0
15
+ - [pre-configured support for Smart
16
+ Agent](https://github.com/signalfx/splunk-otel-ruby/pull/8)
17
+ - [support for SPLUNK_TRACE_RESPONSE_HEADER_ENABLED environment
18
+ variable](https://github.com/signalfx/splunk-otel-ruby/pull/38)
19
+
20
+ ## v0.1.0 - 2022-07-27
21
+
22
+ ### Added
23
+
24
+ - [railtie based RUM Rack instrumentation](https://github.com/signalfx/splunk-otel-ruby/pull/26)
25
+ - [basic example using splunk distro](https://github.com/signalfx/splunk-otel-ruby/pull/20)
26
+ - [example of the most simplified rails setup](https://github.com/signalfx/splunk-otel-ruby/pull/24)
27
+ - [Rack RUM middleware](https://github.com/signalfx/splunk-otel-ruby/pull/23)
28
+ - [splunk.distro.version to resource attributes](https://github.com/signalfx/splunk-otel-ruby/pull/9)
29
+ - [MIGRATING.md docs for migrating from SignalFX Tracing Library](https://github.com/signalfx/splunk-otel-ruby/pull/18)
30
+ - [standard logging correlation formatter](https://github.com/signalfx/splunk-otel-ruby/pull/11)
31
+ - support `SPLUNK_ACCESS_TOKEN` and `SPLUNK_REALM` environment variables for direct
32
+ to Splunk exporting
data/MIGRATING.md CHANGED
@@ -1,20 +1,27 @@
1
1
  # Migrate from the SignalFx Tracing Library for Ruby
2
2
 
3
- The SignalFx Tracing Library for Ruby is deprecated. Replace it with the
4
- agent from the Splunk Distribution of OpenTelemetry Ruby.
3
+ The SignalFx Tracing Library for Ruby is scheduled to be deprecated by the end of 2022.
4
+ Replace it with the Splunk Distribution of OpenTelemetry Ruby.
5
5
 
6
- The agent of the Splunk Distribution of OpenTelemetry Ruby is based on
7
- the OpenTelemetry Instrumentation for Ruby, an open-source project that
8
- uses the OpenTelemetry API.
9
-
10
- Read the following instructions to learn how to migrate to the Splunk
11
- Ruby OTel agent.
6
+ Splunk Distribution of OpenTelemetry Ruby is based on and compatible with
7
+ the OpenTelemetry Instrumentation for Ruby,
8
+ an open-source project that uses the OpenTelemetry API.
12
9
 
13
10
  ## Compatibility and requirements
14
11
 
15
12
  The Splunk Distribution of OpenTelemetry Ruby requires Ruby 2.6 and
16
13
  higher.
17
14
 
15
+ ## Known limitations compared to SignalFx Tracing for Ruby
16
+
17
+ - Different subset of supported Ruby versions, see previous section
18
+ - Currently no auto-instrumentation for:
19
+ - `elasticsearch` (<https://github.com/elastic/elasticsearch-ruby>)
20
+ - `grape` (<https://github.com/ruby-grape/grape>)
21
+ - `sequel` (<https://github.com/jeremyevans/sequel>)
22
+
23
+ More details in [OTel instrumentation equivalents](#signalfx-instrumentations-equivalents).
24
+
18
25
  ## Migrate to the Splunk Distribution of OpenTelemetry Ruby
19
26
 
20
27
  To migrate from the SignalFx Tracing Library for Ruby to the Splunk
@@ -26,6 +33,7 @@ Distribution of OpenTelemetry Ruby, follow these steps:
26
33
 
27
34
  > Semantic conventions for span names and attributes change when you
28
35
  migrate.
36
+
29
37
  ### Remove the SignalFx Tracing Library for Ruby
30
38
 
31
39
  Follow these steps to remove the tracing library and its dependencies:
@@ -36,26 +44,105 @@ Follow these steps to remove the tracing library and its dependencies:
36
44
  gem uninstall signalfx
37
45
  ```
38
46
 
39
- 2. Remove `signalfx` from your Gemfile.
47
+ 1. Remove `signalfx` from your Gemfile.
40
48
 
41
- 3. Remove any additional OpenTracing instrumentation packages you
42
- installed.
49
+ ## Migrate to the Splunk Distribution of OpenTelemetry Ruby
43
50
 
44
- ### Deploy the Splunk Ruby agent
51
+ We're currently only testing installation using Bundler with RubyGems as a source.
52
+ [Contact us](mailto:ssg-observability-instrumentals-ruby@splunk.com) if you require a different way of installation.
45
53
 
46
- To install the Splunk Distribution of OpenTelemetry Ruby, see the [README.md](README.md).
54
+ If you installed
55
+ [Smart Agent](https://github.com/signalfx/signalfx-agent)
56
+ to serve as a gateway (traces/metrics data proxy)
57
+ migrate to
58
+ [OpenTelemetry Collector](https://docs.splunk.com/Observability/gdi/opentelemetry/resources.html)
59
+ first, as soon as (if) possible.
47
60
 
48
- ### Migrate settings for the Splunk Ruby OTel agent
61
+ ### Deploy the Splunk Distribution of OpenTelemetry Ruby
49
62
 
50
- To migrate settings from the SignalFx tracing library to the Splunk
51
- Distribution of OpenTelemetry Ruby, rename the following environment
52
- variables:
63
+ To install the Splunk Distribution of OpenTelemetry Ruby, see the [README.md](README.md).
53
64
 
54
- | SignalFx environment variable | OpenTelemetry environment variable |
55
- |--------------------------------------|------------------------------------------------------------------|
56
- | `SIGNALFX_ACCESS_TOKEN` | `SPLUNK_ACCESS_TOKEN` |
57
- | `SIGNALFX_SERVICE_NAME` | `OTEL_SERVICE_NAME` |
58
- | `SIGNALFX_ENDPOINT_URL` | `OTEL_EXPORTER_JAEGER_ENDPOINT` or `OTEL_EXPORTER_OTLP_ENDPOINT` |
59
- | `SIGNALFX_RECORDED_VALUE_MAX_LENGTH` | `SPLUNK_MAX_ATTR_LENGTH` |
65
+ ### Replace SignalFx / OpenTracing gems with OTel equivalents
66
+
67
+ 1. Make a list of all `signalfx-*` instrumentation gems from your Gemfile, see
68
+ [this table](https://github.com/signalfx/signalfx-ruby-tracing#supported-libraries)
69
+ for a complete list.
70
+
71
+ 1. Replace them with OpenTelemetry, as per the table below.
72
+
73
+ 1. Replace any other OpenTracing instrumentation packages you might have installed yourself.
74
+
75
+ <a name="signalfx-instrumentations-equivalents"></a>
76
+ #### OTel equivalents of SignalFx instrumentation gems
77
+
78
+ | SignalFx instrumentation name | OTel instrumentation name | notes |
79
+ | ----------------------------- | ------------------------- | ----- |
80
+ | signalfx-activerecord-opentracing | opentelemetry-instrumentation-active_record | |
81
+ | signalfx-elasticsearch-instrumentation | no known equivalents | [open issue in OTel](https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues/8) |
82
+ | signalfx-faraday-instrumentation | opentelemetry-instrumentation-faraday | |
83
+ | signalfx-grape-instrumentation | no known equivalents | [open issue in OTel](https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues/9) |
84
+ | signalfgx-mongodb-instrumentation | opentelemetry-instrumentation-mongo | |
85
+ | signalfx-mysql2-instrumentation | opentelemetry-instrumentation-mysql2 | |
86
+ | signalfx-nethttp-instrumentation | opentelemetry-instrumentation-net_http | |
87
+ | signalfx-pg-instrumentation | opentelemetry-instrumentation-pg | |
88
+ | signalfx-rack-tracer | opentelemetry-instrumentation-rack | |
89
+ | signalfx-rails-instrumentation | opentelemetry-instrumentation-rails | |
90
+ | signalfx-redis-instrumentation | opentelemetry-instrumentation-redis | |
91
+ | signalfx-restclient-instrumentation | opentelemetry-instrumentation-restclient | |
92
+ | signalfx-sequel-instrumentation | no known equivalents | [open issue in OTel](https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues/11) |
93
+ | signalfx-sidekiq-opentracing | opentelemetry-instrumentation-sidekiq | |
94
+ | signalfx-sinatra-instrumentation | opentelemetry-instrumentation-sinatra | |
95
+
96
+ #### OTel equivalents of other Open Tracing instrumentation gems
97
+
98
+ See the
99
+ [list of all known OTel Ruby instrumentations](https://opentelemetry.io/registry/?language=ruby&component=instrumentation)
100
+ in OpenTelemetry registry.
101
+
102
+ ### Migrate settings for the Splunk Distribution of OpenTelemetry Ruby
103
+
104
+ 1. `SIGNALFX_ENDPOINT_URL` or `ingest_url` configuration parameter
105
+ - if you installed Smart Agent and can migrate to OpenTelemetry Collector, do that first, then see the point below
106
+ - if you have OpenTelemetry Collector available up as a sidecar (via `localhost`),
107
+ and it accepts OTLP on default ports, just remove this setting, we export OTLP to OTel Collector by default
108
+ - if you need to keep using Smart Agent, you have to set up a jaeger exporter yourself
109
+ - if you export directly to our backend (without OTel Collector as a proxy),
110
+ just set `SPLUNK_REALM` to your realm
111
+ (it's part of the URL, ie. `https://app.<realm>.signalfx.com/`, or `us0` if it's missing)
112
+
113
+ 1. `SIGNALFX_SERVICE_NAME` or `service_name` configuration parameter
114
+ - to set in environment, use `OTEL_SERVICE_NAME`
115
+ - to set in code, use `Splunk::Otel.configure(service_name: 'your service name', ...`
116
+
117
+ 1. `SIGNALFX_ACCESS_TOKEN` or `access_token` configuration parameter
118
+ - to set in environment, use `SPLUNK_ACCESS_TOKEN`
119
+
120
+ 1. `SIGNALFX_SPAN_TAGS` or `span_tags` configuration parameter
121
+ - to set in environment:
122
+ - first, you need to rewrite the existing value to the,
123
+ which has a syntax of comma-separated `<key>=<value>` pairs (e.g. `key1=value1,key2=value2`)
124
+ - set `OTEL_RESOURCE_ATTRIBUTES` to the new value
125
+ - to set in code:
126
+ - call `OpenTelemetry::SDK::Resources::Resource.create` with a `Hash`
127
+ consisting of your existing key-value pairs
128
+ - pass the newly created `Resource` to the `resource=` attribute in configuration
129
+ - for example:
130
+ ```ruby
131
+ Splunk::Otel.configure(other_args) do |c|
132
+ c.resource = OpenTelemetry::SDK::Resources::Resource.create(
133
+ "key" => "value"
134
+ )
135
+ # ...
136
+ end
137
+ ```
138
+
139
+ 1. `SIGNALFX_RECORDED_VALUE_MAX_LENGTH`
140
+ - can be set in environment using `OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT`
141
+ - see
142
+ [the list of span limits settings](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/sdk-environment-variables.md#span-limits)
143
+ to learn more
144
+
145
+ 1. `tracer` configuration parameter
146
+ - if you need to set its equivalent, open an issue, and tell us about your use case
60
147
 
61
148
  For more information about Splunk Ruby OTel settings, see [advanced-config.md](docs/advanced-config.md).
data/README.md CHANGED
@@ -36,7 +36,7 @@ This Splunk distribution comes with the following defaults:
36
36
  baggage](https://www.w3.org/TR/baggage/) context propagation.
37
37
  - OTLP over HTTP exporter configured to send spans to a locally running [Splunk
38
38
  OpenTelemetry Connector](https://github.com/signalfx/splunk-otel-collector)
39
- (http://localhost:4318).
39
+ at http://localhost:4318.
40
40
  - Unlimited default limits for configuration options to support full-fidelity
41
41
  traces.
42
42
 
@@ -46,6 +46,12 @@ Install the gem by adding it to your project's `Gemfile`:
46
46
  gem "splunk-otel", "~> 0.1"
47
47
  ```
48
48
 
49
+ or
50
+
51
+ ```shell
52
+ bundle add splunk-otel --version "~> 0.1"
53
+ ```
54
+
49
55
  Configure OpenTelemetry using the `Splunk::Otel` module from `splunk/otel`:
50
56
 
51
57
  ``` ruby
@@ -69,10 +75,20 @@ Other resource attributes are not strictly required, but
69
75
  are available. These can be set through the environment variable
70
76
  `OTEL_RESOURCE_ATTRIBUTES`:
71
77
 
72
- ```
78
+ ```
73
79
  OTEL_RESOURCE_ATTRIBUTES="service.version=1.2.3,deployment.environment=production"
74
80
  ```
75
81
 
82
+ alternatively, if needed, more attributes can be added in code using:
83
+
84
+ ```ruby
85
+ Splunk::Otel.configure(service_name: "my-service") do |c|
86
+ c.resource = OpenTelemetry::SDK::Resources::Resource.create(
87
+ "key" => "value"
88
+ )
89
+ end
90
+ ```
91
+
76
92
  ## Advanced configuration
77
93
 
78
94
  See [advanced-config.md](docs/advanced-config.md) for information on how to
@@ -88,7 +104,7 @@ See [Correlating traces and logs](docs/correlating-traces-and-logs.md) for more
88
104
  ## Library instrumentation
89
105
 
90
106
  Supported libraries are listed
91
- [here](https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation).
107
+ [here](https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation).
92
108
  The corresponding gems for the instrumentation libraries can be found under the
93
109
  [opentelemetry-ruby](https://rubygems.org/profiles/opentelemetry-ruby) profile
94
110
  on [rubygems.org](https://rubygems.org).
@@ -103,7 +119,7 @@ the
103
119
  gem in your Gemfile:
104
120
 
105
121
  ``` ruby
106
- gem "opentelemetry-instrumentation-all", "~> 0.23"
122
+ gem "opentelemetry-instrumentation-all", "~> 0.23"
107
123
  ```
108
124
 
109
125
  Enable the instrumentations from the gem by passing `auto_instrument:true` to
@@ -143,10 +159,23 @@ OpenTelemetry::SDK.configure do |c|
143
159
  end
144
160
  ```
145
161
 
146
- To enable instrumentation libraries manually, see [Manual instrumentation](#manually-instrument-code).
162
+ To enable instrumentation libraries manually, see [Manual library instrumentation](#manual-library-instrumentation).
147
163
 
148
164
  ### Manual instrumentation
149
165
 
166
+ Documentation on how to manually instrument a Ruby application is available in the
167
+ [OpenTelemetry official documentation](https://opentelemetry.io/docs/instrumentation/ruby/manual/).
168
+
169
+ To extend the instrumentation with the OpenTelemetry Instrumentation for Ruby,
170
+ you have to use a compatible API version.
171
+
172
+ The Splunk Distribution of OpenTelemetry Ruby is compatible with:
173
+
174
+ - OpenTelemetry API version 1.0.0
175
+ - OpenTelemetry SDK version 1.0.0
176
+
177
+ ### Manual library instrumentation
178
+
150
179
  Instrumentation gems can also be installed and enabled individually. This may be
151
180
  preferred in order to control exactly which gems are fetched when building your project.
152
181
 
@@ -155,7 +184,7 @@ the project's `Gemfile`. For example, to install the
155
184
  [Sinatra](https://rubygems.org/gems/opentelemetry-instrumentation-sinatra)
156
185
  instrumentation:
157
186
 
158
- ```
187
+ ```
159
188
  gem "opentelemetry-instrumentation-sinatra", "~> 0.19"
160
189
  ```
161
190
 
@@ -171,6 +200,54 @@ Splunk::Otel.configure do |c|
171
200
  end
172
201
  ```
173
202
 
203
+ ### Real User Monitoring
204
+
205
+ For [Real User Monitoring
206
+ (RUM)](https://www.splunk.com/en_us/products/real-user-monitoring.html) a
207
+ [Rack](https://github.com/rack/rack) middleware is provided which will add trace
208
+ context to the `Server-Timing` header in the response if there is an active
209
+ Span. To use the middleware configure `Splunk::Otel` to use the `Rack`
210
+ instrumentation:
211
+
212
+ ``` ruby
213
+ Splunk::Otel.configure do |c|
214
+ c.use "OpenTelemetry::Instrumentation::Rack"
215
+ end
216
+ ```
217
+
218
+ And add the middleware in `Rack::Builder`:
219
+
220
+ ``` ruby
221
+ Rack::Builder.app do
222
+ use OpenTelemetry::Instrumentation::Rack::Middlewares::TracerMiddleware
223
+ use Splunk::Otel::Rack::RumMiddleware
224
+ run ->(_env) { [200, { "content-type" => "text/plain" }, ["OK"]] }
225
+ end
226
+ ```
227
+
228
+ When using [ActionPack](https://rubygems.org/gems/actionpack/), which Rails
229
+ does, the middleware will be added automatically if the Instrumentation Library
230
+ for ActionPack, "Splunk::Otel::Instrumentation::ActionPack", is used:
231
+
232
+ ``` ruby
233
+ Splunk::Otel.configure do |c|
234
+ c.use "OpenTelemetry::Instrumentation::ActionPack"
235
+ c.use "Splunk::Otel::Instrumentation::ActionPack"
236
+ end
237
+ ```
238
+
239
+ To disable the response headers being added the environment variable
240
+ `SPLUNK_TRACE_RESPONSE_HEADER_ENABLED` can be set to `false`, or pass
241
+ `trace_response_header_enabled: false` to `Splunk::Otel.configure`.
242
+
243
+ ## Configure for use with Smart Agent
244
+
245
+ This distribution includes the `jaeger-thrift-splunk` exporter, which is preconfigured to send data to local instance of the [SignalFx Smart Agent](https://github.com/signalfx/signalfx-agent).
246
+
247
+ To use the `jaeger-thrift-splunk` exporter, set the`OTEL_TRACES_EXPORTER` environment variable to `jaeger-thrift-splunk`, or append the exporter to the existing values. For example, `OTEL_TRACES_EXPORTER=otlp,jaeger-thrift-splunk`.
248
+
249
+ If the `SPLUNK_REALM` or the `OTEL_EXPORTER_JAEGER_ENDPOINT` environmental variables are set, the default endpoint is overwritten.
250
+
174
251
  ## Troubleshooting
175
252
 
176
253
  For troubleshooting information, see the [Troubleshooting](docs/troubleshooting.md) documentation.
@@ -188,3 +265,5 @@ file](./LICENSE).
188
265
  > http://www.apache.org/licenses/LICENSE-2.0
189
266
  >
190
267
  > Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
268
+
269
+ >ℹ️&nbsp;&nbsp;SignalFx was acquired by Splunk in October 2019. See [Splunk SignalFx](https://www.splunk.com/en_us/investor-relations/acquisitions/signalfx.html) for more information.
@@ -2,12 +2,12 @@
2
2
 
3
3
  ## Trace exporters
4
4
 
5
- | Environment variable | Default value | Support | Description |
6
- | --------------------------------- | ------- | ----------- | --- |
7
- | `OTEL_TRACES_EXPORTER` | `otlp` | Stable | Select the traces exporter to use. We recommend using the OTLP exporter (`otlp`).
8
- | `OTEL_EXPORTER_OTLP_ENDPOINT` | `http://localhost:4318` | Stable | The OTLP endpoint to connect to.
5
+ | Environment variable | Default value | Support | Description |
6
+ |-------------------------------|-------------------------|---------|-----------------------------------------------------------------------------------|
7
+ | `OTEL_TRACES_EXPORTER` | `otlp` | Stable | Select the traces exporter to use. We recommend using the OTLP exporter (`otlp`). |
8
+ | `OTEL_EXPORTER_OTLP_ENDPOINT` | `http://localhost:4318` | Stable | The OTLP endpoint to connect to. |
9
9
 
10
- The Splunk Distribution of OpenTelemetry Ruby uses the OTLP traces exporter as
10
+ The Splunk Distribution of OpenTelemetry Ruby uses the HTTP OTLP traces exporter as
11
11
  the default setting. For debugging purposes, use the `console` exporter, which writes
12
12
  spans directly to the console.
13
13
 
@@ -17,20 +17,35 @@ An example of setting an alternate trace exporter:
17
17
  export OTEL_TRACES_EXPORTER=console
18
18
  ```
19
19
 
20
+ Supported values for `OTEL_TRACES_EXPORTER` are `otlp` and
21
+ `jaeger-thrift-splunk`. Only the HTTP version of `otlp` is supported by the
22
+ OpenTelemetry Ruby.
23
+
20
24
  ## Exporting directly to Splunk Observability Cloud
21
25
 
22
26
  To export traces directly to Splunk Observability Cloud, bypassing the Collector,
23
27
  set the `SPLUNK_ACCESS_TOKEN` and `SPLUNK_REALM` environment variables.
24
28
 
25
- | Environment variable | Default value | Support | Description |
26
- | -------------------------------------- | ------------ | ----------- | --- |
27
- | `SPLUNK_ACCESS_TOKEN` | unset | Stable | Splunk authentication token that lets exporters send data directly to Splunk Observability Cloud. Unset by default. Not required unless you need to send data to the Observability Cloud ingest endpoint. See [Create and manage authentication tokens using Splunk Observability Cloud](https://docs.splunk.com/Observability/admin/authentication-tokens/tokens.html#admin-tokens). |
28
- | `SPLUNK_REALM` | us0 | Stable | The name of your organization’s realm, for example, us0. When you set the realm, traces are sent directly to the ingest endpoint of Splunk Observability Cloud, bypassing the Splunk OpenTelemetry Collector. |
29
+ | Environment variable | Config Option | Default value | Support | Description |
30
+ |----------------------------------------|---------------------------------|---------------|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
31
+ | `SPLUNK_ACCESS_TOKEN` | | unset | Stable | Splunk authentication token that lets exporters send data directly to Splunk Observability Cloud. Unset by default. Not required unless you need to send data to the Observability Cloud ingest endpoint. See [Create and manage authentication tokens using Splunk Observability Cloud](https://docs.splunk.com/Observability/admin/authentication-tokens/tokens.html#admin-tokens). |
32
+ | `SPLUNK_REALM` | | unset | Stable | The name of your organization’s realm, for example, us0. When you set the realm, traces are sent directly to the ingest endpoint of Splunk Observability Cloud, bypassing the Splunk OpenTelemetry Collector. |
33
+ | `SPLUNK_TRACE_RESPONSE_HEADER_ENABLED` | `trace_response_header_enabled` | `True` | Stable | Enables adding server trace information to HTTP response headers in Rack middleware. |
34
+
35
+ ## Exporting to the Smart Agent
36
+
37
+ This distribution includes the `jaeger-thrift-splunk` exporter, which is preconfigured to send data to local instance of the [SignalFx Smart Agent](https://github.com/signalfx/signalfx-agent).
38
+
39
+ | Environment variable | Config Option | Default value | Support | Description |
40
+ |---------------------------------|---------------|---------------|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
41
+ | `OTEL_EXPORTER_JAEGER_ENDPOINT` | | unset | Stable | The endpoint to export traces using the `jaeger-thrift-splunk` exporter. If set this overrides the default jaeger endpint of `http://127.0.0.1:9080/v1/trace`. |
42
+
29
43
 
30
44
  ## Propagators configuration
31
45
 
32
- | Environment variable | Default value | Support | Description |
33
- | `OTEL_PROPAGATORS` | `tracecontext,baggage` | Stable | Comma-separated list of propagator names to be used. |
46
+ | Environment variable | Config Option | Default value | Support | Description |
47
+ | ---------------------- | ------------- | ---------------------- | ------- | ---------------------------------------------------- |
48
+ | `OTEL_PROPAGATORS` | | `tracecontext,baggage` | Stable | Comma-separated list of propagator names to be used. |
34
49
 
35
50
  To keep backward compatibility with manual instrumentation for the SignalFx Ruby Tracing library, set the trace propagator to B3:
36
51
 
@@ -38,15 +53,19 @@ To keep backward compatibility with manual instrumentation for the SignalFx Ruby
38
53
  export OTEL_PROPAGATORS=b3multi
39
54
  ```
40
55
 
56
+
57
+ Supported values for `OTEL_PROPAGATORS` are `tracecontext`, `baggage`, `b3`,
58
+ `b3multi`, `jaeger`, `xray`, `ottrace` and `none`.
59
+
41
60
  ## Trace configuration
42
61
 
43
62
  | Environment variable | Config Option | Default value | Notes |
44
63
  | ------------------------- | --------------------- | ------------------------- | ---------------------------------------------------------------------- |
45
- | OTEL_SERVICE_NAME | service_name | `unnamed-ruby-service` | The service name of this Ruby application. |
46
- | OTEL_RESOURCE_ATTRIBUTES | | unset | Comma-separated list of resource attributes added to every reported span. <details><summary>Example</summary>`service.name=my-ruby-service,service.version=3.1,deployment.environment=production`</details> |
47
- | OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT | | `""` (unlimited) | Maximum number of attributes per span. |
48
- | OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT | | `""` (unlimited) | Maximum number of attributes per event. |
49
- | OTEL_LINK_ATTRIBUTE_COUNT_LIMIT | | `""` (unlimited) | Maximum number of attributes per link. |
50
- | OTEL_SPAN_EVENT_COUNT_LIMIT | | `""` (unlimited) | Maximum number of events per span. |
51
- | OTEL_SPAN_LINK_COUNT_LIMIT | | `1000` | Maximum number of links per span. |
52
- | OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT | | `12000` | Maximum length of strings for span attribute values. Values larger than the limit are truncated. |
64
+ | `OTEL_SERVICE_NAME` | `service_name` | `unnamed-ruby-service` | The service name of this Ruby application. |
65
+ | `OTEL_RESOURCE_ATTRIBUTES` | | unset | Comma-separated list of resource attributes added to every reported span. <details><summary>Example</summary>`service.name=my-ruby-service,service.version=3.1,deployment.environment=production`</details> |
66
+ | `OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT` | | unset (unlimited) | Maximum number of attributes per span. |
67
+ | `OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT` | | unset (unlimited) | Maximum number of attributes per event. |
68
+ | `OTEL_LINK_ATTRIBUTE_COUNT_LIMIT` | | unset (unlimited) | Maximum number of attributes per link. |
69
+ | `OTEL_SPAN_EVENT_COUNT_LIMIT` | | unset (unlimited) | Maximum number of events per span. |
70
+ | `OTEL_SPAN_LINK_COUNT_LIMIT` | | `1000` | Maximum number of links per span. |
71
+ | `OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT` | | `12000` | Maximum length of strings for span attribute values. Values larger than the limit are truncated. |
@@ -0,0 +1 @@
1
+ Gemfile.lock
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "opentelemetry-exporter-jaeger"
6
+ gem "splunk-otel", path: "../../"
@@ -0,0 +1,8 @@
1
+ version: "3"
2
+ services:
3
+ otel:
4
+ image: quay.io/signalfx/signalfx-agent:5
5
+ ports:
6
+ - 9080:9080
7
+ volumes:
8
+ - ./smart-agent-config.yaml:/etc/signalfx/agent.yaml
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rubygems"
4
+ require "bundler/setup"
5
+ Bundler.require(:default)
6
+
7
+ Splunk::Otel.configure do |configurator|
8
+ $configurator = configurator # rubocop:disable Style/GlobalVars
9
+
10
+ class << configurator
11
+ def test_shutdown
12
+ @span_processors.each(&:shutdown)
13
+ end
14
+ end
15
+ end
16
+
17
+ tracer = OpenTelemetry.tracer_provider.tracer("test", "1.0")
18
+ tracer.in_span("test-span") do
19
+ puts "test-span execution"
20
+ end
21
+
22
+ $configurator.test_shutdown # rubocop:disable Style/GlobalVars
@@ -0,0 +1,5 @@
1
+ signalFxAccessToken: ""
2
+ ingestUrl: "https://ingest.lab0.signalfx.com"
3
+ signalFxRealm: "lab0"
4
+ monitors:
5
+ - type: trace-forwarder
@@ -15,7 +15,11 @@ module Splunk
15
15
  def call(env)
16
16
  status, headers, body = @app.call(env)
17
17
 
18
- headers = Splunk::Otel::Common.rum_headers(headers)
18
+ headers = if Splunk::Otel.trace_response_header_enabled
19
+ Splunk::Otel::Common.rum_headers(headers)
20
+ else
21
+ headers
22
+ end
19
23
 
20
24
  [status, headers, body]
21
25
  end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Splunk
4
+ module Otel
5
+ OUR_EXPORTERS_KEYS = ["jaeger-thrift-splunk"].freeze
6
+ private_constant :OUR_EXPORTERS_KEYS
7
+
8
+ # internal module for allowing our exporters to be set via ENV
9
+ module ExporterExtensions
10
+ def effective_splunk_jaeger_endpoint
11
+ return "https://ingest.#{ENV["SPLUNK_REALM"]}.signalfx.com/v1/trace" if ENV["SPLUNK_REALM"]
12
+ return ENV["OTEL_EXPORTER_JAEGER_ENDPOINT"] if ENV["OTEL_EXPORTER_JAEGER_ENDPOINT"]
13
+
14
+ "http://127.0.0.1:9080/v1/trace"
15
+ end
16
+
17
+ def wrapped_exporters_from_env
18
+ original_env_value = ENV.fetch("OTEL_TRACES_EXPORTER", "otlp")
19
+ exporters_keys = original_env_value.split(",").map(&:strip)
20
+ non_proprietary_exporters_keys = exporters_keys - OUR_EXPORTERS_KEYS
21
+
22
+ ENV["OTEL_TRACES_EXPORTER"] = non_proprietary_exporters_keys.join(",")
23
+ original_exporters = super
24
+ ENV["OTEL_TRACES_EXPORTER"] = original_env_value
25
+
26
+ original_exporters + proprietary_exporters(exporters_keys)
27
+ end
28
+
29
+ def proprietary_exporters(exporters_keys)
30
+ (exporters_keys & OUR_EXPORTERS_KEYS).map do |exporter_key|
31
+ case exporter_key
32
+ when "jaeger-thrift-splunk"
33
+ args = {
34
+ endpoint: effective_splunk_jaeger_endpoint
35
+ }
36
+ fetch_exporter_with_args("jaeger-thrift-splunk", "OpenTelemetry::Exporter::Jaeger::CollectorExporter",
37
+ **args)
38
+ end
39
+ end.compact
40
+ end
41
+
42
+ def fetch_exporter_with_args(name, class_name, **args)
43
+ # TODO: warn if jaeger exporter gem is not present
44
+ exporter = Kernel.const_get(class_name).new(**args)
45
+ OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new exporter
46
+ rescue NameError
47
+ OpenTelemetry.logger.warn "The #{name} exporter cannot be configured" \
48
+ "- please add opentelemetry-exporter-#{name} to your Gemfile" \
49
+ ", spans will not be exported.."
50
+ nil
51
+ end
52
+ end
53
+ end
54
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Splunk
4
4
  module Otel
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
data/lib/splunk/otel.rb CHANGED
@@ -1,18 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "otel/version"
4
3
  require "opentelemetry/sdk"
5
-
6
- # FIXME: without this, otlp doesn't work out-of-the-box
7
4
  require "opentelemetry-exporter-otlp"
8
5
 
6
+ require_relative "otel/version"
7
+ require_relative "otel/proprietary_exporters"
8
+
9
9
  module Splunk
10
10
  # main module for application startup configuration
11
- module Otel
11
+ module Otel # rubocop:disable Metrics/ModuleLength
12
12
  # custom exception types in this gem must inherit from Splunk::Otel::Error
13
13
  # this allows the user to rescue a generic exception type to catch all exceptions
14
14
  class Error < StandardError; end
15
15
 
16
+ attr_reader(:trace_response_header_enabled)
17
+
18
+ @trace_response_header_enabled = true
19
+
16
20
  # Configures the OpenTelemetry SDK and instrumentation with Splunk defaults.
17
21
  #
18
22
  # @yieldparam [Configurator] configurator Yields a configurator to the
@@ -49,21 +53,25 @@ module Splunk
49
53
  # c.use_all
50
54
  # end
51
55
  def configure(service_name: ENV.fetch("OTEL_SERVICE_NAME", "unnamed-ruby-service"),
52
- auto_instrument: false)
53
- set_default_propagators
54
- set_access_token_header
55
- set_default_exporter
56
- set_default_span_limits
56
+ auto_instrument: false,
57
+ trace_response_header_enabled: ENV.fetch("SPLUNK_TRACE_RESPONSE_HEADER_ENABLED", "true"))
58
+ @trace_response_header_enabled = to_boolean(trace_response_header_enabled)
59
+
60
+ set_defaults
57
61
 
58
62
  # run SDK's setup function
59
- OpenTelemetry::SDK.configure do |c|
60
- c.service_name = service_name
61
- c.resource = OpenTelemetry::SDK::Resources::Resource.create(
63
+ OpenTelemetry::SDK.configure do |configurator|
64
+ class << configurator
65
+ include Splunk::Otel::ExporterExtensions
66
+ end
67
+
68
+ configurator.service_name = service_name
69
+ configurator.resource = OpenTelemetry::SDK::Resources::Resource.create(
62
70
  "splunk.distro.version" => Splunk::Otel::VERSION
63
71
  )
64
72
 
65
- c.use_all if auto_instrument
66
- yield c if block_given?
73
+ configurator.use_all if auto_instrument
74
+ yield configurator if block_given?
67
75
  end
68
76
 
69
77
  # set span limits to GDI defaults if not set by the user
@@ -72,6 +80,13 @@ module Splunk
72
80
  verify_service_name
73
81
  end
74
82
 
83
+ def set_defaults
84
+ set_default_propagators
85
+ set_access_token_header
86
+ set_default_exporter
87
+ set_default_span_limits
88
+ end
89
+
75
90
  # verify `service.name` is set and print a warning if it is still the default
76
91
  def verify_service_name
77
92
  provider_resource = OpenTelemetry.tracer_provider.instance_variable_get(:@resource)
@@ -151,6 +166,20 @@ module Splunk
151
166
  end
152
167
  end
153
168
 
169
+ def to_boolean(val)
170
+ # val could already be a boolean so just return the value if it is already
171
+ # true or false
172
+ case val
173
+ when true then true
174
+ when false then false
175
+ else
176
+ !%w[false
177
+ no
178
+ f
179
+ 0].include?(val.strip.downcase)
180
+ end
181
+ end
182
+
154
183
  def service_name_warning
155
184
  <<~WARNING
156
185
  service.name attribute is not set, your service is unnamed and will be difficult to identify.
@@ -161,7 +190,8 @@ module Splunk
161
190
 
162
191
  module_function :configure, :gdi_span_limits, :set_default_propagators, :set_default_exporter,
163
192
  :verify_service_name, :service_name_warning, :default_env_vars,
164
- :set_default_span_limits, :set_access_token_header, :set_endpoint
193
+ :set_default_span_limits, :set_access_token_header, :set_endpoint,
194
+ :to_boolean, :trace_response_header_enabled, :set_defaults
165
195
  end
166
196
  end
167
197
 
data/splunk-otel.gemspec CHANGED
@@ -43,7 +43,8 @@ Gem::Specification.new do |spec|
43
43
  spec.add_development_dependency "opentelemetry-instrumentation-action_pack", "~> 0.2.0"
44
44
  spec.add_development_dependency "opentelemetry-instrumentation-rack", "~> 0.21"
45
45
  spec.add_development_dependency "rack", "~> 2.2"
46
- spec.add_development_dependency "rack-test", "~> 1.1"
46
+ spec.add_development_dependency "rack-test", "~> 2.0"
47
+ spec.add_development_dependency "simplecov-cobertura", "~> 2.1.0"
47
48
 
48
49
  spec.metadata = {
49
50
  "rubygems_mfa_required" => "true"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: splunk-otel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Splunk
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-27 00:00:00.000000000 Z
11
+ date: 2022-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api
@@ -226,14 +226,28 @@ dependencies:
226
226
  requirements:
227
227
  - - "~>"
228
228
  - !ruby/object:Gem::Version
229
- version: '1.1'
229
+ version: '2.0'
230
230
  type: :development
231
231
  prerelease: false
232
232
  version_requirements: !ruby/object:Gem::Requirement
233
233
  requirements:
234
234
  - - "~>"
235
235
  - !ruby/object:Gem::Version
236
- version: '1.1'
236
+ version: '2.0'
237
+ - !ruby/object:Gem::Dependency
238
+ name: simplecov-cobertura
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - "~>"
242
+ - !ruby/object:Gem::Version
243
+ version: 2.1.0
244
+ type: :development
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - "~>"
249
+ - !ruby/object:Gem::Version
250
+ version: 2.1.0
237
251
  description:
238
252
  email:
239
253
  - splunk-oss@splunk.com
@@ -242,9 +256,11 @@ extensions: []
242
256
  extra_rdoc_files: []
243
257
  files:
244
258
  - ".github/CODEOWNERS"
259
+ - ".github/dependabot.yml"
245
260
  - ".github/workflows/main.yml"
246
261
  - ".gitignore"
247
262
  - ".gitlab-ci.yml"
263
+ - ".lycheeignore"
248
264
  - ".rubocop.yml"
249
265
  - CHANGELOG.md
250
266
  - CODE_OF_CONDUCT.md
@@ -277,6 +293,11 @@ files:
277
293
  - examples/rails-7-barebones/docker-compose.yml
278
294
  - examples/rails-7-barebones/tests-e2e/rails_7_barebones_test.rb
279
295
  - examples/rails-7-barebones/wait-for.sh
296
+ - examples/smart-agent/.gitignore
297
+ - examples/smart-agent/Gemfile
298
+ - examples/smart-agent/docker-compose.yml
299
+ - examples/smart-agent/runner.rb
300
+ - examples/smart-agent/smart-agent-config.yaml
280
301
  - lib/splunk/otel.rb
281
302
  - lib/splunk/otel/common.rb
282
303
  - lib/splunk/otel/instrumentation/action_pack.rb
@@ -286,6 +307,7 @@ files:
286
307
  - lib/splunk/otel/instrumentation/rack.rb
287
308
  - lib/splunk/otel/instrumentation/rack/middleware.rb
288
309
  - lib/splunk/otel/logging.rb
310
+ - lib/splunk/otel/proprietary_exporters.rb
289
311
  - lib/splunk/otel/version.rb
290
312
  - scripts/install-release-deps.sh
291
313
  - scripts/release.sh