ddtrace 0.35.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +22 -0
- data/.gitignore +16 -17
- data/CHANGELOG.md +1969 -293
- data/CONTRIBUTING.md +3 -7
- data/LICENSE-3rdparty.csv +4 -0
- data/README.md +5 -0
- data/bin/ddtracerb +15 -0
- data/ddtrace.gemspec +34 -32
- data/docs/0.x-trace.png +0 -0
- data/docs/1.0-trace.png +0 -0
- data/docs/AutoInstrumentation.md +36 -0
- data/docs/Deprecation.md +8 -0
- data/docs/DevelopmentGuide.md +73 -9
- data/docs/GettingStarted.md +989 -496
- data/docs/ProfilingDevelopment.md +110 -0
- data/docs/PublicApi.md +14 -0
- data/docs/UpgradeGuide.md +736 -0
- data/ext/ddtrace_profiling_loader/ddtrace_profiling_loader.c +118 -0
- data/ext/ddtrace_profiling_loader/extconf.rb +53 -0
- data/ext/ddtrace_profiling_native_extension/NativeExtensionDesign.md +112 -0
- data/ext/ddtrace_profiling_native_extension/clock_id.h +4 -0
- data/ext/ddtrace_profiling_native_extension/clock_id_from_pthread.c +44 -0
- data/ext/ddtrace_profiling_native_extension/clock_id_noop.c +14 -0
- data/ext/ddtrace_profiling_native_extension/collectors_stack.c +278 -0
- data/ext/ddtrace_profiling_native_extension/extconf.rb +176 -0
- data/ext/ddtrace_profiling_native_extension/libddprof_helpers.h +13 -0
- data/ext/ddtrace_profiling_native_extension/native_extension_helpers.rb +186 -0
- data/ext/ddtrace_profiling_native_extension/private_vm_api_access.c +607 -0
- data/ext/ddtrace_profiling_native_extension/private_vm_api_access.h +33 -0
- data/ext/ddtrace_profiling_native_extension/profiling.c +31 -0
- data/ext/ddtrace_profiling_native_extension/stack_recorder.c +139 -0
- data/ext/ddtrace_profiling_native_extension/stack_recorder.h +28 -0
- data/lib/datadog/appsec/assets/blocked.html +4 -0
- data/lib/datadog/appsec/assets/waf_rules/README.md +7 -0
- data/lib/datadog/appsec/assets/waf_rules/recommended.json +5638 -0
- data/lib/datadog/appsec/assets/waf_rules/risky.json +1499 -0
- data/lib/datadog/appsec/assets/waf_rules/strict.json +1298 -0
- data/lib/datadog/appsec/assets.rb +38 -0
- data/lib/datadog/appsec/autoload.rb +16 -0
- data/lib/datadog/appsec/configuration/settings.rb +194 -0
- data/lib/datadog/appsec/configuration.rb +80 -0
- data/lib/datadog/appsec/contrib/auto_instrument.rb +29 -0
- data/lib/datadog/appsec/contrib/configuration/settings.rb +20 -0
- data/lib/datadog/appsec/contrib/integration.rb +37 -0
- data/lib/datadog/appsec/contrib/patcher.rb +12 -0
- data/lib/datadog/appsec/contrib/rack/configuration/settings.rb +22 -0
- data/lib/datadog/appsec/contrib/rack/ext.rb +15 -0
- data/lib/datadog/appsec/contrib/rack/gateway/watcher.rb +169 -0
- data/lib/datadog/appsec/contrib/rack/integration.rb +49 -0
- data/lib/datadog/appsec/contrib/rack/patcher.rb +32 -0
- data/lib/datadog/appsec/contrib/rack/reactive/request.rb +87 -0
- data/lib/datadog/appsec/contrib/rack/reactive/request_body.rb +64 -0
- data/lib/datadog/appsec/contrib/rack/reactive/response.rb +64 -0
- data/lib/datadog/appsec/contrib/rack/request.rb +58 -0
- data/lib/datadog/appsec/contrib/rack/request_body_middleware.rb +41 -0
- data/lib/datadog/appsec/contrib/rack/request_middleware.rb +112 -0
- data/lib/datadog/appsec/contrib/rack/response.rb +24 -0
- data/lib/datadog/appsec/contrib/rails/configuration/settings.rb +22 -0
- data/lib/datadog/appsec/contrib/rails/ext.rb +15 -0
- data/lib/datadog/appsec/contrib/rails/framework.rb +30 -0
- data/lib/datadog/appsec/contrib/rails/gateway/watcher.rb +81 -0
- data/lib/datadog/appsec/contrib/rails/integration.rb +48 -0
- data/lib/datadog/appsec/contrib/rails/patcher.rb +158 -0
- data/lib/datadog/appsec/contrib/rails/reactive/action.rb +68 -0
- data/lib/datadog/appsec/contrib/rails/request.rb +33 -0
- data/lib/datadog/appsec/contrib/rails/request_middleware.rb +20 -0
- data/lib/datadog/appsec/contrib/sinatra/configuration/settings.rb +22 -0
- data/lib/datadog/appsec/contrib/sinatra/ext.rb +15 -0
- data/lib/datadog/appsec/contrib/sinatra/framework.rb +34 -0
- data/lib/datadog/appsec/contrib/sinatra/gateway/watcher.rb +124 -0
- data/lib/datadog/appsec/contrib/sinatra/integration.rb +48 -0
- data/lib/datadog/appsec/contrib/sinatra/patcher.rb +144 -0
- data/lib/datadog/appsec/contrib/sinatra/reactive/routed.rb +63 -0
- data/lib/datadog/appsec/contrib/sinatra/request_middleware.rb +20 -0
- data/lib/datadog/appsec/event.rb +121 -0
- data/lib/datadog/appsec/extensions.rb +118 -0
- data/lib/datadog/appsec/instrumentation/gateway.rb +44 -0
- data/lib/datadog/appsec/processor.rb +164 -0
- data/lib/datadog/appsec/rate_limiter.rb +60 -0
- data/lib/datadog/appsec/reactive/address_hash.rb +18 -0
- data/lib/datadog/appsec/reactive/engine.rb +44 -0
- data/lib/datadog/appsec/reactive/operation.rb +51 -0
- data/lib/datadog/appsec/reactive/subscriber.rb +18 -0
- data/lib/datadog/appsec.rb +23 -0
- data/lib/datadog/ci/configuration/components.rb +32 -0
- data/lib/datadog/ci/configuration/settings.rb +53 -0
- data/lib/datadog/ci/contrib/cucumber/configuration/settings.rb +33 -0
- data/lib/datadog/ci/contrib/cucumber/ext.rb +22 -0
- data/lib/datadog/ci/contrib/cucumber/formatter.rb +94 -0
- data/lib/datadog/ci/contrib/cucumber/instrumentation.rb +28 -0
- data/lib/datadog/ci/contrib/cucumber/integration.rb +49 -0
- data/lib/datadog/ci/contrib/cucumber/patcher.rb +27 -0
- data/lib/datadog/ci/contrib/rspec/configuration/settings.rb +33 -0
- data/lib/datadog/ci/contrib/rspec/example.rb +70 -0
- data/lib/datadog/ci/contrib/rspec/ext.rb +21 -0
- data/lib/datadog/ci/contrib/rspec/integration.rb +50 -0
- data/lib/datadog/ci/contrib/rspec/patcher.rb +27 -0
- data/lib/datadog/ci/ext/app_types.rb +11 -0
- data/lib/datadog/ci/ext/environment.rb +503 -0
- data/lib/datadog/ci/ext/settings.rb +12 -0
- data/lib/datadog/ci/ext/test.rb +37 -0
- data/lib/datadog/ci/extensions.rb +19 -0
- data/lib/datadog/ci/flush.rb +38 -0
- data/lib/datadog/ci/test.rb +83 -0
- data/lib/datadog/ci.rb +20 -0
- data/lib/datadog/core/buffer/cruby.rb +55 -0
- data/lib/datadog/core/buffer/random.rb +134 -0
- data/lib/datadog/core/buffer/thread_safe.rb +58 -0
- data/lib/datadog/core/chunker.rb +35 -0
- data/lib/datadog/core/configuration/agent_settings_resolver.rb +365 -0
- data/lib/datadog/core/configuration/base.rb +89 -0
- data/lib/datadog/core/configuration/components.rb +411 -0
- data/lib/datadog/core/configuration/dependency_resolver.rb +28 -0
- data/lib/datadog/core/configuration/option.rb +69 -0
- data/lib/datadog/core/configuration/option_definition.rb +126 -0
- data/lib/datadog/core/configuration/option_definition_set.rb +22 -0
- data/lib/datadog/core/configuration/option_set.rb +10 -0
- data/lib/datadog/core/configuration/options.rb +118 -0
- data/lib/datadog/core/configuration/settings.rb +618 -0
- data/lib/datadog/core/configuration.rb +286 -0
- data/lib/datadog/core/diagnostics/environment_logger.rb +283 -0
- data/lib/datadog/core/diagnostics/ext.rb +41 -0
- data/lib/datadog/core/diagnostics/health.rb +37 -0
- data/lib/datadog/core/encoding.rb +76 -0
- data/lib/datadog/core/environment/cgroup.rb +55 -0
- data/lib/datadog/core/environment/class_count.rb +21 -0
- data/lib/datadog/core/environment/container.rb +93 -0
- data/lib/datadog/core/environment/ext.rb +46 -0
- data/lib/datadog/core/environment/gc.rb +20 -0
- data/lib/datadog/core/environment/identity.rb +58 -0
- data/lib/datadog/core/environment/socket.rb +24 -0
- data/lib/datadog/core/environment/thread_count.rb +20 -0
- data/lib/datadog/core/environment/variable_helpers.rb +68 -0
- data/lib/datadog/core/environment/vm_cache.rb +47 -0
- data/lib/datadog/core/error.rb +101 -0
- data/lib/datadog/core/extensions.rb +16 -0
- data/lib/datadog/core/git/ext.rb +35 -0
- data/lib/datadog/core/logger.rb +46 -0
- data/lib/datadog/core/logging/ext.rb +11 -0
- data/lib/datadog/core/metrics/client.rb +198 -0
- data/lib/datadog/core/metrics/ext.rb +20 -0
- data/lib/datadog/core/metrics/helpers.rb +25 -0
- data/lib/datadog/core/metrics/logging.rb +44 -0
- data/lib/datadog/core/metrics/metric.rb +14 -0
- data/lib/datadog/core/metrics/options.rb +50 -0
- data/lib/datadog/core/pin.rb +75 -0
- data/lib/datadog/core/runtime/ext.rb +28 -0
- data/lib/datadog/core/runtime/metrics.rb +126 -0
- data/lib/datadog/core/utils/compression.rb +32 -0
- data/lib/datadog/core/utils/forking.rb +63 -0
- data/lib/datadog/core/utils/object_set.rb +43 -0
- data/lib/datadog/core/utils/only_once.rb +44 -0
- data/lib/datadog/core/utils/safe_dup.rb +27 -0
- data/lib/datadog/core/utils/sequence.rb +21 -0
- data/lib/datadog/core/utils/string_table.rb +49 -0
- data/lib/datadog/core/utils/time.rb +54 -0
- data/lib/datadog/core/utils.rb +115 -0
- data/lib/datadog/core/vendor/multipart-post/LICENSE +11 -0
- data/lib/datadog/core/vendor/multipart-post/multipart/post/composite_read_io.rb +120 -0
- data/lib/datadog/core/vendor/multipart-post/multipart/post/multipartable.rb +61 -0
- data/lib/datadog/core/vendor/multipart-post/multipart/post/parts.rb +139 -0
- data/lib/datadog/core/vendor/multipart-post/multipart/post/version.rb +13 -0
- data/lib/datadog/core/vendor/multipart-post/multipart/post.rb +12 -0
- data/lib/datadog/core/vendor/multipart-post/multipart.rb +16 -0
- data/lib/datadog/core/vendor/multipart-post/net/http/post/multipart.rb +36 -0
- data/lib/datadog/core/worker.rb +24 -0
- data/lib/datadog/core/workers/async.rb +182 -0
- data/lib/datadog/core/workers/interval_loop.rb +119 -0
- data/lib/datadog/core/workers/polling.rb +59 -0
- data/lib/datadog/core/workers/queue.rb +44 -0
- data/lib/datadog/core/workers/runtime_metrics.rb +62 -0
- data/lib/datadog/core.rb +80 -0
- data/lib/datadog/kit/enable_core_dumps.rb +50 -0
- data/lib/datadog/kit/identity.rb +63 -0
- data/lib/datadog/kit.rb +11 -0
- data/lib/datadog/opentracer/binary_propagator.rb +26 -0
- data/lib/datadog/opentracer/carrier.rb +9 -0
- data/lib/datadog/opentracer/distributed_headers.rb +58 -0
- data/lib/datadog/opentracer/global_tracer.rb +17 -0
- data/lib/datadog/opentracer/propagator.rb +26 -0
- data/lib/datadog/opentracer/rack_propagator.rb +72 -0
- data/lib/datadog/opentracer/scope.rb +18 -0
- data/lib/datadog/opentracer/scope_manager.rb +9 -0
- data/lib/datadog/opentracer/span.rb +101 -0
- data/lib/datadog/opentracer/span_context.rb +19 -0
- data/lib/datadog/opentracer/span_context_factory.rb +27 -0
- data/lib/datadog/opentracer/text_map_propagator.rb +87 -0
- data/lib/datadog/opentracer/thread_local_scope.rb +34 -0
- data/lib/datadog/opentracer/thread_local_scope_manager.rb +43 -0
- data/lib/datadog/opentracer/tracer.rb +212 -0
- data/lib/datadog/opentracer.rb +24 -0
- data/lib/datadog/profiling/backtrace_location.rb +34 -0
- data/lib/datadog/profiling/buffer.rb +43 -0
- data/lib/datadog/profiling/collectors/code_provenance.rb +114 -0
- data/lib/datadog/profiling/collectors/old_stack.rb +298 -0
- data/lib/datadog/profiling/collectors/stack.rb +16 -0
- data/lib/datadog/profiling/encoding/profile.rb +47 -0
- data/lib/datadog/profiling/event.rb +15 -0
- data/lib/datadog/profiling/events/stack.rb +82 -0
- data/lib/datadog/profiling/exporter.rb +25 -0
- data/lib/datadog/profiling/ext/forking.rb +99 -0
- data/lib/datadog/profiling/ext.rb +57 -0
- data/lib/datadog/profiling/flush.rb +69 -0
- data/lib/datadog/profiling/load_native_extension.rb +22 -0
- data/lib/datadog/profiling/native_extension.rb +41 -0
- data/lib/datadog/profiling/pprof/builder.rb +127 -0
- data/lib/datadog/profiling/pprof/converter.rb +104 -0
- data/lib/datadog/profiling/pprof/message_set.rb +16 -0
- data/lib/datadog/profiling/pprof/payload.rb +20 -0
- data/lib/datadog/profiling/pprof/pprof.proto +212 -0
- data/lib/datadog/profiling/pprof/pprof_pb.rb +83 -0
- data/lib/datadog/profiling/pprof/stack_sample.rb +141 -0
- data/lib/datadog/profiling/pprof/string_table.rb +12 -0
- data/lib/datadog/profiling/pprof/template.rb +120 -0
- data/lib/datadog/profiling/preload.rb +5 -0
- data/lib/datadog/profiling/profiler.rb +34 -0
- data/lib/datadog/profiling/recorder.rb +117 -0
- data/lib/datadog/profiling/scheduler.rb +151 -0
- data/lib/datadog/profiling/stack_recorder.rb +33 -0
- data/lib/datadog/profiling/tag_builder.rb +48 -0
- data/lib/datadog/profiling/tasks/exec.rb +50 -0
- data/lib/datadog/profiling/tasks/help.rb +18 -0
- data/lib/datadog/profiling/tasks/setup.rb +93 -0
- data/lib/datadog/profiling/trace_identifiers/ddtrace.rb +45 -0
- data/lib/datadog/profiling/trace_identifiers/helper.rb +47 -0
- data/lib/datadog/profiling/transport/client.rb +16 -0
- data/lib/datadog/profiling/transport/http/api/endpoint.rb +107 -0
- data/lib/datadog/profiling/transport/http/api/instance.rb +38 -0
- data/lib/datadog/profiling/transport/http/api/spec.rb +42 -0
- data/lib/datadog/profiling/transport/http/api.rb +45 -0
- data/lib/datadog/profiling/transport/http/builder.rb +30 -0
- data/lib/datadog/profiling/transport/http/client.rb +35 -0
- data/lib/datadog/profiling/transport/http/response.rb +23 -0
- data/lib/datadog/profiling/transport/http.rb +112 -0
- data/lib/datadog/profiling/transport/io/client.rb +29 -0
- data/lib/datadog/profiling/transport/io/response.rb +18 -0
- data/lib/datadog/profiling/transport/io.rb +32 -0
- data/lib/datadog/profiling/transport/parcel.rb +19 -0
- data/lib/datadog/profiling/transport/request.rb +17 -0
- data/lib/datadog/profiling/transport/response.rb +10 -0
- data/lib/datadog/profiling.rb +170 -0
- data/lib/datadog/tracing/analytics.rb +25 -0
- data/lib/datadog/tracing/buffer.rb +132 -0
- data/lib/datadog/tracing/configuration/ext.rb +51 -0
- data/lib/datadog/tracing/context.rb +68 -0
- data/lib/datadog/tracing/context_provider.rb +66 -0
- data/lib/datadog/tracing/contrib/action_cable/configuration/settings.rb +35 -0
- data/lib/datadog/tracing/contrib/action_cable/event.rb +72 -0
- data/lib/datadog/tracing/contrib/action_cable/events/broadcast.rb +58 -0
- data/lib/datadog/tracing/contrib/action_cable/events/perform_action.rb +63 -0
- data/lib/datadog/tracing/contrib/action_cable/events/transmit.rb +59 -0
- data/lib/datadog/tracing/contrib/action_cable/events.rb +37 -0
- data/lib/datadog/tracing/contrib/action_cable/ext.rb +32 -0
- data/lib/datadog/tracing/contrib/action_cable/instrumentation.rb +91 -0
- data/lib/datadog/tracing/contrib/action_cable/integration.rb +50 -0
- data/lib/datadog/tracing/contrib/action_cable/patcher.rb +31 -0
- data/lib/datadog/tracing/contrib/action_mailer/configuration/settings.rb +36 -0
- data/lib/datadog/tracing/contrib/action_mailer/event.rb +52 -0
- data/lib/datadog/tracing/contrib/action_mailer/events/deliver.rb +60 -0
- data/lib/datadog/tracing/contrib/action_mailer/events/process.rb +47 -0
- data/lib/datadog/tracing/contrib/action_mailer/events.rb +34 -0
- data/lib/datadog/tracing/contrib/action_mailer/ext.rb +33 -0
- data/lib/datadog/tracing/contrib/action_mailer/integration.rb +50 -0
- data/lib/datadog/tracing/contrib/action_mailer/patcher.rb +29 -0
- data/lib/datadog/tracing/contrib/action_pack/action_controller/instrumentation.rb +156 -0
- data/lib/datadog/tracing/contrib/action_pack/action_controller/patcher.rb +29 -0
- data/lib/datadog/tracing/contrib/action_pack/configuration/settings.rb +36 -0
- data/lib/datadog/tracing/contrib/action_pack/ext.rb +22 -0
- data/lib/datadog/tracing/contrib/action_pack/integration.rb +50 -0
- data/lib/datadog/tracing/contrib/action_pack/patcher.rb +27 -0
- data/lib/datadog/tracing/contrib/action_pack/utils.rb +40 -0
- data/lib/datadog/tracing/contrib/action_view/configuration/settings.rb +36 -0
- data/lib/datadog/tracing/contrib/action_view/event.rb +35 -0
- data/lib/datadog/tracing/contrib/action_view/events/render_partial.rb +54 -0
- data/lib/datadog/tracing/contrib/action_view/events/render_template.rb +57 -0
- data/lib/datadog/tracing/contrib/action_view/events.rb +34 -0
- data/lib/datadog/tracing/contrib/action_view/ext.rb +24 -0
- data/lib/datadog/tracing/contrib/action_view/instrumentation/partial_renderer.rb +78 -0
- data/lib/datadog/tracing/contrib/action_view/instrumentation/template_renderer.rb +91 -0
- data/lib/datadog/tracing/contrib/action_view/integration.rb +57 -0
- data/lib/datadog/tracing/contrib/action_view/patcher.rb +47 -0
- data/lib/datadog/tracing/contrib/action_view/utils.rb +36 -0
- data/lib/datadog/tracing/contrib/active_job/configuration/settings.rb +37 -0
- data/lib/datadog/tracing/contrib/active_job/event.rb +58 -0
- data/lib/datadog/tracing/contrib/active_job/events/discard.rb +50 -0
- data/lib/datadog/tracing/contrib/active_job/events/enqueue.rb +49 -0
- data/lib/datadog/tracing/contrib/active_job/events/enqueue_at.rb +49 -0
- data/lib/datadog/tracing/contrib/active_job/events/enqueue_retry.rb +51 -0
- data/lib/datadog/tracing/contrib/active_job/events/perform.rb +49 -0
- data/lib/datadog/tracing/contrib/active_job/events/retry_stopped.rb +50 -0
- data/lib/datadog/tracing/contrib/active_job/events.rb +42 -0
- data/lib/datadog/tracing/contrib/active_job/ext.rb +39 -0
- data/lib/datadog/tracing/contrib/active_job/integration.rb +50 -0
- data/lib/datadog/tracing/contrib/active_job/log_injection.rb +26 -0
- data/lib/datadog/tracing/contrib/active_job/patcher.rb +36 -0
- data/lib/datadog/tracing/contrib/active_model_serializers/configuration/settings.rb +33 -0
- data/lib/datadog/tracing/contrib/active_model_serializers/event.rb +69 -0
- data/lib/datadog/tracing/contrib/active_model_serializers/events/render.rb +45 -0
- data/lib/datadog/tracing/contrib/active_model_serializers/events/serialize.rb +47 -0
- data/lib/datadog/tracing/contrib/active_model_serializers/events.rb +34 -0
- data/lib/datadog/tracing/contrib/active_model_serializers/ext.rb +24 -0
- data/lib/datadog/tracing/contrib/active_model_serializers/integration.rb +45 -0
- data/lib/datadog/tracing/contrib/active_model_serializers/patcher.rb +33 -0
- data/lib/datadog/tracing/contrib/active_record/configuration/makara_resolver.rb +36 -0
- data/lib/datadog/tracing/contrib/active_record/configuration/resolver.rb +138 -0
- data/lib/datadog/tracing/contrib/active_record/configuration/settings.rb +39 -0
- data/lib/datadog/tracing/contrib/active_record/event.rb +30 -0
- data/lib/datadog/tracing/contrib/active_record/events/instantiation.rb +58 -0
- data/lib/datadog/tracing/contrib/active_record/events/sql.rb +78 -0
- data/lib/datadog/tracing/contrib/active_record/events.rb +34 -0
- data/lib/datadog/tracing/contrib/active_record/ext.rb +29 -0
- data/lib/datadog/tracing/contrib/active_record/integration.rb +56 -0
- data/lib/datadog/tracing/contrib/active_record/patcher.rb +27 -0
- data/lib/datadog/tracing/contrib/active_record/utils.rb +128 -0
- data/lib/datadog/tracing/contrib/active_record/vendor/MIT-LICENSE +20 -0
- data/lib/datadog/tracing/contrib/active_record/vendor/connection_specification.rb +307 -0
- data/lib/datadog/tracing/contrib/active_support/cache/instrumentation.rb +270 -0
- data/lib/datadog/tracing/contrib/active_support/cache/patcher.rb +73 -0
- data/lib/datadog/tracing/contrib/active_support/cache/redis.rb +47 -0
- data/lib/datadog/tracing/contrib/active_support/configuration/settings.rb +35 -0
- data/lib/datadog/tracing/contrib/active_support/ext.rb +31 -0
- data/lib/datadog/tracing/contrib/active_support/integration.rb +51 -0
- data/lib/datadog/tracing/contrib/active_support/notifications/event.rb +71 -0
- data/lib/datadog/tracing/contrib/active_support/notifications/subscriber.rb +71 -0
- data/lib/datadog/tracing/contrib/active_support/notifications/subscription.rb +164 -0
- data/lib/datadog/tracing/contrib/active_support/patcher.rb +27 -0
- data/lib/datadog/tracing/contrib/analytics.rb +29 -0
- data/lib/datadog/tracing/contrib/auto_instrument.rb +53 -0
- data/lib/datadog/tracing/contrib/aws/configuration/settings.rb +35 -0
- data/lib/datadog/tracing/contrib/aws/ext.rb +27 -0
- data/lib/datadog/tracing/contrib/aws/instrumentation.rb +95 -0
- data/lib/datadog/tracing/contrib/aws/integration.rb +47 -0
- data/lib/datadog/tracing/contrib/aws/parsed_context.rb +60 -0
- data/lib/datadog/tracing/contrib/aws/patcher.rb +57 -0
- data/lib/datadog/tracing/contrib/aws/services.rb +123 -0
- data/lib/datadog/tracing/contrib/concurrent_ruby/configuration/settings.rb +23 -0
- data/lib/datadog/tracing/contrib/concurrent_ruby/context_composite_executor_service.rb +53 -0
- data/lib/datadog/tracing/contrib/concurrent_ruby/ext.rb +16 -0
- data/lib/datadog/tracing/contrib/concurrent_ruby/future_patch.rb +27 -0
- data/lib/datadog/tracing/contrib/concurrent_ruby/integration.rb +43 -0
- data/lib/datadog/tracing/contrib/concurrent_ruby/patcher.rb +33 -0
- data/lib/datadog/tracing/contrib/configurable.rb +102 -0
- data/lib/datadog/tracing/contrib/configuration/resolver.rb +85 -0
- data/lib/datadog/tracing/contrib/configuration/resolvers/pattern_resolver.rb +43 -0
- data/lib/datadog/tracing/contrib/configuration/settings.rb +43 -0
- data/lib/datadog/tracing/contrib/dalli/configuration/settings.rb +35 -0
- data/lib/datadog/tracing/contrib/dalli/ext.rb +24 -0
- data/lib/datadog/tracing/contrib/dalli/instrumentation.rb +58 -0
- data/lib/datadog/tracing/contrib/dalli/integration.rb +52 -0
- data/lib/datadog/tracing/contrib/dalli/patcher.rb +28 -0
- data/lib/datadog/tracing/contrib/dalli/quantize.rb +26 -0
- data/lib/datadog/tracing/contrib/delayed_job/configuration/settings.rb +38 -0
- data/lib/datadog/tracing/contrib/delayed_job/ext.rb +26 -0
- data/lib/datadog/tracing/contrib/delayed_job/integration.rb +43 -0
- data/lib/datadog/tracing/contrib/delayed_job/patcher.rb +31 -0
- data/lib/datadog/tracing/contrib/delayed_job/plugin.rb +101 -0
- data/lib/datadog/tracing/contrib/elasticsearch/configuration/settings.rb +36 -0
- data/lib/datadog/tracing/contrib/elasticsearch/ext.rb +26 -0
- data/lib/datadog/tracing/contrib/elasticsearch/integration.rb +50 -0
- data/lib/datadog/tracing/contrib/elasticsearch/patcher.rb +151 -0
- data/lib/datadog/tracing/contrib/elasticsearch/quantize.rb +89 -0
- data/lib/datadog/tracing/contrib/ethon/configuration/settings.rb +37 -0
- data/lib/datadog/tracing/contrib/ethon/easy_patch.rb +177 -0
- data/lib/datadog/tracing/contrib/ethon/ext.rb +24 -0
- data/lib/datadog/tracing/contrib/ethon/integration.rb +48 -0
- data/lib/datadog/tracing/contrib/ethon/multi_patch.rb +96 -0
- data/lib/datadog/tracing/contrib/ethon/patcher.rb +31 -0
- data/lib/datadog/tracing/contrib/excon/configuration/settings.rb +38 -0
- data/lib/datadog/tracing/contrib/excon/ext.rb +21 -0
- data/lib/datadog/tracing/contrib/excon/integration.rb +48 -0
- data/lib/datadog/tracing/contrib/excon/middleware.rb +170 -0
- data/lib/datadog/tracing/contrib/excon/patcher.rb +31 -0
- data/lib/datadog/tracing/contrib/extensions.rb +197 -0
- data/lib/datadog/tracing/contrib/faraday/configuration/settings.rb +42 -0
- data/lib/datadog/tracing/contrib/faraday/connection.rb +22 -0
- data/lib/datadog/tracing/contrib/faraday/ext.rb +21 -0
- data/lib/datadog/tracing/contrib/faraday/integration.rb +48 -0
- data/lib/datadog/tracing/contrib/faraday/middleware.rb +93 -0
- data/lib/datadog/tracing/contrib/faraday/patcher.rb +56 -0
- data/lib/datadog/tracing/contrib/faraday/rack_builder.rb +22 -0
- data/lib/datadog/tracing/contrib/grape/configuration/settings.rb +42 -0
- data/lib/datadog/tracing/contrib/grape/endpoint.rb +253 -0
- data/lib/datadog/tracing/contrib/grape/ext.rb +28 -0
- data/lib/datadog/tracing/contrib/grape/instrumentation.rb +37 -0
- data/lib/datadog/tracing/contrib/grape/integration.rb +44 -0
- data/lib/datadog/tracing/contrib/grape/patcher.rb +33 -0
- data/lib/datadog/tracing/contrib/graphql/configuration/settings.rb +36 -0
- data/lib/datadog/tracing/contrib/graphql/ext.rb +19 -0
- data/lib/datadog/tracing/contrib/graphql/integration.rb +44 -0
- data/lib/datadog/tracing/contrib/graphql/patcher.rb +91 -0
- data/lib/datadog/tracing/contrib/grpc/configuration/settings.rb +37 -0
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/client.rb +84 -0
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/server.rb +90 -0
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor.rb +104 -0
- data/lib/datadog/tracing/contrib/grpc/ext.rb +23 -0
- data/lib/datadog/tracing/contrib/grpc/integration.rb +43 -0
- data/lib/datadog/tracing/contrib/grpc/intercept_with_datadog.rb +53 -0
- data/lib/datadog/tracing/contrib/grpc/patcher.rb +37 -0
- data/lib/datadog/tracing/contrib/http/circuit_breaker.rb +44 -0
- data/lib/datadog/tracing/contrib/http/configuration/settings.rb +37 -0
- data/lib/datadog/tracing/contrib/http/ext.rb +21 -0
- data/lib/datadog/tracing/contrib/http/instrumentation.rb +139 -0
- data/lib/datadog/tracing/contrib/http/integration.rb +49 -0
- data/lib/datadog/tracing/contrib/http/patcher.rb +30 -0
- data/lib/datadog/tracing/contrib/http_annotation_helper.rb +17 -0
- data/lib/datadog/tracing/contrib/httpclient/configuration/settings.rb +37 -0
- data/lib/datadog/tracing/contrib/httpclient/ext.rb +21 -0
- data/lib/datadog/tracing/contrib/httpclient/instrumentation.rb +117 -0
- data/lib/datadog/tracing/contrib/httpclient/integration.rb +48 -0
- data/lib/datadog/tracing/contrib/httpclient/patcher.rb +42 -0
- data/lib/datadog/tracing/contrib/httprb/configuration/settings.rb +37 -0
- data/lib/datadog/tracing/contrib/httprb/ext.rb +21 -0
- data/lib/datadog/tracing/contrib/httprb/instrumentation.rb +128 -0
- data/lib/datadog/tracing/contrib/httprb/integration.rb +48 -0
- data/lib/datadog/tracing/contrib/httprb/patcher.rb +42 -0
- data/lib/datadog/tracing/contrib/integration.rb +78 -0
- data/lib/datadog/tracing/contrib/kafka/configuration/settings.rb +35 -0
- data/lib/datadog/tracing/contrib/kafka/consumer_event.rb +18 -0
- data/lib/datadog/tracing/contrib/kafka/consumer_group_event.rb +18 -0
- data/lib/datadog/tracing/contrib/kafka/event.rb +52 -0
- data/lib/datadog/tracing/contrib/kafka/events/connection/request.rb +42 -0
- data/lib/datadog/tracing/contrib/kafka/events/consumer/process_batch.rb +49 -0
- data/lib/datadog/tracing/contrib/kafka/events/consumer/process_message.rb +47 -0
- data/lib/datadog/tracing/contrib/kafka/events/consumer_group/heartbeat.rb +47 -0
- data/lib/datadog/tracing/contrib/kafka/events/consumer_group/join_group.rb +37 -0
- data/lib/datadog/tracing/contrib/kafka/events/consumer_group/leave_group.rb +37 -0
- data/lib/datadog/tracing/contrib/kafka/events/consumer_group/sync_group.rb +37 -0
- data/lib/datadog/tracing/contrib/kafka/events/produce_operation/send_messages.rb +40 -0
- data/lib/datadog/tracing/contrib/kafka/events/producer/deliver_messages.rb +43 -0
- data/lib/datadog/tracing/contrib/kafka/events.rb +48 -0
- data/lib/datadog/tracing/contrib/kafka/ext.rb +52 -0
- data/lib/datadog/tracing/contrib/kafka/integration.rb +44 -0
- data/lib/datadog/tracing/contrib/kafka/patcher.rb +29 -0
- data/lib/datadog/tracing/contrib/lograge/configuration/settings.rb +23 -0
- data/lib/datadog/tracing/contrib/lograge/ext.rb +15 -0
- data/lib/datadog/tracing/contrib/lograge/instrumentation.rb +47 -0
- data/lib/datadog/tracing/contrib/lograge/integration.rb +50 -0
- data/lib/datadog/tracing/contrib/lograge/patcher.rb +29 -0
- data/lib/datadog/tracing/contrib/mongodb/configuration/settings.rb +38 -0
- data/lib/datadog/tracing/contrib/mongodb/ext.rb +27 -0
- data/lib/datadog/tracing/contrib/mongodb/instrumentation.rb +47 -0
- data/lib/datadog/tracing/contrib/mongodb/integration.rb +48 -0
- data/lib/datadog/tracing/contrib/mongodb/parsers.rb +49 -0
- data/lib/datadog/tracing/contrib/mongodb/patcher.rb +34 -0
- data/lib/datadog/tracing/contrib/mongodb/subscribers.rb +121 -0
- data/lib/datadog/tracing/contrib/mysql2/configuration/settings.rb +35 -0
- data/lib/datadog/tracing/contrib/mysql2/ext.rb +22 -0
- data/lib/datadog/tracing/contrib/mysql2/instrumentation.rb +62 -0
- data/lib/datadog/tracing/contrib/mysql2/integration.rb +43 -0
- data/lib/datadog/tracing/contrib/mysql2/patcher.rb +31 -0
- data/lib/datadog/tracing/contrib/patchable.rb +109 -0
- data/lib/datadog/tracing/contrib/patcher.rb +74 -0
- data/lib/datadog/tracing/contrib/presto/configuration/settings.rb +35 -0
- data/lib/datadog/tracing/contrib/presto/ext.rb +32 -0
- data/lib/datadog/tracing/contrib/presto/instrumentation.rb +125 -0
- data/lib/datadog/tracing/contrib/presto/integration.rb +43 -0
- data/lib/datadog/tracing/contrib/presto/patcher.rb +37 -0
- data/lib/datadog/tracing/contrib/qless/configuration/settings.rb +40 -0
- data/lib/datadog/tracing/contrib/qless/ext.rb +26 -0
- data/lib/datadog/tracing/contrib/qless/integration.rb +43 -0
- data/lib/datadog/tracing/contrib/qless/patcher.rb +38 -0
- data/lib/datadog/tracing/contrib/qless/qless_job.rb +75 -0
- data/lib/datadog/tracing/contrib/qless/tracer_cleaner.rb +32 -0
- data/lib/datadog/tracing/contrib/que/configuration/settings.rb +49 -0
- data/lib/datadog/tracing/contrib/que/ext.rb +34 -0
- data/lib/datadog/tracing/contrib/que/integration.rb +46 -0
- data/lib/datadog/tracing/contrib/que/patcher.rb +28 -0
- data/lib/datadog/tracing/contrib/que/tracer.rb +61 -0
- data/lib/datadog/tracing/contrib/racecar/configuration/settings.rb +35 -0
- data/lib/datadog/tracing/contrib/racecar/event.rb +79 -0
- data/lib/datadog/tracing/contrib/racecar/events/batch.rb +35 -0
- data/lib/datadog/tracing/contrib/racecar/events/consume.rb +35 -0
- data/lib/datadog/tracing/contrib/racecar/events/message.rb +35 -0
- data/lib/datadog/tracing/contrib/racecar/events.rb +36 -0
- data/lib/datadog/tracing/contrib/racecar/ext.rb +31 -0
- data/lib/datadog/tracing/contrib/racecar/integration.rb +44 -0
- data/lib/datadog/tracing/contrib/racecar/patcher.rb +29 -0
- data/lib/datadog/tracing/contrib/rack/configuration/settings.rb +51 -0
- data/lib/datadog/tracing/contrib/rack/ext.rb +25 -0
- data/lib/datadog/tracing/contrib/rack/integration.rb +50 -0
- data/lib/datadog/tracing/contrib/rack/middlewares.rb +255 -0
- data/lib/datadog/tracing/contrib/rack/patcher.rb +109 -0
- data/lib/datadog/tracing/contrib/rack/request_queue.rb +48 -0
- data/lib/datadog/tracing/contrib/rails/auto_instrument_railtie.rb +12 -0
- data/lib/datadog/tracing/contrib/rails/configuration/settings.rb +71 -0
- data/lib/datadog/tracing/contrib/rails/ext.rb +19 -0
- data/lib/datadog/tracing/contrib/rails/framework.rb +152 -0
- data/lib/datadog/tracing/contrib/rails/integration.rb +49 -0
- data/lib/datadog/tracing/contrib/rails/log_injection.rb +34 -0
- data/lib/datadog/tracing/contrib/rails/middlewares.rb +47 -0
- data/lib/datadog/tracing/contrib/rails/patcher.rb +121 -0
- data/lib/datadog/tracing/contrib/rails/railtie.rb +19 -0
- data/lib/datadog/tracing/contrib/rails/utils.rb +28 -0
- data/lib/datadog/tracing/contrib/rake/configuration/settings.rb +36 -0
- data/lib/datadog/tracing/contrib/rake/ext.rb +26 -0
- data/lib/datadog/tracing/contrib/rake/instrumentation.rb +98 -0
- data/lib/datadog/tracing/contrib/rake/integration.rb +43 -0
- data/lib/datadog/tracing/contrib/rake/patcher.rb +34 -0
- data/lib/datadog/tracing/contrib/redis/configuration/resolver.rb +49 -0
- data/lib/datadog/tracing/contrib/redis/configuration/settings.rb +40 -0
- data/lib/datadog/tracing/contrib/redis/ext.rb +26 -0
- data/lib/datadog/tracing/contrib/redis/instrumentation.rb +78 -0
- data/lib/datadog/tracing/contrib/redis/integration.rb +47 -0
- data/lib/datadog/tracing/contrib/redis/patcher.rb +35 -0
- data/lib/datadog/tracing/contrib/redis/quantize.rb +79 -0
- data/lib/datadog/tracing/contrib/redis/tags.rb +54 -0
- data/lib/datadog/tracing/contrib/redis/vendor/LICENSE +20 -0
- data/lib/datadog/tracing/contrib/redis/vendor/resolver.rb +162 -0
- data/lib/datadog/tracing/contrib/registerable.rb +50 -0
- data/lib/datadog/tracing/contrib/registry.rb +52 -0
- data/lib/datadog/tracing/contrib/resque/configuration/settings.rb +37 -0
- data/lib/datadog/tracing/contrib/resque/ext.rb +21 -0
- data/lib/datadog/tracing/contrib/resque/integration.rb +48 -0
- data/lib/datadog/tracing/contrib/resque/patcher.rb +29 -0
- data/lib/datadog/tracing/contrib/resque/resque_job.rb +103 -0
- data/lib/datadog/tracing/contrib/rest_client/configuration/settings.rb +36 -0
- data/lib/datadog/tracing/contrib/rest_client/ext.rb +21 -0
- data/lib/datadog/tracing/contrib/rest_client/integration.rb +43 -0
- data/lib/datadog/tracing/contrib/rest_client/patcher.rb +29 -0
- data/lib/datadog/tracing/contrib/rest_client/request_patch.rb +105 -0
- data/lib/datadog/tracing/contrib/semantic_logger/configuration/settings.rb +23 -0
- data/lib/datadog/tracing/contrib/semantic_logger/ext.rb +15 -0
- data/lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb +51 -0
- data/lib/datadog/tracing/contrib/semantic_logger/integration.rb +52 -0
- data/lib/datadog/tracing/contrib/semantic_logger/patcher.rb +29 -0
- data/lib/datadog/tracing/contrib/sequel/configuration/settings.rb +33 -0
- data/lib/datadog/tracing/contrib/sequel/database.rb +60 -0
- data/lib/datadog/tracing/contrib/sequel/dataset.rb +65 -0
- data/lib/datadog/tracing/contrib/sequel/ext.rb +22 -0
- data/lib/datadog/tracing/contrib/sequel/integration.rb +43 -0
- data/lib/datadog/tracing/contrib/sequel/patcher.rb +37 -0
- data/lib/datadog/tracing/contrib/sequel/utils.rb +87 -0
- data/lib/datadog/tracing/contrib/shoryuken/configuration/settings.rb +38 -0
- data/lib/datadog/tracing/contrib/shoryuken/ext.rb +25 -0
- data/lib/datadog/tracing/contrib/shoryuken/integration.rb +44 -0
- data/lib/datadog/tracing/contrib/shoryuken/patcher.rb +28 -0
- data/lib/datadog/tracing/contrib/shoryuken/tracer.rb +61 -0
- data/lib/datadog/tracing/contrib/sidekiq/client_tracer.rb +53 -0
- data/lib/datadog/tracing/contrib/sidekiq/configuration/settings.rb +44 -0
- data/lib/datadog/tracing/contrib/sidekiq/ext.rb +38 -0
- data/lib/datadog/tracing/contrib/sidekiq/integration.rb +53 -0
- data/lib/datadog/tracing/contrib/sidekiq/patcher.rb +71 -0
- data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/heartbeat.rb +34 -0
- data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/job_fetch.rb +34 -0
- data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/scheduled_push.rb +33 -0
- data/lib/datadog/tracing/contrib/sidekiq/server_tracer.rb +98 -0
- data/lib/datadog/tracing/contrib/sidekiq/tracing.rb +44 -0
- data/lib/datadog/tracing/contrib/sinatra/configuration/settings.rb +43 -0
- data/lib/datadog/tracing/contrib/sinatra/env.rb +66 -0
- data/lib/datadog/tracing/contrib/sinatra/ext.rb +32 -0
- data/lib/datadog/tracing/contrib/sinatra/framework.rb +118 -0
- data/lib/datadog/tracing/contrib/sinatra/headers.rb +35 -0
- data/lib/datadog/tracing/contrib/sinatra/integration.rb +43 -0
- data/lib/datadog/tracing/contrib/sinatra/patcher.rb +76 -0
- data/lib/datadog/tracing/contrib/sinatra/tracer.rb +159 -0
- data/lib/datadog/tracing/contrib/sinatra/tracer_middleware.rb +123 -0
- data/lib/datadog/tracing/contrib/sneakers/configuration/settings.rb +38 -0
- data/lib/datadog/tracing/contrib/sneakers/ext.rb +26 -0
- data/lib/datadog/tracing/contrib/sneakers/integration.rb +46 -0
- data/lib/datadog/tracing/contrib/sneakers/patcher.rb +29 -0
- data/lib/datadog/tracing/contrib/sneakers/tracer.rb +58 -0
- data/lib/datadog/tracing/contrib/status_code_matcher.rb +75 -0
- data/lib/datadog/tracing/contrib/sucker_punch/configuration/settings.rb +35 -0
- data/lib/datadog/tracing/contrib/sucker_punch/exception_handler.rb +28 -0
- data/lib/datadog/tracing/contrib/sucker_punch/ext.rb +27 -0
- data/lib/datadog/tracing/contrib/sucker_punch/instrumentation.rb +105 -0
- data/lib/datadog/tracing/contrib/sucker_punch/integration.rb +43 -0
- data/lib/datadog/tracing/contrib/sucker_punch/patcher.rb +37 -0
- data/lib/datadog/tracing/contrib/utils/database.rb +31 -0
- data/lib/datadog/tracing/contrib/utils/quantization/hash.rb +111 -0
- data/lib/datadog/tracing/contrib/utils/quantization/http.rb +99 -0
- data/lib/datadog/tracing/contrib.rb +76 -0
- data/lib/datadog/tracing/correlation.rb +100 -0
- data/lib/datadog/tracing/distributed/headers/b3.rb +55 -0
- data/lib/datadog/tracing/distributed/headers/b3_single.rb +67 -0
- data/lib/datadog/tracing/distributed/headers/datadog.rb +52 -0
- data/lib/datadog/tracing/distributed/headers/ext.rb +31 -0
- data/lib/datadog/tracing/distributed/helpers.rb +44 -0
- data/lib/datadog/tracing/distributed/parser.rb +70 -0
- data/lib/datadog/tracing/event.rb +78 -0
- data/lib/datadog/tracing/flush.rb +74 -0
- data/lib/datadog/tracing/metadata/analytics.rb +26 -0
- data/lib/datadog/tracing/metadata/errors.rb +24 -0
- data/lib/datadog/tracing/metadata/ext.rb +151 -0
- data/lib/datadog/tracing/metadata/tagging.rb +110 -0
- data/lib/datadog/tracing/metadata.rb +20 -0
- data/lib/datadog/tracing/pipeline/span_filter.rb +42 -0
- data/lib/datadog/tracing/pipeline/span_processor.rb +39 -0
- data/lib/datadog/tracing/pipeline.rb +65 -0
- data/lib/datadog/tracing/propagation/grpc.rb +88 -0
- data/lib/datadog/tracing/propagation/http.rb +109 -0
- data/lib/datadog/tracing/runtime/metrics.rb +19 -0
- data/lib/datadog/tracing/sampling/all_sampler.rb +25 -0
- data/lib/datadog/tracing/sampling/ext.rb +27 -0
- data/lib/datadog/tracing/sampling/matcher.rb +68 -0
- data/lib/datadog/tracing/sampling/priority_sampler.rb +112 -0
- data/lib/datadog/tracing/sampling/rate_by_key_sampler.rb +97 -0
- data/lib/datadog/tracing/sampling/rate_by_service_sampler.rb +41 -0
- data/lib/datadog/tracing/sampling/rate_limiter.rb +185 -0
- data/lib/datadog/tracing/sampling/rate_sampler.rb +55 -0
- data/lib/datadog/tracing/sampling/rule.rb +76 -0
- data/lib/datadog/tracing/sampling/rule_sampler.rb +131 -0
- data/lib/datadog/tracing/sampling/sampler.rb +44 -0
- data/lib/datadog/tracing/span.rb +212 -0
- data/lib/datadog/tracing/span_operation.rb +520 -0
- data/lib/datadog/tracing/sync_writer.rb +69 -0
- data/lib/datadog/tracing/trace_digest.rb +60 -0
- data/lib/datadog/tracing/trace_operation.rb +431 -0
- data/lib/datadog/tracing/trace_segment.rb +207 -0
- data/lib/datadog/tracing/tracer.rb +505 -0
- data/lib/datadog/tracing/workers/trace_writer.rb +195 -0
- data/lib/datadog/tracing/workers.rb +125 -0
- data/lib/datadog/tracing/writer.rb +180 -0
- data/lib/datadog/tracing.rb +142 -0
- data/lib/ddtrace/auto_instrument.rb +9 -0
- data/lib/ddtrace/auto_instrument_base.rb +8 -0
- data/lib/ddtrace/profiling/preload.rb +4 -0
- data/lib/ddtrace/transport/ext.rb +35 -0
- data/lib/ddtrace/transport/http/adapters/net.rb +57 -12
- data/lib/ddtrace/transport/http/adapters/registry.rb +3 -0
- data/lib/ddtrace/transport/http/adapters/test.rb +12 -2
- data/lib/ddtrace/transport/http/adapters/unix_socket.rb +30 -15
- data/lib/ddtrace/transport/http/api/endpoint.rb +2 -0
- data/lib/ddtrace/transport/http/api/fallbacks.rb +2 -0
- data/lib/ddtrace/transport/http/api/instance.rb +2 -0
- data/lib/ddtrace/transport/http/api/map.rb +2 -0
- data/lib/ddtrace/transport/http/api/spec.rb +2 -0
- data/lib/ddtrace/transport/http/api.rb +6 -11
- data/lib/ddtrace/transport/http/builder.rb +22 -7
- data/lib/ddtrace/transport/http/client.rb +5 -1
- data/lib/ddtrace/transport/http/env.rb +10 -0
- data/lib/ddtrace/transport/http/response.rb +36 -4
- data/lib/ddtrace/transport/http/statistics.rb +18 -3
- data/lib/ddtrace/transport/http/traces.rb +9 -6
- data/lib/ddtrace/transport/http.rb +66 -39
- data/lib/ddtrace/transport/io/client.rb +20 -9
- data/lib/ddtrace/transport/io/response.rb +3 -3
- data/lib/ddtrace/transport/io/traces.rb +12 -2
- data/lib/ddtrace/transport/io.rb +5 -3
- data/lib/ddtrace/transport/parcel.rb +9 -0
- data/lib/ddtrace/transport/request.rb +2 -0
- data/lib/ddtrace/transport/response.rb +13 -0
- data/lib/ddtrace/transport/serializable_trace.rb +118 -0
- data/lib/ddtrace/transport/statistics.rb +7 -4
- data/lib/ddtrace/transport/trace_formatter.rb +187 -0
- data/lib/ddtrace/transport/traces.rb +43 -10
- data/lib/ddtrace/version.rb +20 -5
- data/lib/ddtrace.rb +10 -71
- metadata +643 -603
- data/.circleci/config.yml +0 -490
- data/.circleci/images/primary/Dockerfile-2.0.0 +0 -73
- data/.circleci/images/primary/Dockerfile-2.1.10 +0 -73
- data/.circleci/images/primary/Dockerfile-2.2.10 +0 -73
- data/.circleci/images/primary/Dockerfile-2.3.8 +0 -75
- data/.circleci/images/primary/Dockerfile-2.4.6 +0 -73
- data/.circleci/images/primary/Dockerfile-2.5.6 +0 -73
- data/.circleci/images/primary/Dockerfile-2.6.4 +0 -73
- data/.circleci/images/primary/Dockerfile-2.7.0 +0 -73
- data/.circleci/images/primary/Dockerfile-jruby-9.2 +0 -77
- data/.dockerignore +0 -1
- data/.env +0 -26
- data/.github/CODEOWNERS +0 -1
- data/.rspec +0 -1
- data/.rubocop.yml +0 -81
- data/.yardopts +0 -5
- data/Appraisals +0 -944
- data/Gemfile +0 -7
- data/Rakefile +0 -731
- data/benchmarks/postgres_database.yml +0 -9
- data/benchmarks/sidekiq_test.rb +0 -154
- data/docker-compose.yml +0 -335
- data/lib/ddtrace/analytics.rb +0 -36
- data/lib/ddtrace/augmentation/method_wrapper.rb +0 -20
- data/lib/ddtrace/augmentation/method_wrapping.rb +0 -38
- data/lib/ddtrace/augmentation/shim.rb +0 -102
- data/lib/ddtrace/augmentation.rb +0 -13
- data/lib/ddtrace/buffer.rb +0 -119
- data/lib/ddtrace/chunker.rb +0 -34
- data/lib/ddtrace/configuration/base.rb +0 -84
- data/lib/ddtrace/configuration/components.rb +0 -154
- data/lib/ddtrace/configuration/dependency_resolver.rb +0 -24
- data/lib/ddtrace/configuration/option.rb +0 -64
- data/lib/ddtrace/configuration/option_definition.rb +0 -123
- data/lib/ddtrace/configuration/option_definition_set.rb +0 -18
- data/lib/ddtrace/configuration/option_set.rb +0 -6
- data/lib/ddtrace/configuration/options.rb +0 -112
- data/lib/ddtrace/configuration/pin_setup.rb +0 -30
- data/lib/ddtrace/configuration/settings.rb +0 -255
- data/lib/ddtrace/configuration.rb +0 -53
- data/lib/ddtrace/context.rb +0 -305
- data/lib/ddtrace/context_flush.rb +0 -69
- data/lib/ddtrace/context_provider.rb +0 -50
- data/lib/ddtrace/contrib/action_cable/configuration/settings.rb +0 -25
- data/lib/ddtrace/contrib/action_cable/event.rb +0 -65
- data/lib/ddtrace/contrib/action_cable/events/broadcast.rb +0 -49
- data/lib/ddtrace/contrib/action_cable/events/perform_action.rb +0 -55
- data/lib/ddtrace/contrib/action_cable/events/transmit.rb +0 -50
- data/lib/ddtrace/contrib/action_cable/events.rb +0 -33
- data/lib/ddtrace/contrib/action_cable/ext.rb +0 -23
- data/lib/ddtrace/contrib/action_cable/instrumentation.rb +0 -31
- data/lib/ddtrace/contrib/action_cable/integration.rb +0 -38
- data/lib/ddtrace/contrib/action_cable/patcher.rb +0 -27
- data/lib/ddtrace/contrib/action_pack/action_controller/instrumentation.rb +0 -148
- data/lib/ddtrace/contrib/action_pack/action_controller/patcher.rb +0 -25
- data/lib/ddtrace/contrib/action_pack/configuration/settings.rb +0 -27
- data/lib/ddtrace/contrib/action_pack/ext.rb +0 -16
- data/lib/ddtrace/contrib/action_pack/integration.rb +0 -38
- data/lib/ddtrace/contrib/action_pack/patcher.rb +0 -23
- data/lib/ddtrace/contrib/action_pack/utils.rb +0 -36
- data/lib/ddtrace/contrib/action_view/configuration/settings.rb +0 -26
- data/lib/ddtrace/contrib/action_view/event.rb +0 -39
- data/lib/ddtrace/contrib/action_view/events/render_partial.rb +0 -45
- data/lib/ddtrace/contrib/action_view/events/render_template.rb +0 -48
- data/lib/ddtrace/contrib/action_view/events.rb +0 -30
- data/lib/ddtrace/contrib/action_view/ext.rb +0 -17
- data/lib/ddtrace/contrib/action_view/instrumentation/partial_renderer.rb +0 -74
- data/lib/ddtrace/contrib/action_view/instrumentation/template_renderer.rb +0 -167
- data/lib/ddtrace/contrib/action_view/integration.rb +0 -45
- data/lib/ddtrace/contrib/action_view/patcher.rb +0 -47
- data/lib/ddtrace/contrib/action_view/utils.rb +0 -32
- data/lib/ddtrace/contrib/active_model_serializers/configuration/settings.rb +0 -25
- data/lib/ddtrace/contrib/active_model_serializers/event.rb +0 -68
- data/lib/ddtrace/contrib/active_model_serializers/events/render.rb +0 -32
- data/lib/ddtrace/contrib/active_model_serializers/events/serialize.rb +0 -35
- data/lib/ddtrace/contrib/active_model_serializers/events.rb +0 -30
- data/lib/ddtrace/contrib/active_model_serializers/ext.rb +0 -17
- data/lib/ddtrace/contrib/active_model_serializers/integration.rb +0 -40
- data/lib/ddtrace/contrib/active_model_serializers/patcher.rb +0 -29
- data/lib/ddtrace/contrib/active_record/configuration/resolver.rb +0 -45
- data/lib/ddtrace/contrib/active_record/configuration/settings.rb +0 -30
- data/lib/ddtrace/contrib/active_record/event.rb +0 -30
- data/lib/ddtrace/contrib/active_record/events/instantiation.rb +0 -60
- data/lib/ddtrace/contrib/active_record/events/sql.rb +0 -64
- data/lib/ddtrace/contrib/active_record/events.rb +0 -30
- data/lib/ddtrace/contrib/active_record/ext.rb +0 -21
- data/lib/ddtrace/contrib/active_record/integration.rb +0 -46
- data/lib/ddtrace/contrib/active_record/patcher.rb +0 -23
- data/lib/ddtrace/contrib/active_record/utils.rb +0 -76
- data/lib/ddtrace/contrib/active_support/cache/instrumentation.rb +0 -157
- data/lib/ddtrace/contrib/active_support/cache/patcher.rb +0 -48
- data/lib/ddtrace/contrib/active_support/cache/redis.rb +0 -47
- data/lib/ddtrace/contrib/active_support/configuration/settings.rb +0 -25
- data/lib/ddtrace/contrib/active_support/ext.rb +0 -21
- data/lib/ddtrace/contrib/active_support/integration.rb +0 -40
- data/lib/ddtrace/contrib/active_support/notifications/event.rb +0 -62
- data/lib/ddtrace/contrib/active_support/notifications/subscriber.rb +0 -66
- data/lib/ddtrace/contrib/active_support/notifications/subscription.rb +0 -159
- data/lib/ddtrace/contrib/active_support/patcher.rb +0 -23
- data/lib/ddtrace/contrib/analytics.rb +0 -24
- data/lib/ddtrace/contrib/aws/configuration/settings.rb +0 -25
- data/lib/ddtrace/contrib/aws/ext.rb +0 -20
- data/lib/ddtrace/contrib/aws/instrumentation.rb +0 -56
- data/lib/ddtrace/contrib/aws/integration.rb +0 -42
- data/lib/ddtrace/contrib/aws/parsed_context.rb +0 -56
- data/lib/ddtrace/contrib/aws/patcher.rb +0 -49
- data/lib/ddtrace/contrib/aws/services.rb +0 -115
- data/lib/ddtrace/contrib/concurrent_ruby/configuration/settings.rb +0 -15
- data/lib/ddtrace/contrib/concurrent_ruby/context_composite_executor_service.rb +0 -35
- data/lib/ddtrace/contrib/concurrent_ruby/ext.rb +0 -11
- data/lib/ddtrace/contrib/concurrent_ruby/future_patch.rb +0 -23
- data/lib/ddtrace/contrib/concurrent_ruby/integration.rb +0 -38
- data/lib/ddtrace/contrib/concurrent_ruby/patcher.rb +0 -28
- data/lib/ddtrace/contrib/configurable.rb +0 -76
- data/lib/ddtrace/contrib/configuration/resolver.rb +0 -16
- data/lib/ddtrace/contrib/configuration/resolvers/pattern_resolver.rb +0 -39
- data/lib/ddtrace/contrib/configuration/settings.rb +0 -35
- data/lib/ddtrace/contrib/dalli/configuration/settings.rb +0 -25
- data/lib/ddtrace/contrib/dalli/ext.rb +0 -17
- data/lib/ddtrace/contrib/dalli/instrumentation.rb +0 -50
- data/lib/ddtrace/contrib/dalli/integration.rb +0 -38
- data/lib/ddtrace/contrib/dalli/patcher.rb +0 -67
- data/lib/ddtrace/contrib/dalli/quantize.rb +0 -22
- data/lib/ddtrace/contrib/delayed_job/configuration/settings.rb +0 -25
- data/lib/ddtrace/contrib/delayed_job/ext.rb +0 -18
- data/lib/ddtrace/contrib/delayed_job/integration.rb +0 -38
- data/lib/ddtrace/contrib/delayed_job/patcher.rb +0 -28
- data/lib/ddtrace/contrib/delayed_job/plugin.rb +0 -61
- data/lib/ddtrace/contrib/elasticsearch/configuration/settings.rb +0 -26
- data/lib/ddtrace/contrib/elasticsearch/ext.rb +0 -19
- data/lib/ddtrace/contrib/elasticsearch/integration.rb +0 -39
- data/lib/ddtrace/contrib/elasticsearch/patcher.rb +0 -118
- data/lib/ddtrace/contrib/elasticsearch/quantize.rb +0 -80
- data/lib/ddtrace/contrib/ethon/configuration/settings.rb +0 -27
- data/lib/ddtrace/contrib/ethon/easy_patch.rb +0 -148
- data/lib/ddtrace/contrib/ethon/ext.rb +0 -15
- data/lib/ddtrace/contrib/ethon/integration.rb +0 -43
- data/lib/ddtrace/contrib/ethon/multi_patch.rb +0 -80
- data/lib/ddtrace/contrib/ethon/patcher.rb +0 -25
- data/lib/ddtrace/contrib/excon/configuration/settings.rb +0 -28
- data/lib/ddtrace/contrib/excon/ext.rb +0 -14
- data/lib/ddtrace/contrib/excon/integration.rb +0 -43
- data/lib/ddtrace/contrib/excon/middleware.rb +0 -157
- data/lib/ddtrace/contrib/excon/patcher.rb +0 -27
- data/lib/ddtrace/contrib/extensions.rb +0 -59
- data/lib/ddtrace/contrib/faraday/configuration/settings.rb +0 -33
- data/lib/ddtrace/contrib/faraday/connection.rb +0 -18
- data/lib/ddtrace/contrib/faraday/ext.rb +0 -14
- data/lib/ddtrace/contrib/faraday/integration.rb +0 -43
- data/lib/ddtrace/contrib/faraday/middleware.rb +0 -81
- data/lib/ddtrace/contrib/faraday/patcher.rb +0 -81
- data/lib/ddtrace/contrib/faraday/rack_builder.rb +0 -18
- data/lib/ddtrace/contrib/grape/configuration/settings.rb +0 -27
- data/lib/ddtrace/contrib/grape/endpoint.rb +0 -208
- data/lib/ddtrace/contrib/grape/ext.rb +0 -19
- data/lib/ddtrace/contrib/grape/instrumentation.rb +0 -33
- data/lib/ddtrace/contrib/grape/integration.rb +0 -39
- data/lib/ddtrace/contrib/grape/patcher.rb +0 -73
- data/lib/ddtrace/contrib/graphql/configuration/settings.rb +0 -27
- data/lib/ddtrace/contrib/graphql/ext.rb +0 -13
- data/lib/ddtrace/contrib/graphql/integration.rb +0 -39
- data/lib/ddtrace/contrib/graphql/patcher.rb +0 -57
- data/lib/ddtrace/contrib/grpc/configuration/settings.rb +0 -25
- data/lib/ddtrace/contrib/grpc/datadog_interceptor/client.rb +0 -56
- data/lib/ddtrace/contrib/grpc/datadog_interceptor/server.rb +0 -76
- data/lib/ddtrace/contrib/grpc/datadog_interceptor.rb +0 -74
- data/lib/ddtrace/contrib/grpc/ext.rb +0 -15
- data/lib/ddtrace/contrib/grpc/integration.rb +0 -38
- data/lib/ddtrace/contrib/grpc/intercept_with_datadog.rb +0 -49
- data/lib/ddtrace/contrib/grpc/patcher.rb +0 -72
- data/lib/ddtrace/contrib/http/circuit_breaker.rb +0 -39
- data/lib/ddtrace/contrib/http/configuration/settings.rb +0 -27
- data/lib/ddtrace/contrib/http/ext.rb +0 -14
- data/lib/ddtrace/contrib/http/instrumentation.rb +0 -170
- data/lib/ddtrace/contrib/http/integration.rb +0 -45
- data/lib/ddtrace/contrib/http/patcher.rb +0 -26
- data/lib/ddtrace/contrib/http_annotation_helper.rb +0 -10
- data/lib/ddtrace/contrib/integration.rb +0 -16
- data/lib/ddtrace/contrib/mongodb/configuration/settings.rb +0 -28
- data/lib/ddtrace/contrib/mongodb/ext.rb +0 -20
- data/lib/ddtrace/contrib/mongodb/instrumentation.rb +0 -68
- data/lib/ddtrace/contrib/mongodb/integration.rb +0 -38
- data/lib/ddtrace/contrib/mongodb/parsers.rb +0 -68
- data/lib/ddtrace/contrib/mongodb/patcher.rb +0 -31
- data/lib/ddtrace/contrib/mongodb/subscribers.rb +0 -108
- data/lib/ddtrace/contrib/mysql2/configuration/settings.rb +0 -25
- data/lib/ddtrace/contrib/mysql2/ext.rb +0 -15
- data/lib/ddtrace/contrib/mysql2/instrumentation.rb +0 -60
- data/lib/ddtrace/contrib/mysql2/integration.rb +0 -38
- data/lib/ddtrace/contrib/mysql2/patcher.rb +0 -27
- data/lib/ddtrace/contrib/patchable.rb +0 -59
- data/lib/ddtrace/contrib/patcher.rb +0 -56
- data/lib/ddtrace/contrib/presto/configuration/settings.rb +0 -25
- data/lib/ddtrace/contrib/presto/ext.rb +0 -25
- data/lib/ddtrace/contrib/presto/instrumentation.rb +0 -107
- data/lib/ddtrace/contrib/presto/integration.rb +0 -38
- data/lib/ddtrace/contrib/presto/patcher.rb +0 -30
- data/lib/ddtrace/contrib/racecar/configuration/settings.rb +0 -25
- data/lib/ddtrace/contrib/racecar/event.rb +0 -71
- data/lib/ddtrace/contrib/racecar/events/batch.rb +0 -27
- data/lib/ddtrace/contrib/racecar/events/message.rb +0 -27
- data/lib/ddtrace/contrib/racecar/events.rb +0 -30
- data/lib/ddtrace/contrib/racecar/ext.rb +0 -21
- data/lib/ddtrace/contrib/racecar/integration.rb +0 -39
- data/lib/ddtrace/contrib/racecar/patcher.rb +0 -26
- data/lib/ddtrace/contrib/rack/configuration/settings.rb +0 -41
- data/lib/ddtrace/contrib/rack/ext.rb +0 -18
- data/lib/ddtrace/contrib/rack/integration.rb +0 -38
- data/lib/ddtrace/contrib/rack/middlewares.rb +0 -287
- data/lib/ddtrace/contrib/rack/patcher.rb +0 -107
- data/lib/ddtrace/contrib/rack/request_queue.rb +0 -39
- data/lib/ddtrace/contrib/rails/configuration/settings.rb +0 -94
- data/lib/ddtrace/contrib/rails/ext.rb +0 -13
- data/lib/ddtrace/contrib/rails/framework.rb +0 -118
- data/lib/ddtrace/contrib/rails/integration.rb +0 -44
- data/lib/ddtrace/contrib/rails/middlewares.rb +0 -38
- data/lib/ddtrace/contrib/rails/patcher.rb +0 -74
- data/lib/ddtrace/contrib/rails/railtie.rb +0 -17
- data/lib/ddtrace/contrib/rails/utils.rb +0 -20
- data/lib/ddtrace/contrib/rake/configuration/settings.rb +0 -27
- data/lib/ddtrace/contrib/rake/ext.rb +0 -18
- data/lib/ddtrace/contrib/rake/instrumentation.rb +0 -88
- data/lib/ddtrace/contrib/rake/integration.rb +0 -38
- data/lib/ddtrace/contrib/rake/patcher.rb +0 -30
- data/lib/ddtrace/contrib/redis/configuration/resolver.rb +0 -36
- data/lib/ddtrace/contrib/redis/configuration/settings.rb +0 -25
- data/lib/ddtrace/contrib/redis/ext.rb +0 -18
- data/lib/ddtrace/contrib/redis/integration.rb +0 -42
- data/lib/ddtrace/contrib/redis/patcher.rb +0 -97
- data/lib/ddtrace/contrib/redis/quantize.rb +0 -47
- data/lib/ddtrace/contrib/redis/tags.rb +0 -38
- data/lib/ddtrace/contrib/redis/vendor/resolver.rb +0 -159
- data/lib/ddtrace/contrib/registerable.rb +0 -33
- data/lib/ddtrace/contrib/registry.rb +0 -42
- data/lib/ddtrace/contrib/resque/configuration/settings.rb +0 -26
- data/lib/ddtrace/contrib/resque/ext.rb +0 -14
- data/lib/ddtrace/contrib/resque/integration.rb +0 -47
- data/lib/ddtrace/contrib/resque/patcher.rb +0 -29
- data/lib/ddtrace/contrib/resque/resque_job.rb +0 -80
- data/lib/ddtrace/contrib/rest_client/configuration/settings.rb +0 -26
- data/lib/ddtrace/contrib/rest_client/ext.rb +0 -14
- data/lib/ddtrace/contrib/rest_client/integration.rb +0 -38
- data/lib/ddtrace/contrib/rest_client/patcher.rb +0 -23
- data/lib/ddtrace/contrib/rest_client/request_patch.rb +0 -89
- data/lib/ddtrace/contrib/sequel/configuration/settings.rb +0 -23
- data/lib/ddtrace/contrib/sequel/database.rb +0 -61
- data/lib/ddtrace/contrib/sequel/dataset.rb +0 -62
- data/lib/ddtrace/contrib/sequel/ext.rb +0 -15
- data/lib/ddtrace/contrib/sequel/integration.rb +0 -38
- data/lib/ddtrace/contrib/sequel/patcher.rb +0 -33
- data/lib/ddtrace/contrib/sequel/utils.rb +0 -46
- data/lib/ddtrace/contrib/shoryuken/configuration/settings.rb +0 -24
- data/lib/ddtrace/contrib/shoryuken/ext.rb +0 -18
- data/lib/ddtrace/contrib/shoryuken/integration.rb +0 -39
- data/lib/ddtrace/contrib/shoryuken/patcher.rb +0 -24
- data/lib/ddtrace/contrib/shoryuken/tracer.rb +0 -49
- data/lib/ddtrace/contrib/sidekiq/client_tracer.rb +0 -43
- data/lib/ddtrace/contrib/sidekiq/configuration/settings.rb +0 -31
- data/lib/ddtrace/contrib/sidekiq/ext.rb +0 -23
- data/lib/ddtrace/contrib/sidekiq/integration.rb +0 -38
- data/lib/ddtrace/contrib/sidekiq/patcher.rb +0 -34
- data/lib/ddtrace/contrib/sidekiq/server_tracer.rb +0 -66
- data/lib/ddtrace/contrib/sidekiq/tracing.rb +0 -45
- data/lib/ddtrace/contrib/sinatra/configuration/settings.rb +0 -34
- data/lib/ddtrace/contrib/sinatra/env.rb +0 -58
- data/lib/ddtrace/contrib/sinatra/ext.rb +0 -24
- data/lib/ddtrace/contrib/sinatra/headers.rb +0 -31
- data/lib/ddtrace/contrib/sinatra/integration.rb +0 -38
- data/lib/ddtrace/contrib/sinatra/patcher.rb +0 -28
- data/lib/ddtrace/contrib/sinatra/tracer.rb +0 -150
- data/lib/ddtrace/contrib/sinatra/tracer_middleware.rb +0 -78
- data/lib/ddtrace/contrib/sucker_punch/configuration/settings.rb +0 -25
- data/lib/ddtrace/contrib/sucker_punch/exception_handler.rb +0 -26
- data/lib/ddtrace/contrib/sucker_punch/ext.rb +0 -18
- data/lib/ddtrace/contrib/sucker_punch/instrumentation.rb +0 -84
- data/lib/ddtrace/contrib/sucker_punch/integration.rb +0 -38
- data/lib/ddtrace/contrib/sucker_punch/patcher.rb +0 -42
- data/lib/ddtrace/correlation.rb +0 -38
- data/lib/ddtrace/diagnostics/health.rb +0 -33
- data/lib/ddtrace/distributed_tracing/headers/b3.rb +0 -44
- data/lib/ddtrace/distributed_tracing/headers/b3_single.rb +0 -56
- data/lib/ddtrace/distributed_tracing/headers/datadog.rb +0 -42
- data/lib/ddtrace/distributed_tracing/headers/headers.rb +0 -70
- data/lib/ddtrace/distributed_tracing/headers/helpers.rb +0 -45
- data/lib/ddtrace/encoding.rb +0 -69
- data/lib/ddtrace/environment.rb +0 -27
- data/lib/ddtrace/error.rb +0 -27
- data/lib/ddtrace/event.rb +0 -52
- data/lib/ddtrace/ext/analytics.rb +0 -12
- data/lib/ddtrace/ext/app_types.rb +0 -11
- data/lib/ddtrace/ext/correlation.rb +0 -11
- data/lib/ddtrace/ext/diagnostics.rb +0 -33
- data/lib/ddtrace/ext/distributed.rb +0 -33
- data/lib/ddtrace/ext/environment.rb +0 -14
- data/lib/ddtrace/ext/errors.rb +0 -10
- data/lib/ddtrace/ext/forced_tracing.rb +0 -25
- data/lib/ddtrace/ext/http.rb +0 -46
- data/lib/ddtrace/ext/manual_tracing.rb +0 -9
- data/lib/ddtrace/ext/metrics.rb +0 -15
- data/lib/ddtrace/ext/net.rb +0 -10
- data/lib/ddtrace/ext/priority.rb +0 -16
- data/lib/ddtrace/ext/runtime.rb +0 -26
- data/lib/ddtrace/ext/sampling.rb +0 -16
- data/lib/ddtrace/ext/sql.rb +0 -8
- data/lib/ddtrace/ext/transport.rb +0 -17
- data/lib/ddtrace/forced_tracing.rb +0 -36
- data/lib/ddtrace/logger.rb +0 -40
- data/lib/ddtrace/metrics.rb +0 -222
- data/lib/ddtrace/monkey.rb +0 -58
- data/lib/ddtrace/opentelemetry/extensions.rb +0 -13
- data/lib/ddtrace/opentelemetry/span.rb +0 -33
- data/lib/ddtrace/opentracer/binary_propagator.rb +0 -24
- data/lib/ddtrace/opentracer/carrier.rb +0 -6
- data/lib/ddtrace/opentracer/distributed_headers.rb +0 -52
- data/lib/ddtrace/opentracer/global_tracer.rb +0 -15
- data/lib/ddtrace/opentracer/propagator.rb +0 -22
- data/lib/ddtrace/opentracer/rack_propagator.rb +0 -60
- data/lib/ddtrace/opentracer/scope.rb +0 -15
- data/lib/ddtrace/opentracer/scope_manager.rb +0 -6
- data/lib/ddtrace/opentracer/span.rb +0 -98
- data/lib/ddtrace/opentracer/span_context.rb +0 -14
- data/lib/ddtrace/opentracer/span_context_factory.rb +0 -23
- data/lib/ddtrace/opentracer/text_map_propagator.rb +0 -75
- data/lib/ddtrace/opentracer/thread_local_scope.rb +0 -30
- data/lib/ddtrace/opentracer/thread_local_scope_manager.rb +0 -40
- data/lib/ddtrace/opentracer/tracer.rb +0 -208
- data/lib/ddtrace/opentracer.rb +0 -40
- data/lib/ddtrace/patcher.rb +0 -47
- data/lib/ddtrace/pin.rb +0 -114
- data/lib/ddtrace/pipeline/span_filter.rb +0 -38
- data/lib/ddtrace/pipeline/span_processor.rb +0 -20
- data/lib/ddtrace/pipeline.rb +0 -46
- data/lib/ddtrace/propagation/grpc_propagator.rb +0 -61
- data/lib/ddtrace/propagation/http_propagator.rb +0 -75
- data/lib/ddtrace/quantization/hash.rb +0 -103
- data/lib/ddtrace/quantization/http.rb +0 -86
- data/lib/ddtrace/runtime/cgroup.rb +0 -44
- data/lib/ddtrace/runtime/class_count.rb +0 -17
- data/lib/ddtrace/runtime/container.rb +0 -73
- data/lib/ddtrace/runtime/gc.rb +0 -16
- data/lib/ddtrace/runtime/identity.rb +0 -41
- data/lib/ddtrace/runtime/metrics.rb +0 -96
- data/lib/ddtrace/runtime/object_space.rb +0 -19
- data/lib/ddtrace/runtime/socket.rb +0 -14
- data/lib/ddtrace/runtime/thread_count.rb +0 -16
- data/lib/ddtrace/sampler.rb +0 -290
- data/lib/ddtrace/sampling/matcher.rb +0 -57
- data/lib/ddtrace/sampling/rate_limiter.rb +0 -127
- data/lib/ddtrace/sampling/rule.rb +0 -61
- data/lib/ddtrace/sampling/rule_sampler.rb +0 -125
- data/lib/ddtrace/sampling.rb +0 -2
- data/lib/ddtrace/span.rb +0 -297
- data/lib/ddtrace/sync_writer.rb +0 -67
- data/lib/ddtrace/tracer.rb +0 -432
- data/lib/ddtrace/utils/database.rb +0 -25
- data/lib/ddtrace/utils/time.rb +0 -14
- data/lib/ddtrace/utils.rb +0 -65
- data/lib/ddtrace/vendor/active_record/connection_specification.rb +0 -301
- data/lib/ddtrace/worker.rb +0 -20
- data/lib/ddtrace/workers/async.rb +0 -165
- data/lib/ddtrace/workers/loop.rb +0 -105
- data/lib/ddtrace/workers/polling.rb +0 -48
- data/lib/ddtrace/workers/queue.rb +0 -39
- data/lib/ddtrace/workers/runtime_metrics.rb +0 -47
- data/lib/ddtrace/workers/trace_writer.rb +0 -199
- data/lib/ddtrace/workers.rb +0 -117
- data/lib/ddtrace/writer.rb +0 -154
- data/tasks/release_gem.rake +0 -28
@@ -0,0 +1,505 @@
|
|
1
|
+
# typed: true
|
2
|
+
|
3
|
+
require 'datadog/core'
|
4
|
+
require 'datadog/core/environment/ext'
|
5
|
+
require 'datadog/core/environment/socket'
|
6
|
+
|
7
|
+
require 'datadog/tracing/correlation'
|
8
|
+
require 'datadog/tracing/event'
|
9
|
+
require 'datadog/tracing/flush'
|
10
|
+
require 'datadog/tracing/context_provider'
|
11
|
+
require 'datadog/tracing/sampling/all_sampler'
|
12
|
+
require 'datadog/tracing/sampling/rule_sampler'
|
13
|
+
require 'datadog/tracing/sampling/priority_sampler'
|
14
|
+
require 'datadog/tracing/span_operation'
|
15
|
+
require 'datadog/tracing/trace_digest'
|
16
|
+
require 'datadog/tracing/trace_operation'
|
17
|
+
require 'datadog/tracing/writer'
|
18
|
+
|
19
|
+
module Datadog
|
20
|
+
module Tracing
|
21
|
+
# A {Datadog::Tracing::Tracer} keeps track of the time spent by an application processing a single operation. For
|
22
|
+
# example, a trace can be used to track the entire time spent processing a complicated web request.
|
23
|
+
# Even though the request may require multiple resources and machines to handle the request, all
|
24
|
+
# of these function calls and sub-requests would be encapsulated within a single trace.
|
25
|
+
# rubocop:disable Metrics/ClassLength
|
26
|
+
class Tracer
|
27
|
+
attr_reader \
|
28
|
+
:trace_flush,
|
29
|
+
:provider,
|
30
|
+
:sampler,
|
31
|
+
:tags
|
32
|
+
|
33
|
+
attr_accessor \
|
34
|
+
:default_service,
|
35
|
+
:enabled,
|
36
|
+
:writer
|
37
|
+
|
38
|
+
# Initialize a new {Datadog::Tracing::Tracer} used to create, sample and submit spans that measure the
|
39
|
+
# time of sections of code.
|
40
|
+
#
|
41
|
+
# @param trace_flush [Datadog::Tracing::TraceFlush] responsible for flushing spans from the execution context
|
42
|
+
# @param context_provider [Datadog::Tracing::DefaultContextProvider] ensures different
|
43
|
+
# execution contexts have distinct traces
|
44
|
+
# @param default_service [String] A fallback value for {Datadog::Tracing::Span#service}, as spans without
|
45
|
+
# service are rejected
|
46
|
+
# @param enabled [Boolean] set if the tracer submits or not spans to the local agent
|
47
|
+
# @param sampler [Datadog::Tracing::Sampler] a tracer sampler, responsible for filtering out spans when needed
|
48
|
+
# @param tags [Hash] default tags added to all spans
|
49
|
+
# @param writer [Datadog::Tracing::Writer] consumes traces returned by the provided +trace_flush+
|
50
|
+
def initialize(
|
51
|
+
trace_flush: Flush::Finished.new,
|
52
|
+
context_provider: DefaultContextProvider.new,
|
53
|
+
default_service: Core::Environment::Ext::FALLBACK_SERVICE_NAME,
|
54
|
+
enabled: true,
|
55
|
+
sampler: Sampling::PrioritySampler.new(
|
56
|
+
base_sampler: Sampling::AllSampler.new,
|
57
|
+
post_sampler: Sampling::RuleSampler.new
|
58
|
+
),
|
59
|
+
tags: {},
|
60
|
+
writer: Writer.new
|
61
|
+
)
|
62
|
+
@trace_flush = trace_flush
|
63
|
+
@default_service = default_service
|
64
|
+
@enabled = enabled
|
65
|
+
@provider = context_provider
|
66
|
+
@sampler = sampler
|
67
|
+
@tags = tags
|
68
|
+
@writer = writer
|
69
|
+
end
|
70
|
+
|
71
|
+
# Return a {Datadog::Tracing::SpanOperation span_op} and {Datadog::Tracing::TraceOperation trace_op}
|
72
|
+
# that will trace an operation called `name`.
|
73
|
+
#
|
74
|
+
# You could trace your code using a <tt>do-block</tt> like:
|
75
|
+
#
|
76
|
+
# ```
|
77
|
+
# tracer.trace('web.request') do |span_op, trace_op|
|
78
|
+
# span_op.service = 'my-web-site'
|
79
|
+
# span_op.resource = '/'
|
80
|
+
# span_op.set_tag('http.method', request.request_method)
|
81
|
+
# do_something()
|
82
|
+
# end
|
83
|
+
# ```
|
84
|
+
#
|
85
|
+
# The {#trace} method can also be used without a block in this way:
|
86
|
+
# ```
|
87
|
+
# span_op = tracer.trace('web.request', service: 'my-web-site')
|
88
|
+
# do_something()
|
89
|
+
# span_op.finish()
|
90
|
+
# ```
|
91
|
+
#
|
92
|
+
# Remember that in this case, calling {Datadog::Tracing::SpanOperation#finish} is mandatory.
|
93
|
+
#
|
94
|
+
# When a Trace is started, {#trace} will store the created span; subsequent spans will
|
95
|
+
# become its children and will inherit some properties:
|
96
|
+
# ```
|
97
|
+
# parent = tracer.trace('parent') # has no parent span
|
98
|
+
# child = tracer.trace('child') # is a child of 'parent'
|
99
|
+
# child.finish()
|
100
|
+
# parent.finish()
|
101
|
+
# parent2 = tracer.trace('parent2') # has no parent span
|
102
|
+
# parent2.finish()
|
103
|
+
# ```
|
104
|
+
#
|
105
|
+
# @param [String] name {Datadog::Tracing::Span} operation name.
|
106
|
+
# See {https://docs.datadoghq.com/tracing/guide/configuring-primary-operation/ Primary Operations in Services}.
|
107
|
+
# @param [Datadog::Tracing::TraceDigest] continue_from continue a trace from a {Datadog::Tracing::TraceDigest}.
|
108
|
+
# Used for linking traces that are executed asynchronously.
|
109
|
+
# @param [Proc] on_error a block that overrides error handling behavior for this operation.
|
110
|
+
# @param [String] resource the resource this span refers, or `name` if it's missing
|
111
|
+
# @param [String] service the service name for this span.
|
112
|
+
# @param [Time] start_time time which the span should have started.
|
113
|
+
# @param [Hash<String,String>] tags extra tags which should be added to the span.
|
114
|
+
# @param [String] type the type of the span. See {Datadog::Tracing::Metadata::Ext::AppTypes}.
|
115
|
+
# @return [Object] If a block is provided, returns the result of the block execution.
|
116
|
+
# @return [Datadog::Tracing::SpanOperation] If no block is provided, returns the active,
|
117
|
+
# unfinished {Datadog::Tracing::SpanOperation}.
|
118
|
+
# @yield Optional block where new newly created {Datadog::Tracing::SpanOperation} captures the execution.
|
119
|
+
# @yieldparam [Datadog::Tracing::SpanOperation] span_op the newly created and active [Datadog::Tracing::SpanOperation]
|
120
|
+
# @yieldparam [Datadog::Tracing::TraceOperation] trace_op the active [Datadog::Tracing::TraceOperation]
|
121
|
+
# rubocop:disable Lint/UnderscorePrefixedVariableName
|
122
|
+
# rubocop:disable Metrics/MethodLength
|
123
|
+
def trace(
|
124
|
+
name,
|
125
|
+
continue_from: nil,
|
126
|
+
on_error: nil,
|
127
|
+
resource: nil,
|
128
|
+
service: nil,
|
129
|
+
start_time: nil,
|
130
|
+
tags: nil,
|
131
|
+
type: nil,
|
132
|
+
span_type: nil,
|
133
|
+
_context: nil,
|
134
|
+
&block
|
135
|
+
)
|
136
|
+
return skip_trace(name, &block) unless enabled
|
137
|
+
|
138
|
+
context, trace = nil
|
139
|
+
|
140
|
+
# Resolve the trace
|
141
|
+
begin
|
142
|
+
context = _context || call_context
|
143
|
+
active_trace = context.active_trace
|
144
|
+
trace = if continue_from || active_trace.nil?
|
145
|
+
start_trace(continue_from: continue_from)
|
146
|
+
else
|
147
|
+
active_trace
|
148
|
+
end
|
149
|
+
rescue StandardError => e
|
150
|
+
Datadog.logger.debug { "Failed to trace: #{e}" }
|
151
|
+
|
152
|
+
# Tracing failed: fallback and run code without tracing.
|
153
|
+
return skip_trace(name, &block)
|
154
|
+
end
|
155
|
+
|
156
|
+
# Activate and start the trace
|
157
|
+
if block
|
158
|
+
context.activate!(trace) do
|
159
|
+
start_span(
|
160
|
+
name,
|
161
|
+
on_error: on_error,
|
162
|
+
resource: resource,
|
163
|
+
service: service,
|
164
|
+
start_time: start_time,
|
165
|
+
tags: tags,
|
166
|
+
type: span_type || type,
|
167
|
+
_trace: trace,
|
168
|
+
&block
|
169
|
+
)
|
170
|
+
end
|
171
|
+
else
|
172
|
+
# Setup trace activation/deactivation
|
173
|
+
manual_trace_activation!(context, trace)
|
174
|
+
|
175
|
+
# Return the new span
|
176
|
+
start_span(
|
177
|
+
name,
|
178
|
+
on_error: on_error,
|
179
|
+
resource: resource,
|
180
|
+
service: service,
|
181
|
+
start_time: start_time,
|
182
|
+
tags: tags,
|
183
|
+
type: span_type || type,
|
184
|
+
_trace: trace
|
185
|
+
)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
# rubocop:enable Lint/UnderscorePrefixedVariableName
|
189
|
+
# rubocop:enable Metrics/MethodLength
|
190
|
+
|
191
|
+
# Set the given key / value tag pair at the tracer level. These tags will be
|
192
|
+
# appended to each span created by the tracer. Keys and values must be strings.
|
193
|
+
# @example
|
194
|
+
# tracer.set_tags('env' => 'prod', 'component' => 'core')
|
195
|
+
def set_tags(tags)
|
196
|
+
string_tags = tags.collect { |k, v| [k.to_s, v] }.to_h
|
197
|
+
@tags = @tags.merge(string_tags)
|
198
|
+
end
|
199
|
+
|
200
|
+
# The active, unfinished trace, representing the current instrumentation context.
|
201
|
+
#
|
202
|
+
# The active trace is fiber-local.
|
203
|
+
#
|
204
|
+
# @param [Thread] key Thread to retrieve trace from. Defaults to current thread. For internal use only.
|
205
|
+
# @return [Datadog::Tracing::TraceSegment] the active trace
|
206
|
+
# @return [nil] if no trace is active
|
207
|
+
def active_trace(key = nil)
|
208
|
+
call_context(key).active_trace
|
209
|
+
end
|
210
|
+
|
211
|
+
# The active, unfinished span, representing the currently instrumented application section.
|
212
|
+
#
|
213
|
+
# The active span belongs to an {.active_trace}.
|
214
|
+
#
|
215
|
+
# @param [Thread] key Thread to retrieve trace from. Defaults to current thread. For internal use only.
|
216
|
+
# @return [Datadog::Tracing::SpanOperation] the active span
|
217
|
+
# @return [nil] if no trace is active, and thus no span is active
|
218
|
+
def active_span(key = nil)
|
219
|
+
trace = active_trace(key)
|
220
|
+
trace.active_span if trace
|
221
|
+
end
|
222
|
+
|
223
|
+
# Information about the currently active trace.
|
224
|
+
#
|
225
|
+
# The most common use cases are tagging log messages and metrics.
|
226
|
+
#
|
227
|
+
# @param [Thread] key Thread to retrieve trace from. Defaults to current thread. For internal use only.
|
228
|
+
# @return [Datadog::Tracing::Correlation::Identifier] correlation object
|
229
|
+
def active_correlation(key = nil)
|
230
|
+
trace = active_trace(key)
|
231
|
+
Correlation.identifier_from_digest(
|
232
|
+
trace && trace.to_digest
|
233
|
+
)
|
234
|
+
end
|
235
|
+
|
236
|
+
# Setup a new trace to continue from where another
|
237
|
+
# trace left off.
|
238
|
+
#
|
239
|
+
# Used to continue distributed or async traces.
|
240
|
+
#
|
241
|
+
# @param [Datadog::Tracing::TraceDigest] digest continue from the {Datadog::Tracing::TraceDigest}.
|
242
|
+
# @param [Thread] key Thread to retrieve trace from. Defaults to current thread. For internal use only.
|
243
|
+
# @return [Object] If a block is provided, the result of the block execution.
|
244
|
+
# @return [Datadog::Tracing::TraceOperation] If no block, the active {Datadog::Tracing::TraceOperation}.
|
245
|
+
# @yield Optional block where this {#continue_trace!} `digest` scope is active.
|
246
|
+
# If no block, the `digest` remains active after {#continue_trace!} returns.
|
247
|
+
def continue_trace!(digest, key = nil, &block)
|
248
|
+
# Only accept {TraceDigest} as a digest.
|
249
|
+
# Otherwise, create a new execution context.
|
250
|
+
digest = nil unless digest.is_a?(TraceDigest)
|
251
|
+
|
252
|
+
# Start a new trace from the digest
|
253
|
+
context = call_context(key)
|
254
|
+
original_trace = active_trace(key)
|
255
|
+
trace = start_trace(continue_from: digest)
|
256
|
+
|
257
|
+
# If block hasn't been given; we need to manually deactivate
|
258
|
+
# this trace. Subscribe to the trace finished event to do this.
|
259
|
+
subscribe_trace_deactivation!(context, trace, original_trace) unless block
|
260
|
+
|
261
|
+
context.activate!(trace, &block)
|
262
|
+
end
|
263
|
+
|
264
|
+
# @!visibility private
|
265
|
+
# TODO: make this private
|
266
|
+
def trace_completed
|
267
|
+
@trace_completed ||= TraceCompleted.new
|
268
|
+
end
|
269
|
+
|
270
|
+
# Triggered whenever a trace is completed
|
271
|
+
class TraceCompleted < Tracing::Event
|
272
|
+
def initialize
|
273
|
+
super(:trace_completed)
|
274
|
+
end
|
275
|
+
|
276
|
+
# NOTE: Ignore Rubocop rule. This definition allows for
|
277
|
+
# description of and constraints on arguments.
|
278
|
+
# rubocop:disable Lint/UselessMethodDefinition
|
279
|
+
def publish(trace)
|
280
|
+
super(trace)
|
281
|
+
end
|
282
|
+
# rubocop:enable Lint/UselessMethodDefinition
|
283
|
+
end
|
284
|
+
|
285
|
+
# Shorthand that calls the `shutdown!` method of a registered worker.
|
286
|
+
# It's useful to ensure that the Trace Buffer is properly flushed before
|
287
|
+
# shutting down the application.
|
288
|
+
#
|
289
|
+
# @example
|
290
|
+
# tracer.trace('operation_name', service='rake_tasks') do |span_op|
|
291
|
+
# span_op.set_tag('task.name', 'script')
|
292
|
+
# end
|
293
|
+
#
|
294
|
+
# tracer.shutdown!
|
295
|
+
def shutdown!
|
296
|
+
return unless @enabled
|
297
|
+
|
298
|
+
@writer.stop if @writer
|
299
|
+
end
|
300
|
+
|
301
|
+
private
|
302
|
+
|
303
|
+
# Return the current active {Context} for this traced execution. This method is
|
304
|
+
# automatically called when calling Tracer.trace or Tracer.start_span,
|
305
|
+
# but it can be used in the application code during manual instrumentation.
|
306
|
+
#
|
307
|
+
# This method makes use of a {ContextProvider} that is automatically set during the tracer
|
308
|
+
# initialization, or while using a library instrumentation.
|
309
|
+
#
|
310
|
+
# @param [Thread] key Thread to retrieve tracer from. Defaults to current thread.
|
311
|
+
def call_context(key = nil)
|
312
|
+
@provider.context(key)
|
313
|
+
end
|
314
|
+
|
315
|
+
def build_trace(digest = nil)
|
316
|
+
# Resolve hostname if configured
|
317
|
+
hostname = Core::Environment::Socket.hostname if Datadog.configuration.tracing.report_hostname
|
318
|
+
hostname = hostname && !hostname.empty? ? hostname : nil
|
319
|
+
|
320
|
+
if digest
|
321
|
+
TraceOperation.new(
|
322
|
+
hostname: hostname,
|
323
|
+
id: digest.trace_id,
|
324
|
+
origin: digest.trace_origin,
|
325
|
+
parent_span_id: digest.span_id,
|
326
|
+
sampling_priority: digest.trace_sampling_priority
|
327
|
+
)
|
328
|
+
else
|
329
|
+
TraceOperation.new(
|
330
|
+
hostname: hostname
|
331
|
+
)
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
335
|
+
def bind_trace_events!(trace_op)
|
336
|
+
events = trace_op.send(:events)
|
337
|
+
|
338
|
+
events.span_before_start.subscribe do |event_span_op, event_trace_op|
|
339
|
+
event_trace_op.service ||= @default_service
|
340
|
+
event_span_op.service ||= @default_service
|
341
|
+
sample_trace(event_trace_op) if event_span_op && event_span_op.parent_id == 0
|
342
|
+
end
|
343
|
+
|
344
|
+
events.span_finished.subscribe do |_event_span, event_trace_op|
|
345
|
+
flush_trace(event_trace_op)
|
346
|
+
end
|
347
|
+
end
|
348
|
+
|
349
|
+
def start_trace(continue_from: nil)
|
350
|
+
# Build a new trace using digest if provided.
|
351
|
+
trace = build_trace(continue_from)
|
352
|
+
|
353
|
+
# Bind trace events: sample trace, set default service, flush spans.
|
354
|
+
bind_trace_events!(trace)
|
355
|
+
|
356
|
+
trace
|
357
|
+
end
|
358
|
+
|
359
|
+
# rubocop:disable Lint/UnderscorePrefixedVariableName
|
360
|
+
def start_span(
|
361
|
+
name,
|
362
|
+
continue_from: nil,
|
363
|
+
on_error: nil,
|
364
|
+
resource: nil,
|
365
|
+
service: nil,
|
366
|
+
start_time: nil,
|
367
|
+
tags: nil,
|
368
|
+
type: nil,
|
369
|
+
_trace: nil,
|
370
|
+
&block
|
371
|
+
)
|
372
|
+
trace = _trace || start_trace(continue_from: continue_from)
|
373
|
+
|
374
|
+
if block
|
375
|
+
# Ignore start time if a block has been given
|
376
|
+
trace.measure(
|
377
|
+
name,
|
378
|
+
events: build_span_events,
|
379
|
+
on_error: on_error,
|
380
|
+
resource: resource,
|
381
|
+
service: service,
|
382
|
+
tags: resolve_tags(tags),
|
383
|
+
type: type,
|
384
|
+
&block
|
385
|
+
)
|
386
|
+
else
|
387
|
+
# Return the new span
|
388
|
+
span = trace.build_span(
|
389
|
+
name,
|
390
|
+
events: build_span_events,
|
391
|
+
on_error: on_error,
|
392
|
+
resource: resource,
|
393
|
+
service: service,
|
394
|
+
start_time: start_time,
|
395
|
+
tags: resolve_tags(tags),
|
396
|
+
type: type
|
397
|
+
)
|
398
|
+
|
399
|
+
span.start(start_time)
|
400
|
+
span
|
401
|
+
end
|
402
|
+
end
|
403
|
+
# rubocop:enable Lint/UnderscorePrefixedVariableName
|
404
|
+
|
405
|
+
def build_span_events(events = nil)
|
406
|
+
case events
|
407
|
+
when SpanOperation::Events
|
408
|
+
events
|
409
|
+
when Hash
|
410
|
+
SpanOperation::Events.build(events)
|
411
|
+
else
|
412
|
+
SpanOperation::Events.new
|
413
|
+
end
|
414
|
+
end
|
415
|
+
|
416
|
+
def resolve_tags(tags)
|
417
|
+
if @tags.any? && tags
|
418
|
+
# Combine default tags with provided tags,
|
419
|
+
# preferring provided tags.
|
420
|
+
@tags.merge(tags)
|
421
|
+
else
|
422
|
+
# Use provided tags or default tags if none.
|
423
|
+
tags || @tags.dup
|
424
|
+
end
|
425
|
+
end
|
426
|
+
|
427
|
+
# Manually activate and deactivate the trace, when the span completes.
|
428
|
+
def manual_trace_activation!(context, trace)
|
429
|
+
# Get the original trace to restore
|
430
|
+
original_trace = context.active_trace
|
431
|
+
|
432
|
+
# Setup the deactivation callback
|
433
|
+
subscribe_trace_deactivation!(context, trace, original_trace)
|
434
|
+
|
435
|
+
# Activate the trace
|
436
|
+
# Skip this, if it would have no effect.
|
437
|
+
context.activate!(trace) unless trace == original_trace
|
438
|
+
end
|
439
|
+
|
440
|
+
# Reactivate the original trace when trace completes
|
441
|
+
def subscribe_trace_deactivation!(context, trace, original_trace)
|
442
|
+
# Don't override this event if it's set.
|
443
|
+
# The original event should reactivate the original trace correctly.
|
444
|
+
#
|
445
|
+
# This happens when multiple manually-activation spans are created:
|
446
|
+
# ```ruby
|
447
|
+
# tracer.trace('parent') do
|
448
|
+
# span1 = tracer.trace('first') # Registers trace deactivation back to `parent` span.
|
449
|
+
# span2 = tracer.trace('second') # Tries to register trace deactivation back to `first`, which is not correct.
|
450
|
+
# end
|
451
|
+
# ```
|
452
|
+
return if trace.send(:events).trace_finished.deactivate_trace_subscribed?
|
453
|
+
|
454
|
+
trace.send(:events).trace_finished.subscribe_deactivate_trace do
|
455
|
+
context.activate!(original_trace)
|
456
|
+
end
|
457
|
+
end
|
458
|
+
|
459
|
+
# Sample a span, tagging the trace as appropriate.
|
460
|
+
def sample_trace(trace_op)
|
461
|
+
begin
|
462
|
+
@sampler.sample!(trace_op)
|
463
|
+
rescue StandardError => e
|
464
|
+
Datadog.logger.debug { "Failed to sample trace: #{e}" }
|
465
|
+
end
|
466
|
+
end
|
467
|
+
|
468
|
+
# Flush finished spans from the trace buffer, send them to writer.
|
469
|
+
def flush_trace(trace_op)
|
470
|
+
begin
|
471
|
+
trace = @trace_flush.consume!(trace_op)
|
472
|
+
write(trace) if trace && !trace.empty?
|
473
|
+
rescue StandardError => e
|
474
|
+
Datadog.logger.debug { "Failed to flush trace: #{e}" }
|
475
|
+
end
|
476
|
+
end
|
477
|
+
|
478
|
+
# Send the trace to the writer to enqueue the spans list in the agent
|
479
|
+
# sending queue.
|
480
|
+
def write(trace)
|
481
|
+
return unless trace && @writer
|
482
|
+
|
483
|
+
if Datadog.configuration.diagnostics.debug
|
484
|
+
Datadog.logger.debug { "Writing #{trace.length} spans (enabled: #{@enabled})\n#{trace.spans.pretty_inspect}" }
|
485
|
+
end
|
486
|
+
|
487
|
+
@writer.write(trace)
|
488
|
+
trace_completed.publish(trace)
|
489
|
+
end
|
490
|
+
|
491
|
+
# TODO: Make these dummy objects singletons to preserve memory.
|
492
|
+
def skip_trace(name)
|
493
|
+
span = SpanOperation.new(name)
|
494
|
+
|
495
|
+
if block_given?
|
496
|
+
trace = TraceOperation.new
|
497
|
+
yield(span, trace)
|
498
|
+
else
|
499
|
+
span
|
500
|
+
end
|
501
|
+
end
|
502
|
+
end
|
503
|
+
# rubocop:enable Metrics/ClassLength
|
504
|
+
end
|
505
|
+
end
|
@@ -0,0 +1,195 @@
|
|
1
|
+
# typed: false
|
2
|
+
|
3
|
+
require 'datadog/core'
|
4
|
+
require 'datadog/core/worker'
|
5
|
+
require 'datadog/core/workers/async'
|
6
|
+
require 'datadog/core/workers/polling'
|
7
|
+
require 'datadog/core/workers/queue'
|
8
|
+
|
9
|
+
require 'datadog/tracing/buffer'
|
10
|
+
require 'datadog/tracing/pipeline'
|
11
|
+
require 'datadog/tracing/event'
|
12
|
+
|
13
|
+
require 'ddtrace/transport/http'
|
14
|
+
|
15
|
+
module Datadog
|
16
|
+
module Tracing
|
17
|
+
module Workers
|
18
|
+
# Writes traces to transport synchronously
|
19
|
+
class TraceWriter < Core::Worker
|
20
|
+
attr_reader \
|
21
|
+
:transport
|
22
|
+
|
23
|
+
# rubocop:disable Lint/MissingSuper
|
24
|
+
def initialize(options = {})
|
25
|
+
transport_options = options.fetch(:transport_options, {})
|
26
|
+
|
27
|
+
transport_options[:agent_settings] = options[:agent_settings] if options.key?(:agent_settings)
|
28
|
+
|
29
|
+
@transport = options.fetch(:transport) do
|
30
|
+
Transport::HTTP.default(**transport_options)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
# rubocop:enable Lint/MissingSuper
|
34
|
+
|
35
|
+
def perform(traces)
|
36
|
+
write_traces(traces)
|
37
|
+
end
|
38
|
+
|
39
|
+
def write(trace)
|
40
|
+
write_traces([trace])
|
41
|
+
end
|
42
|
+
|
43
|
+
def write_traces(traces)
|
44
|
+
traces = process_traces(traces)
|
45
|
+
flush_traces(traces)
|
46
|
+
rescue StandardError => e
|
47
|
+
Datadog.logger.error(
|
48
|
+
"Error while writing traces: dropped #{traces.length} items. Cause: #{e} Location: #{Array(e.backtrace).first}"
|
49
|
+
)
|
50
|
+
end
|
51
|
+
|
52
|
+
def process_traces(traces)
|
53
|
+
# Run traces through the processing pipeline
|
54
|
+
Pipeline.process!(traces)
|
55
|
+
end
|
56
|
+
|
57
|
+
def flush_traces(traces)
|
58
|
+
transport.send_traces(traces).tap do |response|
|
59
|
+
flush_completed.publish(response)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# TODO: Register `Datadog::Core::Diagnostics::EnvironmentLogger.log!`
|
64
|
+
# TODO: as a flush_completed subscriber when the `TraceWriter`
|
65
|
+
# TODO: instantiation code is implemented.
|
66
|
+
def flush_completed
|
67
|
+
@flush_completed ||= FlushCompleted.new
|
68
|
+
end
|
69
|
+
|
70
|
+
# Flush completed event for worker
|
71
|
+
class FlushCompleted < Event
|
72
|
+
def initialize
|
73
|
+
super(:flush_completed)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# Writes traces to transport asynchronously,
|
79
|
+
# using a thread & buffer.
|
80
|
+
class AsyncTraceWriter < TraceWriter
|
81
|
+
include Core::Workers::Queue
|
82
|
+
include Core::Workers::Polling
|
83
|
+
|
84
|
+
DEFAULT_BUFFER_MAX_SIZE = 1000
|
85
|
+
FORK_POLICY_ASYNC = :async
|
86
|
+
FORK_POLICY_SYNC = :sync
|
87
|
+
|
88
|
+
attr_writer \
|
89
|
+
:async
|
90
|
+
|
91
|
+
def initialize(options = {})
|
92
|
+
# Workers::TraceWriter settings
|
93
|
+
super
|
94
|
+
|
95
|
+
# Workers::Polling settings
|
96
|
+
self.enabled = options.fetch(:enabled, true)
|
97
|
+
|
98
|
+
# Workers::Async::Thread settings
|
99
|
+
@async = true
|
100
|
+
self.fork_policy = options.fetch(:fork_policy, FORK_POLICY_ASYNC)
|
101
|
+
|
102
|
+
# Workers::IntervalLoop settings
|
103
|
+
self.loop_base_interval = options[:interval] if options.key?(:interval)
|
104
|
+
self.loop_back_off_ratio = options[:back_off_ratio] if options.key?(:back_off_ratio)
|
105
|
+
self.loop_back_off_max = options[:back_off_max] if options.key?(:back_off_max)
|
106
|
+
|
107
|
+
# Workers::Queue settings
|
108
|
+
@buffer_size = options.fetch(:buffer_size, DEFAULT_BUFFER_MAX_SIZE)
|
109
|
+
self.buffer = TraceBuffer.new(@buffer_size)
|
110
|
+
end
|
111
|
+
|
112
|
+
# NOTE: #perform is wrapped by other modules:
|
113
|
+
# Polling --> Async --> IntervalLoop --> AsyncTraceWriter --> TraceWriter
|
114
|
+
#
|
115
|
+
# WARNING: This method breaks the Liskov Substitution Principle -- TraceWriter#perform is spec'd to return the
|
116
|
+
# result from the writer, whereas this method always returns nil.
|
117
|
+
def perform(traces)
|
118
|
+
super(traces).tap do |responses|
|
119
|
+
loop_back_off! if responses.find(&:server_error?)
|
120
|
+
end
|
121
|
+
|
122
|
+
nil
|
123
|
+
end
|
124
|
+
|
125
|
+
def stop(*args)
|
126
|
+
buffer.close if running?
|
127
|
+
super
|
128
|
+
end
|
129
|
+
|
130
|
+
def enqueue(trace)
|
131
|
+
buffer.push(trace)
|
132
|
+
end
|
133
|
+
|
134
|
+
def dequeue
|
135
|
+
# Wrap results in Array because they are
|
136
|
+
# splatted as args against TraceWriter#perform.
|
137
|
+
[buffer.pop]
|
138
|
+
end
|
139
|
+
|
140
|
+
# Are there more traces to be processed next?
|
141
|
+
def work_pending?
|
142
|
+
!buffer.empty?
|
143
|
+
end
|
144
|
+
|
145
|
+
def async?
|
146
|
+
@async == true
|
147
|
+
end
|
148
|
+
|
149
|
+
def fork_policy=(policy)
|
150
|
+
# Translate to Workers::Async::Thread policy
|
151
|
+
thread_fork_policy = case policy
|
152
|
+
when Core::Workers::Async::Thread::FORK_POLICY_STOP
|
153
|
+
policy
|
154
|
+
when FORK_POLICY_SYNC
|
155
|
+
# Stop the async thread because the writer
|
156
|
+
# will bypass and run synchronously.
|
157
|
+
Core::Workers::Async::Thread::FORK_POLICY_STOP
|
158
|
+
else
|
159
|
+
Core::Workers::Async::Thread::FORK_POLICY_RESTART
|
160
|
+
end
|
161
|
+
|
162
|
+
# Update thread fork policy
|
163
|
+
super(thread_fork_policy)
|
164
|
+
|
165
|
+
# Update local policy
|
166
|
+
@writer_fork_policy = policy
|
167
|
+
end
|
168
|
+
|
169
|
+
def after_fork
|
170
|
+
# In multiprocess environments, forks will share the same buffer until its written to.
|
171
|
+
# A.K.A. copy-on-write. We don't want forks to write traces generated from another process.
|
172
|
+
# Instead, we reset it after the fork. (Make sure any enqueue operations happen after this.)
|
173
|
+
self.buffer = TraceBuffer.new(@buffer_size)
|
174
|
+
|
175
|
+
# Switch to synchronous mode if configured to do so.
|
176
|
+
# In some cases synchronous writing is preferred because the fork will be short lived.
|
177
|
+
@async = false if @writer_fork_policy == FORK_POLICY_SYNC
|
178
|
+
end
|
179
|
+
|
180
|
+
# WARNING: This method breaks the Liskov Substitution Principle -- TraceWriter#write is spec'd to return the
|
181
|
+
# result from the writer, whereas this method returns something else when running in async mode.
|
182
|
+
def write(trace)
|
183
|
+
# Start worker thread. If the process has forked, it will trigger #after_fork to
|
184
|
+
# reconfigure the worker accordingly.
|
185
|
+
# NOTE: It's important we do this before queuing or it will drop the current trace,
|
186
|
+
# because #after_fork resets the buffer.
|
187
|
+
perform
|
188
|
+
|
189
|
+
# Queue the trace if running asynchronously, otherwise short-circuit and write it directly.
|
190
|
+
async? ? enqueue(trace) : write_traces([trace])
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|