datadog 2.12.1 → 2.17.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 +154 -2
- data/ext/datadog_profiling_native_extension/collectors_thread_context.c +16 -14
- data/ext/datadog_profiling_native_extension/datadog_ruby_common.c +1 -4
- data/ext/datadog_profiling_native_extension/datadog_ruby_common.h +10 -0
- data/ext/datadog_profiling_native_extension/encoded_profile.c +79 -0
- data/ext/datadog_profiling_native_extension/encoded_profile.h +8 -0
- data/ext/datadog_profiling_native_extension/extconf.rb +3 -0
- data/ext/datadog_profiling_native_extension/heap_recorder.c +8 -1
- data/ext/datadog_profiling_native_extension/http_transport.c +60 -94
- data/ext/datadog_profiling_native_extension/private_vm_api_access.c +8 -0
- data/ext/datadog_profiling_native_extension/profiling.c +2 -0
- data/ext/datadog_profiling_native_extension/stack_recorder.c +23 -23
- data/ext/libdatadog_api/crashtracker.c +11 -12
- data/ext/libdatadog_api/crashtracker.h +5 -0
- data/ext/libdatadog_api/datadog_ruby_common.c +1 -4
- data/ext/libdatadog_api/datadog_ruby_common.h +10 -0
- data/ext/libdatadog_api/init.c +15 -0
- data/ext/libdatadog_api/library_config.c +122 -0
- data/ext/libdatadog_api/library_config.h +19 -0
- data/ext/libdatadog_api/macos_development.md +3 -3
- data/ext/libdatadog_api/process_discovery.c +117 -0
- data/ext/libdatadog_api/process_discovery.h +5 -0
- data/ext/libdatadog_extconf_helpers.rb +1 -1
- data/lib/datadog/appsec/actions_handler/serializable_backtrace.rb +89 -0
- data/lib/datadog/appsec/actions_handler.rb +24 -2
- data/lib/datadog/appsec/anonymizer.rb +16 -0
- data/lib/datadog/appsec/api_security/lru_cache.rb +49 -0
- data/lib/datadog/appsec/api_security.rb +9 -0
- data/lib/datadog/appsec/assets/waf_rules/README.md +50 -5
- data/lib/datadog/appsec/assets/waf_rules/processors.json +239 -10
- data/lib/datadog/appsec/assets/waf_rules/scanners.json +926 -17
- data/lib/datadog/appsec/autoload.rb +1 -1
- data/lib/datadog/appsec/component.rb +29 -20
- data/lib/datadog/appsec/compressed_json.rb +40 -0
- data/lib/datadog/appsec/configuration/settings.rb +93 -28
- data/lib/datadog/appsec/context.rb +1 -1
- data/lib/datadog/appsec/contrib/active_record/instrumentation.rb +10 -12
- data/lib/datadog/appsec/contrib/active_record/integration.rb +2 -2
- data/lib/datadog/appsec/contrib/active_record/patcher.rb +22 -22
- data/lib/datadog/appsec/contrib/auto_instrument.rb +1 -1
- data/lib/datadog/appsec/contrib/devise/configuration.rb +7 -31
- data/lib/datadog/appsec/contrib/devise/data_extractor.rb +78 -0
- data/lib/datadog/appsec/contrib/devise/ext.rb +22 -0
- data/lib/datadog/appsec/contrib/devise/integration.rb +1 -2
- data/lib/datadog/appsec/contrib/devise/patcher.rb +34 -23
- data/lib/datadog/appsec/contrib/devise/patches/signin_tracking_patch.rb +102 -0
- data/lib/datadog/appsec/contrib/devise/patches/signup_tracking_patch.rb +69 -0
- data/lib/datadog/appsec/contrib/devise/{patcher/rememberable_patch.rb → patches/skip_signin_tracking_patch.rb} +2 -2
- data/lib/datadog/appsec/contrib/devise/tracking_middleware.rb +106 -0
- data/lib/datadog/appsec/contrib/excon/integration.rb +1 -1
- data/lib/datadog/appsec/contrib/excon/ssrf_detection_middleware.rb +9 -10
- data/lib/datadog/appsec/contrib/faraday/integration.rb +1 -1
- data/lib/datadog/appsec/contrib/faraday/ssrf_detection_middleware.rb +8 -9
- data/lib/datadog/appsec/contrib/graphql/gateway/watcher.rb +8 -9
- data/lib/datadog/appsec/contrib/graphql/integration.rb +1 -1
- data/lib/datadog/appsec/contrib/rack/ext.rb +34 -0
- data/lib/datadog/appsec/contrib/rack/gateway/watcher.rb +49 -32
- data/lib/datadog/appsec/contrib/rack/integration.rb +1 -1
- data/lib/datadog/appsec/contrib/rack/request_middleware.rb +19 -18
- data/lib/datadog/appsec/contrib/rails/gateway/watcher.rb +11 -13
- data/lib/datadog/appsec/contrib/rails/integration.rb +1 -1
- data/lib/datadog/appsec/contrib/rails/patcher.rb +21 -21
- data/lib/datadog/appsec/contrib/rest_client/integration.rb +1 -1
- data/lib/datadog/appsec/contrib/rest_client/request_ssrf_detection_patch.rb +10 -11
- data/lib/datadog/appsec/contrib/sinatra/gateway/watcher.rb +17 -23
- data/lib/datadog/appsec/contrib/sinatra/integration.rb +1 -1
- data/lib/datadog/appsec/event.rb +96 -135
- data/lib/datadog/appsec/ext.rb +4 -2
- data/lib/datadog/appsec/instrumentation/gateway/argument.rb +7 -2
- data/lib/datadog/appsec/instrumentation/gateway/middleware.rb +24 -0
- data/lib/datadog/appsec/instrumentation/gateway.rb +17 -22
- data/lib/datadog/appsec/metrics/telemetry.rb +1 -1
- data/lib/datadog/appsec/monitor/gateway/watcher.rb +49 -14
- data/lib/datadog/appsec/processor/rule_loader.rb +26 -28
- data/lib/datadog/appsec/processor/rule_merger.rb +7 -6
- data/lib/datadog/appsec/processor.rb +1 -1
- data/lib/datadog/appsec/remote.rb +23 -11
- data/lib/datadog/appsec/response.rb +6 -6
- data/lib/datadog/appsec/security_engine/runner.rb +3 -3
- data/lib/datadog/appsec/security_event.rb +39 -0
- data/lib/datadog/appsec/utils.rb +0 -2
- data/lib/datadog/appsec.rb +1 -1
- data/lib/datadog/core/buffer/random.rb +18 -2
- data/lib/datadog/core/configuration/agent_settings_resolver.rb +5 -5
- data/lib/datadog/core/configuration/agentless_settings_resolver.rb +176 -0
- data/lib/datadog/core/configuration/components.rb +50 -31
- data/lib/datadog/core/configuration/components_state.rb +23 -0
- data/lib/datadog/core/configuration/ext.rb +4 -0
- data/lib/datadog/core/configuration/option.rb +79 -43
- data/lib/datadog/core/configuration/option_definition.rb +4 -4
- data/lib/datadog/core/configuration/options.rb +3 -3
- data/lib/datadog/core/configuration/settings.rb +68 -35
- data/lib/datadog/core/configuration/stable_config.rb +23 -0
- data/lib/datadog/core/configuration.rb +40 -16
- data/lib/datadog/core/crashtracking/component.rb +3 -10
- data/lib/datadog/core/diagnostics/environment_logger.rb +1 -1
- data/lib/datadog/core/encoding.rb +1 -1
- data/lib/datadog/core/environment/agent_info.rb +4 -3
- data/lib/datadog/core/environment/cgroup.rb +10 -12
- data/lib/datadog/core/environment/container.rb +38 -40
- data/lib/datadog/core/environment/ext.rb +6 -6
- data/lib/datadog/core/environment/git.rb +1 -0
- data/lib/datadog/core/environment/identity.rb +3 -3
- data/lib/datadog/core/environment/platform.rb +3 -3
- data/lib/datadog/core/environment/variable_helpers.rb +1 -1
- data/lib/datadog/core/error.rb +11 -9
- data/lib/datadog/core/logger.rb +2 -2
- data/lib/datadog/core/metrics/client.rb +20 -21
- data/lib/datadog/core/metrics/logging.rb +5 -5
- data/lib/datadog/core/process_discovery.rb +32 -0
- data/lib/datadog/core/rate_limiter.rb +4 -2
- data/lib/datadog/core/remote/client.rb +40 -32
- data/lib/datadog/core/remote/component.rb +6 -9
- data/lib/datadog/core/remote/configuration/digest.rb +7 -7
- data/lib/datadog/core/remote/configuration/path.rb +1 -1
- data/lib/datadog/core/remote/configuration/repository.rb +2 -1
- data/lib/datadog/core/remote/negotiation.rb +9 -9
- data/lib/datadog/core/remote/transport/config.rb +4 -3
- data/lib/datadog/core/remote/transport/http/client.rb +5 -4
- data/lib/datadog/core/remote/transport/http/config.rb +27 -37
- data/lib/datadog/core/remote/transport/http/negotiation.rb +7 -33
- data/lib/datadog/core/remote/transport/http.rb +22 -57
- data/lib/datadog/core/remote/transport/negotiation.rb +4 -3
- data/lib/datadog/core/runtime/metrics.rb +12 -5
- data/lib/datadog/core/telemetry/component.rb +78 -53
- data/lib/datadog/core/telemetry/emitter.rb +23 -11
- data/lib/datadog/core/telemetry/event/app_client_configuration_change.rb +65 -0
- data/lib/datadog/core/telemetry/event/app_closing.rb +18 -0
- data/lib/datadog/core/telemetry/event/app_dependencies_loaded.rb +33 -0
- data/lib/datadog/core/telemetry/event/app_heartbeat.rb +18 -0
- data/lib/datadog/core/telemetry/event/app_integrations_change.rb +58 -0
- data/lib/datadog/core/telemetry/event/app_started.rb +179 -0
- data/lib/datadog/core/telemetry/event/base.rb +40 -0
- data/lib/datadog/core/telemetry/event/distributions.rb +18 -0
- data/lib/datadog/core/telemetry/event/generate_metrics.rb +43 -0
- data/lib/datadog/core/telemetry/event/log.rb +76 -0
- data/lib/datadog/core/telemetry/event/message_batch.rb +42 -0
- data/lib/datadog/core/telemetry/event/synth_app_client_configuration_change.rb +43 -0
- data/lib/datadog/core/telemetry/event.rb +17 -472
- data/lib/datadog/core/telemetry/http/adapters/net.rb +12 -97
- data/lib/datadog/core/telemetry/logger.rb +1 -1
- data/lib/datadog/core/telemetry/metric.rb +8 -8
- data/lib/datadog/core/telemetry/request.rb +4 -4
- data/lib/datadog/core/telemetry/transport/http/api.rb +43 -0
- data/lib/datadog/core/telemetry/transport/http/client.rb +49 -0
- data/lib/datadog/core/telemetry/transport/http/telemetry.rb +92 -0
- data/lib/datadog/core/telemetry/transport/http.rb +63 -0
- data/lib/datadog/core/telemetry/transport/telemetry.rb +51 -0
- data/lib/datadog/core/telemetry/worker.rb +90 -24
- data/lib/datadog/core/transport/http/adapters/test.rb +2 -1
- data/lib/datadog/core/transport/http/api/instance.rb +17 -0
- data/lib/datadog/core/transport/http/api/spec.rb +17 -0
- data/lib/datadog/core/transport/http/builder.rb +18 -16
- data/lib/datadog/core/transport/http.rb +39 -2
- data/lib/datadog/core/utils/at_fork_monkey_patch.rb +6 -6
- data/lib/datadog/core/utils/duration.rb +32 -32
- data/lib/datadog/core/utils/forking.rb +2 -2
- data/lib/datadog/core/utils/network.rb +6 -6
- data/lib/datadog/core/utils/only_once_successful.rb +16 -5
- data/lib/datadog/core/utils/time.rb +20 -0
- data/lib/datadog/core/utils/truncation.rb +21 -0
- data/lib/datadog/core/vendor/multipart-post/multipart/post/composite_read_io.rb +1 -1
- data/lib/datadog/core/vendor/multipart-post/multipart/post/multipartable.rb +8 -8
- data/lib/datadog/core/vendor/multipart-post/multipart/post/parts.rb +7 -7
- data/lib/datadog/core/worker.rb +1 -1
- data/lib/datadog/core/workers/async.rb +29 -12
- data/lib/datadog/core/workers/interval_loop.rb +12 -1
- data/lib/datadog/core/workers/runtime_metrics.rb +2 -2
- data/lib/datadog/core.rb +8 -0
- data/lib/datadog/di/boot.rb +34 -0
- data/lib/datadog/di/component.rb +0 -2
- data/lib/datadog/di/probe_notification_builder.rb +1 -1
- data/lib/datadog/di/probe_notifier_worker.rb +16 -16
- data/lib/datadog/di/remote.rb +2 -0
- data/lib/datadog/di/transport/diagnostics.rb +4 -3
- data/lib/datadog/di/transport/http/api.rb +2 -12
- data/lib/datadog/di/transport/http/client.rb +4 -3
- data/lib/datadog/di/transport/http/diagnostics.rb +7 -34
- data/lib/datadog/di/transport/http/input.rb +7 -34
- data/lib/datadog/di/transport/http.rb +14 -62
- data/lib/datadog/di/transport/input.rb +4 -3
- data/lib/datadog/di/utils.rb +5 -0
- data/lib/datadog/di.rb +5 -32
- data/lib/datadog/error_tracking/collector.rb +87 -0
- data/lib/datadog/error_tracking/component.rb +167 -0
- data/lib/datadog/error_tracking/configuration/settings.rb +63 -0
- data/lib/datadog/error_tracking/configuration.rb +11 -0
- data/lib/datadog/error_tracking/ext.rb +18 -0
- data/lib/datadog/error_tracking/extensions.rb +16 -0
- data/lib/datadog/error_tracking/filters.rb +77 -0
- data/lib/datadog/error_tracking.rb +18 -0
- data/lib/datadog/kit/appsec/events.rb +12 -0
- data/lib/datadog/kit/identity.rb +5 -1
- data/lib/datadog/opentelemetry/api/baggage.rb +90 -0
- data/lib/datadog/opentelemetry/api/baggage.rbs +26 -0
- data/lib/datadog/opentelemetry/api/context.rb +16 -2
- data/lib/datadog/opentelemetry/sdk/trace/span.rb +1 -1
- data/lib/datadog/opentelemetry.rb +2 -1
- data/lib/datadog/profiling/collectors/code_provenance.rb +1 -1
- data/lib/datadog/profiling/collectors/info.rb +3 -0
- data/lib/datadog/profiling/collectors/thread_context.rb +1 -1
- data/lib/datadog/profiling/encoded_profile.rb +11 -0
- data/lib/datadog/profiling/exporter.rb +3 -4
- data/lib/datadog/profiling/ext.rb +0 -2
- data/lib/datadog/profiling/flush.rb +5 -8
- data/lib/datadog/profiling/http_transport.rb +5 -59
- data/lib/datadog/profiling/scheduler.rb +8 -1
- data/lib/datadog/profiling/stack_recorder.rb +4 -4
- data/lib/datadog/profiling/tag_builder.rb +1 -5
- data/lib/datadog/profiling.rb +6 -2
- data/lib/datadog/tracing/analytics.rb +1 -1
- data/lib/datadog/tracing/component.rb +15 -12
- data/lib/datadog/tracing/configuration/ext.rb +7 -1
- data/lib/datadog/tracing/configuration/settings.rb +18 -2
- data/lib/datadog/tracing/context_provider.rb +1 -1
- data/lib/datadog/tracing/contrib/active_record/integration.rb +1 -1
- data/lib/datadog/tracing/contrib/active_support/cache/events/cache.rb +4 -1
- data/lib/datadog/tracing/contrib/active_support/cache/instrumentation.rb +33 -0
- data/lib/datadog/tracing/contrib/active_support/cache/patcher.rb +4 -0
- data/lib/datadog/tracing/contrib/active_support/cache/redis.rb +2 -4
- data/lib/datadog/tracing/contrib/aws/instrumentation.rb +10 -0
- data/lib/datadog/tracing/contrib/aws/parsed_context.rb +5 -1
- data/lib/datadog/tracing/contrib/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/ethon/easy_patch.rb +4 -5
- data/lib/datadog/tracing/contrib/excon/middleware.rb +5 -3
- data/lib/datadog/tracing/contrib/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/faraday/middleware.rb +5 -3
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/client.rb +7 -1
- data/lib/datadog/tracing/contrib/grpc/distributed/propagation.rb +3 -0
- data/lib/datadog/tracing/contrib/http/circuit_breaker.rb +0 -15
- data/lib/datadog/tracing/contrib/http/distributed/propagation.rb +4 -1
- data/lib/datadog/tracing/contrib/http/instrumentation.rb +6 -10
- data/lib/datadog/tracing/contrib/httpclient/instrumentation.rb +6 -16
- data/lib/datadog/tracing/contrib/httprb/instrumentation.rb +7 -15
- data/lib/datadog/tracing/contrib/karafka/configuration/settings.rb +27 -0
- data/lib/datadog/tracing/contrib/karafka/distributed/propagation.rb +48 -0
- data/lib/datadog/tracing/contrib/karafka/ext.rb +27 -0
- data/lib/datadog/tracing/contrib/karafka/integration.rb +45 -0
- data/lib/datadog/tracing/contrib/karafka/monitor.rb +66 -0
- data/lib/datadog/tracing/contrib/karafka/patcher.rb +71 -0
- data/lib/datadog/tracing/contrib/karafka.rb +37 -0
- data/lib/datadog/tracing/contrib/mongodb/configuration/settings.rb +8 -0
- data/lib/datadog/tracing/contrib/mongodb/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/mongodb/subscribers.rb +18 -1
- data/lib/datadog/tracing/contrib/opensearch/configuration/settings.rb +17 -0
- data/lib/datadog/tracing/contrib/opensearch/ext.rb +9 -0
- data/lib/datadog/tracing/contrib/opensearch/patcher.rb +5 -1
- data/lib/datadog/tracing/contrib/patcher.rb +5 -2
- data/lib/datadog/tracing/contrib/rack/request_queue.rb +1 -1
- data/lib/datadog/tracing/contrib/rest_client/request_patch.rb +5 -3
- data/lib/datadog/tracing/contrib/sidekiq/client_tracer.rb +6 -1
- data/lib/datadog/tracing/contrib/sidekiq/distributed/propagation.rb +3 -0
- data/lib/datadog/tracing/contrib/sidekiq/server_tracer.rb +1 -1
- data/lib/datadog/tracing/contrib/support.rb +28 -0
- data/lib/datadog/tracing/contrib.rb +1 -0
- data/lib/datadog/tracing/correlation.rb +9 -2
- 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 +131 -0
- data/lib/datadog/tracing/distributed/datadog.rb +4 -2
- data/lib/datadog/tracing/distributed/propagation.rb +25 -4
- data/lib/datadog/tracing/distributed/propagation_policy.rb +42 -0
- data/lib/datadog/tracing/metadata/errors.rb +4 -4
- data/lib/datadog/tracing/metadata/ext.rb +5 -0
- data/lib/datadog/tracing/metadata/metastruct.rb +36 -0
- data/lib/datadog/tracing/metadata/metastruct_tagging.rb +42 -0
- data/lib/datadog/tracing/metadata.rb +2 -0
- data/lib/datadog/tracing/sampling/rate_sampler.rb +2 -1
- data/lib/datadog/tracing/sampling/span/rule.rb +0 -1
- data/lib/datadog/tracing/span.rb +10 -1
- data/lib/datadog/tracing/span_event.rb +1 -1
- data/lib/datadog/tracing/span_operation.rb +46 -16
- data/lib/datadog/tracing/sync_writer.rb +1 -2
- data/lib/datadog/tracing/trace_digest.rb +9 -2
- data/lib/datadog/tracing/trace_operation.rb +44 -24
- data/lib/datadog/tracing/trace_segment.rb +6 -4
- data/lib/datadog/tracing/tracer.rb +45 -5
- data/lib/datadog/tracing/transport/http/api.rb +2 -10
- data/lib/datadog/tracing/transport/http/client.rb +5 -4
- data/lib/datadog/tracing/transport/http/traces.rb +13 -41
- data/lib/datadog/tracing/transport/http.rb +11 -44
- data/lib/datadog/tracing/transport/serializable_trace.rb +3 -1
- data/lib/datadog/tracing/transport/trace_formatter.rb +7 -0
- data/lib/datadog/tracing/transport/traces.rb +26 -9
- data/lib/datadog/tracing/utils.rb +1 -1
- data/lib/datadog/tracing/workers/trace_writer.rb +2 -6
- data/lib/datadog/tracing/writer.rb +2 -6
- data/lib/datadog/tracing.rb +16 -3
- data/lib/datadog/version.rb +2 -2
- data/lib/datadog.rb +2 -3
- metadata +80 -19
- data/lib/datadog/appsec/contrib/devise/event.rb +0 -54
- data/lib/datadog/appsec/contrib/devise/patcher/authenticatable_patch.rb +0 -72
- data/lib/datadog/appsec/contrib/devise/patcher/registration_controller_patch.rb +0 -47
- data/lib/datadog/appsec/contrib/devise/resource.rb +0 -35
- data/lib/datadog/appsec/contrib/devise/tracking.rb +0 -57
- data/lib/datadog/appsec/utils/trace_operation.rb +0 -15
- data/lib/datadog/core/telemetry/http/env.rb +0 -20
- data/lib/datadog/core/telemetry/http/ext.rb +0 -28
- data/lib/datadog/core/telemetry/http/response.rb +0 -70
- data/lib/datadog/core/telemetry/http/transport.rb +0 -90
@@ -0,0 +1,90 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'trace/span'
|
4
|
+
require_relative '../../tracing/trace_operation'
|
5
|
+
require_relative '../trace'
|
6
|
+
|
7
|
+
module Datadog
|
8
|
+
module OpenTelemetry
|
9
|
+
module API
|
10
|
+
# The Baggage module provides an implementation of the OpenTelemetry Baggage API.
|
11
|
+
#
|
12
|
+
# Baggage is a set of name/value pairs describing user-defined properties that can be
|
13
|
+
# propagated through a distributed trace. This implementation follows the W3C Baggage
|
14
|
+
# specification and the OpenTelemetry Baggage API.
|
15
|
+
#
|
16
|
+
# @see https://www.w3.org/TR/baggage/
|
17
|
+
# @see https://opentelemetry.io/docs/specs/otel/baggage/api/
|
18
|
+
module Baggage
|
19
|
+
def initialize(trace: nil)
|
20
|
+
@trace = trace
|
21
|
+
end
|
22
|
+
|
23
|
+
# Returns a new context with empty baggage
|
24
|
+
#
|
25
|
+
# @param [optional Context] context Context to clear baggage from. Defaults
|
26
|
+
# to ::OpenTelemetry::Context.current
|
27
|
+
# @return [Context]
|
28
|
+
def clear(context: ::OpenTelemetry::Context.current)
|
29
|
+
context.ensure_trace.baggage.clear
|
30
|
+
context
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns the corresponding value for key
|
34
|
+
#
|
35
|
+
# @param [String] key The lookup key
|
36
|
+
# @param [optional Context] context The context from which to retrieve
|
37
|
+
# the key. Defaults to ::OpenTelemetry::Context.current
|
38
|
+
# @return [String, nil]
|
39
|
+
def value(key, context: ::OpenTelemetry::Context.current)
|
40
|
+
trace = context.ensure_trace
|
41
|
+
return nil if trace.nil?
|
42
|
+
|
43
|
+
trace.baggage && trace.baggage[key]
|
44
|
+
end
|
45
|
+
|
46
|
+
# Returns all baggage values
|
47
|
+
#
|
48
|
+
# @param [optional Context] context The context from which to retrieve
|
49
|
+
# the baggage. Defaults to ::OpenTelemetry::Context.current
|
50
|
+
# @return [Hash<String, String>]
|
51
|
+
def values(context: ::OpenTelemetry::Context.current)
|
52
|
+
trace = context.ensure_trace
|
53
|
+
return {} if trace.nil?
|
54
|
+
|
55
|
+
trace.baggage ? trace.baggage.dup : {}
|
56
|
+
end
|
57
|
+
|
58
|
+
# Returns a new context with new key-value pair
|
59
|
+
#
|
60
|
+
# @param [String] key The key to store this value under
|
61
|
+
# @param [String] value String value to be stored under key
|
62
|
+
# @param [optional String] metadata This is here to store properties
|
63
|
+
# received from other W3C Baggage implementations but is not exposed in
|
64
|
+
# OpenTelemetry. This is considered private API and not for use by
|
65
|
+
# end-users.
|
66
|
+
# @param [optional Context] context The context to update with new
|
67
|
+
# value. Defaults to ::OpenTelemetry::Context.current
|
68
|
+
# @return [Context]
|
69
|
+
def set_value(key, value, metadata: nil, context: ::OpenTelemetry::Context.current)
|
70
|
+
# Delegate to the context to set the value because an active trace is not guaranteed
|
71
|
+
# set_values handles this logic
|
72
|
+
context.set_values({ ::OpenTelemetry::Baggage.const_get(:BAGGAGE_KEY) => { key => value } })
|
73
|
+
end
|
74
|
+
|
75
|
+
# Returns a new context with value at key removed
|
76
|
+
#
|
77
|
+
# @param [String] key The key to remove
|
78
|
+
# @param [optional Context] context The context to remove baggage
|
79
|
+
# from. Defaults to ::OpenTelemetry::Context.current
|
80
|
+
# @return [Context]
|
81
|
+
def remove_value(key, context: ::OpenTelemetry::Context.current)
|
82
|
+
# Delegate to the context to remove the value because an active trace is not guaranteed
|
83
|
+
# set_values handles this logic
|
84
|
+
context.set_values({ Context::BAGGAGE_REMOVE_KEY => key })
|
85
|
+
end
|
86
|
+
::OpenTelemetry::Baggage.singleton_class.prepend(self)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Datadog
|
4
|
+
module OpenTelemetry
|
5
|
+
module API
|
6
|
+
module Baggage
|
7
|
+
def initialize: (?trace: Datadog::Tracing::TraceOperation?) -> void
|
8
|
+
|
9
|
+
# Returns a new context with empty baggage
|
10
|
+
def clear: (?context: OpenTelemetry::Context) -> OpenTelemetry::Context
|
11
|
+
|
12
|
+
# Returns the corresponding value for key
|
13
|
+
def value: (String key, ?context: OpenTelemetry::Context) -> String?
|
14
|
+
|
15
|
+
# Returns all baggage values
|
16
|
+
def values: (?context: OpenTelemetry::Context) -> Hash[String, String]
|
17
|
+
|
18
|
+
# Returns a new context with key-value pair
|
19
|
+
def set_value: (String key, String value, ?metadata: String?, ?context: OpenTelemetry::Context) -> OpenTelemetry::Context
|
20
|
+
|
21
|
+
# Returns a new context with value at key removed
|
22
|
+
def remove_value: (String key, ?context: OpenTelemetry::Context) -> OpenTelemetry::Context
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -21,11 +21,13 @@ module Datadog
|
|
21
21
|
module Context
|
22
22
|
CURRENT_SPAN_KEY = ::OpenTelemetry::Trace.const_get(:CURRENT_SPAN_KEY)
|
23
23
|
private_constant :CURRENT_SPAN_KEY
|
24
|
+
BAGGAGE_REMOVE_KEY = Object.new # sentinel object to indicate the deletion of a value in baggage
|
24
25
|
|
25
|
-
def initialize(entries, trace: nil)
|
26
|
+
def initialize(entries, trace: nil, baggage: nil)
|
26
27
|
@trace = trace || ::Datadog::Tracing.send(:tracer).send(:start_trace)
|
27
28
|
@trace.otel_values.merge!(entries) if entries
|
28
29
|
@trace.otel_context ||= self
|
30
|
+
@trace.baggage = baggage if baggage
|
29
31
|
end
|
30
32
|
|
31
33
|
# Because Context can be reused, we have to make sure we have
|
@@ -79,8 +81,20 @@ module Datadog
|
|
79
81
|
end
|
80
82
|
|
81
83
|
existing_values = @trace && @trace.otel_values || {}
|
84
|
+
existing_baggage = @trace && @trace.baggage || {}
|
82
85
|
|
83
|
-
|
86
|
+
# Retrieve the baggage removal sentinel and remove it from the values hash
|
87
|
+
existing_baggage.delete(values[BAGGAGE_REMOVE_KEY]) if values.key?(BAGGAGE_REMOVE_KEY)
|
88
|
+
|
89
|
+
# If the values hash contains a BAGGAGE_KEY, merge its contents with existing baggage
|
90
|
+
# Otherwise, keep the existing baggage unchanged
|
91
|
+
new_baggage = if values.key?(::OpenTelemetry::Baggage.const_get(:BAGGAGE_KEY))
|
92
|
+
existing_baggage.merge(values[::OpenTelemetry::Baggage.const_get(:BAGGAGE_KEY)])
|
93
|
+
else
|
94
|
+
existing_baggage
|
95
|
+
end
|
96
|
+
|
97
|
+
::OpenTelemetry::Context.new(existing_values.merge(values), trace: trace, baggage: new_baggage)
|
84
98
|
end
|
85
99
|
|
86
100
|
# The Datadog {TraceOperation} associated with this {Context}.
|
@@ -45,7 +45,7 @@ module Datadog
|
|
45
45
|
def add_attributes(attributes)
|
46
46
|
res = super
|
47
47
|
# Attributes can get dropped or their values truncated by `super`
|
48
|
-
attributes.
|
48
|
+
attributes.each_key { |key| datadog_set_attribute(key) }
|
49
49
|
res
|
50
50
|
end
|
51
51
|
|
@@ -13,6 +13,7 @@ require_relative 'tracing'
|
|
13
13
|
require_relative 'tracing/contrib'
|
14
14
|
|
15
15
|
require_relative 'opentelemetry/api/context'
|
16
|
+
require_relative 'opentelemetry/api/baggage'
|
16
17
|
|
17
18
|
# DEV: Should this be a Contrib integration, that depends on the `opentelemetry-sdk`
|
18
19
|
# DEV: and checks for compatibility?
|
@@ -29,7 +30,7 @@ module Datadog
|
|
29
30
|
|
30
31
|
# Use `Datadog.logger` as the default logger
|
31
32
|
def logger
|
32
|
-
|
33
|
+
::Datadog.logger
|
33
34
|
end
|
34
35
|
|
35
36
|
::OpenTelemetry.singleton_class.prepend(self)
|
@@ -31,6 +31,9 @@ module Datadog
|
|
31
31
|
# Instead of trying to figure out real process start time by checking
|
32
32
|
# /proc or some other complex/non-portable way, approximate start time
|
33
33
|
# by time of requirement of this file.
|
34
|
+
#
|
35
|
+
# Note: this does not use Core::Utils::Time.now because this constant
|
36
|
+
# gets initialized before a user has a chance to configure the library.
|
34
37
|
START_TIME = Time.now.utc.freeze
|
35
38
|
|
36
39
|
def collect_platform_info
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Datadog
|
4
|
+
module Profiling
|
5
|
+
# This class exists to wrap a ddog_prof_EncodedProfile into a Ruby object
|
6
|
+
#
|
7
|
+
# This class is not empty; all of this class is implemented as native code.
|
8
|
+
class EncodedProfile # rubocop:disable Lint/EmptyClass
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -49,7 +49,7 @@ module Datadog
|
|
49
49
|
@internal_metadata = internal_metadata
|
50
50
|
# NOTE: At the time of this comment collected info does not change over time so we'll hardcode
|
51
51
|
# it on startup to prevent serializing the same info on every flush.
|
52
|
-
@info_json = JSON.
|
52
|
+
@info_json = JSON.generate(info_collector.info).freeze
|
53
53
|
end
|
54
54
|
|
55
55
|
def flush
|
@@ -57,7 +57,7 @@ module Datadog
|
|
57
57
|
serialization_result = pprof_recorder.serialize
|
58
58
|
return if serialization_result.nil?
|
59
59
|
|
60
|
-
start, finish,
|
60
|
+
start, finish, encoded_profile, profile_stats = serialization_result
|
61
61
|
@last_flush_finish_at = finish
|
62
62
|
|
63
63
|
if duration_below_threshold?(start, finish)
|
@@ -70,8 +70,7 @@ module Datadog
|
|
70
70
|
Flush.new(
|
71
71
|
start: start,
|
72
72
|
finish: finish,
|
73
|
-
|
74
|
-
pprof_data: compressed_pprof.to_s,
|
73
|
+
encoded_profile: encoded_profile,
|
75
74
|
code_provenance_file_name: Datadog::Profiling::Ext::Transport::HTTP::CODE_PROVENANCE_FILENAME,
|
76
75
|
code_provenance_data: uncompressed_code_provenance,
|
77
76
|
tags_as_array: Datadog::Profiling::TagBuilder.call(settings: Datadog.configuration).to_a,
|
@@ -19,14 +19,12 @@ module Datadog
|
|
19
19
|
FORM_FIELD_TAG_RUNTIME = "runtime"
|
20
20
|
FORM_FIELD_TAG_RUNTIME_ENGINE = "runtime_engine"
|
21
21
|
FORM_FIELD_TAG_RUNTIME_ID = "runtime-id"
|
22
|
-
FORM_FIELD_TAG_RUNTIME_PLATFORM = "runtime_platform"
|
23
22
|
FORM_FIELD_TAG_RUNTIME_VERSION = "runtime_version"
|
24
23
|
FORM_FIELD_TAG_SERVICE = "service"
|
25
24
|
FORM_FIELD_TAG_VERSION = "version"
|
26
25
|
TAG_GIT_REPOSITORY_URL = "git.repository_url"
|
27
26
|
TAG_GIT_COMMIT_SHA = "git.commit.sha"
|
28
27
|
|
29
|
-
PPROF_DEFAULT_FILENAME = "rubyprofile.pprof"
|
30
28
|
CODE_PROVENANCE_FILENAME = "code-provenance.json"
|
31
29
|
end
|
32
30
|
end
|
@@ -9,10 +9,9 @@ module Datadog
|
|
9
9
|
attr_reader \
|
10
10
|
:start,
|
11
11
|
:finish,
|
12
|
-
:
|
13
|
-
:pprof_data, # gzipped pprof bytes
|
12
|
+
:encoded_profile,
|
14
13
|
:code_provenance_file_name,
|
15
|
-
:code_provenance_data,
|
14
|
+
:code_provenance_data,
|
16
15
|
:tags_as_array,
|
17
16
|
:internal_metadata_json,
|
18
17
|
:info_json
|
@@ -20,8 +19,7 @@ module Datadog
|
|
20
19
|
def initialize(
|
21
20
|
start:,
|
22
21
|
finish:,
|
23
|
-
|
24
|
-
pprof_data:,
|
22
|
+
encoded_profile:,
|
25
23
|
code_provenance_file_name:,
|
26
24
|
code_provenance_data:,
|
27
25
|
tags_as_array:,
|
@@ -30,12 +28,11 @@ module Datadog
|
|
30
28
|
)
|
31
29
|
@start = start
|
32
30
|
@finish = finish
|
33
|
-
@
|
34
|
-
@pprof_data = pprof_data
|
31
|
+
@encoded_profile = encoded_profile
|
35
32
|
@code_provenance_file_name = code_provenance_file_name
|
36
33
|
@code_provenance_data = code_provenance_data
|
37
34
|
@tags_as_array = tags_as_array
|
38
|
-
@internal_metadata_json = JSON.
|
35
|
+
@internal_metadata_json = JSON.generate(internal_metadata)
|
39
36
|
@info_json = info_json
|
40
37
|
end
|
41
38
|
end
|
@@ -20,34 +20,16 @@ module Datadog
|
|
20
20
|
[:agent, agent_settings.url].freeze
|
21
21
|
end
|
22
22
|
|
23
|
-
status, result =
|
23
|
+
status, result = self.class._native_validate_exporter(exporter_configuration)
|
24
24
|
|
25
25
|
raise(ArgumentError, "Failed to initialize transport: #{result}") if status == :error
|
26
26
|
end
|
27
27
|
|
28
28
|
def export(flush)
|
29
|
-
status, result =
|
30
|
-
exporter_configuration
|
31
|
-
|
32
|
-
|
33
|
-
# why "timespec"?
|
34
|
-
# libdatadog represents time using POSIX's struct timespec, see
|
35
|
-
# https://www.gnu.org/software/libc/manual/html_node/Time-Types.html
|
36
|
-
# aka it represents the seconds part separate from the nanoseconds part
|
37
|
-
start_timespec_seconds: flush.start.tv_sec,
|
38
|
-
start_timespec_nanoseconds: flush.start.tv_nsec,
|
39
|
-
finish_timespec_seconds: flush.finish.tv_sec,
|
40
|
-
finish_timespec_nanoseconds: flush.finish.tv_nsec,
|
41
|
-
|
42
|
-
pprof_file_name: flush.pprof_file_name,
|
43
|
-
pprof_data: flush.pprof_data,
|
44
|
-
code_provenance_file_name: flush.code_provenance_file_name,
|
45
|
-
code_provenance_data: flush.code_provenance_data,
|
46
|
-
|
47
|
-
tags_as_array: flush.tags_as_array,
|
48
|
-
internal_metadata_json: flush.internal_metadata_json,
|
49
|
-
|
50
|
-
info_json: flush.info_json
|
29
|
+
status, result = self.class._native_do_export(
|
30
|
+
exporter_configuration,
|
31
|
+
@upload_timeout_milliseconds,
|
32
|
+
flush
|
51
33
|
)
|
52
34
|
|
53
35
|
if status == :ok
|
@@ -77,42 +59,6 @@ module Datadog
|
|
77
59
|
site && api_key && Core::Environment::VariableHelpers.env_to_bool(Profiling::Ext::ENV_AGENTLESS, false)
|
78
60
|
end
|
79
61
|
|
80
|
-
def validate_exporter(exporter_configuration)
|
81
|
-
self.class._native_validate_exporter(exporter_configuration)
|
82
|
-
end
|
83
|
-
|
84
|
-
def do_export(
|
85
|
-
exporter_configuration:,
|
86
|
-
upload_timeout_milliseconds:,
|
87
|
-
start_timespec_seconds:,
|
88
|
-
start_timespec_nanoseconds:,
|
89
|
-
finish_timespec_seconds:,
|
90
|
-
finish_timespec_nanoseconds:,
|
91
|
-
pprof_file_name:,
|
92
|
-
pprof_data:,
|
93
|
-
code_provenance_file_name:,
|
94
|
-
code_provenance_data:,
|
95
|
-
tags_as_array:,
|
96
|
-
internal_metadata_json:,
|
97
|
-
info_json:
|
98
|
-
)
|
99
|
-
self.class._native_do_export(
|
100
|
-
exporter_configuration,
|
101
|
-
upload_timeout_milliseconds,
|
102
|
-
start_timespec_seconds,
|
103
|
-
start_timespec_nanoseconds,
|
104
|
-
finish_timespec_seconds,
|
105
|
-
finish_timespec_nanoseconds,
|
106
|
-
pprof_file_name,
|
107
|
-
pprof_data,
|
108
|
-
code_provenance_file_name,
|
109
|
-
code_provenance_data,
|
110
|
-
tags_as_array,
|
111
|
-
internal_metadata_json,
|
112
|
-
info_json,
|
113
|
-
)
|
114
|
-
end
|
115
|
-
|
116
62
|
def config_without_api_key
|
117
63
|
"#{exporter_configuration[0]}: #{exporter_configuration[1]}"
|
118
64
|
end
|
@@ -37,6 +37,7 @@ module Datadog
|
|
37
37
|
@exporter = exporter
|
38
38
|
@transport = transport
|
39
39
|
@profiler_failed = false
|
40
|
+
@stop_requested = false
|
40
41
|
|
41
42
|
# Workers::Async::Thread settings
|
42
43
|
self.fork_policy = fork_policy
|
@@ -88,7 +89,7 @@ module Datadog
|
|
88
89
|
end
|
89
90
|
|
90
91
|
def work_pending?
|
91
|
-
!profiler_failed && exporter.can_flush?
|
92
|
+
!profiler_failed && exporter.can_flush? && (run_loop? || !stop_requested?)
|
92
93
|
end
|
93
94
|
|
94
95
|
def reset_after_fork
|
@@ -138,8 +139,14 @@ module Datadog
|
|
138
139
|
Datadog::Core::Telemetry::Logger.report(e, description: "Unable to report profile")
|
139
140
|
end
|
140
141
|
|
142
|
+
@stop_requested = !run_loop?
|
143
|
+
|
141
144
|
true
|
142
145
|
end
|
146
|
+
|
147
|
+
def stop_requested?
|
148
|
+
@stop_requested
|
149
|
+
end
|
143
150
|
end
|
144
151
|
end
|
145
152
|
end
|
@@ -63,11 +63,11 @@ module Datadog
|
|
63
63
|
status, result = @no_concurrent_synchronize_mutex.synchronize { self.class._native_serialize(self) }
|
64
64
|
|
65
65
|
if status == :ok
|
66
|
-
start, finish,
|
66
|
+
start, finish, encoded_profile, profile_stats = result
|
67
67
|
|
68
68
|
Datadog.logger.debug { "Encoded profile covering #{start.iso8601} to #{finish.iso8601}" }
|
69
69
|
|
70
|
-
[start, finish,
|
70
|
+
[start, finish, encoded_profile, profile_stats]
|
71
71
|
else
|
72
72
|
error_message = result
|
73
73
|
|
@@ -82,9 +82,9 @@ module Datadog
|
|
82
82
|
status, result = @no_concurrent_synchronize_mutex.synchronize { self.class._native_serialize(self) }
|
83
83
|
|
84
84
|
if status == :ok
|
85
|
-
_start, _finish,
|
85
|
+
_start, _finish, encoded_profile = result
|
86
86
|
|
87
|
-
|
87
|
+
encoded_profile
|
88
88
|
else
|
89
89
|
error_message = result
|
90
90
|
|
@@ -19,12 +19,9 @@ module Datadog
|
|
19
19
|
host: Core::Environment::Socket.hostname,
|
20
20
|
language: Core::Environment::Identity.lang,
|
21
21
|
pid: Process.pid.to_s,
|
22
|
-
# TODO: If profiling is extracted and its version diverges from the datadog gem, this is inaccurate.
|
23
|
-
# Update if this ever occurs.
|
24
22
|
profiler_version: Core::Environment::Identity.gem_datadog_version,
|
25
23
|
runtime_engine: Core::Environment::Identity.lang_engine,
|
26
24
|
runtime_id: Core::Environment::Identity.id,
|
27
|
-
runtime_platform: Core::Environment::Identity.lang_platform,
|
28
25
|
runtime_version: Core::Environment::Identity.lang_version,
|
29
26
|
git_repository_url: Core::Environment::Git.git_repository_url,
|
30
27
|
git_commit_sha: Core::Environment::Git.git_commit_sha,
|
@@ -41,7 +38,6 @@ module Datadog
|
|
41
38
|
FORM_FIELD_TAG_RUNTIME => language, # This is known to be repeated from language, above
|
42
39
|
FORM_FIELD_TAG_RUNTIME_ENGINE => runtime_engine,
|
43
40
|
FORM_FIELD_TAG_RUNTIME_ID => runtime_id,
|
44
|
-
FORM_FIELD_TAG_RUNTIME_PLATFORM => runtime_platform,
|
45
41
|
FORM_FIELD_TAG_RUNTIME_VERSION => runtime_version,
|
46
42
|
}
|
47
43
|
tags[FORM_FIELD_TAG_ENV] = env if env
|
@@ -50,7 +46,7 @@ module Datadog
|
|
50
46
|
tags[TAG_GIT_REPOSITORY_URL] = git_repository_url if git_repository_url
|
51
47
|
tags[TAG_GIT_COMMIT_SHA] = git_commit_sha if git_commit_sha
|
52
48
|
|
53
|
-
# Make sure everything is an utf-8 string, to avoid encoding issues in native code/
|
49
|
+
# Make sure everything is an utf-8 string, to avoid encoding issues in native code/further downstream
|
54
50
|
user_tags.merge(tags).map do |key, value|
|
55
51
|
[Datadog::Core::Utils.utf8_encode(key), Datadog::Core::Utils.utf8_encode(value)]
|
56
52
|
end.to_h
|
data/lib/datadog/profiling.rb
CHANGED
@@ -78,8 +78,11 @@ module Datadog
|
|
78
78
|
end
|
79
79
|
|
80
80
|
private_class_method def self.replace_noop_allocation_count
|
81
|
-
|
82
|
-
|
81
|
+
class << self
|
82
|
+
remove_method :allocation_count
|
83
|
+
def allocation_count
|
84
|
+
Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_allocation_count
|
85
|
+
end
|
83
86
|
end
|
84
87
|
end
|
85
88
|
|
@@ -146,6 +149,7 @@ module Datadog
|
|
146
149
|
require_relative 'profiling/collectors/thread_context'
|
147
150
|
require_relative 'profiling/stack_recorder'
|
148
151
|
require_relative 'profiling/exporter'
|
152
|
+
require_relative 'profiling/encoded_profile'
|
149
153
|
require_relative 'profiling/flush'
|
150
154
|
require_relative 'profiling/scheduler'
|
151
155
|
require_relative 'profiling/tasks/setup'
|
@@ -16,7 +16,7 @@ module Datadog
|
|
16
16
|
def set_measured(span_op, value = true)
|
17
17
|
return if span_op.nil?
|
18
18
|
|
19
|
-
value = value == true || value == 1 ? 1 : 0
|
19
|
+
value = value == true || value == 1 ? 1 : 0
|
20
20
|
span_op.set_metric(Metadata::Ext::Analytics::TAG_MEASURED, value)
|
21
21
|
end
|
22
22
|
end
|
@@ -6,6 +6,7 @@ require_relative 'sync_writer'
|
|
6
6
|
require_relative 'sampling/span/rule_parser'
|
7
7
|
require_relative 'sampling/span/sampler'
|
8
8
|
require_relative 'diagnostics/environment_logger'
|
9
|
+
require_relative 'contrib/component'
|
9
10
|
|
10
11
|
module Datadog
|
11
12
|
module Tracing
|
@@ -74,18 +75,11 @@ module Datadog
|
|
74
75
|
return sampler
|
75
76
|
end
|
76
77
|
|
77
|
-
#
|
78
|
-
#
|
79
|
-
#
|
80
|
-
#
|
81
|
-
|
82
|
-
if settings.appsec.standalone.enabled
|
83
|
-
post_sampler = Tracing::Sampling::RuleSampler.new(
|
84
|
-
[Tracing::Sampling::SimpleRule.new(sample_rate: 1.0)],
|
85
|
-
rate_limiter: Datadog::Core::TokenBucket.new(1.0 / 60, 1.0),
|
86
|
-
default_sample_rate: 1.0 / 60
|
87
|
-
)
|
88
|
-
end
|
78
|
+
# APM Disablement means that we don't want to send traces that only contains APM data.
|
79
|
+
# Other products can then put the sampling priority to MANUAL_KEEP if they want to keep traces.
|
80
|
+
# (e.g.: AppSec will MANUAL_KEEP traces with AppSec events) and clients will be billed only for those traces.
|
81
|
+
# But to keep the service alive on the backend side, we need to send one trace per minute.
|
82
|
+
post_sampler = build_rate_limit_post_sampler(seconds: 60) unless settings.apm.tracing.enabled
|
89
83
|
|
90
84
|
# Sampling rules are provided
|
91
85
|
if (rules = settings.tracing.sampling.rules)
|
@@ -197,6 +191,15 @@ module Datadog
|
|
197
191
|
end
|
198
192
|
end
|
199
193
|
|
194
|
+
# Build a post-sampler that limits the rate of traces to one per `seconds`.
|
195
|
+
# E.g.: `build_rate_limit_post_sampler(seconds: 60)` will limit the rate to one trace per minute.
|
196
|
+
def build_rate_limit_post_sampler(seconds:)
|
197
|
+
Tracing::Sampling::RuleSampler.new(
|
198
|
+
rate_limiter: Datadog::Core::TokenBucket.new(1.0 / seconds, 1.0),
|
199
|
+
default_sample_rate: 1.0
|
200
|
+
)
|
201
|
+
end
|
202
|
+
|
200
203
|
def build_test_mode_trace_flush(settings)
|
201
204
|
# If context flush behavior is provided, use it instead.
|
202
205
|
settings.tracing.test_mode.trace_flush || build_trace_flush(settings)
|
@@ -12,6 +12,7 @@ module Datadog
|
|
12
12
|
ENV_OTEL_TRACES_EXPORTER = 'OTEL_TRACES_EXPORTER'
|
13
13
|
ENV_HEADER_TAGS = 'DD_TRACE_HEADER_TAGS'
|
14
14
|
ENV_TRACE_ID_128_BIT_GENERATION_ENABLED = 'DD_TRACE_128_BIT_TRACEID_GENERATION_ENABLED'
|
15
|
+
ENV_NATIVE_SPAN_EVENTS = 'DD_TRACE_NATIVE_SPAN_EVENTS'
|
15
16
|
|
16
17
|
# @public_api
|
17
18
|
module SpanAttributeSchema
|
@@ -41,8 +42,13 @@ module Datadog
|
|
41
42
|
# W3C Trace Context
|
42
43
|
PROPAGATION_STYLE_TRACE_CONTEXT = 'tracecontext'
|
43
44
|
|
45
|
+
# W3C Baggage
|
46
|
+
# @see https://www.w3.org/TR/baggage/
|
47
|
+
PROPAGATION_STYLE_BAGGAGE = 'baggage'
|
48
|
+
|
44
49
|
PROPAGATION_STYLE_SUPPORTED = [PROPAGATION_STYLE_DATADOG, PROPAGATION_STYLE_B3_MULTI_HEADER,
|
45
|
-
PROPAGATION_STYLE_B3_SINGLE_HEADER, PROPAGATION_STYLE_TRACE_CONTEXT
|
50
|
+
PROPAGATION_STYLE_B3_SINGLE_HEADER, PROPAGATION_STYLE_TRACE_CONTEXT,
|
51
|
+
PROPAGATION_STYLE_BAGGAGE].freeze
|
46
52
|
|
47
53
|
# Sets both extract and inject propagation style tho the provided value.
|
48
54
|
# Has lower precedence than `DD_TRACE_PROPAGATION_STYLE_INJECT` or
|
@@ -42,7 +42,7 @@ module Datadog
|
|
42
42
|
#
|
43
43
|
# The tracer will try to find distributed headers in the order they are present in the list provided to this option.
|
44
44
|
# The first format to have valid data present will be used.
|
45
|
-
#
|
45
|
+
# Baggage style is a special case, as it will always be extracted in addition if present.
|
46
46
|
# @default `DD_TRACE_PROPAGATION_STYLE_EXTRACT` environment variable (comma-separated list),
|
47
47
|
# otherwise `['datadog','b3multi','b3']`.
|
48
48
|
# @return [Array<String>]
|
@@ -53,6 +53,7 @@ module Datadog
|
|
53
53
|
[
|
54
54
|
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_DATADOG,
|
55
55
|
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_TRACE_CONTEXT,
|
56
|
+
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_BAGGAGE,
|
56
57
|
]
|
57
58
|
)
|
58
59
|
o.after_set do |styles|
|
@@ -74,6 +75,7 @@ module Datadog
|
|
74
75
|
o.default [
|
75
76
|
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_DATADOG,
|
76
77
|
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_TRACE_CONTEXT,
|
78
|
+
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_BAGGAGE,
|
77
79
|
]
|
78
80
|
o.after_set do |styles|
|
79
81
|
# Make values case-insensitive
|
@@ -186,7 +188,7 @@ module Datadog
|
|
186
188
|
# It is not supported by our backend yet. Do not enable it.
|
187
189
|
option :trace_id_128_bit_logging_enabled do |o|
|
188
190
|
o.env Tracing::Configuration::Ext::Correlation::ENV_TRACE_ID_128_BIT_LOGGING_ENABLED
|
189
|
-
o.default
|
191
|
+
o.default true
|
190
192
|
o.type :bool
|
191
193
|
end
|
192
194
|
|
@@ -249,6 +251,20 @@ module Datadog
|
|
249
251
|
o.type :bool
|
250
252
|
end
|
251
253
|
|
254
|
+
# Forces the tracer to always send span events with the native span events format
|
255
|
+
# regardless of the agent support. This is useful in agent-less setups.
|
256
|
+
#
|
257
|
+
# When set to `nil`, the default, the agent will be queried for
|
258
|
+
# native span events support.
|
259
|
+
#
|
260
|
+
# @default `DD_TRACE_NATIVE_SPAN_EVENTS` environment variable, otherwise `false`
|
261
|
+
# @return [Boolean,nil]
|
262
|
+
option :native_span_events do |o|
|
263
|
+
o.env Tracing::Configuration::Ext::ENV_NATIVE_SPAN_EVENTS
|
264
|
+
o.default nil
|
265
|
+
o.type :bool, nilable: true
|
266
|
+
end
|
267
|
+
|
252
268
|
# A custom sampler instance.
|
253
269
|
# The object must respect the {Datadog::Tracing::Sampling::Sampler} interface.
|
254
270
|
# @default `nil`
|
@@ -49,7 +49,7 @@ module Datadog
|
|
49
49
|
# To support multiple tracers simultaneously, each {Datadog::Tracing::FiberLocalContext}
|
50
50
|
# instance has its own fiber-local variable.
|
51
51
|
def initialize
|
52
|
-
@key = "datadog_context_#{FiberLocalContext.next_instance_id}"
|
52
|
+
@key = :"datadog_context_#{FiberLocalContext.next_instance_id}"
|
53
53
|
|
54
54
|
self.local = Context.new
|
55
55
|
end
|