Skip to content

Commit

Permalink
Merge pull request #3437 from DataDog/tonycthsu/merge-master-into-20
Browse files Browse the repository at this point in the history
Merge master(v1.20.0) into 2.0
  • Loading branch information
TonyCTHsu committed Feb 5, 2024
2 parents 33ec11d + 2de4bc6 commit 8ea3eb5
Show file tree
Hide file tree
Showing 530 changed files with 2,680 additions and 699 deletions.
34 changes: 33 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@

## [Unreleased]

## [1.20.0] - 2024-02-05

### Added

* Tracing: Add `Trilogy` instrumentation ([#3274][])
* Rack: Add remote configuration boot tags ([#3315][])
* Faraday: Add `on_error` option ([#3431][])
* Profiling: Add dynamic allocation sampling ([#3395][])

### Changed

* Bump `datadog-ci` dependency to 0.7.0 ([#3408][])
* Improve performance of gathering ClassCount metric ([#3386][])

### Fixed

* OpenTelemetry: Fix internal loading ([#3400][])
* Core: Fix logger deadlock ([#3426][])
* Rack: Fix missing active trace ([#3420][])
* Redis: Fix instance configuration ([#3278][])

## [1.19.0] - 2024-01-10

### Highlights
Expand Down Expand Up @@ -2707,7 +2728,8 @@ 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]: https://github.com/DataDog/dd-trace-rb/compare/v1.19.0...master
[Unreleased]: https://github.com/DataDog/dd-trace-rb/compare/v1.20.0...master
[1.20.0]: https://github.com/DataDog/dd-trace-rb/compare/v1.19.0...v1.20.0
[1.19.0]: https://github.com/DataDog/dd-trace-rb/compare/v1.18.0...v1.19.0
[1.18.0]: https://github.com/DataDog/dd-trace-rb/compare/v1.17.0...v1.18.0
[1.17.0]: https://github.com/DataDog/dd-trace-rb/compare/v1.16.2...v1.17.0
Expand Down Expand Up @@ -3936,6 +3958,8 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
[#3270]: https://github.com/DataDog/dd-trace-rb/issues/3270
[#3271]: https://github.com/DataDog/dd-trace-rb/issues/3271
[#3273]: https://github.com/DataDog/dd-trace-rb/issues/3273
[#3274]: https://github.com/DataDog/dd-trace-rb/issues/3274
[#3278]: https://github.com/DataDog/dd-trace-rb/issues/3278
[#3279]: https://github.com/DataDog/dd-trace-rb/issues/3279
[#3280]: https://github.com/DataDog/dd-trace-rb/issues/3280
[#3281]: https://github.com/DataDog/dd-trace-rb/issues/3281
Expand All @@ -3948,6 +3972,7 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
[#3308]: https://github.com/DataDog/dd-trace-rb/issues/3308
[#3310]: https://github.com/DataDog/dd-trace-rb/issues/3310
[#3313]: https://github.com/DataDog/dd-trace-rb/issues/3313
[#3315]: https://github.com/DataDog/dd-trace-rb/issues/3315
[#3316]: https://github.com/DataDog/dd-trace-rb/issues/3316
[#3317]: https://github.com/DataDog/dd-trace-rb/issues/3317
[#3320]: https://github.com/DataDog/dd-trace-rb/issues/3320
Expand All @@ -3965,6 +3990,13 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
[#3366]: https://github.com/DataDog/dd-trace-rb/issues/3366
[#3373]: https://github.com/DataDog/dd-trace-rb/issues/3373
[#3374]: https://github.com/DataDog/dd-trace-rb/issues/3374
[#3386]: https://github.com/DataDog/dd-trace-rb/issues/3386
[#3395]: https://github.com/DataDog/dd-trace-rb/issues/3395
[#3400]: https://github.com/DataDog/dd-trace-rb/issues/3400
[#3408]: https://github.com/DataDog/dd-trace-rb/issues/3408
[#3420]: https://github.com/DataDog/dd-trace-rb/issues/3420
[#3426]: https://github.com/DataDog/dd-trace-rb/issues/3426
[#3431]: https://github.com/DataDog/dd-trace-rb/issues/3431
[@AdrianLC]: https://github.com/AdrianLC
[@Azure7111]: https://github.com/Azure7111
[@BabyGroot]: https://github.com/BabyGroot
Expand Down
86 changes: 86 additions & 0 deletions benchmarks/profiler_sample_serialize.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Used to quickly run benchmark under RSpec as part of the usual test suite, to validate it didn't bitrot
VALIDATE_BENCHMARK_MODE = ENV['VALIDATE_BENCHMARK'] == 'true'

return unless __FILE__ == $PROGRAM_NAME || VALIDATE_BENCHMARK_MODE

require 'benchmark/ips'
require 'ddtrace'
require 'pry'
require_relative 'dogstatsd_reporter'

require 'libdatadog'

puts "Libdatadog from: #{Libdatadog.pkgconfig_folder}"

# This benchmark measures the performance of sampling + serializing profiles. It enables us to evaluate changes to
# the profiler and/or libdatadog that may impact both individual samples, as well as samples over time (e.g. timeline).

class ProfilerSampleSerializeBenchmark
# This is needed because we're directly invoking the collector through a testing interface; in normal
# use a profiler thread is automatically used.
PROFILER_OVERHEAD_STACK_THREAD = Thread.new { sleep }

def create_profiler
timeline_enabled = ENV['TIMELINE'] == 'true'
@recorder = Datadog::Profiling::StackRecorder.new(
cpu_time_enabled: true,
alloc_samples_enabled: false,
heap_samples_enabled: false,
heap_size_enabled: false,
heap_sample_every: 1,
timeline_enabled: timeline_enabled,
)
@collector = Datadog::Profiling::Collectors::ThreadContext.new(
recorder: @recorder, max_frames: 400, tracer: nil, endpoint_collection_enabled: false, timeline_enabled: timeline_enabled
)
end

def run_benchmark
Benchmark.ips do |x|
benchmark_time = VALIDATE_BENCHMARK_MODE ? { time: 0.01, warmup: 0 } : { time: 10, warmup: 2 }
x.config(
**benchmark_time,
suite: report_to_dogstatsd_if_enabled_via_environment_variable(benchmark_name: 'profiler_sample_serialize')
)

x.report("sample #{ENV['CONFIG']} timeline=#{ENV['TIMELINE'] == 'true'}") do
samples_per_second = 100
simulate_seconds = 60

(samples_per_second * simulate_seconds).times do
Datadog::Profiling::Collectors::ThreadContext::Testing._native_sample(@collector, PROFILER_OVERHEAD_STACK_THREAD)
end

@recorder.serialize
nil
end

x.save! 'profiler_sample_serialize-results.json' unless VALIDATE_BENCHMARK_MODE
x.compare!
end

@recorder.serialize
end

def run_forever
while true
1000.times do
Datadog::Profiling::Collectors::ThreadContext::Testing._native_sample(@collector, PROFILER_OVERHEAD_STACK_THREAD)
end
@recorder.serialize
print '.'
end
end
end

puts "Current pid is #{Process.pid}"

ProfilerSampleSerializeBenchmark.new.instance_exec do
create_profiler
10.times { Thread.new { sleep } }
if ARGV.include?('--forever')
run_forever
else
run_benchmark
end
end
25 changes: 20 additions & 5 deletions docs/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ end
| Key | Description | Default |
|----------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------|
| `service_name` | Name of application running the `active_record` instrumentation. May be overridden by `global_default_service_name`. [See *Additional Configuration* for more details](#additional-configuration) | Name of database adapter (e.g. `'mysql2'`) |
| `service_name` | Override the service name for the SQL query instrumentation. ActiveRecord instantiation instrumentation always uses the application's configured service name. | Name of database adapter (e.g. `'mysql2'`) |

**Configuring trace settings per database**

Expand Down Expand Up @@ -792,7 +792,7 @@ connection.get('/foo')
| `peer_service` | `DD_TRACE_FARADAY_PEER_SERVICE` | Name of external service the application connects to | `nil` |
| `distributed_tracing` | | Enables [distributed tracing](#distributed-tracing) | `true` |
| `split_by_domain` | | Uses the request domain as the service name when set to `true`. | `false` |
| `on_error` || Custom error handler invoked when a request raises an error. Provided `span` and `error` as arguments. Sets error on the span by deault. | `proc { \|span, error\| span.set_error(error) unless span.nil? }` |**default: 400...600**
| `on_error` || Custom error handler invoked when a request raises an error. Provided `span` and `error` as arguments. Sets an error on the span by deault. | `proc { \|span, error\| span.set_error(error) unless span.nil? }` |**default: 400...600**
| `error_status_codes` | `DD_TRACE_FARADAY_ERROR_STATUS_CODES` | Defines HTTP status codes that are traced as errors. Value can be a range (`400...600`), or an array of ranges/integers `[403, 500...600]`. If configured with environment variable, use dash for range (`'400-599'`) and comma for adding element into an array (`'403,500-599'`) | `400...600` |

### Grape
Expand Down Expand Up @@ -1545,6 +1545,21 @@ customer_cache.get(...)
invoice_cache.get(...)
```

With a standalone `RedisClient`:

```ruby
require "redis-client"
require "ddtrace"
redis = RedisClient.config(custom: { datadog: { service_name: "my-custom-redis" } }).new_client
Datadog.configure do |c|
c.tracing.instrument :redis # Enabling integration instrumentation is still required
end
redis.call('PING')
```

With Redis version < 5:

```ruby
Expand Down Expand Up @@ -2104,7 +2119,7 @@ When custom sampling is required, there are two possible strategies:
2. Application-side, which can completely prevent a span from being flushed from the Ruby process, but it prevents
[post-ingestion sampling](https://docs.datadoghq.com/tracing/trace_pipeline/ingestion_controls/) from receiving the data necessary to work correctly.
This strategy should only be used when the gains in performance and bandwidth reduction are essential to the system.
If you are use application-side sampling, please let us know by [opening an issue on GitHub](https://github.com/DataDog/dd-trace-rb/issues/new), so we can better understand and support your use case.
Expand All @@ -2130,15 +2145,15 @@ class CustomSampler
trace.reject!
# Or
# 2. Do not flush span. Ingestion Controls page will be **inaccurate**.
# Can save processing time and bandwidth.
# a. Flush the span
trace.sampled = true
# b. Do not flush the span
trace.sampled = false
end
# The sampling rate, if this sampler has such concept. Otherwise, `nil`.
#
# @param [Datadog::Tracing::TraceOperation] trace
Expand Down
8 changes: 5 additions & 3 deletions docs/OpenTelemetry.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# OpenTelemetry

**ATTENTION**:

***OpenTelemetry support is currently "experimental". It may be subject to breaking changes between minor versions, and is not yet recommended for use in production or other sensitive environments.***
Expand All @@ -10,7 +12,7 @@ If you are interested in using this feature experimentally, please contact the d
| ------------- | ---------------------------------------------------- | --------------- | ------------------- |
| OpenTelemetry | https://github.com/open-telemetry/opentelemetry-ruby | 1.9.0+ | >= 1.1.0 |

#### Configuring OpenTelemetry
## Configuring OpenTelemetry

1. Add the `ddtrace` gem to your Gemfile:

Expand Down Expand Up @@ -48,7 +50,7 @@ If you are interested in using this feature experimentally, please contact the d

[Integration instrumentations](#integration-instrumentation) and OpenTelemetry [Automatic instrumentations](https://opentelemetry.io/docs/instrumentation/ruby/automatic/) are also supported.

##### Limitations
## Limitations

There are a few limitations to OpenTelemetry Tracing when the APM integration is activated:

Expand All @@ -60,7 +62,7 @@ There are a few limitations to OpenTelemetry Tracing when the APM integration is
| `OpenTelemetry.logger` | Special | `OpenTelemetry.logger` is set to the same object as `Datadog.logger`. | Configure through [Custom logging](#custom-logging). | |
| Trace/span [ID generators](https://opentelemetry.io/docs/reference/specification/trace/sdk/#id-generators) | Special | ID generation is performed by `ddtrace`. | N/A | |

##### Exporting OpenTelemetry-only traces
## Exporting OpenTelemetry-only traces

You can send OpenTelemetry traces directly to the Datadog agent (without `ddtrace`) by using [OTLP](https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-exporter-otlp/latest).
Check out our documentation on [OTLP ingest in the Datadog Agent](https://docs.datadoghq.com/tracing/setup_overview/open_standards/#otlp-ingest-in-datadog-agent) for details.
Expand Down
Loading

0 comments on commit 8ea3eb5

Please sign in to comment.