Skip to content

Commit

Permalink
Merge branch 'master' into vpellan/new-graphql-tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
marcotc authored Jun 26, 2024
2 parents 841371d + af37fb6 commit aada4ee
Show file tree
Hide file tree
Showing 33 changed files with 1,929 additions and 686 deletions.
2 changes: 1 addition & 1 deletion .gitlab/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ benchmarks:
script:
- export ARTIFACTS_DIR="$(pwd)/artifacts" && (mkdir "${ARTIFACTS_DIR}" || :)
- git config --global url."https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.ddbuild.io/DataDog/".insteadOf "https://github.com/DataDog/"
- git clone --branch dd-trace-rb https://github.com/DataDog/benchmarking-platform platform && cd platform
- git clone --branch dd-trace-rb https://github.com/DataDog/benchmarking-platform benchmarking-platform && cd benchmarking-platform
- ./steps/capture-hardware-software-info.sh
- ./steps/run-benchmarks.sh
- ./steps/analyze-results.sh
Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ TEST_METADATA = {
'elasticsearch-8' => '✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ 3.4 / ✅ jruby'
},
'ethon' => {
'http' => '✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ 3.4 / jruby'
'http' => '✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ 3.4 / jruby'
},
'excon' => {
'http' => '✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ 3.4 / ✅ jruby'
Expand Down Expand Up @@ -101,7 +101,7 @@ TEST_METADATA = {
'http' => '✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ 3.4 / ✅ jruby'
},
'httprb' => {
'http' => '✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ 3.4 / jruby'
'http' => '✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ 3.4 / jruby'
},
'kafka' => {
'activesupport' => '✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ 3.4 / ✅ jruby'
Expand Down
268 changes: 172 additions & 96 deletions docs/GettingStarted.md

Large diffs are not rendered by default.

20 changes: 3 additions & 17 deletions lib/datadog/core/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,23 +84,16 @@ def configure
configuration = self.configuration
yield(configuration)

built_components = false

components = safely_synchronize do |write_components|
safely_synchronize do |write_components|
write_components.call(
if components?
replace_components!(configuration, @components)
else
components = build_components(configuration)
built_components = true
components
build_components(configuration)
end
)
end

# Should only be called the first time components are built
components.telemetry.started! if built_components

configuration
end

Expand Down Expand Up @@ -200,20 +193,13 @@ def components(allow_initialization: true)
current_components = COMPONENTS_READ_LOCK.synchronize { defined?(@components) && @components }
return current_components if current_components || !allow_initialization

built_components = false

components = safely_synchronize do |write_components|
safely_synchronize do |write_components|
if defined?(@components) && @components
@components
else
built_components = true
write_components.call(build_components(configuration))
end
end

# Should only be called the first time components are built
components&.telemetry&.started! if built_components
components
end

private
Expand Down
7 changes: 4 additions & 3 deletions lib/datadog/core/configuration/components.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
require_relative '../diagnostics/health'
require_relative '../logger'
require_relative '../runtime/metrics'
require_relative '../telemetry/client'
require_relative '../telemetry/component'
require_relative '../workers/runtime_metrics'

require_relative '../remote/component'
Expand Down Expand Up @@ -62,7 +62,7 @@ def build_telemetry(settings, agent_settings, logger)
logger.debug { "Telemetry disabled. Agent network adapter not supported: #{agent_settings.adapter}" }
end

Telemetry::Client.new(
Telemetry::Component.new(
enabled: enabled,
heartbeat_interval_seconds: settings.telemetry.heartbeat_interval_seconds,
dependency_collection: settings.telemetry.dependency_collection
Expand Down Expand Up @@ -169,8 +169,9 @@ def shutdown!(replacement = nil)
unused_statsd = (old_statsd - (old_statsd & new_statsd))
unused_statsd.each(&:close)

telemetry.stop!
# enqueue closing event before stopping telemetry so it will be send out on shutdown
telemetry.emit_closing! unless replacement
telemetry.stop!
end
end
end
Expand Down
95 changes: 0 additions & 95 deletions lib/datadog/core/telemetry/client.rb

This file was deleted.

66 changes: 66 additions & 0 deletions lib/datadog/core/telemetry/component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# frozen_string_literal: true

require_relative 'emitter'
require_relative 'event'
require_relative 'worker'
require_relative '../utils/forking'

module Datadog
module Core
module Telemetry
# Telemetry entrypoint, coordinates sending telemetry events at various points in app lifecycle.
class Component
attr_reader :enabled

include Core::Utils::Forking

# @param enabled [Boolean] Determines whether telemetry events should be sent to the API
# @param heartbeat_interval_seconds [Float] How frequently heartbeats will be reported, in seconds.
# @param [Boolean] dependency_collection Whether to send the `app-dependencies-loaded` event
def initialize(heartbeat_interval_seconds:, dependency_collection:, enabled: true)
@enabled = enabled
@stopped = false

@worker = Telemetry::Worker.new(
enabled: @enabled,
heartbeat_interval_seconds: heartbeat_interval_seconds,
emitter: Emitter.new,
dependency_collection: dependency_collection
)
@worker.start
end

def disable!
@enabled = false
@worker.enabled = false
end

def stop!
return if @stopped

@worker.stop(true)
@stopped = true
end

def emit_closing!
return if !@enabled || forked?

@worker.enqueue(Event::AppClosing.new)
end

def integrations_change!
return if !@enabled || forked?

@worker.enqueue(Event::AppIntegrationsChange.new)
end

# Report configuration changes caused by Remote Configuration.
def client_configuration_change!(changes)
return if !@enabled || forked?

@worker.enqueue(Event::AppClientConfigurationChange.new(changes, 'remote_config'))
end
end
end
end
end
27 changes: 27 additions & 0 deletions lib/datadog/core/telemetry/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,33 @@ def type
'app-closing'
end
end

# Telemetry class for the 'generate-metrics' event
class GenerateMetrics < Base
def type
'generate-metrics'
end

def initialize(namespace, metric_series)
super()
@namespace = namespace
@metric_series = metric_series
end

def payload(_)
{
namespace: @namespace,
series: @metric_series.map(&:to_h)
}
end
end

# Telemetry class for the 'distributions' event
class Distributions < GenerateMetrics
def type
'distributions'
end
end
end
end
end
Expand Down
33 changes: 0 additions & 33 deletions lib/datadog/core/telemetry/heartbeat.rb

This file was deleted.

2 changes: 1 addition & 1 deletion lib/datadog/core/telemetry/http/adapters/net.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Net
:timeout,
:ssl

DEFAULT_TIMEOUT = 30
DEFAULT_TIMEOUT = 2

def initialize(hostname:, port: nil, timeout: DEFAULT_TIMEOUT, ssl: true)
@hostname = hostname
Expand Down
Loading

0 comments on commit aada4ee

Please sign in to comment.