Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.20.0 to stable #711

Merged
merged 33 commits into from
Mar 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
973da4a
Added: Datadog::DeprecatedPin for phasing out Datadog::Pin usage.
delner Feb 15, 2019
fe4ed1a
Merge pull request #692 from DataDog/refactor/add_deprecated_pin
delner Feb 19, 2019
9b988c7
Refactored: Dalli to use configuration instead of pin.
delner Feb 19, 2019
ddc5da5
Refactored: Dalli pin to be a deprecated pin.
delner Feb 19, 2019
c052d55
Merge pull request #693 from DataDog/refactor/dalli_replace_pin_with_…
delner Feb 20, 2019
0bcf323
Refactored: Faraday to use configuration instead of pin.
delner Feb 21, 2019
21a31e9
Refactored: Faraday pin to be a deprecated pin.
delner Feb 21, 2019
2315a45
Merge pull request #696 from DataDog/refactor/faraday_replace_pin_wit…
delner Feb 22, 2019
b6d262e
Refactored: Grape to use configuration instead of pin.
delner Feb 26, 2019
3176939
Refactored: Grape pin to be a deprecated pin.
delner Feb 26, 2019
4a96080
Added: `enabled` flag for Grape to documentation.
delner Feb 26, 2019
d3940d8
Merge pull request #700 from DataDog/refactor/grape_replace_pin_with_…
delner Feb 26, 2019
08826ce
Refactored: GRPC to use configuration instead of global pin.
delner Feb 27, 2019
fc806dd
Refactored: GRPC global pin to be a deprecated pin.
delner Feb 27, 2019
891b248
Refactored: HTTP instrumentation into module.
delner Feb 27, 2019
8016e3f
Refactored: MongoDB instrumentation into module.
delner Feb 27, 2019
353714e
Merge pull request #702 from DataDog/refactor/grpc_replace_pin_with_c…
delner Feb 28, 2019
2708f16
Merge pull request #703 from DataDog/refactor/http_instrumentation_mo…
delner Feb 28, 2019
6481330
[core] Propagate synthetics origin headers (#699)
brettlangdon Feb 28, 2019
ce5f86f
Merge pull request #704 from DataDog/refactor/mongo_instrumentation_m…
delner Feb 28, 2019
3d1706b
Enable distributed tracing by default (#701)
brettlangdon Feb 28, 2019
ec2ccec
Fixed: RestClient test not resetting configuration properly.
delner Mar 2, 2019
d1dad71
Merge pull request #706 from DataDog/ci/fix_rest_client_config_reset
delner Mar 4, 2019
a5d1565
Added: ClimateControl to development dependencies.
delner Mar 1, 2019
511074c
Changed: Disabled casecmp rule for Rubocop.
delner Mar 1, 2019
38735a3
Refactored: Contrib::Sampling into Contrib::Analytics.
delner Mar 1, 2019
ea15b64
Added: analytics_enabled and analytics_sample_rate to default configu…
delner Mar 1, 2019
f611625
Refactored: Integrations to use Contrib::Analytics.
delner Mar 1, 2019
dd19450
Removed: analytics_sample_rate option from documentation.
delner Mar 4, 2019
ca87476
Merge pull request #705 from DataDog/refactor/event_sample_rate_to_an…
delner Mar 4, 2019
fe4f7f7
[core] Only require trace id for distributed tracing headers (#708)
brettlangdon Mar 6, 2019
38e3622
Fix Rack http_server.queue spans missing from distributed traces. (#709)
delner Mar 7, 2019
da217fc
Bump to version 0.20.0 (#710)
brettlangdon Mar 7, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ Metrics/AbcSize:
Metrics/MethodLength:
Max: 36

Performance/Casecmp:
Enabled: false

# TODO: this is not compliant with the Ruby community style guide. We
# should enable again this rule but it will change the public API because
# we're using set_ methods. We should work on that because also Rails
Expand Down
35 changes: 33 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,36 @@

## [Unreleased (beta)]

## [0.20.0] - 2019-03-07

Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.20.0

Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.19.1...v0.20.0

This release will log deprecation warnings for any usage of `Datadog::Pin`.
These changes are backwards compatible, but all integration configuration should be moved away from `Pin` and to the configuration API instead.

### Added

- Propagate synthetics origin header (#699)

### Changed

- Enable distributed tracing by default (#701)

### Fixes

- Fix Rack http_server.queue spans missing from distributed traces (#709)

### Refactored

- Refactor MongoDB to use instrumentation module (#704)
- Refactor HTTP to use instrumentation module (#703)
- Deprecate GRPC global pin in favor of configuration API (#702)
- Deprecate Grape pin in favor of configuration API (#700)
- Deprecate Faraday pin in favor of configuration API (#696)
- Deprecate Dalli pin in favor of configuration API (#693)

## [0.19.1] - 2019-02-07

Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.19.1
Expand Down Expand Up @@ -681,8 +711,9 @@ Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.3.1

Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1

[Unreleased (stable)]: https://github.com/DataDog/dd-trace-rb/compare/v0.19.1...master
[Unreleased (beta)]: https://github.com/DataDog/dd-trace-rb/compare/v0.19.1...0.20-dev
[Unreleased (stable)]: https://github.com/DataDog/dd-trace-rb/compare/v0.20.0...master
[Unreleased (beta)]: https://github.com/DataDog/dd-trace-rb/compare/v0.20.0...0.21-dev
[0.20.0]: https://github.com/DataDog/dd-trace-rb/compare/v0.19.1...v0.20.0
[0.19.1]: https://github.com/DataDog/dd-trace-rb/compare/v0.19.0...v0.19.1
[0.19.0]: https://github.com/DataDog/dd-trace-rb/compare/v0.18.3...v0.19.0
[0.18.3]: https://github.com/DataDog/dd-trace-rb/compare/v0.18.2...v0.18.3
Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ namespace :spec do
end

RSpec::Core::RakeTask.new(:contrib) do |t|
t.pattern = 'spec/**/contrib/{configurable,integration,patchable,patcher,registerable,sampling,configuration/*}_spec.rb'
# rubocop:disable Metrics/LineLength
t.pattern = 'spec/**/contrib/{analytics,configurable,integration,patchable,patcher,registerable,sampling,configuration/*}_spec.rb'
end

[
Expand Down Expand Up @@ -76,7 +77,6 @@ namespace :spec do
:sidekiq,
:sinatra,
:sucker_punch,
:rest_client,
:shoryuken
].each do |contrib|
RSpec::Core::RakeTask.new(contrib) do |t|
Expand Down
1 change: 1 addition & 0 deletions ddtrace.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Gem::Specification.new do |spec|
# TODO: Move this to Appraisals?
spec.add_dependency 'opentracing', '>= 0.4.1'

spec.add_development_dependency 'climate_control', '~> 0.2.0'
spec.add_development_dependency 'rake', '>= 10.5'
spec.add_development_dependency 'rubocop', '= 0.49.1' if RUBY_VERSION >= '2.1.0'
spec.add_development_dependency 'rspec', '~> 3.0'
Expand Down
31 changes: 16 additions & 15 deletions docs/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:

| Key | Description | Default |
| --- | ----------- | ------- |
| `event_sample_rate` | Rate which spans should be sampled for search and analytics. | `nil` |
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `nil` |
| `service_name` | Service name used for `DelayedJob` instrumentation | `'delayed_job'` |
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |

Expand Down Expand Up @@ -568,7 +568,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:

| Key | Description | Default |
| --- | ----------- | ------- |
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `false` |
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
| `error_handler` | A `Proc` that accepts a `response` parameter. If it evaluates to a *truthy* value, the trace span is marked as an error. By default only sets 5XX responses as errors. | `nil` |
| `service_name` | Service name for Excon instrumentation. When provided to middleware for a specific connection, it applies only to that connection object. | `'excon'` |
| `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
Expand Down Expand Up @@ -625,7 +625,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:

| Key | Description | Default |
| --- | ----------- | ------- |
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `false` |
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
| `error_handler` | A `Proc` that accepts a `response` parameter. If it evaluates to a *truthy* value, the trace span is marked as an error. By default only sets 5XX responses as errors. | `nil` |
| `service_name` | Service name for Faraday instrumentation. When provided to middleware for a specific connection, it applies only to that connection object. | `'faraday'` |
| `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
Expand Down Expand Up @@ -659,6 +659,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:

| Key | Description | Default |
| --- | ----------- | ------- |
| `enabled` | Defines whether Grape should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
| `service_name` | Service name used for `grape` instrumentation | `'grape'` |
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |

Expand Down Expand Up @@ -838,7 +839,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:

| Key | Description | Default |
| --- | ----------- | ------- |
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `false` |
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
| `service_name` | Service name used for `http` instrumentation | `'net/http'` |
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |

Expand Down Expand Up @@ -867,7 +868,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:

| Key | Description | Default |
| --- | ----------- | ------- |
| `event_sample_rate` | Rate which spans should be sampled for search and analytics. | `nil` |
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `nil` |
| `service_name` | Service name used for `racecar` instrumentation | `'racecar'` |
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |

Expand Down Expand Up @@ -898,9 +899,9 @@ Where `options` is an optional `Hash` that accepts the following parameters:

| Key | Description | Default |
| --- | ----------- | ------- |
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `nil` |
| `application` | Your Rack application. Required for `middleware_names`. | `nil` |
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) so that this service trace is connected with a trace of another service if tracing headers are received | `false` |
| `event_sample_rate` | Rate which spans should be sampled for search and analytics. | `nil` |
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) so that this service trace is connected with a trace of another service if tracing headers are received | `true` |
| `headers` | Hash of HTTP request or response headers to add as tags to the `rack.request`. Accepts `request` and `response` keys with Array values e.g. `['Last-Modified']`. Adds `http.request.headers.*` and `http.response.headers.*` tags respectively. | `{ response: ['Content-Type', 'X-Request-ID'] }` |
| `middleware_names` | Enable this if you want to use the middleware classes as the resource names for `rack` spans. Requires `application` option to use. | `false` |
| `quantize` | Hash containing options for quantization. May include `:query` or `:fragment`. | `{}` |
Expand Down Expand Up @@ -966,7 +967,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
| `cache_service` | Cache service name used when tracing cache activity | `'<app_name>-cache'` |
| `controller_service` | Service name used when tracing a Rails action controller | `'<app_name>'` |
| `database_service` | Database service name used when tracing database activity | `'<app_name>-<adapter_name>'` |
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) so that this service trace is connected with a trace of another service if tracing headers are received | `false` |
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) so that this service trace is connected with a trace of another service if tracing headers are received | `true` |
| `exception_controller` | Class or Module which identifies a custom exception controller class. Tracer provides improved error behavior when it can identify custom exception controllers. By default, without this option, it 'guesses' what a custom exception controller looks like. Providing this option aids this identification. | `nil` |
| `middleware` | Add the trace middleware to the Rails application. Set to `false` if you don't want the middleware to load. | `true` |
| `middleware_names` | Enables any short-circuited middleware requests to display the middleware name as resource for the trace. | `false` |
Expand Down Expand Up @@ -1009,8 +1010,8 @@ Where `options` is an optional `Hash` that accepts the following parameters:

| Key | Description | Default |
| --- | ----------- | ------- |
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `nil` |
| `enabled` | Defines whether Rake tasks should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
| `event_sample_rate` | Rate which spans should be sampled for search and analytics. | `nil` |
| `quantize` | Hash containing options for quantization of task arguments. See below for more details and examples. | `{}` |
| `service_name` | Service name used for `rake` instrumentation | `'rake'` |
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
Expand Down Expand Up @@ -1112,7 +1113,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:

| Key | Description | Default |
| --- | ----------- | ------- |
| `event_sample_rate` | Rate which spans should be sampled for search and analytics. | `nil` |
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `nil` |
| `service_name` | Service name used for `resque` instrumentation | `'resque'` |
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |
| `workers` | An array including all worker classes you want to trace (eg `[MyJob]`) | `[]` |
Expand All @@ -1134,7 +1135,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:

| Key | Description | Default |
| --- | ----------- | ------- |
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `false` |
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
| `service_name` | Service name for `rest_client` instrumentation. | `'rest_client'` |
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |

Expand Down Expand Up @@ -1204,7 +1205,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:

| Key | Description | Default |
| --- | ----------- | ------- |
| `event_sample_rate` | Rate which spans should be sampled for search and analytics. | `nil` |
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `nil` |
| `service_name` | Service name used for `shoryuken` instrumentation | `'shoryuken'` |
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |

Expand All @@ -1226,8 +1227,8 @@ Where `options` is an optional `Hash` that accepts the following parameters:

| Key | Description | Default |
| --- | ----------- | ------- |
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `nil` |
| `client_service_name` | Service name used for client-side `sidekiq` instrumentation | `'sidekiq-client'` |
| `event_sample_rate` | Rate which spans should be sampled for search and analytics. | `nil` |
| `service_name` | Service name used for server-side `sidekiq` instrumentation | `'sidekiq'` |
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |

Expand All @@ -1254,7 +1255,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:

| Key | Description | Default |
| --- | ----------- | ------- |
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) so that this service trace is connected with a trace of another service if tracing headers are received | `false` |
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) so that this service trace is connected with a trace of another service if tracing headers are received | `true` |
| `headers` | Hash of HTTP request or response headers to add as tags to the `sinatra.request`. Accepts `request` and `response` keys with Array values e.g. `['Last-Modified']`. Adds `http.request.headers.*` and `http.response.headers.*` tags respectively. | `{ response: ['Content-Type', 'X-Request-ID'] }` |
| `resource_script_names` | Prepend resource names with script name | `false` |
| `service_name` | Service name used for `sinatra` instrumentation | `'sinatra'` |
Expand All @@ -1279,7 +1280,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:

| Key | Description | Default |
| --- | ----------- | ------- |
| `event_sample_rate` | Rate which spans should be sampled for search and analytics. | `nil` |
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `nil` |
| `service_name` | Service name used for `sucker_punch` instrumentation | `'sucker_punch'` |
| `tracer` | `Datadog::Tracer` used to perform instrumentation. Usually you don't need to set this. | `Datadog.tracer` |

Expand Down
21 changes: 21 additions & 0 deletions lib/ddtrace/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ def sampling_priority=(priority)
end
end

def origin
@mutex.synchronize do
@origin
end
end

def origin=(origin)
@mutex.synchronize do
@origin = origin
end
end

# Return the last active span that corresponds to the last inserted
# item in the trace list. This cannot be considered as the current active
# span in asynchronous environments, because some spans can be closed
Expand Down Expand Up @@ -138,6 +150,7 @@ def get
sampled = @sampled

attach_sampling_priority if sampled && @sampling_priority
attach_origin if @origin

# still return sampled attribute, even if context is not finished
return nil, sampled unless check_finished_spans()
Expand All @@ -163,6 +176,7 @@ def reset(options = {})
@parent_span_id = options.fetch(:span_id, nil)
@sampled = options.fetch(:sampled, false)
@sampling_priority = options.fetch(:sampling_priority, nil)
@origin = options.fetch(:origin, nil)
@finished_spans = 0
@current_span = nil
@current_root_span = nil
Expand Down Expand Up @@ -192,6 +206,13 @@ def attach_sampling_priority
)
end

def attach_origin
@trace.first.set_tag(
Ext::DistributedTracing::ORIGIN_KEY,
@origin
)
end

# Return the start time of the root span, or nil if there are no spans or this is undefined.
def start_time
@mutex.synchronize do
Expand Down
22 changes: 22 additions & 0 deletions lib/ddtrace/contrib/analytics.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require 'ddtrace/ext/analytics'

module Datadog
module Contrib
# Defines sampling behavior for integrations
module Analytics
module_function

# Checks whether analytics should be enabled.
# `flag` is a truthy/falsey value that represents a setting on the integration.
def enabled?(flag = nil)
# TODO: Check global flag here.
# (global_flag && flag != false) || flag == true
flag == true
end

def set_sample_rate(span, sample_rate)
span.set_metric(Datadog::Ext::Analytics::TAG_SAMPLE_RATE, sample_rate) unless sample_rate.nil?
end
end
end
end
15 changes: 14 additions & 1 deletion lib/ddtrace/contrib/configuration/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ class Settings

option :service_name
option :tracer, default: Datadog.tracer
option :event_sample_rate
option :analytics_enabled, default: false
option :analytics_sample_rate, default: 1.0

def initialize(options = {})
configure(options)
Expand All @@ -30,6 +31,18 @@ def [](name)
def []=(name, value)
respond_to?("#{name}=") ? send("#{name}=", value) : set_option(name, value)
end

class << self
private

def env_to_bool(var, default = nil)
ENV.key?(var) ? ENV[var].to_s.downcase == 'true' : default
end

def env_to_float(var, default = nil)
ENV.key?(var) ? ENV[var].to_f : default
end
end
end
end
end
Expand Down
Loading