-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored: Move Tracing health metrics to Tracing namespace
- Loading branch information
Showing
9 changed files
with
148 additions
and
104 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# typed: true | ||
|
||
module Datadog | ||
module Core | ||
module Configuration | ||
module Ext | ||
# @public_api | ||
module Diagnostics | ||
ENV_DEBUG_ENABLED = 'DD_TRACE_DEBUG'.freeze | ||
ENV_HEALTH_METRICS_ENABLED = 'DD_HEALTH_METRICS_ENABLED'.freeze | ||
ENV_STARTUP_LOGS_ENABLED = 'DD_TRACE_STARTUP_LOGS'.freeze | ||
end | ||
end | ||
end | ||
end | ||
end |
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
7 changes: 1 addition & 6 deletions
7
lib/datadog/core/diagnostics/ext.rb → lib/datadog/tracing/diagnostics/ext.rb
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# typed: ignore | ||
|
||
require_relative 'ext' | ||
|
||
module Datadog | ||
module Tracing | ||
module Diagnostics | ||
# Health-related diagnostics | ||
module Health | ||
# Health metrics for diagnostics | ||
module Metrics | ||
def self.extended(base) | ||
base.class_eval do | ||
count :api_errors, Ext::Health::Metrics::METRIC_API_ERRORS | ||
count :api_requests, Ext::Health::Metrics::METRIC_API_REQUESTS | ||
count :api_responses, Ext::Health::Metrics::METRIC_API_RESPONSES | ||
count :error_context_overflow, Ext::Health::Metrics::METRIC_ERROR_CONTEXT_OVERFLOW | ||
count :error_instrumentation_patch, Ext::Health::Metrics::METRIC_ERROR_INSTRUMENTATION_PATCH | ||
count :error_span_finish, Ext::Health::Metrics::METRIC_ERROR_SPAN_FINISH | ||
count :error_unfinished_spans, Ext::Health::Metrics::METRIC_ERROR_UNFINISHED_SPANS | ||
count :instrumentation_patched, Ext::Health::Metrics::METRIC_INSTRUMENTATION_PATCHED | ||
count :queue_accepted, Ext::Health::Metrics::METRIC_QUEUE_ACCEPTED | ||
count :queue_accepted_lengths, Ext::Health::Metrics::METRIC_QUEUE_ACCEPTED_LENGTHS | ||
count :queue_dropped, Ext::Health::Metrics::METRIC_QUEUE_DROPPED | ||
count :traces_filtered, Ext::Health::Metrics::METRIC_TRACES_FILTERED | ||
count :transport_trace_too_large, Ext::Health::Metrics::METRIC_TRANSPORT_TRACE_TOO_LARGE | ||
count :transport_chunked, Ext::Health::Metrics::METRIC_TRANSPORT_CHUNKED | ||
count :writer_cpu_time, Ext::Health::Metrics::METRIC_WRITER_CPU_TIME | ||
|
||
gauge :queue_length, Ext::Health::Metrics::METRIC_QUEUE_LENGTH | ||
gauge :queue_max_length, Ext::Health::Metrics::METRIC_QUEUE_MAX_LENGTH | ||
gauge :queue_spans, Ext::Health::Metrics::METRIC_QUEUE_SPANS | ||
gauge :sampling_service_cache_length, Ext::Health::Metrics::METRIC_SAMPLING_SERVICE_CACHE_LENGTH | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
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,50 @@ | ||
# typed: ignore | ||
|
||
require 'spec_helper' | ||
require 'ddtrace' | ||
require 'datadog/core/diagnostics/health' | ||
require 'datadog/tracing/diagnostics/health' | ||
|
||
RSpec.describe Datadog::Tracing::Diagnostics::Health::Metrics do | ||
# TODO: Core::Health::Metrics directly extends Tracing::Health::Metrics | ||
# In the future, have tracing add this behavior itself. For now, | ||
# just use the core metrics class to drive the tests. | ||
subject(:health_metrics) { Datadog::Core::Diagnostics::Health::Metrics.new } | ||
|
||
shared_examples_for 'a health metric' do |type, name, stat| | ||
subject(:health_metric) { health_metrics.send(name, *args, &block) } | ||
|
||
let(:args) { [1] } | ||
let(:block) { proc {} } | ||
|
||
it 'sends a measurement of the designated type' do | ||
expect(health_metrics).to receive(type) do |*received_args, &received_block| | ||
expect(received_args).to eq([stat, *args]) | ||
expect(received_block).to be block | ||
end | ||
|
||
health_metric | ||
end | ||
end | ||
|
||
# rubocop:disable Layout/LineLength | ||
it_behaves_like 'a health metric', :count, :api_errors, Datadog::Tracing::Diagnostics::Ext::Health::Metrics::METRIC_API_ERRORS | ||
it_behaves_like 'a health metric', :count, :api_requests, Datadog::Tracing::Diagnostics::Ext::Health::Metrics::METRIC_API_REQUESTS | ||
it_behaves_like 'a health metric', :count, :api_responses, Datadog::Tracing::Diagnostics::Ext::Health::Metrics::METRIC_API_RESPONSES | ||
it_behaves_like 'a health metric', :count, :error_context_overflow, Datadog::Tracing::Diagnostics::Ext::Health::Metrics::METRIC_ERROR_CONTEXT_OVERFLOW | ||
it_behaves_like 'a health metric', :count, :error_instrumentation_patch, Datadog::Tracing::Diagnostics::Ext::Health::Metrics::METRIC_ERROR_INSTRUMENTATION_PATCH | ||
it_behaves_like 'a health metric', :count, :error_span_finish, Datadog::Tracing::Diagnostics::Ext::Health::Metrics::METRIC_ERROR_SPAN_FINISH | ||
it_behaves_like 'a health metric', :count, :error_unfinished_spans, Datadog::Tracing::Diagnostics::Ext::Health::Metrics::METRIC_ERROR_UNFINISHED_SPANS | ||
it_behaves_like 'a health metric', :count, :instrumentation_patched, Datadog::Tracing::Diagnostics::Ext::Health::Metrics::METRIC_INSTRUMENTATION_PATCHED | ||
it_behaves_like 'a health metric', :count, :queue_accepted, Datadog::Tracing::Diagnostics::Ext::Health::Metrics::METRIC_QUEUE_ACCEPTED | ||
it_behaves_like 'a health metric', :count, :queue_accepted_lengths, Datadog::Tracing::Diagnostics::Ext::Health::Metrics::METRIC_QUEUE_ACCEPTED_LENGTHS | ||
it_behaves_like 'a health metric', :count, :queue_dropped, Datadog::Tracing::Diagnostics::Ext::Health::Metrics::METRIC_QUEUE_DROPPED | ||
it_behaves_like 'a health metric', :count, :traces_filtered, Datadog::Tracing::Diagnostics::Ext::Health::Metrics::METRIC_TRACES_FILTERED | ||
it_behaves_like 'a health metric', :count, :writer_cpu_time, Datadog::Tracing::Diagnostics::Ext::Health::Metrics::METRIC_WRITER_CPU_TIME | ||
|
||
it_behaves_like 'a health metric', :gauge, :queue_length, Datadog::Tracing::Diagnostics::Ext::Health::Metrics::METRIC_QUEUE_LENGTH | ||
it_behaves_like 'a health metric', :gauge, :queue_max_length, Datadog::Tracing::Diagnostics::Ext::Health::Metrics::METRIC_QUEUE_MAX_LENGTH | ||
it_behaves_like 'a health metric', :gauge, :queue_spans, Datadog::Tracing::Diagnostics::Ext::Health::Metrics::METRIC_QUEUE_SPANS | ||
it_behaves_like 'a health metric', :gauge, :sampling_service_cache_length, Datadog::Tracing::Diagnostics::Ext::Health::Metrics::METRIC_SAMPLING_SERVICE_CACHE_LENGTH | ||
# rubocop:enable Layout/LineLength | ||
end |
Oops, something went wrong.