ls-trace 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +673 -0
- data/.circleci/images/primary/Dockerfile-2.0.0 +73 -0
- data/.circleci/images/primary/Dockerfile-2.1.10 +73 -0
- data/.circleci/images/primary/Dockerfile-2.2.10 +73 -0
- data/.circleci/images/primary/Dockerfile-2.3.8 +75 -0
- data/.circleci/images/primary/Dockerfile-2.4.6 +73 -0
- data/.circleci/images/primary/Dockerfile-2.5.6 +73 -0
- data/.circleci/images/primary/Dockerfile-2.6.4 +73 -0
- data/.dockerignore +1 -0
- data/.env +24 -0
- data/.github/CODEOWNERS +1 -0
- data/.gitignore +59 -0
- data/.rspec +1 -0
- data/.rubocop.yml +77 -0
- data/.yardopts +5 -0
- data/Appraisals +820 -0
- data/CHANGELOG.md +1051 -0
- data/CONTRIBUTING.md +85 -0
- data/Gemfile +7 -0
- data/LICENSE +24 -0
- data/README.md +108 -0
- data/Rakefile +635 -0
- data/benchmarks/postgres_database.yml +9 -0
- data/benchmarks/sidekiq_test.rb +154 -0
- data/ddtrace.gemspec +63 -0
- data/docker-compose.yml +276 -0
- data/docs/DevelopmentGuide.md +195 -0
- data/docs/GettingStarted.md +1981 -0
- data/lib/ddtrace.rb +63 -0
- data/lib/ddtrace/analytics.rb +29 -0
- data/lib/ddtrace/augmentation.rb +13 -0
- data/lib/ddtrace/augmentation/method_wrapper.rb +20 -0
- data/lib/ddtrace/augmentation/method_wrapping.rb +38 -0
- data/lib/ddtrace/augmentation/shim.rb +102 -0
- data/lib/ddtrace/buffer.rb +119 -0
- data/lib/ddtrace/configuration.rb +30 -0
- data/lib/ddtrace/configuration/base.rb +82 -0
- data/lib/ddtrace/configuration/dependency_resolver.rb +24 -0
- data/lib/ddtrace/configuration/option.rb +55 -0
- data/lib/ddtrace/configuration/option_definition.rb +127 -0
- data/lib/ddtrace/configuration/option_definition_set.rb +18 -0
- data/lib/ddtrace/configuration/option_set.rb +6 -0
- data/lib/ddtrace/configuration/options.rb +107 -0
- data/lib/ddtrace/configuration/pin_setup.rb +30 -0
- data/lib/ddtrace/configuration/settings.rb +105 -0
- data/lib/ddtrace/context.rb +284 -0
- data/lib/ddtrace/context_flush.rb +132 -0
- data/lib/ddtrace/contrib/action_pack/action_controller/instrumentation.rb +144 -0
- data/lib/ddtrace/contrib/action_pack/action_controller/patcher.rb +37 -0
- data/lib/ddtrace/contrib/action_pack/configuration/settings.rb +27 -0
- data/lib/ddtrace/contrib/action_pack/ext.rb +16 -0
- data/lib/ddtrace/contrib/action_pack/integration.rb +36 -0
- data/lib/ddtrace/contrib/action_pack/patcher.rb +29 -0
- data/lib/ddtrace/contrib/action_pack/utils.rb +36 -0
- data/lib/ddtrace/contrib/action_view/configuration/settings.rb +26 -0
- data/lib/ddtrace/contrib/action_view/ext.rb +17 -0
- data/lib/ddtrace/contrib/action_view/instrumentation/partial_renderer.rb +78 -0
- data/lib/ddtrace/contrib/action_view/instrumentation/template_renderer.rb +167 -0
- data/lib/ddtrace/contrib/action_view/integration.rb +43 -0
- data/lib/ddtrace/contrib/action_view/patcher.rb +53 -0
- data/lib/ddtrace/contrib/action_view/utils.rb +32 -0
- data/lib/ddtrace/contrib/active_model_serializers/configuration/settings.rb +25 -0
- data/lib/ddtrace/contrib/active_model_serializers/event.rb +65 -0
- data/lib/ddtrace/contrib/active_model_serializers/events.rb +30 -0
- data/lib/ddtrace/contrib/active_model_serializers/events/render.rb +32 -0
- data/lib/ddtrace/contrib/active_model_serializers/events/serialize.rb +35 -0
- data/lib/ddtrace/contrib/active_model_serializers/ext.rb +17 -0
- data/lib/ddtrace/contrib/active_model_serializers/integration.rb +39 -0
- data/lib/ddtrace/contrib/active_model_serializers/patcher.rb +36 -0
- data/lib/ddtrace/contrib/active_record/configuration/resolver.rb +46 -0
- data/lib/ddtrace/contrib/active_record/configuration/settings.rb +30 -0
- data/lib/ddtrace/contrib/active_record/event.rb +30 -0
- data/lib/ddtrace/contrib/active_record/events.rb +30 -0
- data/lib/ddtrace/contrib/active_record/events/instantiation.rb +57 -0
- data/lib/ddtrace/contrib/active_record/events/sql.rb +64 -0
- data/lib/ddtrace/contrib/active_record/ext.rb +21 -0
- data/lib/ddtrace/contrib/active_record/integration.rb +44 -0
- data/lib/ddtrace/contrib/active_record/patcher.rb +29 -0
- data/lib/ddtrace/contrib/active_record/utils.rb +76 -0
- data/lib/ddtrace/contrib/active_support/cache/instrumentation.rb +157 -0
- data/lib/ddtrace/contrib/active_support/cache/patcher.rb +62 -0
- data/lib/ddtrace/contrib/active_support/cache/redis.rb +47 -0
- data/lib/ddtrace/contrib/active_support/configuration/settings.rb +25 -0
- data/lib/ddtrace/contrib/active_support/ext.rb +21 -0
- data/lib/ddtrace/contrib/active_support/integration.rb +38 -0
- data/lib/ddtrace/contrib/active_support/notifications/event.rb +62 -0
- data/lib/ddtrace/contrib/active_support/notifications/subscriber.rb +66 -0
- data/lib/ddtrace/contrib/active_support/notifications/subscription.rb +159 -0
- data/lib/ddtrace/contrib/active_support/patcher.rb +29 -0
- data/lib/ddtrace/contrib/analytics.rb +20 -0
- data/lib/ddtrace/contrib/aws/configuration/settings.rb +25 -0
- data/lib/ddtrace/contrib/aws/ext.rb +20 -0
- data/lib/ddtrace/contrib/aws/instrumentation.rb +56 -0
- data/lib/ddtrace/contrib/aws/integration.rb +36 -0
- data/lib/ddtrace/contrib/aws/parsed_context.rb +56 -0
- data/lib/ddtrace/contrib/aws/patcher.rb +49 -0
- data/lib/ddtrace/contrib/aws/services.rb +115 -0
- data/lib/ddtrace/contrib/concurrent_ruby/configuration/settings.rb +15 -0
- data/lib/ddtrace/contrib/concurrent_ruby/context_composite_executor_service.rb +35 -0
- data/lib/ddtrace/contrib/concurrent_ruby/ext.rb +11 -0
- data/lib/ddtrace/contrib/concurrent_ruby/future_patch.rb +23 -0
- data/lib/ddtrace/contrib/concurrent_ruby/integration.rb +32 -0
- data/lib/ddtrace/contrib/concurrent_ruby/patcher.rb +35 -0
- data/lib/ddtrace/contrib/configurable.rb +59 -0
- data/lib/ddtrace/contrib/configuration/resolver.rb +12 -0
- data/lib/ddtrace/contrib/configuration/settings.rb +35 -0
- data/lib/ddtrace/contrib/dalli/configuration/settings.rb +25 -0
- data/lib/ddtrace/contrib/dalli/ext.rb +17 -0
- data/lib/ddtrace/contrib/dalli/instrumentation.rb +50 -0
- data/lib/ddtrace/contrib/dalli/integration.rb +36 -0
- data/lib/ddtrace/contrib/dalli/patcher.rb +73 -0
- data/lib/ddtrace/contrib/dalli/quantize.rb +22 -0
- data/lib/ddtrace/contrib/delayed_job/configuration/settings.rb +25 -0
- data/lib/ddtrace/contrib/delayed_job/ext.rb +18 -0
- data/lib/ddtrace/contrib/delayed_job/integration.rb +32 -0
- data/lib/ddtrace/contrib/delayed_job/patcher.rb +34 -0
- data/lib/ddtrace/contrib/delayed_job/plugin.rb +57 -0
- data/lib/ddtrace/contrib/elasticsearch/configuration/settings.rb +26 -0
- data/lib/ddtrace/contrib/elasticsearch/ext.rb +19 -0
- data/lib/ddtrace/contrib/elasticsearch/integration.rb +37 -0
- data/lib/ddtrace/contrib/elasticsearch/patcher.rb +124 -0
- data/lib/ddtrace/contrib/elasticsearch/quantize.rb +80 -0
- data/lib/ddtrace/contrib/ethon/configuration/settings.rb +26 -0
- data/lib/ddtrace/contrib/ethon/easy_patch.rb +139 -0
- data/lib/ddtrace/contrib/ethon/ext.rb +15 -0
- data/lib/ddtrace/contrib/ethon/integration.rb +31 -0
- data/lib/ddtrace/contrib/ethon/multi_patch.rb +80 -0
- data/lib/ddtrace/contrib/ethon/patcher.rb +27 -0
- data/lib/ddtrace/contrib/excon/configuration/settings.rb +28 -0
- data/lib/ddtrace/contrib/excon/ext.rb +14 -0
- data/lib/ddtrace/contrib/excon/integration.rb +32 -0
- data/lib/ddtrace/contrib/excon/middleware.rb +154 -0
- data/lib/ddtrace/contrib/excon/patcher.rb +34 -0
- data/lib/ddtrace/contrib/extensions.rb +59 -0
- data/lib/ddtrace/contrib/faraday/configuration/settings.rb +33 -0
- data/lib/ddtrace/contrib/faraday/ext.rb +14 -0
- data/lib/ddtrace/contrib/faraday/integration.rb +36 -0
- data/lib/ddtrace/contrib/faraday/middleware.rb +93 -0
- data/lib/ddtrace/contrib/faraday/patcher.rb +82 -0
- data/lib/ddtrace/contrib/faraday/rack_builder.rb +18 -0
- data/lib/ddtrace/contrib/grape/configuration/settings.rb +27 -0
- data/lib/ddtrace/contrib/grape/endpoint.rb +199 -0
- data/lib/ddtrace/contrib/grape/ext.rb +19 -0
- data/lib/ddtrace/contrib/grape/instrumentation.rb +33 -0
- data/lib/ddtrace/contrib/grape/integration.rb +36 -0
- data/lib/ddtrace/contrib/grape/patcher.rb +79 -0
- data/lib/ddtrace/contrib/graphql/configuration/settings.rb +27 -0
- data/lib/ddtrace/contrib/graphql/ext.rb +13 -0
- data/lib/ddtrace/contrib/graphql/integration.rb +38 -0
- data/lib/ddtrace/contrib/graphql/patcher.rb +63 -0
- data/lib/ddtrace/contrib/grpc/configuration/settings.rb +25 -0
- data/lib/ddtrace/contrib/grpc/datadog_interceptor.rb +74 -0
- data/lib/ddtrace/contrib/grpc/datadog_interceptor/client.rb +56 -0
- data/lib/ddtrace/contrib/grpc/datadog_interceptor/server.rb +73 -0
- data/lib/ddtrace/contrib/grpc/ext.rb +15 -0
- data/lib/ddtrace/contrib/grpc/integration.rb +36 -0
- data/lib/ddtrace/contrib/grpc/intercept_with_datadog.rb +49 -0
- data/lib/ddtrace/contrib/grpc/patcher.rb +78 -0
- data/lib/ddtrace/contrib/http/circuit_breaker.rb +63 -0
- data/lib/ddtrace/contrib/http/configuration/settings.rb +26 -0
- data/lib/ddtrace/contrib/http/ext.rb +14 -0
- data/lib/ddtrace/contrib/http/instrumentation.rb +114 -0
- data/lib/ddtrace/contrib/http/integration.rb +32 -0
- data/lib/ddtrace/contrib/http/patcher.rb +32 -0
- data/lib/ddtrace/contrib/integration.rb +16 -0
- data/lib/ddtrace/contrib/mongodb/configuration/settings.rb +28 -0
- data/lib/ddtrace/contrib/mongodb/ext.rb +20 -0
- data/lib/ddtrace/contrib/mongodb/instrumentation.rb +68 -0
- data/lib/ddtrace/contrib/mongodb/integration.rb +36 -0
- data/lib/ddtrace/contrib/mongodb/parsers.rb +68 -0
- data/lib/ddtrace/contrib/mongodb/patcher.rb +37 -0
- data/lib/ddtrace/contrib/mongodb/subscribers.rb +108 -0
- data/lib/ddtrace/contrib/mysql2/configuration/settings.rb +25 -0
- data/lib/ddtrace/contrib/mysql2/ext.rb +15 -0
- data/lib/ddtrace/contrib/mysql2/instrumentation.rb +60 -0
- data/lib/ddtrace/contrib/mysql2/integration.rb +32 -0
- data/lib/ddtrace/contrib/mysql2/patcher.rb +33 -0
- data/lib/ddtrace/contrib/patchable.rb +42 -0
- data/lib/ddtrace/contrib/patcher.rb +28 -0
- data/lib/ddtrace/contrib/racecar/configuration/settings.rb +25 -0
- data/lib/ddtrace/contrib/racecar/event.rb +67 -0
- data/lib/ddtrace/contrib/racecar/events.rb +30 -0
- data/lib/ddtrace/contrib/racecar/events/batch.rb +27 -0
- data/lib/ddtrace/contrib/racecar/events/message.rb +27 -0
- data/lib/ddtrace/contrib/racecar/ext.rb +21 -0
- data/lib/ddtrace/contrib/racecar/integration.rb +36 -0
- data/lib/ddtrace/contrib/racecar/patcher.rb +32 -0
- data/lib/ddtrace/contrib/rack/configuration/settings.rb +41 -0
- data/lib/ddtrace/contrib/rack/ext.rb +18 -0
- data/lib/ddtrace/contrib/rack/integration.rb +32 -0
- data/lib/ddtrace/contrib/rack/middlewares.rb +283 -0
- data/lib/ddtrace/contrib/rack/patcher.rb +72 -0
- data/lib/ddtrace/contrib/rack/request_queue.rb +39 -0
- data/lib/ddtrace/contrib/rails/configuration/settings.rb +80 -0
- data/lib/ddtrace/contrib/rails/ext.rb +12 -0
- data/lib/ddtrace/contrib/rails/framework.rb +100 -0
- data/lib/ddtrace/contrib/rails/integration.rb +37 -0
- data/lib/ddtrace/contrib/rails/middlewares.rb +38 -0
- data/lib/ddtrace/contrib/rails/patcher.rb +78 -0
- data/lib/ddtrace/contrib/rails/railtie.rb +17 -0
- data/lib/ddtrace/contrib/rails/utils.rb +20 -0
- data/lib/ddtrace/contrib/rake/configuration/settings.rb +27 -0
- data/lib/ddtrace/contrib/rake/ext.rb +18 -0
- data/lib/ddtrace/contrib/rake/instrumentation.rb +84 -0
- data/lib/ddtrace/contrib/rake/integration.rb +32 -0
- data/lib/ddtrace/contrib/rake/patcher.rb +36 -0
- data/lib/ddtrace/contrib/redis/configuration/settings.rb +25 -0
- data/lib/ddtrace/contrib/redis/ext.rb +18 -0
- data/lib/ddtrace/contrib/redis/integration.rb +36 -0
- data/lib/ddtrace/contrib/redis/patcher.rb +94 -0
- data/lib/ddtrace/contrib/redis/quantize.rb +47 -0
- data/lib/ddtrace/contrib/redis/tags.rb +38 -0
- data/lib/ddtrace/contrib/registerable.rb +33 -0
- data/lib/ddtrace/contrib/registry.rb +42 -0
- data/lib/ddtrace/contrib/resque/configuration/settings.rb +26 -0
- data/lib/ddtrace/contrib/resque/ext.rb +14 -0
- data/lib/ddtrace/contrib/resque/integration.rb +37 -0
- data/lib/ddtrace/contrib/resque/patcher.rb +35 -0
- data/lib/ddtrace/contrib/resque/resque_job.rb +76 -0
- data/lib/ddtrace/contrib/rest_client/configuration/settings.rb +26 -0
- data/lib/ddtrace/contrib/rest_client/ext.rb +14 -0
- data/lib/ddtrace/contrib/rest_client/integration.rb +31 -0
- data/lib/ddtrace/contrib/rest_client/patcher.rb +25 -0
- data/lib/ddtrace/contrib/rest_client/request_patch.rb +89 -0
- data/lib/ddtrace/contrib/sequel/configuration/settings.rb +23 -0
- data/lib/ddtrace/contrib/sequel/database.rb +61 -0
- data/lib/ddtrace/contrib/sequel/dataset.rb +62 -0
- data/lib/ddtrace/contrib/sequel/ext.rb +15 -0
- data/lib/ddtrace/contrib/sequel/integration.rb +32 -0
- data/lib/ddtrace/contrib/sequel/patcher.rb +39 -0
- data/lib/ddtrace/contrib/sequel/utils.rb +46 -0
- data/lib/ddtrace/contrib/shoryuken/configuration/settings.rb +24 -0
- data/lib/ddtrace/contrib/shoryuken/ext.rb +18 -0
- data/lib/ddtrace/contrib/shoryuken/integration.rb +35 -0
- data/lib/ddtrace/contrib/shoryuken/patcher.rb +30 -0
- data/lib/ddtrace/contrib/shoryuken/tracer.rb +45 -0
- data/lib/ddtrace/contrib/sidekiq/client_tracer.rb +43 -0
- data/lib/ddtrace/contrib/sidekiq/configuration/settings.rb +26 -0
- data/lib/ddtrace/contrib/sidekiq/ext.rb +21 -0
- data/lib/ddtrace/contrib/sidekiq/integration.rb +36 -0
- data/lib/ddtrace/contrib/sidekiq/patcher.rb +40 -0
- data/lib/ddtrace/contrib/sidekiq/server_tracer.rb +58 -0
- data/lib/ddtrace/contrib/sidekiq/tracing.rb +28 -0
- data/lib/ddtrace/contrib/sinatra/configuration/settings.rb +34 -0
- data/lib/ddtrace/contrib/sinatra/env.rb +38 -0
- data/lib/ddtrace/contrib/sinatra/ext.rb +18 -0
- data/lib/ddtrace/contrib/sinatra/headers.rb +31 -0
- data/lib/ddtrace/contrib/sinatra/integration.rb +36 -0
- data/lib/ddtrace/contrib/sinatra/patcher.rb +33 -0
- data/lib/ddtrace/contrib/sinatra/tracer.rb +84 -0
- data/lib/ddtrace/contrib/sinatra/tracer_middleware.rb +72 -0
- data/lib/ddtrace/contrib/sucker_punch/configuration/settings.rb +25 -0
- data/lib/ddtrace/contrib/sucker_punch/exception_handler.rb +26 -0
- data/lib/ddtrace/contrib/sucker_punch/ext.rb +18 -0
- data/lib/ddtrace/contrib/sucker_punch/instrumentation.rb +70 -0
- data/lib/ddtrace/contrib/sucker_punch/integration.rb +36 -0
- data/lib/ddtrace/contrib/sucker_punch/patcher.rb +48 -0
- data/lib/ddtrace/correlation.rb +28 -0
- data/lib/ddtrace/diagnostics/health.rb +30 -0
- data/lib/ddtrace/distributed_tracing/headers/b3.rb +44 -0
- data/lib/ddtrace/distributed_tracing/headers/b3_single.rb +56 -0
- data/lib/ddtrace/distributed_tracing/headers/datadog.rb +42 -0
- data/lib/ddtrace/distributed_tracing/headers/headers.rb +70 -0
- data/lib/ddtrace/distributed_tracing/headers/helpers.rb +45 -0
- data/lib/ddtrace/encoding.rb +65 -0
- data/lib/ddtrace/environment.rb +23 -0
- data/lib/ddtrace/error.rb +27 -0
- data/lib/ddtrace/ext/analytics.rb +11 -0
- data/lib/ddtrace/ext/app_types.rb +11 -0
- data/lib/ddtrace/ext/diagnostics.rb +25 -0
- data/lib/ddtrace/ext/distributed.rb +33 -0
- data/lib/ddtrace/ext/errors.rb +10 -0
- data/lib/ddtrace/ext/forced_tracing.rb +25 -0
- data/lib/ddtrace/ext/http.rb +46 -0
- data/lib/ddtrace/ext/manual_tracing.rb +9 -0
- data/lib/ddtrace/ext/metrics.rb +15 -0
- data/lib/ddtrace/ext/net.rb +10 -0
- data/lib/ddtrace/ext/priority.rb +16 -0
- data/lib/ddtrace/ext/runtime.rb +26 -0
- data/lib/ddtrace/ext/sql.rb +8 -0
- data/lib/ddtrace/ext/transport.rb +17 -0
- data/lib/ddtrace/forced_tracing.rb +36 -0
- data/lib/ddtrace/logger.rb +39 -0
- data/lib/ddtrace/metrics.rb +215 -0
- data/lib/ddtrace/monkey.rb +58 -0
- data/lib/ddtrace/opentracer.rb +40 -0
- data/lib/ddtrace/opentracer/binary_propagator.rb +24 -0
- data/lib/ddtrace/opentracer/carrier.rb +6 -0
- data/lib/ddtrace/opentracer/distributed_headers.rb +52 -0
- data/lib/ddtrace/opentracer/global_tracer.rb +15 -0
- data/lib/ddtrace/opentracer/propagator.rb +22 -0
- data/lib/ddtrace/opentracer/rack_propagator.rb +60 -0
- data/lib/ddtrace/opentracer/scope.rb +15 -0
- data/lib/ddtrace/opentracer/scope_manager.rb +6 -0
- data/lib/ddtrace/opentracer/span.rb +98 -0
- data/lib/ddtrace/opentracer/span_context.rb +14 -0
- data/lib/ddtrace/opentracer/span_context_factory.rb +23 -0
- data/lib/ddtrace/opentracer/text_map_propagator.rb +75 -0
- data/lib/ddtrace/opentracer/thread_local_scope.rb +30 -0
- data/lib/ddtrace/opentracer/thread_local_scope_manager.rb +40 -0
- data/lib/ddtrace/opentracer/tracer.rb +208 -0
- data/lib/ddtrace/patcher.rb +47 -0
- data/lib/ddtrace/pin.rb +114 -0
- data/lib/ddtrace/pipeline.rb +46 -0
- data/lib/ddtrace/pipeline/span_filter.rb +38 -0
- data/lib/ddtrace/pipeline/span_processor.rb +20 -0
- data/lib/ddtrace/propagation/grpc_propagator.rb +61 -0
- data/lib/ddtrace/propagation/http_propagator.rb +75 -0
- data/lib/ddtrace/provider.rb +21 -0
- data/lib/ddtrace/quantization/hash.rb +103 -0
- data/lib/ddtrace/quantization/http.rb +86 -0
- data/lib/ddtrace/runtime/cgroup.rb +44 -0
- data/lib/ddtrace/runtime/class_count.rb +17 -0
- data/lib/ddtrace/runtime/container.rb +73 -0
- data/lib/ddtrace/runtime/gc.rb +16 -0
- data/lib/ddtrace/runtime/identity.rb +41 -0
- data/lib/ddtrace/runtime/metrics.rb +93 -0
- data/lib/ddtrace/runtime/object_space.rb +19 -0
- data/lib/ddtrace/runtime/socket.rb +14 -0
- data/lib/ddtrace/runtime/thread_count.rb +16 -0
- data/lib/ddtrace/sampler.rb +195 -0
- data/lib/ddtrace/span.rb +260 -0
- data/lib/ddtrace/sync_writer.rb +62 -0
- data/lib/ddtrace/tracer.rb +459 -0
- data/lib/ddtrace/transport/http.rb +91 -0
- data/lib/ddtrace/transport/http/adapters/net.rb +112 -0
- data/lib/ddtrace/transport/http/adapters/registry.rb +24 -0
- data/lib/ddtrace/transport/http/adapters/test.rb +77 -0
- data/lib/ddtrace/transport/http/adapters/unix_socket.rb +64 -0
- data/lib/ddtrace/transport/http/api.rb +46 -0
- data/lib/ddtrace/transport/http/api/endpoint.rb +27 -0
- data/lib/ddtrace/transport/http/api/fallbacks.rb +22 -0
- data/lib/ddtrace/transport/http/api/instance.rb +29 -0
- data/lib/ddtrace/transport/http/api/map.rb +14 -0
- data/lib/ddtrace/transport/http/api/spec.rb +15 -0
- data/lib/ddtrace/transport/http/builder.rb +165 -0
- data/lib/ddtrace/transport/http/client.rb +107 -0
- data/lib/ddtrace/transport/http/env.rb +48 -0
- data/lib/ddtrace/transport/http/response.rb +26 -0
- data/lib/ddtrace/transport/http/statistics.rb +30 -0
- data/lib/ddtrace/transport/http/traces.rb +140 -0
- data/lib/ddtrace/transport/parcel.rb +13 -0
- data/lib/ddtrace/transport/request.rb +13 -0
- data/lib/ddtrace/transport/response.rb +49 -0
- data/lib/ddtrace/transport/statistics.rb +72 -0
- data/lib/ddtrace/transport/traces.rb +33 -0
- data/lib/ddtrace/utils.rb +65 -0
- data/lib/ddtrace/utils/database.rb +25 -0
- data/lib/ddtrace/utils/time.rb +14 -0
- data/lib/ddtrace/vendor/active_record/connection_specification.rb +301 -0
- data/lib/ddtrace/version.rb +12 -0
- data/lib/ddtrace/workers.rb +125 -0
- data/lib/ddtrace/writer.rb +157 -0
- data/tasks/release_gem.rake +28 -0
- metadata +682 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
module Datadog
|
2
|
+
# Pipeline
|
3
|
+
module Pipeline
|
4
|
+
require_relative 'pipeline/span_filter'
|
5
|
+
require_relative 'pipeline/span_processor'
|
6
|
+
|
7
|
+
@mutex = Mutex.new
|
8
|
+
@processors = []
|
9
|
+
|
10
|
+
def self.before_flush(*processors, &processor_block)
|
11
|
+
processors = [processor_block] if processors.empty?
|
12
|
+
|
13
|
+
@mutex.synchronize do
|
14
|
+
@processors.concat(processors)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.process!(traces)
|
19
|
+
@mutex.synchronize do
|
20
|
+
traces
|
21
|
+
.map(&method(:apply_processors!))
|
22
|
+
.select(&:any?)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.processors=(value)
|
27
|
+
@processors = value
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.apply_processors!(trace)
|
31
|
+
result = @processors.inject(trace) do |current_trace, processor|
|
32
|
+
processor.call(current_trace)
|
33
|
+
end
|
34
|
+
|
35
|
+
result || []
|
36
|
+
rescue => e
|
37
|
+
Datadog::Tracer.log.debug(
|
38
|
+
"trace dropped entirely due to `Pipeline.before_flush` error: #{e}"
|
39
|
+
)
|
40
|
+
|
41
|
+
[]
|
42
|
+
end
|
43
|
+
|
44
|
+
private_class_method :apply_processors!
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Datadog
|
2
|
+
module Pipeline
|
3
|
+
# SpanFilter implements a processor that filters entire span subtrees
|
4
|
+
class SpanFilter
|
5
|
+
def initialize(filter = nil, &block)
|
6
|
+
callable = filter || block
|
7
|
+
|
8
|
+
raise(ArgumentError) unless callable.respond_to?(:call)
|
9
|
+
|
10
|
+
@criteria = filter || block
|
11
|
+
end
|
12
|
+
|
13
|
+
def call(trace)
|
14
|
+
black_list = trace.select(&method(:drop_it?))
|
15
|
+
|
16
|
+
clean_trace(black_list, trace) while black_list.any?
|
17
|
+
|
18
|
+
trace
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def drop_it?(span)
|
24
|
+
@criteria.call(span) rescue false
|
25
|
+
end
|
26
|
+
|
27
|
+
def clean_trace(black_list, trace)
|
28
|
+
current = black_list.shift
|
29
|
+
|
30
|
+
trace.delete(current)
|
31
|
+
|
32
|
+
trace.each do |span|
|
33
|
+
black_list << span if span.parent == current
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Datadog
|
2
|
+
module Pipeline
|
3
|
+
# SpanProcessor
|
4
|
+
class SpanProcessor
|
5
|
+
def initialize(operation = nil, &block)
|
6
|
+
callable = operation || block
|
7
|
+
|
8
|
+
raise(ArgumentError) unless callable.respond_to?(:call)
|
9
|
+
|
10
|
+
@operation = operation || block
|
11
|
+
end
|
12
|
+
|
13
|
+
def call(trace)
|
14
|
+
trace.each do |span|
|
15
|
+
@operation.call(span) rescue next
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'ddtrace/context'
|
2
|
+
require 'ddtrace/ext/distributed'
|
3
|
+
|
4
|
+
module Datadog
|
5
|
+
# opentracing.io compliant methods for distributing trace context
|
6
|
+
# between two or more distributed services. Note this is very close
|
7
|
+
# to the HTTPPropagator; the key difference is the way gRPC handles
|
8
|
+
# header information (called "metadata") as it operates over HTTP2
|
9
|
+
module GRPCPropagator
|
10
|
+
include Ext::DistributedTracing
|
11
|
+
|
12
|
+
def self.inject!(context, metadata)
|
13
|
+
metadata[GRPC_METADATA_TRACE_ID] = context.trace_id.to_s
|
14
|
+
metadata[GRPC_METADATA_PARENT_ID] = context.span_id.to_s
|
15
|
+
metadata[GRPC_METADATA_SAMPLING_PRIORITY] = context.sampling_priority.to_s if context.sampling_priority
|
16
|
+
metadata[GRPC_METADATA_ORIGIN] = context.origin.to_s if context.origin
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.extract(metadata)
|
20
|
+
metadata = Carrier.new(metadata)
|
21
|
+
return Datadog::Context.new unless metadata.valid?
|
22
|
+
Datadog::Context.new(trace_id: metadata.trace_id,
|
23
|
+
span_id: metadata.parent_id,
|
24
|
+
sampling_priority: metadata.sampling_priority,
|
25
|
+
origin: metadata.origin)
|
26
|
+
end
|
27
|
+
|
28
|
+
# opentracing.io compliant carrier object
|
29
|
+
class Carrier
|
30
|
+
include Ext::DistributedTracing
|
31
|
+
|
32
|
+
def initialize(metadata = {})
|
33
|
+
@metadata = metadata || {}
|
34
|
+
end
|
35
|
+
|
36
|
+
def valid?
|
37
|
+
trace_id && parent_id
|
38
|
+
end
|
39
|
+
|
40
|
+
def trace_id
|
41
|
+
value = @metadata[GRPC_METADATA_TRACE_ID].to_i
|
42
|
+
value if (1..Span::MAX_ID).cover? value
|
43
|
+
end
|
44
|
+
|
45
|
+
def parent_id
|
46
|
+
value = @metadata[GRPC_METADATA_PARENT_ID].to_i
|
47
|
+
value if (1..Span::MAX_ID).cover? value
|
48
|
+
end
|
49
|
+
|
50
|
+
def sampling_priority
|
51
|
+
value = @metadata[GRPC_METADATA_SAMPLING_PRIORITY]
|
52
|
+
value && value.to_i
|
53
|
+
end
|
54
|
+
|
55
|
+
def origin
|
56
|
+
value = @metadata[GRPC_METADATA_ORIGIN]
|
57
|
+
value if value != ''
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'ddtrace/configuration'
|
2
|
+
require 'ddtrace/context'
|
3
|
+
require 'ddtrace/ext/distributed'
|
4
|
+
require 'ddtrace/ext/priority'
|
5
|
+
require 'ddtrace/distributed_tracing/headers/b3'
|
6
|
+
require 'ddtrace/distributed_tracing/headers/b3_single'
|
7
|
+
require 'ddtrace/distributed_tracing/headers/datadog'
|
8
|
+
|
9
|
+
module Datadog
|
10
|
+
# HTTPPropagator helps extracting and injecting HTTP headers.
|
11
|
+
module HTTPPropagator
|
12
|
+
include Ext::DistributedTracing
|
13
|
+
|
14
|
+
PROPAGATION_STYLES = { PROPAGATION_STYLE_B3 => DistributedTracing::Headers::B3,
|
15
|
+
PROPAGATION_STYLE_B3_SINGLE_HEADER => DistributedTracing::Headers::B3Single,
|
16
|
+
PROPAGATION_STYLE_DATADOG => DistributedTracing::Headers::Datadog }.freeze
|
17
|
+
|
18
|
+
# inject! popolates the env with span ID, trace ID and sampling priority
|
19
|
+
def self.inject!(context, env)
|
20
|
+
# Prevent propagation from being attempted if context provided is nil.
|
21
|
+
if context.nil?
|
22
|
+
::Datadog::Tracer.log.debug('Cannot inject context into env to propagate over HTTP: context is nil.'.freeze)
|
23
|
+
return
|
24
|
+
end
|
25
|
+
|
26
|
+
# Inject all configured propagation styles
|
27
|
+
::Datadog.configuration.distributed_tracing.propagation_inject_style.each do |style|
|
28
|
+
propagator = PROPAGATION_STYLES[style]
|
29
|
+
propagator.inject!(context, env) unless propagator.nil?
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# extract returns a context containing the span ID, trace ID and
|
34
|
+
# sampling priority defined in env.
|
35
|
+
def self.extract(env)
|
36
|
+
context = nil
|
37
|
+
dd_context = nil
|
38
|
+
|
39
|
+
::Datadog.configuration.distributed_tracing.propagation_extract_style.each do |style|
|
40
|
+
propagator = PROPAGATION_STYLES[style]
|
41
|
+
next if propagator.nil?
|
42
|
+
|
43
|
+
# Extract context
|
44
|
+
# DEV: `propagator.extract` will return `nil`, where `HTTPPropagator#extract` will not
|
45
|
+
extracted_context = propagator.extract(env)
|
46
|
+
# Skip this style if no valid headers were found
|
47
|
+
next if extracted_context.nil?
|
48
|
+
|
49
|
+
# Keep track of the Datadog extract context, we want to return
|
50
|
+
# this one if we have one
|
51
|
+
dd_context = extracted_context if extracted_context && style == PROPAGATION_STYLE_DATADOG
|
52
|
+
|
53
|
+
# No previously extracted context, use the one we just extracted
|
54
|
+
if context.nil?
|
55
|
+
context = extracted_context
|
56
|
+
else
|
57
|
+
unless context.trace_id == extracted_context.trace_id && context.span_id == extracted_context.span_id
|
58
|
+
# Return an empty/new context if we have a mismatch in values extracted
|
59
|
+
msg = "#{context.trace_id} != #{extracted_context.trace_id} && " \
|
60
|
+
"#{context.span_id} != #{extracted_context.span_id}"
|
61
|
+
::Datadog::Tracer.log.debug("Cannot extract context from HTTP: extracted contexts differ, #{msg}".freeze)
|
62
|
+
# DEV: This will return from `self.extract` not this `each` block
|
63
|
+
return ::Datadog::Context.new
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# Return the extracted context if we found one or else a new empty context
|
69
|
+
# Always return the Datadog context if one exists since it has more
|
70
|
+
# information than the B3 headers e.g. origin, expanded priority
|
71
|
+
# sampling values, etc
|
72
|
+
dd_context || context || ::Datadog::Context.new
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Datadog
|
2
|
+
# DefaultContextProvider is a default context provider that retrieves
|
3
|
+
# all contexts from the current thread-local storage. It is suitable for
|
4
|
+
# synchronous programming.
|
5
|
+
class DefaultContextProvider
|
6
|
+
# Initializes the default context provider with a thread-bound context.
|
7
|
+
def initialize
|
8
|
+
@context = Datadog::ThreadLocalContext.new
|
9
|
+
end
|
10
|
+
|
11
|
+
# Sets the current context.
|
12
|
+
def context=(ctx)
|
13
|
+
@context.local = ctx
|
14
|
+
end
|
15
|
+
|
16
|
+
# Return the current context.
|
17
|
+
def context
|
18
|
+
@context.local
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
module Datadog
|
2
|
+
module Quantization
|
3
|
+
# Quantization for HTTP resources
|
4
|
+
module Hash
|
5
|
+
PLACEHOLDER = '?'.freeze
|
6
|
+
EXCLUDE_KEYS = [].freeze
|
7
|
+
SHOW_KEYS = [].freeze
|
8
|
+
DEFAULT_OPTIONS = {
|
9
|
+
exclude: EXCLUDE_KEYS,
|
10
|
+
show: SHOW_KEYS,
|
11
|
+
placeholder: PLACEHOLDER
|
12
|
+
}.freeze
|
13
|
+
|
14
|
+
module_function
|
15
|
+
|
16
|
+
def format(hash_obj, options = {})
|
17
|
+
options ||= {}
|
18
|
+
format!(hash_obj, options)
|
19
|
+
rescue StandardError
|
20
|
+
options[:placeholder] || PLACEHOLDER
|
21
|
+
end
|
22
|
+
|
23
|
+
def format!(hash_obj, options = {})
|
24
|
+
options ||= {}
|
25
|
+
options = merge_options(DEFAULT_OPTIONS, options)
|
26
|
+
format_hash(hash_obj, options)
|
27
|
+
end
|
28
|
+
|
29
|
+
def format_hash(hash_obj, options = {})
|
30
|
+
case hash_obj
|
31
|
+
when ::Hash
|
32
|
+
return {} if options[:exclude] == :all
|
33
|
+
return hash_obj if options[:show] == :all
|
34
|
+
|
35
|
+
hash_obj.each_with_object({}) do |(key, value), quantized|
|
36
|
+
if options[:show].any?(&indifferent_equals(key))
|
37
|
+
quantized[key] = value
|
38
|
+
elsif options[:exclude].none?(&indifferent_equals(key))
|
39
|
+
quantized[key] = format_value(value, options)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
else
|
43
|
+
format_value(hash_obj, options)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def format_value(value, options = {})
|
48
|
+
return value if options[:show] == :all
|
49
|
+
|
50
|
+
case value
|
51
|
+
when ::Hash
|
52
|
+
format_hash(value, options)
|
53
|
+
when Array
|
54
|
+
# If any are objects, format them.
|
55
|
+
format_array(value, options)
|
56
|
+
else
|
57
|
+
options[:placeholder]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def format_array(value, options)
|
62
|
+
if value.any? { |v| v.class <= ::Hash || v.class <= Array }
|
63
|
+
first_entry = format_value(value.first, options)
|
64
|
+
value.size > 1 ? [first_entry, options[:placeholder]] : [first_entry]
|
65
|
+
# Otherwise short-circuit and return single placeholder
|
66
|
+
else
|
67
|
+
[options[:placeholder]]
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def merge_options(original, additional)
|
72
|
+
{}.tap do |options|
|
73
|
+
# Show
|
74
|
+
# If either is :all, value becomes :all
|
75
|
+
options[:show] = if original[:show] == :all || additional[:show] == :all
|
76
|
+
:all
|
77
|
+
else
|
78
|
+
(original[:show] || []).dup.concat(additional[:show] || []).uniq
|
79
|
+
end
|
80
|
+
|
81
|
+
# Exclude
|
82
|
+
# If either is :all, value becomes :all
|
83
|
+
options[:exclude] = if original[:exclude] == :all || additional[:exclude] == :all
|
84
|
+
:all
|
85
|
+
else
|
86
|
+
(original[:exclude] || []).dup.concat(additional[:exclude] || []).uniq
|
87
|
+
end
|
88
|
+
|
89
|
+
options[:placeholder] = additional[:placeholder] || original[:placeholder]
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def indifferent_equals(value)
|
94
|
+
value = convert_value(value)
|
95
|
+
->(compared_value) { value == convert_value(compared_value) }
|
96
|
+
end
|
97
|
+
|
98
|
+
def convert_value(value)
|
99
|
+
value.is_a?(Symbol) ? value.to_s : value
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'set'
|
3
|
+
|
4
|
+
module Datadog
|
5
|
+
module Quantization
|
6
|
+
# Quantization for HTTP resources
|
7
|
+
module HTTP
|
8
|
+
PLACEHOLDER = '?'.freeze
|
9
|
+
|
10
|
+
module_function
|
11
|
+
|
12
|
+
def url(url, options = {})
|
13
|
+
url!(url, options)
|
14
|
+
rescue StandardError
|
15
|
+
options[:placeholder] || PLACEHOLDER
|
16
|
+
end
|
17
|
+
|
18
|
+
def url!(url, options = {})
|
19
|
+
options ||= {}
|
20
|
+
|
21
|
+
URI.parse(url).tap do |uri|
|
22
|
+
# Format the query string
|
23
|
+
if uri.query
|
24
|
+
query = query(uri.query, options[:query])
|
25
|
+
uri.query = (!query.nil? && query.empty? ? nil : query)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Remove any URI framents
|
29
|
+
uri.fragment = nil unless options[:fragment] == :show
|
30
|
+
end.to_s
|
31
|
+
end
|
32
|
+
|
33
|
+
def query(query, options = {})
|
34
|
+
query!(query, options)
|
35
|
+
rescue StandardError
|
36
|
+
options[:placeholder] || PLACEHOLDER
|
37
|
+
end
|
38
|
+
|
39
|
+
def query!(query, options = {})
|
40
|
+
options ||= {}
|
41
|
+
options[:show] = options[:show] || []
|
42
|
+
options[:exclude] = options[:exclude] || []
|
43
|
+
|
44
|
+
# Short circuit if query string is meant to exclude everything
|
45
|
+
# or if the query string is meant to include everything
|
46
|
+
return '' if options[:exclude] == :all
|
47
|
+
return query if options[:show] == :all
|
48
|
+
|
49
|
+
collect_query(query, uniq: true) do |key, value|
|
50
|
+
if options[:exclude].include?(key)
|
51
|
+
[nil, nil]
|
52
|
+
else
|
53
|
+
value = options[:show].include?(key) ? value : nil
|
54
|
+
[key, value]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# Iterate over each key value pair, yielding to the block given.
|
60
|
+
# Accepts :uniq option, which keeps uniq copies of keys without values.
|
61
|
+
# e.g. Reduces "foo&bar=bar&bar=bar&foo" to "foo&bar=bar&bar=bar"
|
62
|
+
def collect_query(query, options = {})
|
63
|
+
return query unless block_given?
|
64
|
+
uniq = options[:uniq].nil? ? false : options[:uniq]
|
65
|
+
keys = Set.new
|
66
|
+
|
67
|
+
delims = query.scan(/(^|&|;)/).flatten
|
68
|
+
query.split(/[&;]/).collect.with_index do |pairs, i|
|
69
|
+
key, value = pairs.split('=', 2)
|
70
|
+
key, value = yield(key, value, delims[i])
|
71
|
+
if uniq && keys.include?(key)
|
72
|
+
''
|
73
|
+
elsif key && value
|
74
|
+
"#{delims[i]}#{key}=#{value}"
|
75
|
+
elsif key
|
76
|
+
"#{delims[i]}#{key}".tap { keys << key }
|
77
|
+
else
|
78
|
+
''
|
79
|
+
end
|
80
|
+
end.join.sub(/^[&;]/, '')
|
81
|
+
end
|
82
|
+
|
83
|
+
private_class_method :collect_query
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|