-
Notifications
You must be signed in to change notification settings - Fork 375
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
[SDTEST-409] Send telemetry events in background thread to remove blocking HTTP calls from critical path #3718
Merged
anmarchenko
merged 21 commits into
master
from
anmarchenko/telemetry_send_events_in_background_thread
Jun 25, 2024
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
3db289f
rename Telemetry::Heartbeat to Telemetry::Worker
anmarchenko b1061ef
Add queue to telemetry worker. Move sending heartbeat logic to the te…
anmarchenko d4350ca
move AppStarted telemetry event out of the critical path
anmarchenko bb9f888
fix failing tests by waiting for worker startup
anmarchenko a11e48d
debug logging, flushing events, attempt at fixing failing test for wo…
anmarchenko 6b9204e
don't send heartbeat event if started event wasn't successfully sent
anmarchenko dcedde6
fix client_spec
anmarchenko 3a0256f
enqueue events to be sent later by worker instead of sending them syn…
anmarchenko 06293a4
rename Telemetry::Client to Telemetry::Component to better reflect it…
anmarchenko d31a088
leftover of telemetry component rename
anmarchenko 4f2aab8
add Core::Utils::OnlyOnceSuccessful to execute code with only one suc…
anmarchenko 8b7a50e
ensure that app-started event is sent at most once, flush events befo…
anmarchenko 69adca1
remove Telemetry::Component.started! as right now it just contains de…
anmarchenko 440746a
change the wrong expectation in workers spec
anmarchenko 76bfd9f
send app-dependencies-loaded event right after app-started event in t…
anmarchenko cd239cb
add limit option to OnlyOnceSuccessful util
anmarchenko 71c9e5c
limit telemetry app-started event retries
anmarchenko f4d349a
do not instantiate empty array every time when sending events
anmarchenko 3ccf58b
lower HTTP timeout for telemetry worker
anmarchenko 5729921
do not run httprb spec for jruby
anmarchenko 3b4e4d4
skip more http specs for jruby
anmarchenko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are able to remove this logic because
Telemetry::Worker
now handles thatapp-started
is sent once. Note that before it was not guaranteed that app-started event was sent: if agent URL was not configured via environment variable, telemetry would silently fail to start. This is handled correctly now.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love removing "special behavior" like this!