datadog 2.20.0 → 2.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +212 -1
- data/README.md +0 -1
- data/ext/LIBDATADOG_DEVELOPMENT.md +3 -0
- data/ext/datadog_profiling_native_extension/collectors_cpu_and_wall_time_worker.c +93 -23
- data/ext/datadog_profiling_native_extension/collectors_discrete_dynamic_sampler.c +1 -1
- data/ext/datadog_profiling_native_extension/collectors_stack.c +21 -5
- data/ext/datadog_profiling_native_extension/crashtracking_runtime_stacks.c +239 -0
- data/ext/datadog_profiling_native_extension/datadog_ruby_common.h +1 -1
- data/ext/datadog_profiling_native_extension/extconf.rb +9 -4
- data/ext/datadog_profiling_native_extension/heap_recorder.c +1 -1
- data/ext/datadog_profiling_native_extension/http_transport.c +1 -0
- data/ext/datadog_profiling_native_extension/private_vm_api_access.c +12 -0
- data/ext/datadog_profiling_native_extension/private_vm_api_access.h +4 -0
- data/ext/datadog_profiling_native_extension/profiling.c +2 -0
- data/ext/libdatadog_api/datadog_ruby_common.h +1 -1
- data/ext/libdatadog_api/ddsketch.c +106 -0
- data/ext/libdatadog_api/feature_flags.c +554 -0
- data/ext/libdatadog_api/feature_flags.h +5 -0
- data/ext/libdatadog_api/init.c +5 -0
- data/ext/libdatadog_api/library_config.c +34 -25
- data/ext/libdatadog_api/process_discovery.c +24 -18
- data/ext/libdatadog_extconf_helpers.rb +1 -1
- data/lib/datadog/ai_guard/api_client.rb +82 -0
- data/lib/datadog/ai_guard/component.rb +42 -0
- data/lib/datadog/ai_guard/configuration/ext.rb +17 -0
- data/lib/datadog/ai_guard/configuration/settings.rb +98 -0
- data/lib/datadog/ai_guard/configuration.rb +11 -0
- data/lib/datadog/ai_guard/evaluation/message.rb +25 -0
- data/lib/datadog/ai_guard/evaluation/no_op_result.rb +34 -0
- data/lib/datadog/ai_guard/evaluation/request.rb +81 -0
- data/lib/datadog/ai_guard/evaluation/result.rb +43 -0
- data/lib/datadog/ai_guard/evaluation/tool_call.rb +18 -0
- data/lib/datadog/ai_guard/evaluation.rb +72 -0
- data/lib/datadog/ai_guard/ext.rb +16 -0
- data/lib/datadog/ai_guard.rb +153 -0
- data/lib/datadog/appsec/api_security/endpoint_collection/grape_route_serializer.rb +26 -0
- data/lib/datadog/appsec/api_security/endpoint_collection/rails_collector.rb +59 -0
- data/lib/datadog/appsec/api_security/endpoint_collection/rails_route_serializer.rb +29 -0
- data/lib/datadog/appsec/api_security/endpoint_collection/sinatra_route_serializer.rb +26 -0
- data/lib/datadog/appsec/api_security/endpoint_collection.rb +10 -0
- data/lib/datadog/appsec/api_security/route_extractor.rb +26 -5
- data/lib/datadog/appsec/api_security/sampler.rb +7 -4
- data/lib/datadog/appsec/assets/blocked.html +8 -0
- data/lib/datadog/appsec/assets/blocked.json +1 -1
- data/lib/datadog/appsec/assets/blocked.text +3 -1
- data/lib/datadog/appsec/assets/waf_rules/README.md +30 -36
- data/lib/datadog/appsec/assets/waf_rules/recommended.json +359 -4
- data/lib/datadog/appsec/assets/waf_rules/strict.json +43 -2
- data/lib/datadog/appsec/assets.rb +1 -1
- data/lib/datadog/appsec/autoload.rb +1 -1
- data/lib/datadog/appsec/compressed_json.rb +1 -1
- data/lib/datadog/appsec/configuration/settings.rb +9 -0
- data/lib/datadog/appsec/context.rb +2 -1
- data/lib/datadog/appsec/contrib/active_record/instrumentation.rb +3 -1
- data/lib/datadog/appsec/contrib/excon/ssrf_detection_middleware.rb +3 -2
- data/lib/datadog/appsec/contrib/faraday/ssrf_detection_middleware.rb +3 -1
- data/lib/datadog/appsec/contrib/graphql/gateway/watcher.rb +3 -1
- data/lib/datadog/appsec/contrib/rack/gateway/watcher.rb +9 -4
- data/lib/datadog/appsec/contrib/rack/request_middleware.rb +5 -1
- data/lib/datadog/appsec/contrib/rails/gateway/watcher.rb +7 -2
- data/lib/datadog/appsec/contrib/rails/patcher.rb +30 -0
- data/lib/datadog/appsec/contrib/rest_client/request_ssrf_detection_patch.rb +3 -1
- data/lib/datadog/appsec/contrib/sinatra/gateway/watcher.rb +10 -4
- data/lib/datadog/appsec/event.rb +12 -14
- data/lib/datadog/appsec/metrics/collector.rb +19 -3
- data/lib/datadog/appsec/metrics/telemetry_exporter.rb +2 -1
- data/lib/datadog/appsec/monitor/gateway/watcher.rb +4 -4
- data/lib/datadog/appsec/remote.rb +34 -25
- data/lib/datadog/appsec/response.rb +18 -4
- data/lib/datadog/appsec/security_engine/engine.rb +3 -3
- data/lib/datadog/appsec/security_engine/result.rb +29 -9
- data/lib/datadog/appsec/security_engine/runner.rb +19 -9
- data/lib/datadog/appsec/security_event.rb +5 -7
- data/lib/datadog/core/configuration/agent_settings_resolver.rb +4 -4
- data/lib/datadog/core/configuration/components.rb +59 -11
- data/lib/datadog/core/configuration/config_helper.rb +100 -0
- data/lib/datadog/core/configuration/deprecations.rb +36 -0
- data/lib/datadog/core/configuration/ext.rb +0 -1
- data/lib/datadog/core/configuration/option.rb +38 -43
- data/lib/datadog/core/configuration/option_definition.rb +4 -11
- data/lib/datadog/core/configuration/options.rb +9 -10
- data/lib/datadog/core/configuration/settings.rb +38 -9
- data/lib/datadog/core/configuration/stable_config.rb +10 -0
- data/lib/datadog/core/configuration/supported_configurations.rb +373 -0
- data/lib/datadog/core/configuration.rb +2 -2
- data/lib/datadog/core/ddsketch.rb +19 -0
- data/lib/datadog/core/deprecations.rb +2 -2
- data/lib/datadog/core/environment/cgroup.rb +52 -25
- data/lib/datadog/core/environment/container.rb +140 -46
- data/lib/datadog/core/environment/ext.rb +7 -2
- data/lib/datadog/core/environment/git.rb +2 -2
- data/lib/datadog/core/environment/process.rb +87 -0
- data/lib/datadog/core/environment/variable_helpers.rb +3 -3
- data/lib/datadog/core/environment/yjit.rb +2 -1
- data/lib/datadog/core/error.rb +6 -6
- data/lib/datadog/core/feature_flags.rb +61 -0
- data/lib/datadog/core/metrics/client.rb +2 -2
- data/lib/datadog/core/pin.rb +8 -8
- data/lib/datadog/core/process_discovery/tracer_memfd.rb +2 -4
- data/lib/datadog/core/process_discovery.rb +48 -23
- data/lib/datadog/core/rate_limiter.rb +9 -1
- data/lib/datadog/core/remote/client/capabilities.rb +7 -0
- data/lib/datadog/core/remote/client.rb +14 -6
- data/lib/datadog/core/remote/component.rb +10 -10
- data/lib/datadog/core/remote/configuration/content.rb +15 -2
- data/lib/datadog/core/remote/configuration/digest.rb +14 -7
- data/lib/datadog/core/remote/configuration/repository.rb +1 -1
- data/lib/datadog/core/remote/configuration/target.rb +13 -6
- data/lib/datadog/core/remote/transport/config.rb +4 -25
- data/lib/datadog/core/remote/transport/http/config.rb +10 -50
- data/lib/datadog/core/remote/transport/http/negotiation.rb +14 -44
- data/lib/datadog/core/remote/transport/http.rb +15 -24
- data/lib/datadog/core/remote/transport/negotiation.rb +8 -33
- data/lib/datadog/core/remote/worker.rb +25 -37
- data/lib/datadog/core/runtime/ext.rb +0 -1
- data/lib/datadog/core/runtime/metrics.rb +11 -1
- data/lib/datadog/core/semaphore.rb +1 -4
- data/lib/datadog/core/tag_builder.rb +0 -4
- data/lib/datadog/core/tag_normalizer.rb +84 -0
- data/lib/datadog/core/telemetry/component.rb +69 -15
- data/lib/datadog/core/telemetry/emitter.rb +6 -6
- data/lib/datadog/core/telemetry/event/app_endpoints_loaded.rb +30 -0
- data/lib/datadog/core/telemetry/event/app_started.rb +89 -51
- data/lib/datadog/core/telemetry/event/synth_app_client_configuration_change.rb +27 -4
- data/lib/datadog/core/telemetry/event.rb +1 -0
- data/lib/datadog/core/telemetry/logger.rb +2 -2
- data/lib/datadog/core/telemetry/logging.rb +2 -8
- data/lib/datadog/core/telemetry/metrics_manager.rb +9 -0
- data/lib/datadog/core/telemetry/request.rb +17 -3
- data/lib/datadog/core/telemetry/transport/http/telemetry.rb +3 -34
- data/lib/datadog/core/telemetry/transport/http.rb +21 -16
- data/lib/datadog/core/telemetry/transport/telemetry.rb +3 -11
- data/lib/datadog/core/telemetry/worker.rb +88 -32
- data/lib/datadog/core/transport/ext.rb +2 -0
- data/lib/datadog/core/transport/http/api/endpoint.rb +9 -4
- data/lib/datadog/core/transport/http/api/instance.rb +4 -21
- data/lib/datadog/core/transport/http/builder.rb +9 -5
- data/lib/datadog/core/transport/http/client.rb +80 -0
- data/lib/datadog/core/transport/http.rb +22 -19
- data/lib/datadog/core/transport/response.rb +15 -1
- data/lib/datadog/core/transport/transport.rb +90 -0
- data/lib/datadog/core/utils/array.rb +29 -0
- data/lib/datadog/{appsec/api_security → core/utils}/lru_cache.rb +10 -21
- data/lib/datadog/core/utils/network.rb +22 -1
- data/lib/datadog/core/utils/only_once_successful.rb +8 -2
- data/lib/datadog/core/utils/safe_dup.rb +2 -2
- data/lib/datadog/core/utils/sequence.rb +2 -0
- data/lib/datadog/core/utils/time.rb +1 -1
- data/lib/datadog/core/utils.rb +2 -0
- data/lib/datadog/core/workers/async.rb +10 -1
- data/lib/datadog/core/workers/interval_loop.rb +44 -3
- data/lib/datadog/core/workers/polling.rb +2 -0
- data/lib/datadog/core/workers/queue.rb +100 -1
- data/lib/datadog/core.rb +2 -0
- data/lib/datadog/data_streams/configuration/settings.rb +49 -0
- data/lib/datadog/data_streams/configuration.rb +11 -0
- data/lib/datadog/data_streams/ext.rb +11 -0
- data/lib/datadog/data_streams/extensions.rb +16 -0
- data/lib/datadog/data_streams/pathway_context.rb +169 -0
- data/lib/datadog/data_streams/processor.rb +509 -0
- data/lib/datadog/data_streams/transport/http/stats.rb +52 -0
- data/lib/datadog/data_streams/transport/http.rb +40 -0
- data/lib/datadog/data_streams/transport/stats.rb +46 -0
- data/lib/datadog/data_streams.rb +100 -0
- data/lib/datadog/di/boot.rb +7 -3
- data/lib/datadog/di/component.rb +14 -16
- data/lib/datadog/di/context.rb +70 -0
- data/lib/datadog/di/contrib/active_record.rb +30 -5
- data/lib/datadog/di/el/compiler.rb +168 -0
- data/lib/datadog/di/el/evaluator.rb +159 -0
- data/lib/datadog/di/el/expression.rb +42 -0
- data/lib/datadog/di/el.rb +5 -0
- data/lib/datadog/di/error.rb +34 -0
- data/lib/datadog/di/instrumenter.rb +189 -55
- data/lib/datadog/di/logger.rb +2 -2
- data/lib/datadog/di/probe.rb +55 -15
- data/lib/datadog/di/probe_builder.rb +41 -2
- data/lib/datadog/di/probe_file_loader/railtie.rb +1 -1
- data/lib/datadog/di/probe_file_loader.rb +1 -1
- data/lib/datadog/di/probe_manager.rb +50 -35
- data/lib/datadog/di/probe_notification_builder.rb +121 -70
- data/lib/datadog/di/probe_notifier_worker.rb +5 -5
- data/lib/datadog/di/proc_responder.rb +32 -0
- data/lib/datadog/di/remote.rb +89 -84
- data/lib/datadog/di/serializer.rb +151 -7
- data/lib/datadog/di/transport/diagnostics.rb +8 -36
- data/lib/datadog/di/transport/http/diagnostics.rb +1 -33
- data/lib/datadog/di/transport/http/input.rb +1 -33
- data/lib/datadog/di/transport/http.rb +32 -17
- data/lib/datadog/di/transport/input.rb +67 -34
- data/lib/datadog/di.rb +61 -5
- data/lib/datadog/error_tracking/filters.rb +2 -2
- data/lib/datadog/kit/appsec/events/v2.rb +2 -3
- data/lib/datadog/open_feature/component.rb +60 -0
- data/lib/datadog/open_feature/configuration.rb +27 -0
- data/lib/datadog/open_feature/evaluation_engine.rb +70 -0
- data/lib/datadog/open_feature/exposures/batch_builder.rb +32 -0
- data/lib/datadog/open_feature/exposures/buffer.rb +43 -0
- data/lib/datadog/open_feature/exposures/deduplicator.rb +30 -0
- data/lib/datadog/open_feature/exposures/event.rb +60 -0
- data/lib/datadog/open_feature/exposures/reporter.rb +40 -0
- data/lib/datadog/open_feature/exposures/worker.rb +116 -0
- data/lib/datadog/open_feature/ext.rb +14 -0
- data/lib/datadog/open_feature/native_evaluator.rb +38 -0
- data/lib/datadog/open_feature/noop_evaluator.rb +26 -0
- data/lib/datadog/open_feature/provider.rb +141 -0
- data/lib/datadog/open_feature/remote.rb +67 -0
- data/lib/datadog/open_feature/resolution_details.rb +35 -0
- data/lib/datadog/open_feature/transport.rb +70 -0
- data/lib/datadog/open_feature.rb +19 -0
- data/lib/datadog/opentelemetry/api/baggage.rb +1 -1
- data/lib/datadog/opentelemetry/configuration/settings.rb +159 -0
- data/lib/datadog/opentelemetry/metrics.rb +117 -0
- data/lib/datadog/opentelemetry/sdk/configurator.rb +26 -2
- data/lib/datadog/opentelemetry/sdk/metrics_exporter.rb +35 -0
- data/lib/datadog/opentelemetry.rb +3 -0
- data/lib/datadog/profiling/collectors/code_provenance.rb +41 -7
- data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +3 -2
- data/lib/datadog/profiling/collectors/idle_sampling_helper.rb +1 -1
- data/lib/datadog/profiling/collectors/info.rb +6 -5
- data/lib/datadog/profiling/component.rb +12 -11
- data/lib/datadog/profiling/ext/dir_monkey_patches.rb +18 -0
- data/lib/datadog/profiling/ext.rb +2 -1
- data/lib/datadog/profiling/http_transport.rb +5 -2
- data/lib/datadog/profiling/profiler.rb +4 -0
- data/lib/datadog/profiling/tag_builder.rb +36 -3
- data/lib/datadog/profiling/tasks/exec.rb +2 -2
- data/lib/datadog/profiling.rb +1 -2
- data/lib/datadog/single_step_instrument.rb +1 -1
- data/lib/datadog/tracing/component.rb +6 -17
- data/lib/datadog/tracing/configuration/dynamic.rb +2 -2
- data/lib/datadog/tracing/configuration/ext.rb +9 -3
- data/lib/datadog/tracing/configuration/settings.rb +89 -10
- data/lib/datadog/tracing/contrib/action_pack/action_controller/instrumentation.rb +4 -4
- data/lib/datadog/tracing/contrib/action_pack/utils.rb +1 -2
- data/lib/datadog/tracing/contrib/active_job/log_injection.rb +21 -7
- data/lib/datadog/tracing/contrib/active_job/patcher.rb +5 -1
- data/lib/datadog/tracing/contrib/aws/instrumentation.rb +4 -2
- data/lib/datadog/tracing/contrib/component.rb +2 -2
- data/lib/datadog/tracing/contrib/ethon/easy_patch.rb +4 -1
- data/lib/datadog/tracing/contrib/excon/configuration/settings.rb +11 -3
- data/lib/datadog/tracing/contrib/extensions.rb +10 -2
- data/lib/datadog/tracing/contrib/faraday/configuration/settings.rb +11 -7
- data/lib/datadog/tracing/contrib/grape/configuration/settings.rb +7 -3
- data/lib/datadog/tracing/contrib/graphql/configuration/settings.rb +7 -0
- data/lib/datadog/tracing/contrib/graphql/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/graphql/unified_trace.rb +84 -43
- data/lib/datadog/tracing/contrib/http/configuration/settings.rb +11 -3
- data/lib/datadog/tracing/contrib/httpclient/configuration/settings.rb +11 -3
- data/lib/datadog/tracing/contrib/httprb/configuration/settings.rb +11 -3
- data/lib/datadog/tracing/contrib/kafka/instrumentation/consumer.rb +66 -0
- data/lib/datadog/tracing/contrib/kafka/instrumentation/producer.rb +66 -0
- data/lib/datadog/tracing/contrib/kafka/patcher.rb +14 -0
- data/lib/datadog/tracing/contrib/karafka/framework.rb +30 -0
- data/lib/datadog/tracing/contrib/karafka/monitor.rb +11 -0
- data/lib/datadog/tracing/contrib/karafka/patcher.rb +35 -4
- data/lib/datadog/tracing/contrib/rack/middlewares.rb +59 -27
- data/lib/datadog/tracing/contrib/rack/request_queue.rb +1 -0
- data/lib/datadog/tracing/contrib/rack/route_inference.rb +53 -0
- data/lib/datadog/tracing/contrib/rack/trace_proxy_middleware.rb +7 -1
- data/lib/datadog/tracing/contrib/rails/ext.rb +2 -1
- data/lib/datadog/tracing/contrib/rails/integration.rb +1 -1
- data/lib/datadog/tracing/contrib/rails/middlewares.rb +2 -2
- data/lib/datadog/tracing/contrib/rest_client/request_patch.rb +4 -1
- data/lib/datadog/tracing/contrib/roda/instrumentation.rb +3 -1
- data/lib/datadog/tracing/contrib/sinatra/tracer_middleware.rb +3 -1
- data/lib/datadog/tracing/contrib/span_attribute_schema.rb +1 -1
- data/lib/datadog/tracing/contrib/status_range_matcher.rb +9 -1
- data/lib/datadog/tracing/contrib/utils/quantization/hash.rb +3 -1
- data/lib/datadog/tracing/contrib/waterdrop/configuration/settings.rb +27 -0
- data/lib/datadog/tracing/contrib/waterdrop/distributed/propagation.rb +48 -0
- data/lib/datadog/tracing/contrib/waterdrop/ext.rb +17 -0
- data/lib/datadog/tracing/contrib/waterdrop/integration.rb +43 -0
- data/lib/datadog/tracing/contrib/waterdrop/middleware.rb +46 -0
- data/lib/datadog/tracing/contrib/waterdrop/patcher.rb +49 -0
- data/lib/datadog/tracing/contrib/waterdrop/producer.rb +50 -0
- data/lib/datadog/tracing/contrib/waterdrop.rb +41 -0
- data/lib/datadog/tracing/contrib.rb +1 -0
- data/lib/datadog/tracing/diagnostics/environment_logger.rb +1 -1
- data/lib/datadog/tracing/distributed/baggage.rb +3 -2
- data/lib/datadog/tracing/metadata/ext.rb +9 -1
- data/lib/datadog/tracing/remote.rb +1 -9
- data/lib/datadog/tracing/sampling/priority_sampler.rb +3 -1
- data/lib/datadog/tracing/span.rb +1 -1
- data/lib/datadog/tracing/span_event.rb +2 -2
- data/lib/datadog/tracing/span_operation.rb +20 -9
- data/lib/datadog/tracing/trace_operation.rb +44 -6
- data/lib/datadog/tracing/tracer.rb +42 -16
- data/lib/datadog/tracing/transport/http/client.rb +12 -26
- data/lib/datadog/tracing/transport/http/traces.rb +2 -50
- data/lib/datadog/tracing/transport/http.rb +15 -9
- data/lib/datadog/tracing/transport/io/client.rb +1 -1
- data/lib/datadog/tracing/transport/trace_formatter.rb +11 -0
- data/lib/datadog/tracing/transport/traces.rb +9 -71
- data/lib/datadog/tracing/workers/trace_writer.rb +5 -0
- data/lib/datadog/tracing/writer.rb +1 -0
- data/lib/datadog/version.rb +2 -2
- data/lib/datadog.rb +3 -0
- metadata +110 -24
- data/ext/libdatadog_api/macos_development.md +0 -26
- data/lib/datadog/core/remote/transport/http/api.rb +0 -53
- data/lib/datadog/core/remote/transport/http/client.rb +0 -49
- data/lib/datadog/core/telemetry/transport/http/api.rb +0 -43
- data/lib/datadog/core/telemetry/transport/http/client.rb +0 -49
- data/lib/datadog/core/transport/http/api/spec.rb +0 -36
- data/lib/datadog/di/transport/http/api.rb +0 -42
- data/lib/datadog/di/transport/http/client.rb +0 -47
- data/lib/datadog/opentelemetry/api/baggage.rbs +0 -26
- data/lib/datadog/tracing/transport/http/api.rb +0 -44
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'opentelemetry/exporter/otlp_metrics'
|
|
4
|
+
|
|
5
|
+
module Datadog
|
|
6
|
+
module OpenTelemetry
|
|
7
|
+
module SDK
|
|
8
|
+
class MetricsExporter < ::OpenTelemetry::Exporter::OTLP::Metrics::MetricsExporter
|
|
9
|
+
METRIC_EXPORT_ATTEMPTS = 'otel.metrics_export_attempts'
|
|
10
|
+
METRIC_EXPORT_SUCCESSES = 'otel.metrics_export_successes'
|
|
11
|
+
METRIC_EXPORT_FAILURES = 'otel.metrics_export_failures'
|
|
12
|
+
TELEMETRY_NAMESPACE = 'tracers'
|
|
13
|
+
TELEMETRY_TAGS = {'protocol' => "http", 'encoding' => 'protobuf'}
|
|
14
|
+
|
|
15
|
+
def export(metrics, timeout: nil)
|
|
16
|
+
telemetry&.inc(TELEMETRY_NAMESPACE, METRIC_EXPORT_ATTEMPTS, 1, tags: TELEMETRY_TAGS)
|
|
17
|
+
result = super
|
|
18
|
+
metric_name = (result == 0) ? METRIC_EXPORT_SUCCESSES : METRIC_EXPORT_FAILURES
|
|
19
|
+
telemetry&.inc(TELEMETRY_NAMESPACE, metric_name, 1, tags: TELEMETRY_TAGS)
|
|
20
|
+
result
|
|
21
|
+
rescue => e
|
|
22
|
+
Datadog.logger.error("Failed to export OpenTelemetry Metrics: #{e.class}: #{e}")
|
|
23
|
+
telemetry&.inc(TELEMETRY_NAMESPACE, METRIC_EXPORT_FAILURES, 1, tags: TELEMETRY_TAGS)
|
|
24
|
+
raise
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
private
|
|
28
|
+
|
|
29
|
+
def telemetry
|
|
30
|
+
Datadog.send(:components).telemetry
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -22,6 +22,8 @@ require_relative 'opentelemetry/api/baggage'
|
|
|
22
22
|
require_relative 'opentelemetry/sdk/configurator' if defined?(OpenTelemetry::SDK)
|
|
23
23
|
require_relative 'opentelemetry/sdk/trace/span' if defined?(OpenTelemetry::SDK)
|
|
24
24
|
|
|
25
|
+
require_relative 'opentelemetry/metrics' if defined?(OpenTelemetry::SDK::Metrics)
|
|
26
|
+
|
|
25
27
|
module Datadog
|
|
26
28
|
# Datadog OpenTelemetry integration.
|
|
27
29
|
module OpenTelemetry
|
|
@@ -47,6 +49,7 @@ end
|
|
|
47
49
|
# Currently, this closely translates to Datadog's partial flushing.
|
|
48
50
|
#
|
|
49
51
|
# @see OpenTelemetry::SDK::Trace::SpanProcessor#on_finish
|
|
52
|
+
|
|
50
53
|
Datadog.configure do |c|
|
|
51
54
|
c.tracing.partial_flush.enabled = true
|
|
52
55
|
end
|
|
@@ -22,6 +22,7 @@ module Datadog
|
|
|
22
22
|
@libraries_by_path = {}
|
|
23
23
|
@seen_files = Set.new
|
|
24
24
|
@seen_libraries = Set.new
|
|
25
|
+
@executable_paths = [Gem.bindir, bundler_bin_path].uniq.compact.freeze
|
|
25
26
|
|
|
26
27
|
record_library(
|
|
27
28
|
Library.new(
|
|
@@ -29,7 +30,7 @@ module Datadog
|
|
|
29
30
|
name: "stdlib",
|
|
30
31
|
version: RUBY_VERSION,
|
|
31
32
|
path: standard_library_path,
|
|
32
|
-
|
|
33
|
+
extra_paths: [ruby_native_filename],
|
|
33
34
|
)
|
|
34
35
|
)
|
|
35
36
|
end
|
|
@@ -51,7 +52,8 @@ module Datadog
|
|
|
51
52
|
:libraries_by_name,
|
|
52
53
|
:libraries_by_path,
|
|
53
54
|
:seen_files,
|
|
54
|
-
:seen_libraries
|
|
55
|
+
:seen_libraries,
|
|
56
|
+
:executable_paths
|
|
55
57
|
|
|
56
58
|
def record_library(library)
|
|
57
59
|
libraries_by_name[library.name] = library
|
|
@@ -79,13 +81,20 @@ module Datadog
|
|
|
79
81
|
loaded_specs.each do |spec|
|
|
80
82
|
next if libraries_by_name.key?(spec.name)
|
|
81
83
|
|
|
84
|
+
extra_paths = [(spec.extension_dir if spec.extensions.any?)]
|
|
85
|
+
spec.executables&.each do |executable|
|
|
86
|
+
executable_paths.each do |path|
|
|
87
|
+
extra_paths << File.join(path, executable)
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
82
91
|
record_library(
|
|
83
92
|
Library.new(
|
|
84
93
|
kind: "library",
|
|
85
94
|
name: spec.name,
|
|
86
95
|
version: spec.version,
|
|
87
96
|
path: spec.gem_dir,
|
|
88
|
-
|
|
97
|
+
extra_paths: extra_paths,
|
|
89
98
|
)
|
|
90
99
|
)
|
|
91
100
|
recorded_library = true
|
|
@@ -107,6 +116,30 @@ module Datadog
|
|
|
107
116
|
end
|
|
108
117
|
end
|
|
109
118
|
|
|
119
|
+
# This is intended to mirror bundler's `Bundler.bin_path` with one key difference: the bundler version of the
|
|
120
|
+
# method **tries to create the path** if it doesn't exist, whereas our version doesn't.
|
|
121
|
+
#
|
|
122
|
+
# This "try to create the path" is annoying because creating the path can fail if e.g. the app doesn't have
|
|
123
|
+
# permissions to do that, see https://github.com/DataDog/dd-trace-rb/issues/5137.
|
|
124
|
+
# Thus we have our own version that a) Avoids creating the path, and b) Rescues exceptions to avoid any
|
|
125
|
+
# bundler complaints here impacting the application. (Bundler tends to go "something is wrong, raise!" which
|
|
126
|
+
# I think makes a lot of sense given how bundler is intended to be used, but for this our kind of "ask a few
|
|
127
|
+
# questions usage" it's not what we want.)
|
|
128
|
+
def bundler_bin_path
|
|
129
|
+
return unless defined?(Bundler)
|
|
130
|
+
|
|
131
|
+
path = Bundler.settings[:bin] || "bin"
|
|
132
|
+
root = Bundler.root
|
|
133
|
+
result = Pathname.new(path).expand_path(root).expand_path
|
|
134
|
+
result.to_s
|
|
135
|
+
rescue Exception => e # rubocop:disable Lint/RescueException
|
|
136
|
+
Datadog.logger.debug(
|
|
137
|
+
"CodeProvenance#bundler_bin_path failed. " \
|
|
138
|
+
"Cause: #{e.class.name} #{e.message} Location: #{Array(e.backtrace).first}"
|
|
139
|
+
)
|
|
140
|
+
nil
|
|
141
|
+
end
|
|
142
|
+
|
|
110
143
|
# Represents metadata we have for a ruby gem
|
|
111
144
|
#
|
|
112
145
|
# Important note: This class gets encoded to JSON with the built-in JSON gem. But, we've found that in some
|
|
@@ -118,17 +151,18 @@ module Datadog
|
|
|
118
151
|
class Library
|
|
119
152
|
attr_reader :kind, :name, :version
|
|
120
153
|
|
|
121
|
-
def initialize(kind:, name:, version:, path:,
|
|
122
|
-
|
|
154
|
+
def initialize(kind:, name:, version:, path:, extra_paths:)
|
|
155
|
+
extra_paths = Array(extra_paths).compact.reject(&:empty?).map { |p| p.dup.freeze }
|
|
123
156
|
@kind = kind.freeze
|
|
124
157
|
@name = name.dup.freeze
|
|
125
158
|
@version = version.to_s.dup.freeze
|
|
126
|
-
@paths = [path.dup.freeze,
|
|
159
|
+
@paths = [path.dup.freeze, *extra_paths].freeze
|
|
127
160
|
freeze
|
|
128
161
|
end
|
|
129
162
|
|
|
130
163
|
def to_json(arg = nil)
|
|
131
|
-
|
|
164
|
+
# Steep: https://github.com/ruby/rbs/pull/2691 (remove after RBS 4.0 release)
|
|
165
|
+
{kind: @kind, name: @name, version: @version, paths: @paths}.to_json(arg) # steep:ignore ArgumentTypeMismatch
|
|
132
166
|
end
|
|
133
167
|
|
|
134
168
|
def path
|
|
@@ -77,12 +77,13 @@ module Datadog
|
|
|
77
77
|
Datadog.logger.debug("CpuAndWallTimeWorker thread stopping cleanly")
|
|
78
78
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
|
79
79
|
@failure_exception = e
|
|
80
|
+
operation_name = self.class._native_failure_exception_during_operation(self).inspect
|
|
80
81
|
Datadog.logger.warn(
|
|
81
82
|
"CpuAndWallTimeWorker thread error. " \
|
|
82
|
-
"Cause: #{e.class.name} #{e.message} Location: #{Array(e.backtrace).first}"
|
|
83
|
+
"Operation: #{operation_name} Cause: #{e.class.name} #{e.message} Location: #{Array(e.backtrace).first}"
|
|
83
84
|
)
|
|
84
85
|
on_failure_proc&.call
|
|
85
|
-
Datadog::Core::Telemetry::Logger.report(e, description: "CpuAndWallTimeWorker thread error
|
|
86
|
+
Datadog::Core::Telemetry::Logger.report(e, description: "CpuAndWallTimeWorker thread error: #{operation_name}")
|
|
86
87
|
end
|
|
87
88
|
@worker_thread.name = self.class.name # Repeated from above to make sure thread gets named asap
|
|
88
89
|
@worker_thread.thread_variable_set(:fork_safe, true)
|
|
@@ -41,7 +41,7 @@ module Datadog
|
|
|
41
41
|
"IdleSamplingHelper thread error. " \
|
|
42
42
|
"Cause: #{e.class.name} #{e.message} Location: #{Array(e.backtrace).first}"
|
|
43
43
|
)
|
|
44
|
-
Datadog::Core::Telemetry::Logger.report(e, description: "IdleSamplingHelper thread error"
|
|
44
|
+
Datadog::Core::Telemetry::Logger.report(e, description: "IdleSamplingHelper thread error")
|
|
45
45
|
end
|
|
46
46
|
@worker_thread.name = self.class.name # Repeated from above to make sure thread gets named asap
|
|
47
47
|
@worker_thread.thread_variable_set(:fork_safe, true)
|
|
@@ -16,7 +16,9 @@ module Datadog
|
|
|
16
16
|
class Info
|
|
17
17
|
def initialize(settings)
|
|
18
18
|
@profiler_info = nil
|
|
19
|
-
|
|
19
|
+
|
|
20
|
+
# Steep: https://github.com/soutaro/steep/issues/363
|
|
21
|
+
@info = { # steep:ignore IncompatibleAssignment
|
|
20
22
|
platform: collect_platform_info,
|
|
21
23
|
runtime: collect_runtime_info,
|
|
22
24
|
application: collect_application_info(settings),
|
|
@@ -96,7 +98,7 @@ module Datadog
|
|
|
96
98
|
end
|
|
97
99
|
|
|
98
100
|
def collect_profiler_info(settings)
|
|
99
|
-
|
|
101
|
+
@profiler_info ||= begin
|
|
100
102
|
lib_datadog_gem = ::Gem.loaded_specs["libdatadog"]
|
|
101
103
|
|
|
102
104
|
libdatadog_version =
|
|
@@ -108,13 +110,12 @@ module Datadog
|
|
|
108
110
|
"#{Libdatadog::VERSION}-(unknown)"
|
|
109
111
|
end
|
|
110
112
|
|
|
111
|
-
|
|
113
|
+
{
|
|
112
114
|
version: Datadog::Core::Environment::Identity.gem_datadog_version,
|
|
113
115
|
libdatadog: libdatadog_version,
|
|
114
116
|
settings: collect_settings_recursively(settings.profiling),
|
|
115
117
|
}.freeze
|
|
116
118
|
end
|
|
117
|
-
@profiler_info
|
|
118
119
|
end
|
|
119
120
|
|
|
120
121
|
# The settings/option model isn't directly serializable because
|
|
@@ -146,7 +147,7 @@ module Datadog
|
|
|
146
147
|
return @gc_tuning_info if defined?(@gc_tuning_info)
|
|
147
148
|
|
|
148
149
|
@gc_tuning_info = RUBY_GC_TUNING_ENV_VARS.each_with_object({}) do |var, hash|
|
|
149
|
-
current_value =
|
|
150
|
+
current_value = DATADOG_ENV[var]
|
|
150
151
|
hash[var.to_sym] = current_value if current_value
|
|
151
152
|
end.freeze
|
|
152
153
|
end
|
|
@@ -4,9 +4,6 @@ module Datadog
|
|
|
4
4
|
module Profiling
|
|
5
5
|
# Responsible for wiring up the Profiler for execution
|
|
6
6
|
module Component
|
|
7
|
-
ALLOCATION_WITH_RACTORS_ONLY_ONCE = Datadog::Core::Utils::OnlyOnce.new
|
|
8
|
-
private_constant :ALLOCATION_WITH_RACTORS_ONLY_ONCE
|
|
9
|
-
|
|
10
7
|
# Passing in a `nil` tracer is supported and will disable the following profiling features:
|
|
11
8
|
# * Profiling in the trace viewer, as well as scoping a profile down to a span
|
|
12
9
|
# * Endpoint aggregation in the profiler UX, including normalization (resource per endpoint call)
|
|
@@ -145,7 +142,7 @@ module Datadog
|
|
|
145
142
|
logger.debug(
|
|
146
143
|
"Using Ractors may result in GC profiling unexpectedly " \
|
|
147
144
|
"stopping (https://bugs.ruby-lang.org/issues/19112). Note that this stop has no impact in your " \
|
|
148
|
-
"application stability or performance. This
|
|
145
|
+
"application stability or performance. This issue is fixed on Ruby 4."
|
|
149
146
|
)
|
|
150
147
|
end
|
|
151
148
|
|
|
@@ -195,13 +192,11 @@ module Datadog
|
|
|
195
192
|
# On all known versions of Ruby 3.x, due to https://bugs.ruby-lang.org/issues/19112, when a ractor gets
|
|
196
193
|
# garbage collected, Ruby will disable all active tracepoints, which this feature internally relies on.
|
|
197
194
|
elsif RUBY_VERSION.start_with?("3.")
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
)
|
|
204
|
-
end
|
|
195
|
+
logger.debug(
|
|
196
|
+
"Using Ractors may result in allocation profiling " \
|
|
197
|
+
"stopping (https://bugs.ruby-lang.org/issues/19112). Note that this stop has no impact in your " \
|
|
198
|
+
"application stability or performance. This issue is fixed on Ruby 4."
|
|
199
|
+
)
|
|
205
200
|
end
|
|
206
201
|
|
|
207
202
|
logger.debug("Enabled allocation profiling")
|
|
@@ -220,6 +215,12 @@ module Datadog
|
|
|
220
215
|
"Please upgrade to Ruby >= 3.1 in order to use this feature. Heap profiling has been disabled."
|
|
221
216
|
)
|
|
222
217
|
return false
|
|
218
|
+
elsif RUBY_VERSION.start_with?("4.")
|
|
219
|
+
logger.warn(
|
|
220
|
+
"Datadog Ruby heap profiler is currently incompatible with Ruby 4. " \
|
|
221
|
+
"Heap profiling has been disabled."
|
|
222
|
+
)
|
|
223
|
+
return false
|
|
223
224
|
end
|
|
224
225
|
|
|
225
226
|
unless allocation_profiling_enabled
|
|
@@ -30,6 +30,10 @@ module Datadog
|
|
|
30
30
|
if RUBY_VERSION.start_with?("2.")
|
|
31
31
|
# Monkey patches for Dir.singleton_class (Ruby 2 version). See DirMonkeyPatches above for more details.
|
|
32
32
|
module DirClassMonkeyPatches
|
|
33
|
+
# Steep: Workaround that defines args and block only for Ruby 2.x.
|
|
34
|
+
# @type var args: ::Array[any]
|
|
35
|
+
# @type var block: ^(?) -> any | nil
|
|
36
|
+
|
|
33
37
|
def [](*args, &block)
|
|
34
38
|
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
|
35
39
|
super
|
|
@@ -148,6 +152,11 @@ module Datadog
|
|
|
148
152
|
else
|
|
149
153
|
# Monkey patches for Dir.singleton_class (Ruby 3 version). See DirMonkeyPatches above for more details.
|
|
150
154
|
module DirClassMonkeyPatches
|
|
155
|
+
# Steep: Workaround that defines args, kwargs and block only for Ruby 3.x.
|
|
156
|
+
# @type var args: ::Array[any]
|
|
157
|
+
# @type var kwargs: ::Hash[::Symbol, any]
|
|
158
|
+
# @type var block: ^(?) -> any | nil
|
|
159
|
+
|
|
151
160
|
def [](*args, **kwargs, &block)
|
|
152
161
|
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
|
|
153
162
|
super
|
|
@@ -263,6 +272,10 @@ module Datadog
|
|
|
263
272
|
if RUBY_VERSION.start_with?("2.")
|
|
264
273
|
# Monkey patches for Dir (Ruby 2 version). See DirMonkeyPatches above for more details.
|
|
265
274
|
module DirInstanceMonkeyPatches
|
|
275
|
+
# Steep: Workaround that defines args and block only for Ruby 2.x.
|
|
276
|
+
# @type var args: ::Array[any]
|
|
277
|
+
# @type var block: ^(?) -> any | nil
|
|
278
|
+
|
|
266
279
|
# See note on methods that yield above.
|
|
267
280
|
def each(*args, &block)
|
|
268
281
|
if block
|
|
@@ -336,6 +349,11 @@ module Datadog
|
|
|
336
349
|
else
|
|
337
350
|
# Monkey patches for Dir (Ruby 3 version). See DirMonkeyPatches above for more details.
|
|
338
351
|
module DirInstanceMonkeyPatches
|
|
352
|
+
# Steep: Workaround that defines args, kwargs and block only for Ruby 3.x.
|
|
353
|
+
# @type var args: ::Array[any]
|
|
354
|
+
# @type var kwargs: ::Hash[::Symbol, any]
|
|
355
|
+
# @type var block: ^(?) -> any | nil
|
|
356
|
+
|
|
339
357
|
# See note on methods that yield above.
|
|
340
358
|
def each(*args, **kwargs, &block)
|
|
341
359
|
if block
|
|
@@ -6,9 +6,10 @@ module Datadog
|
|
|
6
6
|
ENV_ENABLED = "DD_PROFILING_ENABLED"
|
|
7
7
|
ENV_UPLOAD_TIMEOUT = "DD_PROFILING_UPLOAD_TIMEOUT"
|
|
8
8
|
ENV_MAX_FRAMES = "DD_PROFILING_MAX_FRAMES"
|
|
9
|
-
ENV_AGENTLESS = "DD_PROFILING_AGENTLESS"
|
|
10
9
|
ENV_ENDPOINT_COLLECTION_ENABLED = "DD_PROFILING_ENDPOINT_COLLECTION_ENABLED"
|
|
11
10
|
|
|
11
|
+
# WARNING: This should not be used, only for internal testing
|
|
12
|
+
ENV_AGENTLESS = "DD_PROFILING_AGENTLESS" # rubocop:disable CustomCops/EnvStringValidationCop
|
|
12
13
|
module Transport
|
|
13
14
|
module HTTP
|
|
14
15
|
FORM_FIELD_TAG_PROFILER_VERSION = "profiler_version"
|
|
@@ -13,7 +13,10 @@ module Datadog
|
|
|
13
13
|
def initialize(agent_settings:, site:, api_key:, upload_timeout_seconds:)
|
|
14
14
|
@upload_timeout_milliseconds = (upload_timeout_seconds * 1_000).to_i
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
# Steep: multiple issues here
|
|
17
|
+
# first https://github.com/soutaro/steep/issues/363
|
|
18
|
+
# then https://github.com/soutaro/steep/issues/1603 (remove the .freeze to see it)
|
|
19
|
+
@exporter_configuration = # steep:ignore IncompatibleAssignment
|
|
17
20
|
if agentless?(site, api_key)
|
|
18
21
|
[:agentless, site, api_key].freeze
|
|
19
22
|
else
|
|
@@ -56,7 +59,7 @@ module Datadog
|
|
|
56
59
|
private
|
|
57
60
|
|
|
58
61
|
def agentless?(site, api_key)
|
|
59
|
-
site && api_key &&
|
|
62
|
+
site && api_key && %w[1 true].include?(ENV[Profiling::Ext::ENV_AGENTLESS] || '') # rubocop:disable CustomCops/EnvUsageCop
|
|
60
63
|
end
|
|
61
64
|
|
|
62
65
|
def config_without_api_key
|
|
@@ -1,17 +1,48 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative
|
|
4
|
-
require_relative
|
|
3
|
+
require_relative '../core/tag_builder'
|
|
4
|
+
require_relative '../core/utils'
|
|
5
|
+
|
|
6
|
+
require 'set'
|
|
5
7
|
|
|
6
8
|
module Datadog
|
|
7
9
|
module Profiling
|
|
8
10
|
# Builds a hash of default plus user tags to be included in a profile
|
|
11
|
+
#
|
|
12
|
+
# @api private
|
|
9
13
|
module TagBuilder
|
|
10
14
|
include Datadog::Profiling::Ext::Transport::HTTP # Tag name constants
|
|
11
15
|
|
|
16
|
+
# When changing or adding profiling-related tags, make sure they are
|
|
17
|
+
# kept in sync with
|
|
18
|
+
# https://docs.google.com/spreadsheets/d/1LOGMf4c4Avbtn36uZ2SWvhIGKRPLM1BoWkUP4JYj7hA/
|
|
19
|
+
# (Datadog internal link).
|
|
20
|
+
#
|
|
21
|
+
# For consistency between the different profilers, every tag should be
|
|
22
|
+
# vetted before it gets reported with a profile, as otherwise it's too
|
|
23
|
+
# easy to end up with different tags in different languages.
|
|
24
|
+
ALLOWED_TAGS = Set.new(
|
|
25
|
+
[
|
|
26
|
+
'env',
|
|
27
|
+
'service',
|
|
28
|
+
'version',
|
|
29
|
+
'git.commit.sha',
|
|
30
|
+
'git.repository_url',
|
|
31
|
+
'host',
|
|
32
|
+
'language',
|
|
33
|
+
'runtime',
|
|
34
|
+
'runtime_engine',
|
|
35
|
+
'runtime_platform',
|
|
36
|
+
'runtime_version',
|
|
37
|
+
'runtime-id',
|
|
38
|
+
'process_id',
|
|
39
|
+
'profiler_version',
|
|
40
|
+
'profile_seq',
|
|
41
|
+
]
|
|
42
|
+
).freeze
|
|
43
|
+
|
|
12
44
|
def self.call(
|
|
13
45
|
settings:,
|
|
14
|
-
# Other metadata
|
|
15
46
|
profile_seq:,
|
|
16
47
|
profiler_version: Core::Environment::Identity.gem_datadog_version
|
|
17
48
|
)
|
|
@@ -19,6 +50,8 @@ module Datadog
|
|
|
19
50
|
FORM_FIELD_TAG_PROFILER_VERSION => profiler_version,
|
|
20
51
|
'profile_seq' => profile_seq.to_s,
|
|
21
52
|
)
|
|
53
|
+
user_tag_keys = settings.tags.keys
|
|
54
|
+
hash.keep_if { |tag| user_tag_keys.include?(tag) || ALLOWED_TAGS.include?(tag) }
|
|
22
55
|
Core::Utils.encode_tags(hash)
|
|
23
56
|
end
|
|
24
57
|
end
|
|
@@ -25,9 +25,9 @@ module Datadog
|
|
|
25
25
|
private
|
|
26
26
|
|
|
27
27
|
def set_rubyopt!
|
|
28
|
-
existing_rubyopt = ENV["RUBYOPT"]
|
|
28
|
+
existing_rubyopt = ENV["RUBYOPT"] # rubocop:disable CustomCops/EnvUsageCop
|
|
29
29
|
|
|
30
|
-
ENV["RUBYOPT"] = existing_rubyopt ? "#{existing_rubyopt} #{rubyopts.join(" ")}" : rubyopts.join(" ")
|
|
30
|
+
ENV["RUBYOPT"] = existing_rubyopt ? "#{existing_rubyopt} #{rubyopts.join(" ")}" : rubyopts.join(" ") # rubocop:disable CustomCops/EnvUsageCop
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
# If there's an error here, rather than throwing a cryptic stack trace, let's instead have clearer messages, and
|
data/lib/datadog/profiling.rb
CHANGED
|
@@ -62,8 +62,7 @@ module Datadog
|
|
|
62
62
|
|
|
63
63
|
def self.enabled?
|
|
64
64
|
profiler = Datadog.send(:components).profiler
|
|
65
|
-
|
|
66
|
-
!!profiler&.send(:scheduler)&.running?
|
|
65
|
+
!!profiler&.enabled?
|
|
67
66
|
end
|
|
68
67
|
|
|
69
68
|
def self.wait_until_running(timeout_seconds: 5)
|
|
@@ -15,7 +15,7 @@ end
|
|
|
15
15
|
|
|
16
16
|
begin
|
|
17
17
|
require_relative 'auto_instrument'
|
|
18
|
-
Datadog::SingleStepInstrument
|
|
18
|
+
Datadog::SingleStepInstrument.const_set(:LOADED, true)
|
|
19
19
|
rescue StandardError, LoadError => e
|
|
20
20
|
warn "Single step instrumentation failed: #{e.class}:#{e.message}\n\tSource:\n\t#{Array(e.backtrace).join("\n\t")}"
|
|
21
21
|
end
|
|
@@ -12,16 +12,7 @@ module Datadog
|
|
|
12
12
|
module Tracing
|
|
13
13
|
# Tracing component
|
|
14
14
|
module Component
|
|
15
|
-
|
|
16
|
-
module InstanceMethods
|
|
17
|
-
# Hot-swaps with a new sampler.
|
|
18
|
-
# This operation acquires the Components lock to ensure
|
|
19
|
-
# there is no concurrent modification of the sampler.
|
|
20
|
-
def reconfigure_live_sampler
|
|
21
|
-
sampler = self.class.build_sampler(Datadog.configuration)
|
|
22
|
-
Datadog.send(:safely_synchronize) { tracer.sampler.sampler = sampler }
|
|
23
|
-
end
|
|
24
|
-
end
|
|
15
|
+
module_function
|
|
25
16
|
|
|
26
17
|
def build_tracer(settings, agent_settings, logger:)
|
|
27
18
|
# If a custom tracer has been provided, use it instead.
|
|
@@ -156,11 +147,6 @@ module Datadog
|
|
|
156
147
|
Tracing::Sampling::Span::Sampler.new(rules || [])
|
|
157
148
|
end
|
|
158
149
|
|
|
159
|
-
# Configure non-privileged components.
|
|
160
|
-
def configure_tracing(settings)
|
|
161
|
-
Datadog::Tracing::Contrib::Component.configure(settings)
|
|
162
|
-
end
|
|
163
|
-
|
|
164
150
|
# Sampler wrapper component, to allow for hot-swapping
|
|
165
151
|
# the sampler instance used by the tracer.
|
|
166
152
|
# Swapping samplers happens during Dynamic Configuration.
|
|
@@ -182,8 +168,7 @@ module Datadog
|
|
|
182
168
|
end
|
|
183
169
|
end
|
|
184
170
|
|
|
185
|
-
private
|
|
186
|
-
|
|
171
|
+
# @api private
|
|
187
172
|
def build_tracer_tags(settings)
|
|
188
173
|
settings.tags.dup.tap do |tags|
|
|
189
174
|
tags[Core::Environment::Ext::TAG_ENV] = settings.env unless settings.env.nil?
|
|
@@ -193,6 +178,7 @@ module Datadog
|
|
|
193
178
|
|
|
194
179
|
# Build a post-sampler that limits the rate of traces to one per `seconds`.
|
|
195
180
|
# E.g.: `build_rate_limit_post_sampler(seconds: 60)` will limit the rate to one trace per minute.
|
|
181
|
+
# @api private
|
|
196
182
|
def build_rate_limit_post_sampler(seconds:)
|
|
197
183
|
Tracing::Sampling::RuleSampler.new(
|
|
198
184
|
rate_limiter: Datadog::Core::TokenBucket.new(1.0 / seconds, 1.0),
|
|
@@ -200,11 +186,13 @@ module Datadog
|
|
|
200
186
|
)
|
|
201
187
|
end
|
|
202
188
|
|
|
189
|
+
# @api private
|
|
203
190
|
def build_test_mode_trace_flush(settings)
|
|
204
191
|
# If context flush behavior is provided, use it instead.
|
|
205
192
|
settings.tracing.test_mode.trace_flush || build_trace_flush(settings)
|
|
206
193
|
end
|
|
207
194
|
|
|
195
|
+
# @api private
|
|
208
196
|
def build_test_mode_sampler
|
|
209
197
|
# Do not sample any spans for tests; all must be preserved.
|
|
210
198
|
# Set priority sampler to ensure the agent doesn't drop any traces.
|
|
@@ -214,6 +202,7 @@ module Datadog
|
|
|
214
202
|
)
|
|
215
203
|
end
|
|
216
204
|
|
|
205
|
+
# @api private
|
|
217
206
|
def build_test_mode_writer(settings, agent_settings)
|
|
218
207
|
writer_options = settings.tracing.test_mode.writer_options || {}
|
|
219
208
|
|
|
@@ -41,7 +41,7 @@ module Datadog
|
|
|
41
41
|
# Ensures sampler is rebuilt and new configuration is applied
|
|
42
42
|
def call(tracing_sampling_rate)
|
|
43
43
|
super
|
|
44
|
-
Datadog.send(:components).
|
|
44
|
+
Datadog.send(:components).reconfigure_sampler
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
protected
|
|
@@ -79,7 +79,7 @@ module Datadog
|
|
|
79
79
|
end
|
|
80
80
|
|
|
81
81
|
super
|
|
82
|
-
Datadog.send(:components).
|
|
82
|
+
Datadog.send(:components).reconfigure_sampler
|
|
83
83
|
end
|
|
84
84
|
|
|
85
85
|
protected
|
|
@@ -9,11 +9,13 @@ module Datadog
|
|
|
9
9
|
# e.g. Env vars, default values, enums, etc...
|
|
10
10
|
module Ext
|
|
11
11
|
ENV_ENABLED = 'DD_TRACE_ENABLED'
|
|
12
|
-
ENV_OTEL_TRACES_EXPORTER = 'OTEL_TRACES_EXPORTER'
|
|
13
12
|
ENV_HEADER_TAGS = 'DD_TRACE_HEADER_TAGS'
|
|
14
13
|
ENV_BAGGAGE_TAG_KEYS = 'DD_TRACE_BAGGAGE_TAG_KEYS'
|
|
15
14
|
ENV_TRACE_ID_128_BIT_GENERATION_ENABLED = 'DD_TRACE_128_BIT_TRACEID_GENERATION_ENABLED'
|
|
16
15
|
ENV_NATIVE_SPAN_EVENTS = 'DD_TRACE_NATIVE_SPAN_EVENTS'
|
|
16
|
+
ENV_RESOURCE_RENAMING_ENABLED = 'DD_TRACE_RESOURCE_RENAMING_ENABLED'
|
|
17
|
+
ENV_RESOURCE_RENAMING_ALWAYS_SIMPLIFIED_ENDPOINT = 'DD_TRACE_RESOURCE_RENAMING_ALWAYS_SIMPLIFIED_ENDPOINT'
|
|
18
|
+
ENV_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED = 'DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED'
|
|
17
19
|
|
|
18
20
|
# @public_api
|
|
19
21
|
module SpanAttributeSchema
|
|
@@ -55,7 +57,6 @@ module Datadog
|
|
|
55
57
|
# Has lower precedence than `DD_TRACE_PROPAGATION_STYLE_INJECT` or
|
|
56
58
|
# `DD_TRACE_PROPAGATION_STYLE_EXTRACT`.
|
|
57
59
|
ENV_PROPAGATION_STYLE = 'DD_TRACE_PROPAGATION_STYLE'
|
|
58
|
-
ENV_OTEL_PROPAGATION_STYLE = 'OTEL_PROPAGATORS'
|
|
59
60
|
|
|
60
61
|
ENV_PROPAGATION_STYLE_INJECT = 'DD_TRACE_PROPAGATION_STYLE_INJECT'
|
|
61
62
|
|
|
@@ -81,7 +82,6 @@ module Datadog
|
|
|
81
82
|
ENV_SAMPLE_RATE = 'DD_TRACE_SAMPLE_RATE'
|
|
82
83
|
ENV_RATE_LIMIT = 'DD_TRACE_RATE_LIMIT'
|
|
83
84
|
ENV_RULES = 'DD_TRACE_SAMPLING_RULES'
|
|
84
|
-
ENV_OTEL_TRACES_SAMPLER = 'OTEL_TRACES_SAMPLER'
|
|
85
85
|
OTEL_TRACES_SAMPLER_ARG = 'OTEL_TRACES_SAMPLER_ARG'
|
|
86
86
|
|
|
87
87
|
# @public_api
|
|
@@ -107,6 +107,12 @@ module Datadog
|
|
|
107
107
|
ENV_ENABLED = 'DD_TRACE_CLIENT_IP_ENABLED'
|
|
108
108
|
ENV_HEADER_NAME = 'DD_TRACE_CLIENT_IP_HEADER'
|
|
109
109
|
end
|
|
110
|
+
|
|
111
|
+
# @public_api
|
|
112
|
+
module HTTPErrorStatuses
|
|
113
|
+
ENV_SERVER_ERROR_STATUSES = 'DD_TRACE_HTTP_SERVER_ERROR_STATUSES'
|
|
114
|
+
ENV_CLIENT_ERROR_STATUSES = 'DD_TRACE_HTTP_CLIENT_ERROR_STATUSES'
|
|
115
|
+
end
|
|
110
116
|
end
|
|
111
117
|
end
|
|
112
118
|
end
|