datadog 2.47.0 → 2.49.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 +76 -1
- data/LICENSE-3rdparty.csv +1 -0
- data/ext/datadog_profiling_native_extension/collectors_stack.c +142 -102
- data/ext/datadog_profiling_native_extension/collectors_stack.h +13 -3
- data/ext/datadog_profiling_native_extension/collectors_thread_context.c +6 -1
- data/ext/datadog_profiling_native_extension/extconf.rb +10 -13
- data/ext/datadog_profiling_native_extension/native_extension_helpers.rb +3 -3
- data/ext/datadog_profiling_native_extension/private_vm_api_access.c +79 -34
- data/ext/datadog_profiling_native_extension/private_vm_api_access.h +5 -1
- data/ext/datadog_profiling_native_extension/profiling.c +1 -1
- data/ext/libdatadog_api/extconf.rb +11 -7
- data/ext/libdatadog_api/feature_flags.c +137 -0
- data/ext/libdatadog_api/process_discovery.c +3 -3
- data/ext/libdatadog_api/trace_exporter.c +34 -7
- data/ext/libdatadog_extconf_helpers.rb +2 -2
- data/lib/datadog/ai_guard/component.rb +1 -1
- data/lib/datadog/ai_guard/contrib/rack/patcher.rb +3 -5
- data/lib/datadog/ai_guard/contrib/rack/request_middleware.rb +1 -9
- data/lib/datadog/ai_guard/contrib/rails/patcher.rb +8 -10
- data/lib/datadog/ai_guard/contrib/ruby_llm/message_adapter.rb +1 -1
- data/lib/datadog/ai_guard/contrib/ruby_llm/patcher.rb +3 -5
- data/lib/datadog/ai_guard/contrib/ruby_llm/redaction_change_set.rb +3 -3
- data/lib/datadog/ai_guard/evaluation/client.rb +3 -3
- data/lib/datadog/ai_guard/evaluation.rb +2 -2
- data/lib/datadog/ai_guard/http_client.rb +3 -2
- data/lib/datadog/ai_guard/metrics/telemetry.rb +2 -4
- data/lib/datadog/ai_guard/redaction.rb +1 -1
- data/lib/datadog/appsec/actions_handler.rb +5 -7
- data/lib/datadog/appsec/api_security/endpoint_collection/grape_route_serializer.rb +1 -3
- data/lib/datadog/appsec/api_security/endpoint_collection/rails_collector.rb +1 -1
- data/lib/datadog/appsec/api_security/endpoint_collection/rails_route_serializer.rb +1 -3
- data/lib/datadog/appsec/api_security/endpoint_collection/sinatra_route_serializer.rb +1 -3
- data/lib/datadog/appsec/assets/waf_rules/README.md +3 -3
- data/lib/datadog/appsec/assets/waf_rules/recommended.json +5366 -1517
- data/lib/datadog/appsec/assets/waf_rules/strict.json +2 -2
- data/lib/datadog/appsec/assets.rb +8 -10
- data/lib/datadog/appsec/autoload.rb +1 -1
- data/lib/datadog/appsec/component.rb +1 -1
- data/lib/datadog/appsec/compressed_json.rb +1 -1
- data/lib/datadog/appsec/configuration.rb +4 -4
- data/lib/datadog/appsec/context.rb +64 -7
- data/lib/datadog/appsec/contrib/active_record/instrumentation.rb +12 -4
- data/lib/datadog/appsec/contrib/active_record/patcher.rb +33 -28
- data/lib/datadog/appsec/contrib/aws_lambda/gateway/watcher.rb +2 -2
- data/lib/datadog/appsec/contrib/aws_lambda/patcher.rb +3 -5
- data/lib/datadog/appsec/contrib/aws_lambda/waf_addresses.rb +10 -12
- data/lib/datadog/appsec/contrib/devise/configuration.rb +3 -5
- data/lib/datadog/appsec/contrib/devise/patcher.rb +3 -5
- data/lib/datadog/appsec/contrib/devise/patches/signin_tracking_patch.rb +1 -1
- data/lib/datadog/appsec/contrib/devise/patches/signup_tracking_patch.rb +1 -1
- data/lib/datadog/appsec/contrib/devise/tracking_middleware.rb +1 -1
- data/lib/datadog/appsec/contrib/excon/patcher.rb +3 -5
- data/lib/datadog/appsec/contrib/excon/ssrf_detection_middleware.rb +1 -1
- data/lib/datadog/appsec/contrib/faraday/patcher.rb +4 -6
- data/lib/datadog/appsec/contrib/faraday/ssrf_detection_middleware.rb +1 -1
- data/lib/datadog/appsec/contrib/graphql/gateway/multiplex.rb +7 -7
- data/lib/datadog/appsec/contrib/graphql/gateway/watcher.rb +1 -1
- data/lib/datadog/appsec/contrib/graphql/patcher.rb +3 -5
- data/lib/datadog/appsec/contrib/rack/gateway/watcher.rb +3 -3
- data/lib/datadog/appsec/contrib/rack/input_peeker.rb +3 -5
- data/lib/datadog/appsec/contrib/rack/patcher.rb +3 -5
- data/lib/datadog/appsec/contrib/rack/request_body_middleware.rb +5 -4
- data/lib/datadog/appsec/contrib/rack/request_middleware.rb +11 -12
- data/lib/datadog/appsec/contrib/rails/gateway/watcher.rb +2 -2
- data/lib/datadog/appsec/contrib/rails/patcher.rb +21 -18
- data/lib/datadog/appsec/contrib/rails/patches/live_thread_patch.rb +33 -0
- data/lib/datadog/appsec/contrib/rest_client/patcher.rb +3 -5
- data/lib/datadog/appsec/contrib/rest_client/request_ssrf_detection_patch.rb +1 -1
- data/lib/datadog/appsec/contrib/sinatra/gateway/watcher.rb +3 -3
- data/lib/datadog/appsec/contrib/sinatra/patcher.rb +5 -7
- data/lib/datadog/appsec/default_header_tags.rb +2 -4
- data/lib/datadog/appsec/metrics/collector.rb +5 -5
- data/lib/datadog/appsec/metrics/exporter.rb +4 -6
- data/lib/datadog/appsec/metrics/telemetry.rb +1 -3
- data/lib/datadog/appsec/metrics/telemetry_exporter.rb +5 -7
- data/lib/datadog/appsec/monitor/gateway/watcher.rb +2 -2
- data/lib/datadog/appsec/processor/rule_loader.rb +1 -1
- data/lib/datadog/appsec/response.rb +1 -1
- data/lib/datadog/appsec/route_normalizer/route_text.rb +1 -3
- data/lib/datadog/appsec/route_normalizer.rb +4 -6
- data/lib/datadog/appsec/security_engine/engine.rb +6 -6
- data/lib/datadog/appsec/security_engine/runner.rb +2 -2
- data/lib/datadog/appsec/trace_keeper.rb +1 -1
- data/lib/datadog/appsec/utils/http/body_reader.rb +3 -5
- data/lib/datadog/appsec/utils/http/url_encoded.rb +2 -4
- data/lib/datadog/appsec.rb +1 -1
- data/lib/datadog/core/borrowing_token_bucket.rb +60 -0
- data/lib/datadog/core/chunker.rb +1 -3
- data/lib/datadog/core/configuration/agent_settings_resolver.rb +14 -13
- data/lib/datadog/core/configuration/agentless_settings_resolver.rb +2 -2
- data/lib/datadog/core/configuration/components.rb +49 -18
- data/lib/datadog/core/configuration/settings.rb +7 -3
- data/lib/datadog/core/configuration/supported_configurations.rb +3 -0
- data/lib/datadog/core/configuration.rb +2 -2
- data/lib/datadog/core/crashtracking/component.rb +1 -1
- data/lib/datadog/core/diagnostics/environment_logger.rb +2 -7
- data/lib/datadog/core/encoding.rb +8 -12
- data/lib/datadog/core/environment/cgroup.rb +5 -7
- data/lib/datadog/core/environment/container.rb +12 -14
- data/lib/datadog/core/environment/ext.rb +1 -6
- data/lib/datadog/core/environment/gc.rb +2 -4
- data/lib/datadog/core/environment/identity.rb +13 -15
- data/lib/datadog/core/environment/platform.rb +10 -12
- data/lib/datadog/core/environment/socket.rb +3 -5
- data/lib/datadog/core/environment/thread_count.rb +2 -4
- data/lib/datadog/core/environment/variable_helpers.rb +2 -6
- data/lib/datadog/core/environment/vm_cache.rb +5 -7
- data/lib/datadog/core/environment/yjit.rb +25 -24
- data/lib/datadog/core/logger.rb +5 -2
- data/lib/datadog/core/metrics/client.rb +13 -21
- data/lib/datadog/core/metrics/helpers.rb +3 -0
- data/lib/datadog/core/metrics/metric.rb +3 -1
- data/lib/datadog/core/process_discovery.rb +1 -1
- data/lib/datadog/core/rate_limiter.rb +9 -31
- data/lib/datadog/core/refillable_bucket.rb +72 -0
- data/lib/datadog/core/remote/client/capabilities.rb +4 -0
- data/lib/datadog/core/remote/client.rb +1 -5
- data/lib/datadog/core/remote/tie/tracing.rb +4 -3
- data/lib/datadog/core/remote/transport/http.rb +4 -6
- data/lib/datadog/core/runtime/metrics.rb +14 -14
- data/lib/datadog/core/semaphore.rb +3 -1
- data/lib/datadog/core/tag_normalizer.rb +0 -2
- data/lib/datadog/core/telemetry/configuration_value.rb +1 -3
- data/lib/datadog/core/telemetry/event/app_started.rb +9 -9
- data/lib/datadog/core/telemetry/logger.rb +1 -1
- data/lib/datadog/core/telemetry/logging.rb +1 -1
- data/lib/datadog/core/telemetry/request.rb +9 -3
- data/lib/datadog/core/telemetry/transport/http.rb +4 -6
- data/lib/datadog/core/telemetry/worker.rb +30 -24
- data/lib/datadog/core/transport/http/adapters/net.rb +1 -1
- data/lib/datadog/core/transport/http/adapters/unix_socket.rb +1 -1
- data/lib/datadog/core/transport/http/builder.rb +1 -1
- data/lib/datadog/core/transport/http.rb +5 -7
- data/lib/datadog/core/utils/at_fork_monkey_patch.rb +4 -4
- data/lib/datadog/core/utils/forking.rb +1 -1
- data/lib/datadog/core/utils/lru_cache.rb +2 -2
- data/lib/datadog/core/utils/network.rb +1 -1
- data/lib/datadog/core/utils/time.rb +2 -2
- data/lib/datadog/core/utils/truncation.rb +1 -3
- data/lib/datadog/core/workers/async.rb +17 -15
- data/lib/datadog/core/workers/runtime_metrics.rb +2 -2
- data/lib/datadog/data_streams/pathway_context.rb +1 -1
- data/lib/datadog/data_streams/processor.rb +48 -27
- data/lib/datadog/data_streams/transport/http.rb +2 -4
- data/lib/datadog/data_streams.rb +16 -0
- data/lib/datadog/di/capture_expression_evaluator.rb +48 -11
- data/lib/datadog/di/component.rb +17 -4
- data/lib/datadog/di/configuration.rb +19 -0
- data/lib/datadog/di/context.rb +50 -0
- data/lib/datadog/di/contrib/active_record.rb +1 -1
- data/lib/datadog/di/contrib.rb +2 -2
- data/lib/datadog/di/correlation_sampler/trace_budget.rb +75 -0
- data/lib/datadog/di/correlation_sampler/trace_budget_ledger/entry.rb +34 -0
- data/lib/datadog/di/correlation_sampler/trace_budget_ledger.rb +104 -0
- data/lib/datadog/di/correlation_sampler.rb +224 -0
- data/lib/datadog/di/el/compiler.rb +4 -4
- data/lib/datadog/di/el/evaluator.rb +247 -43
- data/lib/datadog/di/el/expression.rb +36 -6
- data/lib/datadog/di/error.rb +16 -0
- data/lib/datadog/di/guardrails_telemetry/reason.rb +11 -5
- data/lib/datadog/di/instrumenter.rb +325 -111
- data/lib/datadog/di/probe.rb +13 -2
- data/lib/datadog/di/probe_builder.rb +6 -8
- data/lib/datadog/di/probe_file_loader.rb +2 -2
- data/lib/datadog/di/probe_manager.rb +7 -30
- data/lib/datadog/di/probe_notification_builder.rb +100 -21
- data/lib/datadog/di/probe_notifier_worker.rb +12 -1
- data/lib/datadog/di/serializer.rb +20 -2
- data/lib/datadog/di/snapshot_pruner/node.rb +190 -0
- data/lib/datadog/di/snapshot_pruner/node_queue.rb +104 -0
- data/lib/datadog/di/snapshot_pruner/parser.rb +102 -0
- data/lib/datadog/di/snapshot_pruner.rb +128 -0
- data/lib/datadog/di/transport/input.rb +75 -15
- data/lib/datadog/di/utils.rb +3 -3
- data/lib/datadog/di.rb +56 -0
- data/lib/datadog/error_tracking/component.rb +1 -1
- data/lib/datadog/error_tracking/configuration.rb +1 -1
- data/lib/datadog/error_tracking/filters.rb +6 -8
- data/lib/datadog/kit/appsec/events/v2.rb +6 -6
- data/lib/datadog/kit/appsec/events.rb +1 -1
- data/lib/datadog/kit/enable_core_dumps.rb +1 -1
- data/lib/datadog/kit/identity.rb +1 -1
- data/lib/datadog/open_feature/activation.rb +26 -1
- data/lib/datadog/open_feature/agentless/configuration_source.rb +94 -15
- data/lib/datadog/open_feature/agentless/parser.rb +2 -4
- data/lib/datadog/open_feature/component.rb +46 -4
- data/lib/datadog/open_feature/configuration/agentless_endpoint.rb +6 -0
- data/lib/datadog/open_feature/configuration.rb +17 -4
- data/lib/datadog/open_feature/evaluation_engine.rb +67 -9
- data/lib/datadog/open_feature/exposure_hook.rb +146 -0
- data/lib/datadog/open_feature/exposures/buffer.rb +4 -0
- data/lib/datadog/open_feature/exposures/event.rb +10 -8
- data/lib/datadog/open_feature/exposures/reporter.rb +40 -18
- data/lib/datadog/open_feature/exposures/worker.rb +37 -6
- data/lib/datadog/open_feature/ext.rb +12 -0
- data/lib/datadog/open_feature/flag_evaluation/aggregator.rb +13 -11
- data/lib/datadog/open_feature/flag_evaluation/writer.rb +10 -7
- data/lib/datadog/open_feature/hooks/debug_logging_hook.rb +56 -0
- data/lib/datadog/open_feature/hooks/exposure_logging_hook.rb +58 -0
- data/lib/datadog/open_feature/hooks/flag_eval_evp_hook.rb +4 -2
- data/lib/datadog/open_feature/hooks/flag_eval_metrics_hook.rb +3 -5
- data/lib/datadog/open_feature/hooks/span_enrichment_hook/codec.rb +3 -5
- data/lib/datadog/open_feature/hooks/span_enrichment_hook.rb +2 -2
- data/lib/datadog/open_feature/metrics/flag_eval_metrics.rb +1 -1
- data/lib/datadog/open_feature/native_evaluator.rb +31 -3
- data/lib/datadog/open_feature/noop_evaluator.rb +4 -2
- data/lib/datadog/open_feature/provider.rb +103 -15
- data/lib/datadog/open_feature/remote.rb +8 -1
- data/lib/datadog/open_feature/resolution_details.rb +3 -2
- data/lib/datadog/open_feature/split_features.rb +76 -0
- data/lib/datadog/open_feature/transport.rb +6 -6
- data/lib/datadog/opentelemetry/api/context.rb +3 -3
- data/lib/datadog/opentelemetry/logs.rb +5 -5
- data/lib/datadog/opentelemetry/metrics.rb +3 -3
- data/lib/datadog/opentelemetry/sdk/propagator.rb +8 -5
- data/lib/datadog/opentelemetry/sdk/span_processor.rb +2 -2
- data/lib/datadog/opentelemetry/sdk/trace/span.rb +1 -1
- data/lib/datadog/profiling/collectors/code_provenance.rb +3 -3
- data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +32 -35
- data/lib/datadog/profiling/collectors/idle_sampling_helper.rb +1 -1
- data/lib/datadog/profiling/collectors/thread_context.rb +1 -1
- data/lib/datadog/profiling/component.rb +50 -28
- data/lib/datadog/profiling/exporter.rb +1 -1
- data/lib/datadog/profiling/http_transport.rb +3 -3
- data/lib/datadog/profiling/profiler.rb +8 -2
- data/lib/datadog/profiling/remote.rb +381 -0
- data/lib/datadog/profiling/scheduler.rb +2 -2
- data/lib/datadog/profiling/tag_builder.rb +1 -1
- data/lib/datadog/profiling/worker_state.rb +65 -0
- data/lib/datadog/profiling.rb +1 -0
- data/lib/datadog/symbol_database/extractor.rb +8 -8
- data/lib/datadog/symbol_database/file_hash.rb +1 -3
- data/lib/datadog/symbol_database/uploader.rb +1 -1
- data/lib/datadog/tracing/buffer.rb +3 -3
- data/lib/datadog/tracing/client_ip.rb +1 -1
- data/lib/datadog/tracing/component.rb +22 -24
- data/lib/datadog/tracing/configuration/dynamic/option.rb +2 -2
- data/lib/datadog/tracing/configuration/settings.rb +5 -5
- data/lib/datadog/tracing/context.rb +1 -1
- data/lib/datadog/tracing/contrib/action_cable/events/broadcast.rb +4 -6
- data/lib/datadog/tracing/contrib/action_cable/events/perform_action.rb +4 -6
- data/lib/datadog/tracing/contrib/action_cable/events/transmit.rb +4 -6
- data/lib/datadog/tracing/contrib/action_cable/events.rb +3 -5
- data/lib/datadog/tracing/contrib/action_cable/instrumentation.rb +2 -2
- data/lib/datadog/tracing/contrib/action_cable/patcher.rb +2 -4
- data/lib/datadog/tracing/contrib/action_mailer/events/deliver.rb +5 -7
- data/lib/datadog/tracing/contrib/action_mailer/events/process.rb +4 -6
- data/lib/datadog/tracing/contrib/action_mailer/events.rb +3 -5
- data/lib/datadog/tracing/contrib/action_mailer/patcher.rb +2 -4
- data/lib/datadog/tracing/contrib/action_pack/action_controller/instrumentation.rb +2 -4
- data/lib/datadog/tracing/contrib/action_pack/action_controller/patcher.rb +2 -4
- data/lib/datadog/tracing/contrib/action_pack/action_dispatch/instrumentation.rb +2 -4
- data/lib/datadog/tracing/contrib/action_pack/action_dispatch/patcher.rb +2 -4
- data/lib/datadog/tracing/contrib/action_pack/patcher.rb +2 -4
- data/lib/datadog/tracing/contrib/action_view/events/render_partial.rb +3 -5
- data/lib/datadog/tracing/contrib/action_view/events/render_template.rb +3 -5
- data/lib/datadog/tracing/contrib/action_view/events.rb +3 -5
- data/lib/datadog/tracing/contrib/action_view/patcher.rb +3 -5
- data/lib/datadog/tracing/contrib/action_view/utils.rb +1 -3
- data/lib/datadog/tracing/contrib/active_job/data_streams.rb +27 -2
- data/lib/datadog/tracing/contrib/active_job/events/discard.rb +3 -5
- data/lib/datadog/tracing/contrib/active_job/events/enqueue.rb +3 -5
- data/lib/datadog/tracing/contrib/active_job/events/enqueue_at.rb +3 -5
- data/lib/datadog/tracing/contrib/active_job/events/enqueue_retry.rb +3 -5
- data/lib/datadog/tracing/contrib/active_job/events/perform.rb +3 -5
- data/lib/datadog/tracing/contrib/active_job/events/retry_stopped.rb +3 -5
- data/lib/datadog/tracing/contrib/active_job/events.rb +3 -5
- data/lib/datadog/tracing/contrib/active_job/patcher.rb +4 -6
- data/lib/datadog/tracing/contrib/active_model_serializers/events/render.rb +4 -6
- data/lib/datadog/tracing/contrib/active_model_serializers/events/serialize.rb +4 -6
- data/lib/datadog/tracing/contrib/active_model_serializers/events.rb +3 -5
- data/lib/datadog/tracing/contrib/active_model_serializers/patcher.rb +3 -5
- data/lib/datadog/tracing/contrib/active_record/configuration/resolver.rb +2 -2
- data/lib/datadog/tracing/contrib/active_record/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/active_record/events/instantiation.rb +4 -6
- data/lib/datadog/tracing/contrib/active_record/events/sql.rb +3 -5
- data/lib/datadog/tracing/contrib/active_record/events.rb +3 -5
- data/lib/datadog/tracing/contrib/active_record/patcher.rb +2 -4
- data/lib/datadog/tracing/contrib/active_record/utils.rb +1 -1
- data/lib/datadog/tracing/contrib/active_support/cache/events/cache.rb +8 -10
- data/lib/datadog/tracing/contrib/active_support/cache/events.rb +3 -5
- data/lib/datadog/tracing/contrib/active_support/cache/instrumentation.rb +6 -8
- data/lib/datadog/tracing/contrib/active_support/cache/patcher.rb +4 -6
- data/lib/datadog/tracing/contrib/active_support/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/active_support/notifications/subscriber.rb +2 -2
- data/lib/datadog/tracing/contrib/active_support/notifications/subscription.rb +2 -2
- data/lib/datadog/tracing/contrib/active_support/patcher.rb +2 -4
- data/lib/datadog/tracing/contrib/analytics.rb +4 -6
- data/lib/datadog/tracing/contrib/aws/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/aws/instrumentation.rb +1 -1
- data/lib/datadog/tracing/contrib/aws/patcher.rb +5 -7
- data/lib/datadog/tracing/contrib/concurrent_ruby/patcher.rb +5 -7
- data/lib/datadog/tracing/contrib/configuration/settings.rb +17 -0
- data/lib/datadog/tracing/contrib/dalli/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/dalli/instrumentation.rb +1 -1
- data/lib/datadog/tracing/contrib/dalli/patcher.rb +2 -4
- data/lib/datadog/tracing/contrib/dalli/quantize.rb +1 -3
- data/lib/datadog/tracing/contrib/delayed_job/patcher.rb +4 -6
- data/lib/datadog/tracing/contrib/delayed_job/plugin.rb +2 -2
- data/lib/datadog/tracing/contrib/elasticsearch/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/elasticsearch/patcher.rb +6 -8
- data/lib/datadog/tracing/contrib/elasticsearch/quantize.rb +6 -8
- data/lib/datadog/tracing/contrib/ethon/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/ethon/easy_patch.rb +8 -8
- data/lib/datadog/tracing/contrib/ethon/multi_patch.rb +1 -1
- data/lib/datadog/tracing/contrib/ethon/patcher.rb +2 -4
- data/lib/datadog/tracing/contrib/excon/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/excon/middleware.rb +7 -7
- data/lib/datadog/tracing/contrib/excon/patcher.rb +3 -5
- data/lib/datadog/tracing/contrib/faraday/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/faraday/middleware.rb +5 -5
- data/lib/datadog/tracing/contrib/faraday/patcher.rb +4 -6
- data/lib/datadog/tracing/contrib/grape/endpoint.rb +4 -4
- data/lib/datadog/tracing/contrib/grape/patcher.rb +2 -4
- data/lib/datadog/tracing/contrib/graphql/patcher.rb +5 -7
- data/lib/datadog/tracing/contrib/graphql/trace_patcher.rb +1 -3
- data/lib/datadog/tracing/contrib/graphql/tracing_patcher.rb +1 -3
- data/lib/datadog/tracing/contrib/graphql/unified_trace.rb +3 -3
- data/lib/datadog/tracing/contrib/graphql/unified_trace_patcher.rb +1 -3
- data/lib/datadog/tracing/contrib/grpc/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/client.rb +2 -2
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/server.rb +1 -1
- data/lib/datadog/tracing/contrib/grpc/patcher.rb +3 -5
- data/lib/datadog/tracing/contrib/grpc.rb +1 -1
- data/lib/datadog/tracing/contrib/hanami/action_tracer.rb +1 -1
- data/lib/datadog/tracing/contrib/hanami/patcher.rb +2 -4
- data/lib/datadog/tracing/contrib/hanami/plugin.rb +1 -1
- data/lib/datadog/tracing/contrib/hanami/renderer_policy_tracing.rb +1 -1
- data/lib/datadog/tracing/contrib/hanami/router_tracing.rb +1 -1
- data/lib/datadog/tracing/contrib/http/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/http/instrumentation.rb +6 -6
- data/lib/datadog/tracing/contrib/http/patcher.rb +2 -4
- data/lib/datadog/tracing/contrib/http.rb +1 -1
- data/lib/datadog/tracing/contrib/httpclient/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/httpclient/instrumentation.rb +7 -7
- data/lib/datadog/tracing/contrib/httpclient/patcher.rb +2 -4
- data/lib/datadog/tracing/contrib/httprb/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/httprb/instrumentation.rb +5 -5
- data/lib/datadog/tracing/contrib/httprb/patcher.rb +2 -4
- data/lib/datadog/tracing/contrib/kafka/events/connection/request.rb +4 -6
- data/lib/datadog/tracing/contrib/kafka/events/consumer/process_batch.rb +3 -5
- data/lib/datadog/tracing/contrib/kafka/events/consumer/process_message.rb +3 -5
- data/lib/datadog/tracing/contrib/kafka/events/consumer_group/heartbeat.rb +3 -5
- data/lib/datadog/tracing/contrib/kafka/events/consumer_group/join_group.rb +2 -4
- data/lib/datadog/tracing/contrib/kafka/events/consumer_group/leave_group.rb +2 -4
- data/lib/datadog/tracing/contrib/kafka/events/consumer_group/sync_group.rb +2 -4
- data/lib/datadog/tracing/contrib/kafka/events/produce_operation/send_messages.rb +4 -6
- data/lib/datadog/tracing/contrib/kafka/events/producer/deliver_messages.rb +4 -6
- data/lib/datadog/tracing/contrib/kafka/events.rb +3 -5
- data/lib/datadog/tracing/contrib/kafka/instrumentation/consumer.rb +2 -2
- data/lib/datadog/tracing/contrib/kafka/instrumentation/producer.rb +2 -2
- data/lib/datadog/tracing/contrib/kafka/patcher.rb +4 -6
- data/lib/datadog/tracing/contrib/karafka/monitor.rb +1 -1
- data/lib/datadog/tracing/contrib/karafka/patcher.rb +3 -5
- data/lib/datadog/tracing/contrib/karafka.rb +1 -1
- data/lib/datadog/tracing/contrib/lograge/patcher.rb +3 -5
- data/lib/datadog/tracing/contrib/mongodb/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/mongodb/parsers.rb +6 -8
- data/lib/datadog/tracing/contrib/mongodb/patcher.rb +3 -5
- data/lib/datadog/tracing/contrib/mongodb/subscribers.rb +1 -1
- data/lib/datadog/tracing/contrib/mysql2/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/mysql2/instrumentation.rb +3 -3
- data/lib/datadog/tracing/contrib/mysql2/patcher.rb +3 -5
- data/lib/datadog/tracing/contrib/opensearch/configuration/settings.rb +2 -2
- data/lib/datadog/tracing/contrib/opensearch/patcher.rb +4 -6
- data/lib/datadog/tracing/contrib/opensearch/quantize.rb +5 -7
- data/lib/datadog/tracing/contrib/pg/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/pg/instrumentation.rb +4 -4
- data/lib/datadog/tracing/contrib/pg/patcher.rb +3 -5
- data/lib/datadog/tracing/contrib/presto/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/presto/instrumentation.rb +4 -4
- data/lib/datadog/tracing/contrib/presto/patcher.rb +1 -3
- data/lib/datadog/tracing/contrib/propagation/sql_comment.rb +1 -1
- data/lib/datadog/tracing/contrib/que/patcher.rb +2 -4
- data/lib/datadog/tracing/contrib/que/tracer.rb +1 -1
- data/lib/datadog/tracing/contrib/racecar/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/racecar/events/batch.rb +4 -6
- data/lib/datadog/tracing/contrib/racecar/events/consume.rb +3 -5
- data/lib/datadog/tracing/contrib/racecar/events/message.rb +4 -6
- data/lib/datadog/tracing/contrib/racecar/events.rb +3 -5
- data/lib/datadog/tracing/contrib/racecar/patcher.rb +2 -4
- data/lib/datadog/tracing/contrib/rack/middlewares.rb +3 -3
- data/lib/datadog/tracing/contrib/rack/patcher.rb +14 -20
- data/lib/datadog/tracing/contrib/rack/request_queue.rb +1 -3
- data/lib/datadog/tracing/contrib/rack/route_inference.rb +4 -6
- data/lib/datadog/tracing/contrib/rack/trace_proxy_middleware.rb +4 -6
- data/lib/datadog/tracing/contrib/rails/configuration/settings.rb +4 -0
- data/lib/datadog/tracing/contrib/rails/ext.rb +2 -0
- data/lib/datadog/tracing/contrib/rails/framework.rb +12 -14
- data/lib/datadog/tracing/contrib/rails/log_injection.rb +2 -4
- data/lib/datadog/tracing/contrib/rails/patcher.rb +9 -11
- data/lib/datadog/tracing/contrib/rails/runner.rb +4 -4
- data/lib/datadog/tracing/contrib/rake/patcher.rb +3 -5
- data/lib/datadog/tracing/contrib/redis/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/redis/patcher.rb +2 -4
- data/lib/datadog/tracing/contrib/redis/quantize.rb +8 -10
- data/lib/datadog/tracing/contrib/redis/tags.rb +1 -1
- data/lib/datadog/tracing/contrib/resque/patcher.rb +2 -4
- data/lib/datadog/tracing/contrib/rest_client/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/rest_client/patcher.rb +2 -4
- data/lib/datadog/tracing/contrib/rest_client/request_patch.rb +8 -8
- data/lib/datadog/tracing/contrib/roda/patcher.rb +2 -4
- data/lib/datadog/tracing/contrib/semantic_logger/patcher.rb +2 -4
- data/lib/datadog/tracing/contrib/sequel/database.rb +1 -1
- data/lib/datadog/tracing/contrib/sequel/dataset.rb +1 -1
- data/lib/datadog/tracing/contrib/sequel/patcher.rb +4 -6
- data/lib/datadog/tracing/contrib/shoryuken/patcher.rb +2 -4
- data/lib/datadog/tracing/contrib/shoryuken/tracer.rb +1 -1
- data/lib/datadog/tracing/contrib/sidekiq/client_tracer.rb +2 -2
- data/lib/datadog/tracing/contrib/sidekiq/patcher.rb +7 -9
- data/lib/datadog/tracing/contrib/sidekiq/server_tracer.rb +2 -2
- data/lib/datadog/tracing/contrib/sidekiq.rb +1 -1
- data/lib/datadog/tracing/contrib/sinatra/env.rb +3 -5
- data/lib/datadog/tracing/contrib/sinatra/patcher.rb +5 -7
- data/lib/datadog/tracing/contrib/sinatra/tracer_middleware.rb +1 -1
- data/lib/datadog/tracing/contrib/sneakers/patcher.rb +2 -4
- data/lib/datadog/tracing/contrib/status_range_env_parser.rb +1 -1
- data/lib/datadog/tracing/contrib/stripe/patcher.rb +2 -4
- data/lib/datadog/tracing/contrib/stripe/request.rb +4 -6
- data/lib/datadog/tracing/contrib/sucker_punch/exception_handler.rb +1 -3
- data/lib/datadog/tracing/contrib/sucker_punch/instrumentation.rb +2 -4
- data/lib/datadog/tracing/contrib/sucker_punch/patcher.rb +3 -5
- data/lib/datadog/tracing/contrib/support.rb +1 -3
- data/lib/datadog/tracing/contrib/trilogy/configuration/settings.rb +5 -1
- data/lib/datadog/tracing/contrib/trilogy/instrumentation.rb +5 -4
- data/lib/datadog/tracing/contrib/trilogy/patcher.rb +3 -5
- data/lib/datadog/tracing/contrib/utils/database.rb +1 -3
- data/lib/datadog/tracing/contrib/utils/quantization/hash_formatter.rb +8 -10
- data/lib/datadog/tracing/contrib/utils/quantization/http.rb +11 -13
- data/lib/datadog/tracing/contrib/waterdrop/middleware.rb +2 -2
- data/lib/datadog/tracing/contrib/waterdrop/patcher.rb +3 -5
- data/lib/datadog/tracing/contrib/waterdrop.rb +1 -1
- data/lib/datadog/tracing/correlation.rb +3 -5
- data/lib/datadog/tracing/diagnostics/environment_logger.rb +1 -1
- data/lib/datadog/tracing/distributed/b3_multi.rb +1 -1
- data/lib/datadog/tracing/distributed/b3_single.rb +1 -1
- data/lib/datadog/tracing/distributed/baggage.rb +3 -3
- data/lib/datadog/tracing/distributed/datadog.rb +3 -3
- data/lib/datadog/tracing/distributed/propagation.rb +9 -9
- data/lib/datadog/tracing/distributed/propagation_policy.rb +1 -3
- data/lib/datadog/tracing/distributed/trace_context.rb +1 -1
- data/lib/datadog/tracing/distributed/trace_state/datadog.rb +5 -5
- data/lib/datadog/tracing/distributed/trace_state/open_telemetry.rb +3 -3
- data/lib/datadog/tracing/metadata/ext.rb +3 -9
- data/lib/datadog/tracing/otel_thread_context.rb +3 -3
- data/lib/datadog/tracing/pipeline.rb +1 -1
- data/lib/datadog/tracing/remote.rb +1 -1
- data/lib/datadog/tracing/sampling/priority_sampler.rb +1 -1
- data/lib/datadog/tracing/sampling/rule.rb +1 -1
- data/lib/datadog/tracing/sampling/rule_sampler.rb +1 -1
- data/lib/datadog/tracing/sampling/span/rule_parser.rb +2 -2
- data/lib/datadog/tracing/span_operation.rb +1 -1
- data/lib/datadog/tracing/trace_digest.rb +1 -1
- data/lib/datadog/tracing/trace_operation.rb +17 -9
- data/lib/datadog/tracing/tracer.rb +15 -7
- data/lib/datadog/tracing/transport/http/telemetry.rb +1 -1
- data/lib/datadog/tracing/transport/http.rb +3 -5
- data/lib/datadog/tracing/transport/io.rb +3 -5
- data/lib/datadog/tracing/transport/native.rb +3 -3
- data/lib/datadog/tracing/transport/statistics.rb +2 -2
- data/lib/datadog/tracing/transport/telemetry.rb +3 -1
- data/lib/datadog/tracing/transport/trace_formatter.rb +12 -12
- data/lib/datadog/tracing/transport/traces.rb +2 -4
- data/lib/datadog/tracing/utils.rb +5 -7
- data/lib/datadog/tracing/workers.rb +1 -1
- data/lib/datadog/version.rb +1 -1
- metadata +23 -6
|
@@ -94,9 +94,9 @@ module Datadog
|
|
|
94
94
|
)
|
|
95
95
|
|
|
96
96
|
# Validation for this check is done in extconf.rb because it relies on mkmf
|
|
97
|
-
|
|
98
|
-
"your C compiler
|
|
99
|
-
"This issue can
|
|
97
|
+
COMPILER_C11_MISSING = explain_issue(
|
|
98
|
+
"your C compiler does not support C11 (-std=gnu11).",
|
|
99
|
+
"This issue can be fixed by upgrading to a later version of your",
|
|
100
100
|
"operating system image or compiler.",
|
|
101
101
|
suggested: CONTACT_SUPPORT,
|
|
102
102
|
)
|
|
@@ -315,21 +315,65 @@ VALUE thread_name_for(VALUE thread) {
|
|
|
315
315
|
return thread_struct_from_object(thread)->name;
|
|
316
316
|
}
|
|
317
317
|
|
|
318
|
-
// This test
|
|
319
|
-
// the
|
|
318
|
+
// This test validates the layout of the rb_thread_t structure. Because the fields we check are near the end of
|
|
319
|
+
// the structure, if somehow we can't read the values we set, this probably means we're getting the structure wrong
|
|
320
320
|
// and we should stop immediately (this includes covering the use of `stat_insn_usage` on Ruby <= 3.2).
|
|
321
321
|
//
|
|
322
322
|
// One example where this happens is in patches such as
|
|
323
323
|
// https://github.com/gitlabhq/omnibus-gitlab/blob/master/config/patches/ruby/thread-memory-allocations-3.2.patch
|
|
324
|
-
// that add items to the structure and thus shift its
|
|
325
|
-
|
|
326
|
-
VALUE thread =
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
324
|
+
// that add items to the structure and thus shift its fields from where we expect.
|
|
325
|
+
static VALUE self_test_thread_struct_in_thread(DDTRACE_UNUSED void *unused) {
|
|
326
|
+
VALUE thread = rb_thread_current();
|
|
327
|
+
rb_thread_t *thread_struct = thread_struct_from_object(thread);
|
|
328
|
+
|
|
329
|
+
// Without a root fiber, Ruby includes the VM stack in the thread's reported size. Calling rb_fiber_current()
|
|
330
|
+
// creates the root fiber, so Ruby accounts for the stack under that fiber instead, leaving it out of thread size.
|
|
331
|
+
VALUE fiber = rb_fiber_current();
|
|
332
|
+
|
|
333
|
+
// Check size first, when possible, to avoid out-of-bounds field reads if Ruby's structure is smaller than we expect.
|
|
334
|
+
// For a new thread with a root fiber + no thread-local keys, we expect the reported size to be exactly the
|
|
335
|
+
// same as `rb_thread_t`
|
|
336
|
+
if (RARRAY_LEN(rb_funcall(thread, rb_intern("keys"), 0)) == 0) {
|
|
337
|
+
size_t actual_size = private_vm_api_global.thread_data_type->function.dsize(thread_struct);
|
|
338
|
+
if (actual_size != sizeof(rb_thread_t)) {
|
|
339
|
+
return rb_sprintf("size mismatch (Ruby reports %zu bytes, profiler expects %zu)", actual_size, sizeof(rb_thread_t));
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
if (thread_struct->root_fiber != DATA_PTR(fiber)) {
|
|
344
|
+
return rb_str_new_cstr("root_fiber does not match the current fiber");
|
|
332
345
|
}
|
|
346
|
+
|
|
347
|
+
// Are we reading the name from the right place?
|
|
348
|
+
VALUE name = rb_obj_freeze(rb_str_new_cstr("dd-prof-test"));
|
|
349
|
+
rb_funcall(thread, rb_intern("name="), 1, name);
|
|
350
|
+
// We check for rb_method_basic_definition_p to avoid the issue in https://github.com/DataDog/dd-trace-rb/issues/6582:
|
|
351
|
+
// If `Thread#name` gets redefined, we fall back to the next steps, rather than failing the self-test.
|
|
352
|
+
// (This means we don't block users of the `semantic_logger` gem from profiling)
|
|
353
|
+
if (thread_struct->name != name && rb_method_basic_definition_p(rb_cThread, rb_intern("name"))) {
|
|
354
|
+
return rb_str_new_cstr("name does not match the assigned name");
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
#ifdef HAVE_RB_EXT_RACTOR_SAFE
|
|
358
|
+
bool original_ractor_safe = thread_struct->ext_config.ractor_safe;
|
|
359
|
+
rb_ext_ractor_safe(!original_ractor_safe);
|
|
360
|
+
if (thread_struct->ext_config.ractor_safe != !original_ractor_safe) {
|
|
361
|
+
return rb_str_new_cstr("ext_config.ractor_safe did not change after toggling it");
|
|
362
|
+
}
|
|
363
|
+
rb_ext_ractor_safe(original_ractor_safe);
|
|
364
|
+
if (thread_struct->ext_config.ractor_safe != original_ractor_safe) {
|
|
365
|
+
return rb_str_new_cstr("ext_config.ractor_safe did not match after restoring it");
|
|
366
|
+
}
|
|
367
|
+
#endif
|
|
368
|
+
|
|
369
|
+
return Qnil;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
void self_test_thread_struct(void) {
|
|
373
|
+
// We do this in a separate thread to isolate any of the changes we make
|
|
374
|
+
VALUE error = rb_funcall(rb_thread_create(self_test_thread_struct_in_thread, NULL), rb_intern("value"), 0);
|
|
375
|
+
|
|
376
|
+
if (!NIL_P(error)) rb_raise(rb_eRuntimeError, "rb_thread_t self-test failed: %"PRIsVALUE, error);
|
|
333
377
|
}
|
|
334
378
|
|
|
335
379
|
// -----------------------------------------------------------------------------
|
|
@@ -664,6 +708,7 @@ int ddtrace_rb_profile_frames(VALUE thread, int start, int limit, frame_info *st
|
|
|
664
708
|
stack_buffer[i].as.ruby_frame.iseq = iseq;
|
|
665
709
|
stack_buffer[i].as.ruby_frame.caching_pc = (void *) pc;
|
|
666
710
|
stack_buffer[i].cme = cme;
|
|
711
|
+
stack_buffer[i].cached_name_len = 0;
|
|
667
712
|
|
|
668
713
|
// The topmost frame may not have an updated PC because the JIT
|
|
669
714
|
// may not have set one. The JIT compiler will update the PC
|
|
@@ -699,6 +744,7 @@ int ddtrace_rb_profile_frames(VALUE thread, int start, int limit, frame_info *st
|
|
|
699
744
|
}
|
|
700
745
|
|
|
701
746
|
stack_buffer[i].cme = cme;
|
|
747
|
+
stack_buffer[i].cached_name_len = 0;
|
|
702
748
|
stack_buffer[i].is_ruby_frame = false;
|
|
703
749
|
i++;
|
|
704
750
|
}
|
|
@@ -994,23 +1040,6 @@ void self_test_current_fiber_for(void) { } // Nothing to do
|
|
|
994
1040
|
// Also, those functions are static functions in vm_backtrace.c so not reusable.
|
|
995
1041
|
// There is also AFAIK no reasonable way to create a rb_backtrace_location_t from outside that file.
|
|
996
1042
|
|
|
997
|
-
// Return true if a given location is a C method or supposed to behave like one.
|
|
998
|
-
static bool location_cfunc_p(const rb_callable_method_entry_t *cme) {
|
|
999
|
-
if (!cme) {
|
|
1000
|
-
return false;
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1003
|
-
switch (cme->def->type) {
|
|
1004
|
-
case VM_METHOD_TYPE_CFUNC:
|
|
1005
|
-
return true;
|
|
1006
|
-
// Upstream, but we don't want that behavior:
|
|
1007
|
-
// case VM_METHOD_TYPE_ISEQ:
|
|
1008
|
-
// return is_internal_location(loc->cme->def->body.iseq.iseqptr);
|
|
1009
|
-
default:
|
|
1010
|
-
return false;
|
|
1011
|
-
}
|
|
1012
|
-
}
|
|
1013
|
-
|
|
1014
1043
|
// RCLASS_SINGLETON_P() is only defined on Ruby 3.4+, so we have a copy for older versions
|
|
1015
1044
|
static bool ddtrace_RCLASS_SINGLETON_P(VALUE klass) {
|
|
1016
1045
|
return RB_TYPE_P(klass, T_CLASS) && FL_TEST_RAW(klass, FL_SINGLETON);
|
|
@@ -1036,15 +1065,22 @@ static bool is_metaclass(VALUE mod, VALUE* attached) {
|
|
|
1036
1065
|
}
|
|
1037
1066
|
|
|
1038
1067
|
VALUE ddtrace_alloc_free_rb_mod_name(VALUE mod) {
|
|
1039
|
-
|
|
1068
|
+
// Reading the field is what rb_mod_name() does (MRI: classname()), minus the cross-library call, which shows up in
|
|
1069
|
+
// profiles as we do this for every frame. See has_permanent_classpath() below for why RCLASS_EXT_PRIME.
|
|
1070
|
+
#if defined(RCLASS_EXT_PRIME) // 4.0+
|
|
1071
|
+
VALUE name = RCLASS_EXT_PRIME(mod)->classpath;
|
|
1072
|
+
#elif defined(HAVE_PERMANENT_CLASSPATH) // 3.3 - 3.4
|
|
1073
|
+
VALUE name = RCLASS_EXT(mod)->classpath;
|
|
1074
|
+
#elif defined(NO_ALLOC_FREE_MOD_NAME) // 2.6 and older
|
|
1040
1075
|
VALUE name = rb_attr_get(mod, rb_intern("__classpath__"));
|
|
1041
|
-
#else
|
|
1076
|
+
#else // 2.7 - 3.2
|
|
1042
1077
|
VALUE name = rb_mod_name(mod);
|
|
1043
1078
|
#endif
|
|
1079
|
+
// `classpath` is Qfalse, not Qnil, for a module that has no name.
|
|
1044
1080
|
// While Module#const_set rejects empty strings,
|
|
1045
1081
|
// an empty String is possible if `rb_const_set(mod, "", val)` was used
|
|
1046
1082
|
// but that's not understandable so consider those anonymous too.
|
|
1047
|
-
if (name == Qnil || RSTRING_LEN(name) == 0) {
|
|
1083
|
+
if (name == Qfalse || name == Qnil || RSTRING_LEN(name) == 0) {
|
|
1048
1084
|
return Qnil;
|
|
1049
1085
|
} else {
|
|
1050
1086
|
return name;
|
|
@@ -1128,7 +1164,7 @@ static ssize_t calculate_iseq_label(VALUE owner, const rb_iseq_t *iseq, char *bu
|
|
|
1128
1164
|
case ISEQ_TYPE_METHOD:
|
|
1129
1165
|
return rb_gen_method_name(owner, ISEQ_BODY(iseq)->location.label, buf, buf_size);
|
|
1130
1166
|
|
|
1131
|
-
#
|
|
1167
|
+
#ifndef NO_ISEQ_TYPE_PLAIN
|
|
1132
1168
|
case ISEQ_TYPE_PLAIN:
|
|
1133
1169
|
#endif
|
|
1134
1170
|
case ISEQ_TYPE_BLOCK: {
|
|
@@ -1170,9 +1206,17 @@ static ssize_t calculate_iseq_label(VALUE owner, const rb_iseq_t *iseq, char *bu
|
|
|
1170
1206
|
}
|
|
1171
1207
|
|
|
1172
1208
|
// MRI: location_label()
|
|
1173
|
-
// C methods don't have an iseq, only Ruby methods have
|
|
1174
1209
|
ssize_t ddtrace_location_label(const rb_callable_method_entry_t *cme, const rb_iseq_t *iseq, char *buf, size_t buf_size) {
|
|
1175
|
-
|
|
1210
|
+
// The upstream `location_label` uses `location_cfunc_p` instead of testing `iseq == NULL`, which checks cme->def->type.
|
|
1211
|
+
// Between capturing the stack and naming its frames, a refinement can replace cme->def
|
|
1212
|
+
// with a VM_METHOD_TYPE_REFINED definition. The captured frame is still a C frame with
|
|
1213
|
+
// no ISEQ, so we use its captured frame kind rather than the method entry's current type.
|
|
1214
|
+
//
|
|
1215
|
+
// Upstream also names internal Ruby methods like C ones:
|
|
1216
|
+
// case VM_METHOD_TYPE_ISEQ:
|
|
1217
|
+
// return is_internal_location(loc->cme->def->body.iseq.iseqptr);
|
|
1218
|
+
// but we don't want that behavior.
|
|
1219
|
+
if (iseq == NULL) {
|
|
1176
1220
|
VALUE method_name = rb_id2str(cme->def->original_id);
|
|
1177
1221
|
if (method_name == Qfalse) {
|
|
1178
1222
|
return NO_METHOD_NAME;
|
|
@@ -1186,7 +1230,8 @@ ssize_t ddtrace_location_label(const rb_callable_method_entry_t *cme, const rb_i
|
|
|
1186
1230
|
|
|
1187
1231
|
// Returns a String or Qfalse (like rb_id2str())
|
|
1188
1232
|
VALUE ddtrace_location_base_label(const rb_callable_method_entry_t *cme, const rb_iseq_t *iseq) {
|
|
1189
|
-
|
|
1233
|
+
// We test `iseq == NULL` and not `location_cfunc_p` for the same reason as `ddtrace_location_label` above
|
|
1234
|
+
if (iseq == NULL) {
|
|
1190
1235
|
return rb_id2str(cme->def->original_id);
|
|
1191
1236
|
} else {
|
|
1192
1237
|
return rb_iseq_base_label(iseq);
|
|
@@ -34,6 +34,10 @@ typedef struct {
|
|
|
34
34
|
int line;
|
|
35
35
|
} ruby_frame;
|
|
36
36
|
} as;
|
|
37
|
+
// Length of the frame name cached for this slot in `sampling_buffer`, or 0 when there's none.
|
|
38
|
+
// ddtrace_rb_profile_frames() clears it when it replaces this frame, so a non-zero length always describes the
|
|
39
|
+
// cme and iseq currently here.
|
|
40
|
+
uint8_t cached_name_len;
|
|
37
41
|
bool is_ruby_frame : 1;
|
|
38
42
|
bool same_frame : 1;
|
|
39
43
|
} frame_info;
|
|
@@ -48,7 +52,7 @@ uint64_t native_thread_id_for(VALUE thread);
|
|
|
48
52
|
void ddtrace_thread_list(VALUE result_array);
|
|
49
53
|
bool is_thread_alive(VALUE thread);
|
|
50
54
|
VALUE thread_name_for(VALUE thread);
|
|
51
|
-
void
|
|
55
|
+
void self_test_thread_struct(void);
|
|
52
56
|
|
|
53
57
|
int ddtrace_rb_profile_frames(VALUE thread, int start, int limit, frame_info *stack_buffer);
|
|
54
58
|
|
|
@@ -107,7 +107,7 @@ void DDTRACE_EXPORT Init_datadog_profiling_native_extension(void) {
|
|
|
107
107
|
|
|
108
108
|
static VALUE native_working_p(DDTRACE_UNUSED VALUE _self) {
|
|
109
109
|
private_vm_api_access_self_test();
|
|
110
|
-
|
|
110
|
+
self_test_thread_struct();
|
|
111
111
|
self_test_clock_id();
|
|
112
112
|
self_test_current_fiber_for();
|
|
113
113
|
self_test_mn_enabled();
|
|
@@ -6,7 +6,7 @@ require_relative "../libdatadog_extconf_helpers"
|
|
|
6
6
|
|
|
7
7
|
def skip_building_extension!(reason)
|
|
8
8
|
$stderr.puts(
|
|
9
|
-
"WARN: Skipping build of libdatadog_api (#{reason}). Some functionality will not be available."
|
|
9
|
+
"WARN: Skipping build of libdatadog_api (#{reason}). Some functionality will not be available.",
|
|
10
10
|
)
|
|
11
11
|
|
|
12
12
|
fail_install_if_missing_extension = ENV["DD_FAIL_INSTALL_IF_MISSING_EXTENSION"].to_s.strip.downcase == "true"
|
|
@@ -47,12 +47,14 @@ append_cflags "-Werror" if ENV["DATADOG_GEM_CI"] == "true"
|
|
|
47
47
|
# header lands upstream in libdatadog/libdatadog-rb. Remove this once that ships.
|
|
48
48
|
append_cflags "-Wno-error=typedef-redefinition" if ENV["DATADOG_GEM_CI"] == "true"
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
unless try_cflags("-std=gnu11")
|
|
51
|
+
skip_building_extension!(
|
|
52
|
+
"your C compiler does not support C11 (-std=gnu11). " \
|
|
53
|
+
"This issue can be fixed by upgrading to a later version of your " \
|
|
54
|
+
"operating system image or compiler.",
|
|
55
|
+
)
|
|
56
|
+
end
|
|
57
|
+
$CFLAGS += " -std=gnu11"
|
|
56
58
|
|
|
57
59
|
# Allow defining variables at any point in a function
|
|
58
60
|
append_cflags "-Wno-declaration-after-statement"
|
|
@@ -97,6 +99,8 @@ Datadog::LibdatadogExtconfHelpers.add_libdatadog_version_define
|
|
|
97
99
|
EXTENSION_NAME = "libdatadog_api.#{RUBY_VERSION[/\d+.\d+/]}_#{RUBY_PLATFORM}".freeze
|
|
98
100
|
|
|
99
101
|
have_func("rb_iseq_type")
|
|
102
|
+
have_func("ddog_ffe_get_assignment_with_options", ["datadog/common.h", "datadog/ffe.h"])
|
|
103
|
+
have_func("ddog_ffe_get_assignment_with_opt_out_mode", ["datadog/common.h", "datadog/ffe.h"])
|
|
100
104
|
|
|
101
105
|
$defs << "-DHAVE_RB_IMEMO_NAME" if RUBY_VERSION >= "3.0"
|
|
102
106
|
$defs << "-DHAVE_SHIFTED_IMEMO_MASK" if RUBY_VERSION >= "4.1"
|
|
@@ -16,6 +16,14 @@ static void configuration_free(void *ptr);
|
|
|
16
16
|
static VALUE configuration_get_observe_full_evaluation_data(VALUE self);
|
|
17
17
|
static VALUE configuration_get_assignment(
|
|
18
18
|
VALUE self, VALUE flag_key, VALUE expected_type, VALUE context);
|
|
19
|
+
#ifdef HAVE_DDOG_FFE_GET_ASSIGNMENT_WITH_OPTIONS
|
|
20
|
+
static VALUE configuration_get_assignment_with_options(
|
|
21
|
+
VALUE self, VALUE flag_key, VALUE expected_type, VALUE context, VALUE experimentation_opt_out_immediate);
|
|
22
|
+
#endif
|
|
23
|
+
#ifdef HAVE_DDOG_FFE_GET_ASSIGNMENT_WITH_OPT_OUT_MODE
|
|
24
|
+
static VALUE configuration_get_assignment_with_opt_out_mode(
|
|
25
|
+
VALUE self, VALUE flag_key, VALUE expected_type, VALUE context, VALUE experimentation_opt_out_mode);
|
|
26
|
+
#endif
|
|
19
27
|
|
|
20
28
|
static void resolution_details_free(void *ptr);
|
|
21
29
|
static VALUE resolution_details_get_raw_value(VALUE self);
|
|
@@ -28,6 +36,7 @@ static VALUE resolution_details_get_error_code(VALUE self);
|
|
|
28
36
|
static VALUE resolution_details_get_error_message(VALUE self);
|
|
29
37
|
static VALUE resolution_details_get_do_log(VALUE self);
|
|
30
38
|
static VALUE resolution_details_get_flag_metadata(VALUE self);
|
|
39
|
+
static VALUE resolution_details_get_features(VALUE self);
|
|
31
40
|
|
|
32
41
|
static const rb_data_type_t configuration_data_type = {
|
|
33
42
|
.wrap_struct_name = "Datadog::Core::FeatureFlags::Configuration",
|
|
@@ -52,6 +61,7 @@ static const rb_data_type_t resolution_details_typed_data = {
|
|
|
52
61
|
// Cached values to use in function later in the code.
|
|
53
62
|
static VALUE feature_flags_error_class = Qnil;
|
|
54
63
|
static VALUE resolution_details_class = Qnil;
|
|
64
|
+
static VALUE empty_features = Qnil;
|
|
55
65
|
static ID id_boolean;
|
|
56
66
|
static ID id_string;
|
|
57
67
|
static ID id_number;
|
|
@@ -95,6 +105,12 @@ void feature_flags_init(VALUE core_module) {
|
|
|
95
105
|
rb_undef_alloc_func(configuration_class);
|
|
96
106
|
rb_define_singleton_method(configuration_class, "new", configuration_new, 1);
|
|
97
107
|
rb_define_method(configuration_class, "get_assignment", configuration_get_assignment, 3);
|
|
108
|
+
#ifdef HAVE_DDOG_FFE_GET_ASSIGNMENT_WITH_OPTIONS
|
|
109
|
+
rb_define_method(configuration_class, "get_assignment_with_options", configuration_get_assignment_with_options, 4);
|
|
110
|
+
#endif
|
|
111
|
+
#ifdef HAVE_DDOG_FFE_GET_ASSIGNMENT_WITH_OPT_OUT_MODE
|
|
112
|
+
rb_define_method(configuration_class, "get_assignment_with_opt_out_mode", configuration_get_assignment_with_opt_out_mode, 4);
|
|
113
|
+
#endif
|
|
98
114
|
rb_define_method(configuration_class, "observe_full_evaluation_data", configuration_get_observe_full_evaluation_data, 0);
|
|
99
115
|
|
|
100
116
|
rb_gc_register_address(&resolution_details_class);
|
|
@@ -110,6 +126,10 @@ void feature_flags_init(VALUE core_module) {
|
|
|
110
126
|
rb_define_method(resolution_details_class, "error_message", resolution_details_get_error_message, 0);
|
|
111
127
|
rb_define_method(resolution_details_class, "log?", resolution_details_get_do_log, 0);
|
|
112
128
|
rb_define_method(resolution_details_class, "flag_metadata", resolution_details_get_flag_metadata, 0);
|
|
129
|
+
rb_define_method(resolution_details_class, "features", resolution_details_get_features, 0);
|
|
130
|
+
|
|
131
|
+
rb_gc_register_address(&empty_features);
|
|
132
|
+
empty_features = rb_obj_freeze(rb_ary_new());
|
|
113
133
|
|
|
114
134
|
// Cache symbol IDs for expected types
|
|
115
135
|
id_boolean = rb_intern_const("boolean");
|
|
@@ -188,6 +208,10 @@ static int evaluation_context_foreach_callback(VALUE key, VALUE value, VALUE arg
|
|
|
188
208
|
|
|
189
209
|
ENFORCE_TYPE(key, T_STRING);
|
|
190
210
|
const char *name = RSTRING_PTR(key);
|
|
211
|
+
// C strings must not turn a different attribute into a reserved key.
|
|
212
|
+
if (memchr(name, '\0', RSTRING_LEN(key)) != NULL) {
|
|
213
|
+
return ST_CONTINUE;
|
|
214
|
+
}
|
|
191
215
|
|
|
192
216
|
// Extract targeting_key separately if present.
|
|
193
217
|
//
|
|
@@ -329,6 +353,69 @@ static VALUE configuration_get_assignment(VALUE self, VALUE flag_key, VALUE expe
|
|
|
329
353
|
return TypedData_Wrap_Struct(resolution_details_class, &resolution_details_typed_data, resolution_details);
|
|
330
354
|
}
|
|
331
355
|
|
|
356
|
+
#ifdef HAVE_DDOG_FFE_GET_ASSIGNMENT_WITH_OPTIONS
|
|
357
|
+
static VALUE configuration_get_assignment_with_options(
|
|
358
|
+
VALUE self, VALUE flag_key, VALUE expected_type, VALUE context_hash, VALUE experimentation_opt_out_immediate
|
|
359
|
+
) {
|
|
360
|
+
ENFORCE_TYPED_DATA(self, &configuration_data_type);
|
|
361
|
+
ENFORCE_TYPE(flag_key, T_STRING);
|
|
362
|
+
ENFORCE_TYPE(expected_type, T_SYMBOL);
|
|
363
|
+
ENFORCE_TYPE(context_hash, T_HASH);
|
|
364
|
+
if (experimentation_opt_out_immediate != Qtrue && experimentation_opt_out_immediate != Qfalse) {
|
|
365
|
+
rb_raise(rb_eTypeError, "experimentation_opt_out_immediate must be a boolean");
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
const ddog_ffe_Handle_Configuration config =
|
|
369
|
+
(ddog_ffe_Handle_Configuration)rb_check_typeddata(self, &configuration_data_type);
|
|
370
|
+
const ddog_ffe_ExpectedFlagType expected_ty = expected_type_from_value(expected_type);
|
|
371
|
+
ddog_ffe_Handle_EvaluationContext context = evaluation_context_from_hash(context_hash);
|
|
372
|
+
const struct ddog_ffe_EvaluationOptions options = {
|
|
373
|
+
.experimentation_opt_out_immediate = experimentation_opt_out_immediate == Qtrue
|
|
374
|
+
};
|
|
375
|
+
ddog_ffe_Handle_ResolutionDetails resolution_details = ddog_ffe_get_assignment_with_options(
|
|
376
|
+
config, RSTRING_PTR(flag_key), expected_ty, context, options
|
|
377
|
+
);
|
|
378
|
+
ddog_ffe_evaluation_context_drop(&context);
|
|
379
|
+
|
|
380
|
+
return TypedData_Wrap_Struct(resolution_details_class, &resolution_details_typed_data, resolution_details);
|
|
381
|
+
}
|
|
382
|
+
#endif
|
|
383
|
+
|
|
384
|
+
#ifdef HAVE_DDOG_FFE_GET_ASSIGNMENT_WITH_OPT_OUT_MODE
|
|
385
|
+
static VALUE configuration_get_assignment_with_opt_out_mode(
|
|
386
|
+
VALUE self, VALUE flag_key, VALUE expected_type, VALUE context_hash, VALUE experimentation_opt_out_mode
|
|
387
|
+
) {
|
|
388
|
+
ENFORCE_TYPED_DATA(self, &configuration_data_type);
|
|
389
|
+
ENFORCE_TYPE(flag_key, T_STRING);
|
|
390
|
+
ENFORCE_TYPE(expected_type, T_SYMBOL);
|
|
391
|
+
ENFORCE_TYPE(context_hash, T_HASH);
|
|
392
|
+
ENFORCE_TYPE(experimentation_opt_out_mode, T_SYMBOL);
|
|
393
|
+
|
|
394
|
+
const ID mode_id = SYM2ID(experimentation_opt_out_mode);
|
|
395
|
+
enum ddog_ffe_ExperimentationOptOutMode mode;
|
|
396
|
+
if (mode_id == rb_intern("disabled")) {
|
|
397
|
+
mode = DDOG_FFE_EXPERIMENTATION_OPT_OUT_MODE_DISABLED;
|
|
398
|
+
} else if (mode_id == rb_intern("immediate")) {
|
|
399
|
+
mode = DDOG_FFE_EXPERIMENTATION_OPT_OUT_MODE_IMMEDIATE;
|
|
400
|
+
} else if (mode_id == rb_intern("future_experiments_only")) {
|
|
401
|
+
mode = DDOG_FFE_EXPERIMENTATION_OPT_OUT_MODE_FUTURE_EXPERIMENTS_ONLY;
|
|
402
|
+
} else {
|
|
403
|
+
rb_raise(rb_eArgError, "Unsupported experimentation opt-out mode");
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
const ddog_ffe_Handle_Configuration config =
|
|
407
|
+
(ddog_ffe_Handle_Configuration)rb_check_typeddata(self, &configuration_data_type);
|
|
408
|
+
const ddog_ffe_ExpectedFlagType expected_ty = expected_type_from_value(expected_type);
|
|
409
|
+
ddog_ffe_Handle_EvaluationContext context = evaluation_context_from_hash(context_hash);
|
|
410
|
+
ddog_ffe_Handle_ResolutionDetails resolution_details = ddog_ffe_get_assignment_with_opt_out_mode(
|
|
411
|
+
config, RSTRING_PTR(flag_key), expected_ty, context, mode
|
|
412
|
+
);
|
|
413
|
+
ddog_ffe_evaluation_context_drop(&context);
|
|
414
|
+
|
|
415
|
+
return TypedData_Wrap_Struct(resolution_details_class, &resolution_details_typed_data, resolution_details);
|
|
416
|
+
}
|
|
417
|
+
#endif
|
|
418
|
+
|
|
332
419
|
static void resolution_details_free(void *ptr) {
|
|
333
420
|
ddog_ffe_Handle_ResolutionDetails resolution_details = (ddog_ffe_Handle_ResolutionDetails)ptr;
|
|
334
421
|
ddog_ffe_assignment_drop(&resolution_details);
|
|
@@ -586,3 +673,53 @@ static VALUE resolution_details_get_flag_metadata(VALUE self) {
|
|
|
586
673
|
|
|
587
674
|
return hash;
|
|
588
675
|
}
|
|
676
|
+
|
|
677
|
+
static VALUE feature_value_to_ruby(const struct ddog_ffe_FeatureValue *value) {
|
|
678
|
+
switch (value->tag) {
|
|
679
|
+
case DDOG_FFE_FEATURE_VALUE_STRING:
|
|
680
|
+
// Frozen because flag metadata reaches customer code while queued telemetry still holds the value.
|
|
681
|
+
return rb_obj_freeze(rb_utf8_str_new((const char *)value->string.ptr, value->string.len));
|
|
682
|
+
case DDOG_FFE_FEATURE_VALUE_FLOAT:
|
|
683
|
+
return rb_float_new(value->float_);
|
|
684
|
+
case DDOG_FFE_FEATURE_VALUE_BOOLEAN:
|
|
685
|
+
return value->boolean ? Qtrue : Qfalse;
|
|
686
|
+
default:
|
|
687
|
+
// This should never happen as we checked for all possible tag values.
|
|
688
|
+
raise_error(feature_flags_error_class, "Internal: Unexpected feature value tag");
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
/*
|
|
693
|
+
* call-seq:
|
|
694
|
+
* resolution_details.features() -> Array
|
|
695
|
+
*
|
|
696
|
+
* Get the features of the selected split, in configuration order.
|
|
697
|
+
*
|
|
698
|
+
* @return [Array<Array(String, String | Float | Boolean, Array<String>)>]
|
|
699
|
+
* `[key, value, destinations]` triples; a shared frozen empty array when the split has none
|
|
700
|
+
*/
|
|
701
|
+
static VALUE resolution_details_get_features(VALUE self) {
|
|
702
|
+
ddog_ffe_Handle_ResolutionDetails resolution_details =
|
|
703
|
+
(ddog_ffe_Handle_ResolutionDetails)rb_check_typeddata(self, &resolution_details_typed_data);
|
|
704
|
+
// Borrowed from the handle, which `self` keeps alive while Ruby allocates below.
|
|
705
|
+
struct ddog_ffe_FeatureArray features = ddog_ffe_assignment_get_features(resolution_details);
|
|
706
|
+
if (features.count == 0) {
|
|
707
|
+
return empty_features;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
VALUE result = rb_ary_new_capa((long)features.count);
|
|
711
|
+
for (size_t i = 0; i < features.count; i++) {
|
|
712
|
+
const struct ddog_ffe_Feature *feature = &features.elements[i];
|
|
713
|
+
|
|
714
|
+
VALUE destinations = rb_ary_new_capa((long)feature->destinations.count);
|
|
715
|
+
for (size_t j = 0; j < feature->destinations.count; j++) {
|
|
716
|
+
const struct ddog_ffe_BorrowedStr destination = feature->destinations.elements[j];
|
|
717
|
+
rb_ary_push(destinations, rb_utf8_str_new((const char *)destination.ptr, destination.len));
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
VALUE key = rb_utf8_str_new((const char *)feature->key.ptr, feature->key.len);
|
|
721
|
+
rb_ary_push(result, rb_ary_new_from_args(3, key, feature_value_to_ruby(&feature->value), destinations));
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
return result;
|
|
725
|
+
}
|
|
@@ -32,9 +32,9 @@ void process_discovery_init(VALUE core_module) {
|
|
|
32
32
|
VALUE tracer_memfd_class = rb_define_class_under(process_discovery_module, "TracerMemfd", rb_cObject);
|
|
33
33
|
rb_undef_alloc_func(tracer_memfd_class); // Class cannot be instantiated from Ruby
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
rb_define_singleton_method(process_discovery_module, "_native_store_tracer_metadata", _native_store_tracer_metadata, -1);
|
|
36
|
+
rb_define_singleton_method(process_discovery_module, "_native_to_rb_int", _native_to_rb_int, 1);
|
|
37
|
+
rb_define_singleton_method(process_discovery_module, "_native_close_tracer_memfd", _native_close_tracer_memfd, 2);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
static VALUE _native_store_tracer_metadata(int argc, VALUE *argv, VALUE self) {
|
|
@@ -1692,6 +1692,9 @@ static int check_if_pending_exception(void) {
|
|
|
1692
1692
|
* On success returns [Response(ok: true, trace_count: N)].
|
|
1693
1693
|
* On error returns [Response(ok: false, ...)].
|
|
1694
1694
|
*
|
|
1695
|
+
* The optional block receives one observation Hash: the native report, or
|
|
1696
|
+
* cancelled drops when an interrupt prevented the native send from running.
|
|
1697
|
+
*
|
|
1695
1698
|
* The chunk-building loop calls into Ruby (ENFORCE_TYPE,
|
|
1696
1699
|
* convert_ruby_span_to_rust) which may raise. We use rb_ensure so
|
|
1697
1700
|
* that the Rust-allocated chunks are freed if an exception fires
|
|
@@ -1704,21 +1707,39 @@ typedef struct {
|
|
|
1704
1707
|
VALUE traces;
|
|
1705
1708
|
VALUE native_events_supported;
|
|
1706
1709
|
long trace_count;
|
|
1710
|
+
size_t span_count;
|
|
1707
1711
|
raw_span_owner span_owner;
|
|
1708
1712
|
ddog_TracerTraceChunks *chunks; /* NULL after send consumes it */
|
|
1709
1713
|
ddog_TraceExporterResponse *response;
|
|
1710
1714
|
} send_traces_ctx;
|
|
1711
1715
|
|
|
1712
1716
|
typedef struct {
|
|
1713
|
-
const ddog_TraceExporterObservations *report;
|
|
1717
|
+
const ddog_TraceExporterObservations *report; /* NULL when the send never ran */
|
|
1718
|
+
size_t cancelled_chunks;
|
|
1719
|
+
size_t cancelled_spans;
|
|
1720
|
+
} send_outcome;
|
|
1721
|
+
|
|
1722
|
+
typedef struct {
|
|
1723
|
+
const send_outcome *outcome;
|
|
1714
1724
|
VALUE block;
|
|
1715
1725
|
} observations_callback_args;
|
|
1716
1726
|
|
|
1727
|
+
/* Only for chunks never handed to an HTTP attempt: a cancelled in-flight
|
|
1728
|
+
* request may still have been received, so it must not be reported here. */
|
|
1729
|
+
static void add_cancelled_drop(VALUE values, size_t chunks, size_t spans) {
|
|
1730
|
+
if (chunks == 0) return;
|
|
1731
|
+
rb_hash_aset(values, ID2SYM(rb_intern_const("chunks_dropped_cancelled")), SIZET2NUM(chunks));
|
|
1732
|
+
if (spans == 0) return;
|
|
1733
|
+
rb_hash_aset(values, ID2SYM(rb_intern_const("spans_dropped_cancelled")), SIZET2NUM(spans));
|
|
1734
|
+
VALUE enqueued = ID2SYM(rb_intern_const("spans_enqueued_for_serialization"));
|
|
1735
|
+
rb_hash_aset(values, enqueued, ULL2NUM(NUM2ULL(rb_hash_lookup2(values, enqueued, INT2FIX(0))) + spans));
|
|
1736
|
+
}
|
|
1737
|
+
|
|
1717
1738
|
static VALUE yield_observations(VALUE arg) {
|
|
1718
1739
|
observations_callback_args *callback = (observations_callback_args *)arg;
|
|
1719
|
-
const ddog_TraceExporterObservations *report = callback->report;
|
|
1740
|
+
const ddog_TraceExporterObservations *report = callback->outcome->report;
|
|
1720
1741
|
VALUE values = rb_hash_new();
|
|
1721
|
-
#define ADD_OBSERVATION(field) if (report->field > 0) rb_hash_aset(values, ID2SYM(rb_intern_const(#field)), ULL2NUM(report->field))
|
|
1742
|
+
#define ADD_OBSERVATION(field) if (report != NULL && report->field > 0) rb_hash_aset(values, ID2SYM(rb_intern_const(#field)), ULL2NUM(report->field))
|
|
1722
1743
|
ADD_OBSERVATION(requests_count);
|
|
1723
1744
|
ADD_OBSERVATION(errors_network);
|
|
1724
1745
|
ADD_OBSERVATION(errors_timeout);
|
|
@@ -1733,6 +1754,7 @@ static VALUE yield_observations(VALUE arg) {
|
|
|
1733
1754
|
ADD_OBSERVATION(responses_count);
|
|
1734
1755
|
ADD_OBSERVATION(status_code);
|
|
1735
1756
|
#undef ADD_OBSERVATION
|
|
1757
|
+
add_cancelled_drop(values, callback->outcome->cancelled_chunks, callback->outcome->cancelled_spans);
|
|
1736
1758
|
return rb_proc_call_with_block(callback->block, 1, &values, Qnil);
|
|
1737
1759
|
}
|
|
1738
1760
|
|
|
@@ -1751,7 +1773,7 @@ static VALUE protected_observations(RB_BLOCK_CALL_FUNC_ARGLIST(yielded, arg)) {
|
|
|
1751
1773
|
|
|
1752
1774
|
static VALUE forward_observations(VALUE arg) {
|
|
1753
1775
|
observations_callback_args callback = {
|
|
1754
|
-
.
|
|
1776
|
+
.outcome = (const send_outcome *)arg,
|
|
1755
1777
|
.block = rb_block_proc(),
|
|
1756
1778
|
};
|
|
1757
1779
|
/* Deliver fresh interrupts after the callback's StandardError rescue has ended. */
|
|
@@ -1785,6 +1807,7 @@ static VALUE build_and_send_traces(VALUE arg) {
|
|
|
1785
1807
|
ENFORCE_TYPE(chunk_spans, T_ARRAY);
|
|
1786
1808
|
|
|
1787
1809
|
long span_count = RARRAY_LEN(chunk_spans);
|
|
1810
|
+
ctx->span_count += (size_t)span_count;
|
|
1788
1811
|
/* Propagate a begin_chunk failure instead of swallowing it: continuing
|
|
1789
1812
|
* would build an incomplete payload and still report success. rb_ensure
|
|
1790
1813
|
* frees chunks on the raise. Today this only fails for an absurd
|
|
@@ -1856,13 +1879,17 @@ static VALUE build_and_send_traces(VALUE arg) {
|
|
|
1856
1879
|
if (!pending_exception) {
|
|
1857
1880
|
pending_exception = check_if_pending_exception();
|
|
1858
1881
|
}
|
|
1859
|
-
if (
|
|
1882
|
+
if (rb_block_given_p()) {
|
|
1883
|
+
/* A send that never ran left only an interrupt, and the chunks are freed unsent. */
|
|
1884
|
+
send_outcome outcome = args.send_ran
|
|
1885
|
+
? (send_outcome){.report = &args.observations}
|
|
1886
|
+
: (send_outcome){.cancelled_chunks = (size_t)ctx->trace_count, .cancelled_spans = ctx->span_count};
|
|
1860
1887
|
if (pending_exception) {
|
|
1861
1888
|
/* rb_ensure preserves Thread#kill's fatal sentinel, which rb_set_errinfo cannot restore. */
|
|
1862
1889
|
rb_ensure(rethrow_interrupt, INT2FIX(pending_exception),
|
|
1863
|
-
ensure_observations, (VALUE)&
|
|
1890
|
+
ensure_observations, (VALUE)&outcome);
|
|
1864
1891
|
} else {
|
|
1865
|
-
forward_observations((VALUE)&
|
|
1892
|
+
forward_observations((VALUE)&outcome);
|
|
1866
1893
|
}
|
|
1867
1894
|
}
|
|
1868
1895
|
if (pending_exception) {
|
|
@@ -11,7 +11,7 @@ module Datadog
|
|
|
11
11
|
module LibdatadogExtconfHelpers
|
|
12
12
|
# Used to make sure the correct gem version gets loaded, as extconf.rb does not get run with "bundle exec" and thus
|
|
13
13
|
# may see multiple libdatadog versions. See https://github.com/DataDog/dd-trace-rb/pull/2531 for the horror story.
|
|
14
|
-
LIBDATADOG_VERSION = "~>
|
|
14
|
+
LIBDATADOG_VERSION = "~> 48.0.0.1.1"
|
|
15
15
|
|
|
16
16
|
# Used as an workaround for a limitation with how dynamic linking works in environments where the datadog gem and
|
|
17
17
|
# libdatadog are moved after the extension gets compiled.
|
|
@@ -203,7 +203,7 @@ module Datadog
|
|
|
203
203
|
"#{last_entry.chomp}" \
|
|
204
204
|
"+------------------------------------------------------------------------------+\n" \
|
|
205
205
|
"| Full failure log is at #{log_path}\n" \
|
|
206
|
-
"+------------------------------------------------------------------------------+\n"
|
|
206
|
+
"+------------------------------------------------------------------------------+\n",
|
|
207
207
|
)
|
|
208
208
|
end
|
|
209
209
|
end
|
|
@@ -33,7 +33,7 @@ module Datadog
|
|
|
33
33
|
endpoint: settings.ai_guard.endpoint,
|
|
34
34
|
api_key: settings.api_key,
|
|
35
35
|
application_key: settings.ai_guard.app_key,
|
|
36
|
-
timeout: settings.ai_guard.timeout_ms / 1_000
|
|
36
|
+
timeout: settings.ai_guard.timeout_ms / 1_000,
|
|
37
37
|
)
|
|
38
38
|
|
|
39
39
|
new(http_client, logger: logger, telemetry: telemetry)
|
|
@@ -6,17 +6,15 @@ module Datadog
|
|
|
6
6
|
module Rack
|
|
7
7
|
# Patcher for Rack integration
|
|
8
8
|
module Patcher
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def patched?
|
|
9
|
+
def self.patched?
|
|
12
10
|
!!Patcher.instance_variable_get(:@patched)
|
|
13
11
|
end
|
|
14
12
|
|
|
15
|
-
def target_version
|
|
13
|
+
def self.target_version
|
|
16
14
|
Integration.version
|
|
17
15
|
end
|
|
18
16
|
|
|
19
|
-
def patch
|
|
17
|
+
def self.patch
|
|
20
18
|
Patcher.instance_variable_set(:@patched, true)
|
|
21
19
|
end
|
|
22
20
|
end
|