From 4b387b9a1f9ac950b7f68e685a76438679afa574 Mon Sep 17 00:00:00 2001 From: Ariel Valentin Date: Fri, 17 Jun 2022 00:46:27 +0000 Subject: [PATCH 1/3] refactor: Remove Contrib Libraries This change removes libraries that were relocated to the contrib package. Related: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues/1 See https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/3 --- .github/workflows/ci.yml | 228 --------- .../instrumentation_generator.rb | 90 ---- .../templates/Appraisals | 16 - .../templates/CHANGELOG.md.tt | 1 - .instrumentation_generator/templates/Gemfile | 17 - .instrumentation_generator/templates/LICENSE | 201 -------- .instrumentation_generator/templates/Rakefile | 28 -- .../templates/Readme.md.tt | 52 -- .../templates/gemspec.tt | 49 -- .../templates/lib/entrypoint.rb | 7 - .../templates/lib/instrumentation.rb.tt | 19 - .../instrumentation_name.rb.tt | 19 - .../instrumentation.rb.tt | 30 -- .../instrumentation_name/version.rb.tt | 13 - .../templates/rubocop.yml.tt | 5 - .../templates/test/.rubocop.yml | 4 - .../templates/test/instrumentation.rb.tt | 29 -- .../templates/test/test_helper.rb | 18 - .../templates/yardopts.tt | 9 - .toys/.data/releases.yml | 159 ------ README.md | 16 +- bin/instrumentation_generator | 15 - docker-compose.yml | 186 ------- instrumentation/.rubocop-examples.yml | 29 -- instrumentation/README.md | 59 --- instrumentation/action_pack/.rubocop.yml | 5 - instrumentation/action_pack/.yardopts | 9 - instrumentation/action_pack/Appraisals | 26 - instrumentation/action_pack/CHANGELOG.md | 27 -- instrumentation/action_pack/Gemfile | 14 - instrumentation/action_pack/LICENSE | 201 -------- instrumentation/action_pack/README.md | 63 --- instrumentation/action_pack/Rakefile | 28 -- .../example/trace_demonstration.ru | 44 -- ...entelemetry-instrumentation-action_pack.rb | 7 - .../lib/opentelemetry/instrumentation.rb | 19 - .../instrumentation/action_pack.rb | 20 - .../action_pack/instrumentation.rb | 50 -- .../patches/action_controller/metal.rb | 43 -- .../instrumentation/action_pack/railtie.rb | 23 - .../instrumentation/action_pack/version.rb | 13 - ...emetry-instrumentation-action_pack.gemspec | 51 -- instrumentation/action_pack/test/.rubocop.yml | 4 - .../action_pack/instrumentation_test.rb | 29 -- .../patches/action_controller/metal_test.rb | 124 ----- .../action_pack/test/test_helper.rb | 32 -- .../test/test_helpers/app_config.rb | 96 ---- .../test/test_helpers/controllers.rb | 8 - .../controllers/example_controller.rb | 17 - .../controllers/exceptions_controller.rb | 11 - .../test/test_helpers/middlewares.rb | 8 - .../exception_raising_middleware.rb | 23 - .../middlewares/redirect_middleware.rb | 23 - .../action_pack/test/test_helpers/routes.rb | 12 - instrumentation/action_view/.rubocop.yml | 5 - instrumentation/action_view/.yardopts | 9 - instrumentation/action_view/Appraisals | 26 - instrumentation/action_view/CHANGELOG.md | 31 -- instrumentation/action_view/Gemfile | 15 - instrumentation/action_view/LICENSE | 201 -------- instrumentation/action_view/README.md | 71 --- instrumentation/action_view/Rakefile | 28 -- .../example/trace_request_demonstration.ru | 67 --- ...entelemetry-instrumentation-action_view.rb | 7 - .../lib/opentelemetry/instrumentation.rb | 19 - .../instrumentation/action_view.rb | 19 - .../action_view/instrumentation.rb | 40 -- .../instrumentation/action_view/railtie.rb | 29 -- .../instrumentation/action_view/version.rb | 13 - ...emetry-instrumentation-action_view.gemspec | 51 -- instrumentation/action_view/test/.rubocop.yml | 4 - .../action_view/instrumentation_test.rb | 29 -- .../action_view/test/test_helper.rb | 25 - instrumentation/active_job/.rubocop.yml | 29 -- instrumentation/active_job/.yardopts | 9 - instrumentation/active_job/Appraisals | 27 -- instrumentation/active_job/CHANGELOG.md | 37 -- instrumentation/active_job/Gemfile | 13 - instrumentation/active_job/LICENSE | 201 -------- instrumentation/active_job/README.md | 53 -- instrumentation/active_job/Rakefile | 28 -- instrumentation/active_job/example/Gemfile | 8 - .../active_job/example/active_job.rb | 33 -- ...pentelemetry-instrumentation-active_job.rb | 7 - .../lib/opentelemetry/instrumentation.rb | 19 - .../instrumentation/active_job.rb | 19 - .../active_job/instrumentation.rb | 77 --- .../patches/active_job_callbacks.rb | 94 ---- .../active_job/patches/base.rb | 37 -- .../instrumentation/active_job/version.rb | 13 - ...lemetry-instrumentation-active_job.gemspec | 51 -- instrumentation/active_job/test/.rubocop.yml | 4 - .../active_job/instrumentation_test.rb | 42 -- .../patches/active_job_callbacks_test.rb | 399 --------------- .../active_job/patches/base_test.rb | 43 -- .../active_job/test/test_helper.rb | 82 ---- .../active_model_serializers/.rubocop.yml | 5 - .../active_model_serializers/.yardopts | 9 - .../active_model_serializers/Appraisals | 9 - .../active_model_serializers/CHANGELOG.md | 74 --- .../active_model_serializers/Gemfile | 13 - .../active_model_serializers/LICENSE | 201 -------- .../active_model_serializers/README.md | 53 -- .../active_model_serializers/Rakefile | 28 -- .../active_model_serializers/example/Gemfile | 9 - .../example/active_model_serializers.rb | 26 - ...nstrumentation-active_model_serializers.rb | 7 - .../lib/opentelemetry/instrumentation.rb | 22 - .../active_model_serializers.rb | 19 - .../active_model_serializers/event_handler.rb | 48 -- .../instrumentation.rb | 49 -- .../active_model_serializers/version.rb | 13 - ...mentation-active_model_serializers.gemspec | 50 -- .../test/.rubocop.yml | 4 - .../event_handler_test.rb | 63 --- .../active_model_serializers_test.rb | 47 -- .../test/test_helper.rb | 38 -- instrumentation/active_record/.rubocop.yml | 5 - instrumentation/active_record/.yardopts | 9 - instrumentation/active_record/Appraisals | 27 -- instrumentation/active_record/CHANGELOG.md | 32 -- instrumentation/active_record/Gemfile | 16 - instrumentation/active_record/LICENSE | 201 -------- instrumentation/active_record/README.md | 52 -- instrumentation/active_record/Rakefile | 28 -- .../example/trace_demonstration.rb | 49 -- ...telemetry-instrumentation-active_record.rb | 7 - .../lib/opentelemetry/instrumentation.rb | 19 - .../instrumentation/active_record.rb | 19 - .../active_record/instrumentation.rb | 75 --- .../active_record/patches/persistence.rb | 131 ----- .../patches/persistence_class_methods.rb | 61 --- .../persistence_insert_class_methods.rb | 67 --- .../active_record/patches/querying.rb | 37 -- .../patches/relation_persistence.rb | 34 -- .../patches/transactions_class_methods.rb | 37 -- .../active_record/patches/validations.rb | 38 -- .../instrumentation/active_record/version.rb | 13 - ...etry-instrumentation-active_record.gemspec | 51 -- .../active_record/test/.rubocop.yml | 6 - .../active_record/instrumentation_test.rb | 54 --- .../patches/persistence_class_methods_test.rb | 70 --- .../persistence_insert_class_methods_test.rb | 68 --- .../active_record/patches/persistence_test.rb | 200 -------- .../active_record/patches/querying_test.rb | 26 - .../patches/relation_persistence_test.rb | 49 -- .../transactions_class_methods_test.rb | 33 -- .../active_record/test/test_helper.rb | 69 --- instrumentation/active_support/.rubocop.yml | 5 - instrumentation/active_support/.yardopts | 9 - instrumentation/active_support/Appraisals | 26 - instrumentation/active_support/CHANGELOG.md | 18 - instrumentation/active_support/Gemfile | 13 - instrumentation/active_support/LICENSE | 201 -------- instrumentation/active_support/README.md | 57 --- instrumentation/active_support/Rakefile | 28 -- .../active_support/example/Gemfile | 9 - .../example/trace_demonstration.rb | 18 - ...elemetry-instrumentation-active_support.rb | 7 - .../lib/opentelemetry/instrumentation.rb | 19 - .../instrumentation/active_support.rb | 19 - .../active_support/instrumentation.rb | 28 -- .../active_support/span_subscriber.rb | 123 ----- .../instrumentation/active_support/version.rb | 13 - ...try-instrumentation-active_support.gemspec | 52 -- .../active_support/test/.rubocop.yml | 4 - .../active_support/instrumentation_test.rb | 29 -- .../active_support/span_subscriber_test.rb | 243 ---------- .../active_support/test/test_helper.rb | 25 - instrumentation/all/.rubocop.yml | 11 - instrumentation/all/.yardopts | 9 - instrumentation/all/CHANGELOG.md | 119 ----- instrumentation/all/Gemfile | 9 - instrumentation/all/LICENSE | 201 -------- instrumentation/all/README.md | 87 ---- instrumentation/all/Rakefile | 28 -- .../lib/opentelemetry-instrumentation-all.rb | 7 - .../lib/opentelemetry/instrumentation/all.rb | 56 --- .../instrumentation/all/version.rb | 13 - .../opentelemetry-instrumentation-all.gemspec | 80 --- instrumentation/all/test/.rubocop.yml | 4 - .../opentelemetry/instrumentation/all_test.rb | 23 - instrumentation/all/test/test_helper.rb | 7 - instrumentation/aws_sdk/.rubocop.yml | 5 - instrumentation/aws_sdk/.yardopts | 9 - instrumentation/aws_sdk/Appraisals | 61 --- instrumentation/aws_sdk/CHANGELOG.md | 26 - instrumentation/aws_sdk/Gemfile | 14 - instrumentation/aws_sdk/LICENSE | 201 -------- instrumentation/aws_sdk/README.md | 65 --- instrumentation/aws_sdk/Rakefile | 29 -- instrumentation/aws_sdk/example/Gemfile | 8 - .../aws_sdk/example/trace_demonstration.rb | 20 - .../opentelemetry-instrumentation-aws_sdk.rb | 7 - .../lib/opentelemetry/instrumentation.rb | 22 - .../opentelemetry/instrumentation/aws_sdk.rb | 19 - .../instrumentation/aws_sdk/handler.rb | 116 ----- .../aws_sdk/instrumentation.rb | 72 --- .../aws_sdk/message_attributes.rb | 37 -- .../aws_sdk/messaging_helper.rb | 52 -- .../instrumentation/aws_sdk/services.rb | 121 ----- .../instrumentation/aws_sdk/version.rb | 13 - ...ntelemetry-instrumentation-aws_sdk.gemspec | 52 -- instrumentation/aws_sdk/test/.rubocop.yml | 6 - .../opentelemetry/instrumentation_test.rb | 238 --------- instrumentation/aws_sdk/test/test_helper.rb | 24 - instrumentation/base/.rubocop.yml | 27 -- instrumentation/base/.yardopts | 9 - instrumentation/base/CHANGELOG.md | 36 -- instrumentation/base/Gemfile | 9 - instrumentation/base/LICENSE | 201 -------- instrumentation/base/README.md | 154 ------ instrumentation/base/Rakefile | 28 -- .../lib/opentelemetry-instrumentation-base.rb | 7 - .../base/lib/opentelemetry/instrumentation.rb | 16 - .../lib/opentelemetry/instrumentation/base.rb | 368 -------------- .../opentelemetry/instrumentation/version.rb | 11 - ...opentelemetry-instrumentation-base.gemspec | 46 -- instrumentation/base/test/.rubocop.yml | 4 - .../base/test/instrumentation/base_test.rb | 456 ------------------ .../base/test/instrumentation_test.rb | 17 - instrumentation/base/test/test_helper.rb | 15 - instrumentation/bunny/.rubocop.yml | 29 -- instrumentation/bunny/.yardopts | 9 - instrumentation/bunny/Appraisals | 9 - instrumentation/bunny/CHANGELOG.md | 30 -- instrumentation/bunny/Gemfile | 14 - instrumentation/bunny/LICENSE | 201 -------- instrumentation/bunny/README.md | 53 -- instrumentation/bunny/Rakefile | 28 -- instrumentation/bunny/example/Gemfile | 8 - instrumentation/bunny/example/bunny.rb | 40 -- .../opentelemetry-instrumentation-bunny.rb | 7 - .../lib/opentelemetry/instrumentation.rb | 19 - .../opentelemetry/instrumentation/bunny.rb | 18 - .../instrumentation/bunny/instrumentation.rb | 43 -- .../instrumentation/bunny/patch_helpers.rb | 94 ---- .../instrumentation/bunny/patches/channel.rb | 51 -- .../instrumentation/bunny/patches/consumer.rb | 28 -- .../instrumentation/bunny/patches/queue.rb | 32 -- .../bunny/patches/reader_loop.rb | 29 -- .../instrumentation/bunny/version.rb | 13 - ...pentelemetry-instrumentation-bunny.gemspec | 48 -- instrumentation/bunny/test/.rubocop.yml | 6 - .../bunny/instrumentation_test.rb | 29 -- .../bunny/patches/channel_test.rb | 84 ---- .../bunny/patches/consumer_test.rb | 74 --- .../bunny/patches/queue_test.rb | 76 --- instrumentation/bunny/test/test_helper.rb | 22 - instrumentation/concurrent_ruby/.rubocop.yml | 7 - instrumentation/concurrent_ruby/.yardopts | 9 - instrumentation/concurrent_ruby/Appraisals | 9 - instrumentation/concurrent_ruby/CHANGELOG.md | 88 ---- instrumentation/concurrent_ruby/Gemfile | 13 - instrumentation/concurrent_ruby/LICENSE | 201 -------- instrumentation/concurrent_ruby/README.md | 49 -- instrumentation/concurrent_ruby/Rakefile | 28 -- .../concurrent_ruby/example/Gemfile | 9 - .../example/concurrent_ruby.rb | 47 -- ...lemetry-instrumentation-concurrent_ruby.rb | 7 - .../lib/opentelemetry/instrumentation.rb | 22 - .../instrumentation/concurrent_ruby.rb | 19 - .../concurrent_ruby/instrumentation.rb | 34 -- .../patches/thread_pool_executor.rb | 28 -- .../concurrent_ruby/version.rb | 13 - ...ry-instrumentation-concurrent_ruby.gemspec | 48 -- .../concurrent_ruby/test/.rubocop.yml | 4 - .../concurrent-ruby/instrumentation_test.rb | 101 ---- .../concurrent_ruby/test/test_helper.rb | 20 - instrumentation/dalli/.rubocop.yml | 7 - instrumentation/dalli/.yardopts | 9 - instrumentation/dalli/Appraisals | 9 - instrumentation/dalli/CHANGELOG.md | 85 ---- instrumentation/dalli/Gemfile | 14 - instrumentation/dalli/LICENSE | 201 -------- instrumentation/dalli/README.md | 49 -- instrumentation/dalli/Rakefile | 28 -- instrumentation/dalli/example/Gemfile | 9 - instrumentation/dalli/example/dalli.rb | 13 - .../opentelemetry-instrumentation-dalli.rb | 7 - .../lib/opentelemetry/instrumentation.rb | 22 - .../opentelemetry/instrumentation/dalli.rb | 20 - .../instrumentation/dalli/instrumentation.rb | 42 -- .../instrumentation/dalli/patches/server.rb | 45 -- .../instrumentation/dalli/utils.rb | 65 --- .../instrumentation/dalli/version.rb | 13 - ...pentelemetry-instrumentation-dalli.gemspec | 49 -- instrumentation/dalli/test/.rubocop.yml | 6 - .../dalli/instrumentation_test.rb | 133 ----- instrumentation/dalli/test/test_helper.rb | 21 - instrumentation/datadog-porting-guide.md | 115 ----- instrumentation/delayed_job/.rubocop.yml | 5 - instrumentation/delayed_job/.yardopts | 9 - instrumentation/delayed_job/Appraisals | 9 - instrumentation/delayed_job/CHANGELOG.md | 71 --- instrumentation/delayed_job/Gemfile | 13 - instrumentation/delayed_job/LICENSE | 201 -------- instrumentation/delayed_job/README.md | 53 -- instrumentation/delayed_job/Rakefile | 28 -- instrumentation/delayed_job/example/Gemfile | 9 - .../delayed_job/example/delayed_job.rb | 26 - ...entelemetry-instrumentation-delayed_job.rb | 7 - .../lib/opentelemetry/instrumentation.rb | 22 - .../instrumentation/delayed_job.rb | 19 - .../delayed_job/instrumentation.rb | 42 -- .../delayed_job/plugins/tracer_plugin.rb | 90 ---- .../instrumentation/delayed_job/version.rb | 13 - ...emetry-instrumentation-delayed_job.gemspec | 52 -- instrumentation/delayed_job/test/.rubocop.yml | 4 - .../delayed_job/plugins/tracer_plugin_test.rb | 192 -------- .../instrumentation/delayed_job_test.rb | 77 --- .../delayed_job/test/test_helper.rb | 53 -- instrumentation/ethon/.rubocop.yml | 5 - instrumentation/ethon/.yardopts | 9 - instrumentation/ethon/Appraisals | 9 - instrumentation/ethon/CHANGELOG.md | 96 ---- instrumentation/ethon/Gemfile | 13 - instrumentation/ethon/LICENSE | 201 -------- instrumentation/ethon/README.md | 54 --- instrumentation/ethon/Rakefile | 28 -- instrumentation/ethon/example/Gemfile | 9 - instrumentation/ethon/example/ethon.rb | 13 - .../opentelemetry-instrumentation-ethon.rb | 7 - .../lib/opentelemetry/instrumentation.rb | 22 - .../opentelemetry/instrumentation/ethon.rb | 19 - .../instrumentation/ethon/instrumentation.rb | 38 -- .../instrumentation/ethon/patches/easy.rb | 104 ---- .../instrumentation/ethon/patches/multi.rb | 30 -- .../instrumentation/ethon/version.rb | 13 - ...pentelemetry-instrumentation-ethon.gemspec | 49 -- instrumentation/ethon/test/.rubocop.yml | 4 - .../ethon/instrumentation_test.rb | 285 ----------- instrumentation/ethon/test/test_helper.rb | 20 - instrumentation/excon/.rubocop.yml | 5 - instrumentation/excon/.yardopts | 9 - instrumentation/excon/Appraisals | 12 - instrumentation/excon/CHANGELOG.md | 95 ---- instrumentation/excon/Gemfile | 13 - instrumentation/excon/LICENSE | 201 -------- instrumentation/excon/README.md | 50 -- instrumentation/excon/Rakefile | 28 -- instrumentation/excon/example/Gemfile | 9 - instrumentation/excon/example/excon.rb | 13 - .../opentelemetry-instrumentation-excon.rb | 7 - .../lib/opentelemetry/instrumentation.rb | 22 - .../opentelemetry/instrumentation/excon.rb | 19 - .../instrumentation/excon/instrumentation.rb | 37 -- .../excon/middlewares/tracer_middleware.rb | 115 ----- .../instrumentation/excon/version.rb | 13 - ...pentelemetry-instrumentation-excon.gemspec | 50 -- instrumentation/excon/test/.rubocop.yml | 4 - .../excon/instrumentation_test.rb | 154 ------ instrumentation/excon/test/test_helper.rb | 21 - instrumentation/faraday/.rubocop.yml | 5 - instrumentation/faraday/.yardopts | 9 - instrumentation/faraday/Appraisals | 27 -- instrumentation/faraday/CHANGELOG.md | 98 ---- instrumentation/faraday/Gemfile | 13 - instrumentation/faraday/LICENSE | 201 -------- instrumentation/faraday/README.md | 53 -- instrumentation/faraday/Rakefile | 28 -- instrumentation/faraday/example/Gemfile | 9 - instrumentation/faraday/example/faraday.rb | 18 - .../opentelemetry-instrumentation-faraday.rb | 7 - .../lib/opentelemetry/instrumentation.rb | 22 - .../opentelemetry/instrumentation/faraday.rb | 20 - .../faraday/instrumentation.rb | 44 -- .../faraday/middlewares/tracer_middleware.rb | 69 --- .../faraday/patches/rack_builder.rb | 25 - .../instrumentation/faraday/version.rb | 13 - ...ntelemetry-instrumentation-faraday.gemspec | 50 -- instrumentation/faraday/test/.rubocop.yml | 4 - .../middlewares/tracer_middleware_test.rb | 124 ----- .../instrumentation/faraday_test.rb | 33 -- instrumentation/faraday/test/test_helper.rb | 23 - instrumentation/graphql/.rubocop.yml | 5 - instrumentation/graphql/.yardopts | 9 - instrumentation/graphql/Appraisals | 20 - instrumentation/graphql/CHANGELOG.md | 56 --- instrumentation/graphql/Gemfile | 14 - instrumentation/graphql/LICENSE | 201 -------- instrumentation/graphql/README.md | 76 --- instrumentation/graphql/Rakefile | 29 -- instrumentation/graphql/example/Gemfile | 13 - instrumentation/graphql/example/graphql.rb | 53 -- .../opentelemetry-instrumentation-graphql.rb | 7 - .../lib/opentelemetry/instrumentation.rb | 19 - .../opentelemetry/instrumentation/graphql.rb | 19 - .../graphql/instrumentation.rb | 62 --- .../graphql/tracers/graphql_tracer.rb | 87 ---- .../instrumentation/graphql/version.rb | 13 - ...ntelemetry-instrumentation-graphql.gemspec | 50 -- instrumentation/graphql/test/.rubocop.yml | 4 - .../graphql/instrumentation_test.rb | 51 -- .../graphql/tracers/graphql_tracer_test.rb | 254 ---------- instrumentation/graphql/test/test_helper.rb | 22 - instrumentation/http/.rubocop.yml | 5 - instrumentation/http/.yardopts | 9 - instrumentation/http/Appraisals | 13 - instrumentation/http/CHANGELOG.md | 56 --- instrumentation/http/Gemfile | 14 - instrumentation/http/LICENSE | 201 -------- instrumentation/http/README.md | 53 -- instrumentation/http/Rakefile | 28 -- .../http/example/trace_demonstration.rb | 27 -- .../lib/opentelemetry-instrumentation-http.rb | 7 - .../http/lib/opentelemetry/instrumentation.rb | 19 - .../lib/opentelemetry/instrumentation/http.rb | 19 - .../instrumentation/http/instrumentation.rb | 33 -- .../instrumentation/http/patches/client.rb | 51 -- .../http/patches/connection.rb | 33 -- .../instrumentation/http/version.rb | 13 - ...opentelemetry-instrumentation-http.gemspec | 51 -- instrumentation/http/test/.rubocop.yml | 4 - .../http/instrumentation_test.rb | 39 -- .../http/patches/client_test.rb | 119 ----- .../http/patches/connection_test.rb | 45 -- instrumentation/http/test/test_helper.rb | 22 - instrumentation/http_client/.rubocop.yml | 5 - instrumentation/http_client/.yardopts | 9 - instrumentation/http_client/Appraisals | 9 - instrumentation/http_client/CHANGELOG.md | 50 -- instrumentation/http_client/Gemfile | 14 - instrumentation/http_client/LICENSE | 201 -------- instrumentation/http_client/README.md | 53 -- instrumentation/http_client/Rakefile | 28 -- instrumentation/http_client/example/Gemfile | 8 - .../example/trace_demonstration.rb | 16 - ...entelemetry-instrumentation-http_client.rb | 7 - .../lib/opentelemetry/instrumentation.rb | 19 - .../instrumentation/http_client.rb | 19 - .../http_client/instrumentation.rb | 37 -- .../http_client/patches/client.rb | 55 --- .../http_client/patches/session.rb | 32 -- .../instrumentation/http_client/version.rb | 13 - ...emetry-instrumentation-http_client.gemspec | 51 -- instrumentation/http_client/test/.rubocop.yml | 4 - .../http_client/instrumentation_test.rb | 28 -- .../http_client/patches/client_test.rb | 127 ----- .../http_client/patches/session_test.rb | 46 -- .../http_client/test/test_helper.rb | 21 - instrumentation/koala/.rubocop.yml | 5 - instrumentation/koala/.yardopts | 9 - instrumentation/koala/Appraisals | 9 - instrumentation/koala/CHANGELOG.md | 30 -- instrumentation/koala/Gemfile | 14 - instrumentation/koala/LICENSE | 201 -------- instrumentation/koala/README.md | 54 --- instrumentation/koala/Rakefile | 28 -- instrumentation/koala/example/Gemfile | 8 - .../koala/example/trace_demonstration.rb | 16 - .../opentelemetry-instrumentation-koala.rb | 7 - .../lib/opentelemetry/instrumentation.rb | 19 - .../opentelemetry/instrumentation/koala.rb | 19 - .../instrumentation/koala/instrumentation.rb | 35 -- .../koala/patches/instrumentation.rb | 22 - .../instrumentation/koala/version.rb | 13 - ...pentelemetry-instrumentation-koala.gemspec | 52 -- .../koala/instrumentation_test.rb | 52 -- instrumentation/koala/test/test_helper.rb | 24 - instrumentation/lmdb/.rubocop.yml | 5 - instrumentation/lmdb/.yardopts | 9 - instrumentation/lmdb/Appraisals | 13 - instrumentation/lmdb/CHANGELOG.md | 39 -- instrumentation/lmdb/Gemfile | 14 - instrumentation/lmdb/LICENSE | 201 -------- instrumentation/lmdb/README.md | 49 -- instrumentation/lmdb/Rakefile | 28 -- .../lib/opentelemetry-instrumentation-lmdb.rb | 7 - .../lmdb/lib/opentelemetry/instrumentation.rb | 19 - .../lib/opentelemetry/instrumentation/lmdb.rb | 19 - .../instrumentation/lmdb/instrumentation.rb | 40 -- .../instrumentation/lmdb/patches/database.rb | 78 --- .../lmdb/patches/environment.rb | 37 -- .../instrumentation/lmdb/version.rb | 13 - ...opentelemetry-instrumentation-lmdb.gemspec | 50 -- instrumentation/lmdb/test/.rubocop.yml | 4 - .../lmdb/instrumentation_test.rb | 30 -- .../lmdb/patches/database_test.rb | 158 ------ .../lmdb/patches/environment_test.rb | 48 -- instrumentation/lmdb/test/test_helper.rb | 21 - instrumentation/mongo/.rubocop.yml | 5 - instrumentation/mongo/.yardopts | 9 - instrumentation/mongo/Appraisals | 9 - instrumentation/mongo/CHANGELOG.md | 76 --- instrumentation/mongo/Gemfile | 19 - instrumentation/mongo/LICENSE | 201 -------- instrumentation/mongo/README.md | 64 --- instrumentation/mongo/Rakefile | 29 -- instrumentation/mongo/example/Gemfile | 8 - instrumentation/mongo/example/mongo.rb | 23 - .../opentelemetry-instrumentation-mongo.rb | 7 - .../lib/opentelemetry/instrumentation.rb | 22 - .../opentelemetry/instrumentation/mongo.rb | 19 - .../mongo/command_serializer.rb | 103 ---- .../instrumentation/mongo/instrumentation.rb | 47 -- .../instrumentation/mongo/subscriber.rb | 105 ---- .../instrumentation/mongo/version.rb | 13 - ...pentelemetry-instrumentation-mongo.gemspec | 51 -- instrumentation/mongo/test/.rubocop.yml | 6 - .../instrumentation/mongo/subscriber_test.rb | 384 --------------- .../instrumentation/mongo_test.rb | 78 --- instrumentation/mongo/test/test_helper.rb | 58 --- instrumentation/mysql2/.rubocop.yml | 5 - instrumentation/mysql2/.yardopts | 9 - instrumentation/mysql2/Appraisals | 5 - instrumentation/mysql2/CHANGELOG.md | 94 ---- instrumentation/mysql2/Gemfile | 13 - instrumentation/mysql2/LICENSE | 201 -------- instrumentation/mysql2/README.md | 76 --- instrumentation/mysql2/Rakefile | 28 -- instrumentation/mysql2/example/Gemfile | 9 - instrumentation/mysql2/example/mysql2.rb | 21 - .../opentelemetry-instrumentation-mysql2.rb | 7 - .../lib/opentelemetry/instrumentation.rb | 22 - .../opentelemetry/instrumentation/mysql2.rb | 58 --- .../instrumentation/mysql2/instrumentation.rb | 46 -- .../instrumentation/mysql2/patches/client.rb | 150 ------ .../instrumentation/mysql2/version.rb | 13 - ...entelemetry-instrumentation-mysql2.gemspec | 50 -- instrumentation/mysql2/test/.rubocop.yml | 6 - .../mysql2/instrumentation_test.rb | 301 ------------ instrumentation/mysql2/test/test_helper.rb | 19 - instrumentation/net_http/.rubocop.yml | 5 - instrumentation/net_http/.yardopts | 9 - instrumentation/net_http/CHANGELOG.md | 91 ---- instrumentation/net_http/Gemfile | 13 - instrumentation/net_http/LICENSE | 201 -------- instrumentation/net_http/README.md | 53 -- instrumentation/net_http/Rakefile | 28 -- instrumentation/net_http/example/Gemfile | 8 - instrumentation/net_http/example/net_http.rb | 14 - .../opentelemetry-instrumentation-net_http.rb | 7 - .../lib/opentelemetry/instrumentation.rb | 22 - .../opentelemetry/instrumentation/net/http.rb | 22 - .../net/http/instrumentation.rb | 36 -- .../net/http/patches/instrumentation.rb | 80 --- .../instrumentation/net/http/version.rb | 15 - ...telemetry-instrumentation-net_http.gemspec | 49 -- instrumentation/net_http/test/.rubocop.yml | 4 - .../net/http/instrumentation_test.rb | 167 ------- instrumentation/net_http/test/test_helper.rb | 21 - instrumentation/pg/.rubocop.yml | 5 - instrumentation/pg/.yardopts | 9 - instrumentation/pg/Appraisals | 5 - instrumentation/pg/CHANGELOG.md | 39 -- instrumentation/pg/Gemfile | 13 - instrumentation/pg/LICENSE | 201 -------- instrumentation/pg/README.md | 70 --- instrumentation/pg/Rakefile | 28 -- instrumentation/pg/example/Gemfile | 9 - instrumentation/pg/example/pg.rb | 29 -- .../lib/opentelemetry-instrumentation-pg.rb | 7 - .../pg/lib/opentelemetry/instrumentation.rb | 22 - .../lib/opentelemetry/instrumentation/pg.rb | 19 - .../instrumentation/pg/constants.rb | 124 ----- .../instrumentation/pg/instrumentation.rb | 64 --- .../instrumentation/pg/lru_cache.rb | 44 -- .../instrumentation/pg/patches/connection.rb | 156 ------ .../instrumentation/pg/version.rb | 13 - .../opentelemetry-instrumentation-pg.gemspec | 51 -- instrumentation/pg/test/.rubocop.yml | 6 - .../pg/instrumentation_test.rb | 278 ----------- .../instrumentation/pg/lru_cache_test.rb | 60 --- instrumentation/pg/test/test_helper.rb | 23 - instrumentation/que/.gitignore | 1 - instrumentation/que/.rubocop.yml | 5 - instrumentation/que/.yardopts | 9 - instrumentation/que/Appraisals | 9 - instrumentation/que/CHANGELOG.md | 23 - instrumentation/que/Gemfile | 14 - instrumentation/que/LICENSE | 201 -------- instrumentation/que/README.md | 78 --- instrumentation/que/Rakefile | 28 -- instrumentation/que/example/Gemfile | 15 - instrumentation/que/example/example.rb | 48 -- instrumentation/que/example/run.sh | 4 - .../lib/opentelemetry-instrumentation-que.rb | 7 - .../que/lib/opentelemetry/instrumentation.rb | 22 - .../lib/opentelemetry/instrumentation/que.rb | 19 - .../instrumentation/que/instrumentation.rb | 71 --- .../que/middlewares/server_middleware.rb | 95 ---- .../instrumentation/que/patches/poller.rb | 29 -- .../instrumentation/que/patches/que_job.rb | 71 --- .../instrumentation/que/tag_setter.rb | 22 - .../instrumentation/que/version.rb | 13 - .../opentelemetry-instrumentation-que.gemspec | 52 -- instrumentation/que/test/.rubocop.yml | 6 - .../opentelemetry/instrumentation/que_test.rb | 291 ----------- instrumentation/que/test/test_helper.rb | 57 --- instrumentation/rack/.rubocop.yml | 5 - instrumentation/rack/.yardopts | 9 - instrumentation/rack/Appraisals | 13 - instrumentation/rack/CHANGELOG.md | 119 ----- instrumentation/rack/Gemfile | 14 - instrumentation/rack/LICENSE | 201 -------- instrumentation/rack/README.md | 72 --- instrumentation/rack/Rakefile | 28 -- instrumentation/rack/example/Gemfile | 10 - .../rack/example/trace_demonstration.rb | 28 -- .../rack/example/trace_demonstration2.rb | 30 -- .../lib/opentelemetry-instrumentation-rack.rb | 7 - .../rack/lib/opentelemetry/instrumentation.rb | 19 - .../lib/opentelemetry/instrumentation/rack.rb | 53 -- .../instrumentation/rack/instrumentation.rb | 66 --- .../rack/middlewares/tracer_middleware.rb | 202 -------- .../instrumentation/rack/util/queue_time.rb | 48 -- .../instrumentation/rack/version.rb | 13 - ...opentelemetry-instrumentation-rack.gemspec | 52 -- instrumentation/rack/test/.rubocop.yml | 4 - .../rack/instrumentation_test.rb | 74 --- .../middlewares/tracer_middleware_test.rb | 328 ------------- .../rack/util/queue_time_test.rb | 90 ---- .../instrumentation/rack_test.rb | 55 --- instrumentation/rack/test/test_helper.rb | 24 - instrumentation/rails/.rubocop.yml | 15 - instrumentation/rails/.yardopts | 9 - instrumentation/rails/Appraisals | 32 -- instrumentation/rails/CHANGELOG.md | 91 ---- instrumentation/rails/Gemfile | 19 - instrumentation/rails/LICENSE | 201 -------- instrumentation/rails/README.md | 56 --- instrumentation/rails/Rakefile | 39 -- .../example/trace_request_demonstration.ru | 44 -- .../opentelemetry-instrumentation-rails.rb | 7 - .../lib/opentelemetry/instrumentation.rb | 19 - .../opentelemetry/instrumentation/rails.rb | 23 - .../instrumentation/rails/instrumentation.rb | 32 -- .../instrumentation/rails/railtie.rb | 30 -- .../instrumentation/rails/version.rb | 13 - ...pentelemetry-instrumentation-rails.gemspec | 50 -- .../rails/instrumentation_test.rb | 13 - .../patches/action_controller/metal_test.rb | 44 -- .../rails/test/instrumentation/test_helper.rb | 32 -- .../test_helpers/app_config.rb | 94 ---- .../test_helpers/controllers.rb | 8 - .../controllers/example_controller.rb | 17 - .../controllers/exceptions_controller.rb | 11 - .../test_helpers/middlewares.rb | 8 - .../exception_raising_middleware.rb | 23 - .../middlewares/redirect_middleware.rb | 23 - .../instrumentation/test_helpers/routes.rb | 12 - .../rails/test/railtie/dummy/Rakefile | 6 - .../app/controllers/application_controller.rb | 2 - .../dummy/app/controllers/concerns/.keep | 0 .../rails/test/railtie/dummy/bin/rails | 4 - .../rails/test/railtie/dummy/bin/rake | 4 - .../rails/test/railtie/dummy/bin/setup | 33 -- .../rails/test/railtie/dummy/config.ru | 6 - .../test/railtie/dummy/config/application.rb | 37 -- .../rails/test/railtie/dummy/config/boot.rb | 5 - .../test/railtie/dummy/config/environment.rb | 5 - .../dummy/config/environments/development.rb | 68 --- .../dummy/config/environments/production.rb | 87 ---- .../railtie/dummy/config/environments/test.rb | 60 --- .../initializers/content_security_policy.rb | 26 - .../initializers/filter_parameter_logging.rb | 6 - .../dummy/config/initializers/inflections.rb | 16 - .../config/initializers/permissions_policy.rb | 11 - .../test/railtie/dummy/config/locales/en.yml | 33 -- .../rails/test/railtie/dummy/config/puma.rb | 43 -- .../rails/test/railtie/dummy/config/routes.rb | 6 - .../railtie/dummy/tmp/development_secret.txt | 1 - .../instrumentation/rails/railtie_test.rb | 47 -- .../rails/test/railtie/test_helper.rb | 17 - instrumentation/rdkafka/.rubocop.yml | 5 - instrumentation/rdkafka/.yardopts | 9 - instrumentation/rdkafka/Appraisals | 10 - instrumentation/rdkafka/CHANGELOG.md | 10 - instrumentation/rdkafka/Gemfile | 13 - instrumentation/rdkafka/LICENSE | 201 -------- instrumentation/rdkafka/README.md | 52 -- instrumentation/rdkafka/Rakefile | 29 -- .../example/rdkafka_trace_demonstration.rb | 63 --- .../opentelemetry-instrumentation-rdkafka.rb | 7 - .../lib/opentelemetry/instrumentation.rb | 19 - .../opentelemetry/instrumentation/rdkafka.rb | 19 - .../rdkafka/instrumentation.rb | 41 -- .../rdkafka/patches/consumer.rb | 69 --- .../rdkafka/patches/producer.rb | 37 -- .../instrumentation/rdkafka/version.rb | 13 - ...ntelemetry-instrumentation-rdkafka.gemspec | 52 -- instrumentation/rdkafka/test/.rubocop.yml | 4 - .../rdkafka/instrumentation_test.rb | 29 -- .../rdkafka/patches/consumer_test.rb | 179 ------- .../rdkafka/patches/producer_test.rb | 61 --- instrumentation/rdkafka/test/test_helper.rb | 21 - instrumentation/redis/.rubocop.yml | 5 - instrumentation/redis/.yardopts | 9 - instrumentation/redis/Appraisals | 29 -- instrumentation/redis/CHANGELOG.md | 113 ----- instrumentation/redis/Gemfile | 13 - instrumentation/redis/LICENSE | 201 -------- instrumentation/redis/README.md | 83 ---- instrumentation/redis/Rakefile | 35 -- instrumentation/redis/example/Gemfile | 9 - instrumentation/redis/example/redis.rb | 18 - .../opentelemetry-instrumentation-redis.rb | 7 - .../lib/opentelemetry/instrumentation.rb | 22 - .../opentelemetry/instrumentation/redis.rb | 59 --- .../instrumentation/redis/instrumentation.rb | 38 -- .../instrumentation/redis/patches/client.rb | 95 ---- .../instrumentation/redis/version.rb | 13 - ...pentelemetry-instrumentation-redis.gemspec | 49 -- instrumentation/redis/test/.rubocop.yml | 6 - .../redis/instrumentation_test.rb | 30 -- .../redis/patches/client_test.rb | 352 -------------- .../instrumentation/redis_test.rb | 101 ---- instrumentation/redis/test/redis.conf | 6 - instrumentation/redis/test/test_helper.rb | 23 - instrumentation/resque/.rubocop.yml | 5 - instrumentation/resque/.yardopts | 9 - instrumentation/resque/Appraisals | 14 - instrumentation/resque/CHANGELOG.md | 26 - instrumentation/resque/Gemfile | 15 - instrumentation/resque/LICENSE | 201 -------- instrumentation/resque/README.md | 53 -- instrumentation/resque/Rakefile | 35 -- .../resque/example/trace_demonstration.rb | 37 -- .../opentelemetry-instrumentation-resque.rb | 7 - .../lib/opentelemetry/instrumentation.rb | 19 - .../opentelemetry/instrumentation/resque.rb | 19 - .../instrumentation/resque/instrumentation.rb | 38 -- .../resque/patches/resque_job.rb | 72 --- .../resque/patches/resque_module.rb | 60 --- .../instrumentation/resque/version.rb | 13 - ...entelemetry-instrumentation-resque.gemspec | 50 -- instrumentation/resque/test/.rubocop.yml | 6 - .../resque/instrumentation_test.rb | 29 -- .../resque/patches/resque_job_test.rb | 195 -------- .../resque/patches/resque_test.rb | 60 --- instrumentation/resque/test/redis.conf | 6 - instrumentation/resque/test/test_helper.rb | 59 --- instrumentation/restclient/.rubocop.yml | 5 - instrumentation/restclient/.yardopts | 9 - instrumentation/restclient/Appraisals | 9 - instrumentation/restclient/CHANGELOG.md | 90 ---- instrumentation/restclient/Gemfile | 13 - instrumentation/restclient/LICENSE | 201 -------- instrumentation/restclient/README.md | 49 -- instrumentation/restclient/Rakefile | 28 -- instrumentation/restclient/example/Gemfile | 9 - .../restclient/example/restclient.rb | 13 - ...pentelemetry-instrumentation-restclient.rb | 7 - .../lib/opentelemetry/instrumentation.rb | 22 - .../instrumentation/restclient.rb | 19 - .../restclient/instrumentation.rb | 36 -- .../restclient/patches/request.rb | 65 --- .../instrumentation/restclient/version.rb | 13 - ...lemetry-instrumentation-restclient.gemspec | 50 -- instrumentation/restclient/test/.rubocop.yml | 4 - .../restclient/instrumentation_test.rb | 114 ----- .../restclient/test/test_helper.rb | 21 - instrumentation/rspec/.rubocop.yml | 5 - instrumentation/rspec/.yardopts | 9 - instrumentation/rspec/CHANGELOG.md | 11 - instrumentation/rspec/Gemfile | 13 - instrumentation/rspec/LICENSE | 201 -------- instrumentation/rspec/README.md | 76 --- instrumentation/rspec/Rakefile | 28 -- instrumentation/rspec/example/Gemfile | 10 - ...spec_with_rspec_formatter_configuration.rb | 28 -- .../rspec/example/rspec_with_sdk_configure.rb | 30 -- .../opentelemetry-instrumentation-rspec.rb | 7 - .../lib/opentelemetry/instrumentation.rb | 19 - .../opentelemetry/instrumentation/rspec.rb | 19 - .../instrumentation/rspec/formatter.rb | 129 ----- .../instrumentation/rspec/instrumentation.rb | 35 -- .../instrumentation/rspec/version.rb | 13 - ...pentelemetry-instrumentation-rspec.gemspec | 50 -- instrumentation/rspec/test/.rubocop.yml | 4 - .../instrumentation/rspec/formatter_test.rb | 375 -------------- .../rspec/instrumentation_test.rb | 34 -- instrumentation/rspec/test/rspec_patches.rb | 14 - instrumentation/rspec/test/test_helper.rb | 21 - instrumentation/ruby_kafka/.rubocop.yml | 7 - instrumentation/ruby_kafka/.yardopts | 9 - instrumentation/ruby_kafka/Appraisals | 20 - instrumentation/ruby_kafka/CHANGELOG.md | 63 --- instrumentation/ruby_kafka/Gemfile | 14 - instrumentation/ruby_kafka/LICENSE | 201 -------- instrumentation/ruby_kafka/README.md | 76 --- instrumentation/ruby_kafka/Rakefile | 28 -- instrumentation/ruby_kafka/docker-compose.yml | 25 - instrumentation/ruby_kafka/example/Gemfile | 10 - .../ruby_kafka/example/ruby_kafka.rb | 36 -- ...pentelemetry-instrumentation-ruby_kafka.rb | 7 - .../lib/opentelemetry/instrumentation.rb | 19 - .../instrumentation/ruby_kafka.rb | 19 - .../ruby_kafka/instrumentation.rb | 48 -- .../ruby_kafka/patches/client.rb | 63 --- .../ruby_kafka/patches/consumer.rb | 71 --- .../ruby_kafka/patches/producer.rb | 35 -- .../instrumentation/ruby_kafka/utils.rb | 25 - .../instrumentation/ruby_kafka/version.rb | 13 - ...lemetry-instrumentation-ruby_kafka.gemspec | 49 -- instrumentation/ruby_kafka/test/.rubocop.yml | 6 - .../ruby-kafka/instrumentation_test.rb | 66 --- .../ruby-kafka/patches/client_test.rb | 70 --- .../ruby-kafka/patches/consumer_test.rb | 157 ------ .../ruby-kafka/patches/producer_test.rb | 75 --- .../instrumentation/ruby-kafka/utils_test.rb | 27 -- .../ruby_kafka/test/test_helper.rb | 34 -- instrumentation/sidekiq/.rubocop.yml | 9 - instrumentation/sidekiq/.yardopts | 9 - instrumentation/sidekiq/Appraisals | 29 -- instrumentation/sidekiq/CHANGELOG.md | 107 ---- instrumentation/sidekiq/Gemfile | 15 - instrumentation/sidekiq/LICENSE | 201 -------- instrumentation/sidekiq/README.md | 61 --- instrumentation/sidekiq/Rakefile | 36 -- instrumentation/sidekiq/example/Gemfile | 11 - instrumentation/sidekiq/example/sidekiq.rb | 24 - .../opentelemetry-instrumentation-sidekiq.rb | 7 - .../lib/opentelemetry/instrumentation.rb | 22 - .../opentelemetry/instrumentation/sidekiq.rb | 20 - .../sidekiq/instrumentation.rb | 94 ---- .../middlewares/client/tracer_middleware.rb | 51 -- .../middlewares/server/tracer_middleware.rb | 73 --- .../sidekiq/patches/launcher.rb | 36 -- .../instrumentation/sidekiq/patches/poller.rb | 44 -- .../sidekiq/patches/processor.rb | 36 -- .../instrumentation/sidekiq/version.rb | 13 - ...ntelemetry-instrumentation-sidekiq.gemspec | 51 -- instrumentation/sidekiq/test/.rubocop.yml | 6 - .../sidekiq/test/helpers/mock_loader.rb | 29 -- .../test/helpers/mock_loader_new_launcher.rb | 27 -- .../sidekiq/instrumentation_test.rb | 32 -- .../client/tracer_middleware_test.rb | 85 ---- .../server/tracer_middleware_test.rb | 256 ---------- .../sidekiq/patches/launcher_test.rb | 63 --- .../sidekiq/patches/poller_test.rb | 86 ---- .../sidekiq/patches/processor_test.rb | 63 --- instrumentation/sidekiq/test/redis.conf | 6 - instrumentation/sidekiq/test/test_helper.rb | 87 ---- instrumentation/sinatra/.rubocop.yml | 5 - instrumentation/sinatra/.yardopts | 9 - instrumentation/sinatra/Appraisals | 13 - instrumentation/sinatra/CHANGELOG.md | 96 ---- instrumentation/sinatra/Gemfile | 13 - instrumentation/sinatra/LICENSE | 201 -------- instrumentation/sinatra/README.md | 60 --- instrumentation/sinatra/Rakefile | 28 -- instrumentation/sinatra/example/Gemfile | 13 - instrumentation/sinatra/example/server.rb | 42 -- instrumentation/sinatra/example/sinatra.rb | 16 - .../sinatra/example/start_server.sh | 4 - .../opentelemetry-instrumentation-sinatra.rb | 7 - .../lib/opentelemetry/instrumentation.rb | 22 - .../opentelemetry/instrumentation/sinatra.rb | 19 - .../sinatra/extensions/tracer_extension.rb | 38 -- .../sinatra/instrumentation.rb | 25 - .../sinatra/middlewares/tracer_middleware.rb | 52 -- .../instrumentation/sinatra/version.rb | 13 - ...ntelemetry-instrumentation-sinatra.gemspec | 51 -- instrumentation/sinatra/test/.rubocop.yml | 4 - .../instrumentation/sinatra_test.rb | 137 ------ instrumentation/sinatra/test/test_helper.rb | 23 - instrumentation/trilogy/.rubocop.yml | 5 - instrumentation/trilogy/.yardopts | 9 - instrumentation/trilogy/Appraisals | 9 - instrumentation/trilogy/CHANGELOG.md | 18 - instrumentation/trilogy/Gemfile | 13 - instrumentation/trilogy/LICENSE | 201 -------- instrumentation/trilogy/README.md | 59 --- instrumentation/trilogy/Rakefile | 28 -- .../opentelemetry-instrumentation-trilogy.rb | 8 - .../lib/opentelemetry/instrumentation.rb | 19 - .../opentelemetry/instrumentation/trilogy.rb | 19 - .../trilogy/instrumentation.rb | 40 -- .../instrumentation/trilogy/patches/client.rb | 148 ------ .../instrumentation/trilogy/version.rb | 13 - ...ntelemetry-instrumentation-trilogy.gemspec | 53 -- instrumentation/trilogy/test/.rubocop.yml | 4 - .../trilogy/instrumentation_test.rb | 249 ---------- instrumentation/trilogy/test/test_helper.rb | 24 - propagator/ottrace/.rubocop.yml | 22 - propagator/ottrace/.yardopts | 9 - propagator/ottrace/CHANGELOG.md | 41 -- propagator/ottrace/Gemfile | 6 - propagator/ottrace/LICENSE | 201 -------- propagator/ottrace/README.md | 91 ---- propagator/ottrace/Rakefile | 30 -- .../lib/opentelemetry-propagator-ottrace.rb | 8 - .../lib/opentelemetry/propagator/ottrace.rb | 35 -- .../propagator/ottrace/text_map_propagator.rb | 151 ------ .../propagator/ottrace/version.rb | 21 - .../opentelemetry-propagator-ottrace.gemspec | 42 -- .../ottrace/text_map_propagator_test.rb | 412 ---------------- .../opentelemetry/propagator/ottrace_test.rb | 18 - propagator/ottrace/test/test_helper.rb | 18 - propagator/xray/.rubocop.yml | 17 - propagator/xray/.yardopts | 9 - propagator/xray/CHANGELOG.md | 31 -- propagator/xray/Gemfile | 9 - propagator/xray/LICENSE | 201 -------- propagator/xray/README.md | 60 --- propagator/xray/Rakefile | 28 -- .../xray/lib/opentelemetry-propagator-xray.rb | 8 - .../xray/lib/opentelemetry/propagator/xray.rb | 49 -- .../propagator/xray/id_generator.rb | 44 -- .../propagator/xray/text_map_propagator.rb | 127 ----- .../opentelemetry/propagator/xray/version.rb | 13 - .../opentelemetry-propagator-xray.gemspec | 45 -- propagator/xray/test/.rubocop.yml | 4 - propagator/xray/test/aws_xray_trace_test.rb | 35 -- propagator/xray/test/test_helper.rb | 8 - .../xray/test/text_map_propagator_test.rb | 178 ------- propagator/xray/test/xray_test.rb | 18 - resource_detectors/.rubocop.yml | 29 -- resource_detectors/.yardopts | 9 - resource_detectors/CHANGELOG.md | 82 ---- resource_detectors/Gemfile | 14 - resource_detectors/LICENSE | 201 -------- resource_detectors/README.md | 51 -- resource_detectors/Rakefile | 28 -- .../lib/opentelemetry-resource_detectors.rb | 7 - .../lib/opentelemetry/resource/detectors.rb | 25 - .../resource/detectors/auto_detector.rb | 24 - .../detectors/google_cloud_platform.rb | 72 --- .../resource/detectors/version.rb | 13 - .../opentelemetry-resource_detectors.gemspec | 45 -- .../detectors/auto_detector_test.rb | 21 - .../detectors/google_cloud_platform_test.rb | 92 ---- resource_detectors/test/test_helper.rb | 12 - 925 files changed, 7 insertions(+), 43322 deletions(-) delete mode 100644 .instrumentation_generator/instrumentation_generator.rb delete mode 100644 .instrumentation_generator/templates/Appraisals delete mode 100644 .instrumentation_generator/templates/CHANGELOG.md.tt delete mode 100644 .instrumentation_generator/templates/Gemfile delete mode 100644 .instrumentation_generator/templates/LICENSE delete mode 100644 .instrumentation_generator/templates/Rakefile delete mode 100644 .instrumentation_generator/templates/Readme.md.tt delete mode 100644 .instrumentation_generator/templates/gemspec.tt delete mode 100644 .instrumentation_generator/templates/lib/entrypoint.rb delete mode 100644 .instrumentation_generator/templates/lib/instrumentation.rb.tt delete mode 100644 .instrumentation_generator/templates/lib/instrumentation/instrumentation_name.rb.tt delete mode 100644 .instrumentation_generator/templates/lib/instrumentation/instrumentation_name/instrumentation.rb.tt delete mode 100644 .instrumentation_generator/templates/lib/instrumentation/instrumentation_name/version.rb.tt delete mode 100644 .instrumentation_generator/templates/rubocop.yml.tt delete mode 100644 .instrumentation_generator/templates/test/.rubocop.yml delete mode 100644 .instrumentation_generator/templates/test/instrumentation.rb.tt delete mode 100644 .instrumentation_generator/templates/test/test_helper.rb delete mode 100644 .instrumentation_generator/templates/yardopts.tt delete mode 100755 bin/instrumentation_generator delete mode 100644 instrumentation/.rubocop-examples.yml delete mode 100644 instrumentation/README.md delete mode 100644 instrumentation/action_pack/.rubocop.yml delete mode 100644 instrumentation/action_pack/.yardopts delete mode 100644 instrumentation/action_pack/Appraisals delete mode 100644 instrumentation/action_pack/CHANGELOG.md delete mode 100644 instrumentation/action_pack/Gemfile delete mode 100644 instrumentation/action_pack/LICENSE delete mode 100644 instrumentation/action_pack/README.md delete mode 100644 instrumentation/action_pack/Rakefile delete mode 100644 instrumentation/action_pack/example/trace_demonstration.ru delete mode 100644 instrumentation/action_pack/lib/opentelemetry-instrumentation-action_pack.rb delete mode 100644 instrumentation/action_pack/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack.rb delete mode 100644 instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/instrumentation.rb delete mode 100644 instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/patches/action_controller/metal.rb delete mode 100644 instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/railtie.rb delete mode 100644 instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/version.rb delete mode 100644 instrumentation/action_pack/opentelemetry-instrumentation-action_pack.gemspec delete mode 100644 instrumentation/action_pack/test/.rubocop.yml delete mode 100644 instrumentation/action_pack/test/opentelemetry/instrumentation/action_pack/instrumentation_test.rb delete mode 100644 instrumentation/action_pack/test/opentelemetry/instrumentation/action_pack/patches/action_controller/metal_test.rb delete mode 100644 instrumentation/action_pack/test/test_helper.rb delete mode 100644 instrumentation/action_pack/test/test_helpers/app_config.rb delete mode 100644 instrumentation/action_pack/test/test_helpers/controllers.rb delete mode 100644 instrumentation/action_pack/test/test_helpers/controllers/example_controller.rb delete mode 100644 instrumentation/action_pack/test/test_helpers/controllers/exceptions_controller.rb delete mode 100644 instrumentation/action_pack/test/test_helpers/middlewares.rb delete mode 100644 instrumentation/action_pack/test/test_helpers/middlewares/exception_raising_middleware.rb delete mode 100644 instrumentation/action_pack/test/test_helpers/middlewares/redirect_middleware.rb delete mode 100644 instrumentation/action_pack/test/test_helpers/routes.rb delete mode 100644 instrumentation/action_view/.rubocop.yml delete mode 100644 instrumentation/action_view/.yardopts delete mode 100644 instrumentation/action_view/Appraisals delete mode 100644 instrumentation/action_view/CHANGELOG.md delete mode 100644 instrumentation/action_view/Gemfile delete mode 100644 instrumentation/action_view/LICENSE delete mode 100644 instrumentation/action_view/README.md delete mode 100644 instrumentation/action_view/Rakefile delete mode 100644 instrumentation/action_view/example/trace_request_demonstration.ru delete mode 100644 instrumentation/action_view/lib/opentelemetry-instrumentation-action_view.rb delete mode 100644 instrumentation/action_view/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/action_view/lib/opentelemetry/instrumentation/action_view.rb delete mode 100644 instrumentation/action_view/lib/opentelemetry/instrumentation/action_view/instrumentation.rb delete mode 100644 instrumentation/action_view/lib/opentelemetry/instrumentation/action_view/railtie.rb delete mode 100644 instrumentation/action_view/lib/opentelemetry/instrumentation/action_view/version.rb delete mode 100644 instrumentation/action_view/opentelemetry-instrumentation-action_view.gemspec delete mode 100644 instrumentation/action_view/test/.rubocop.yml delete mode 100644 instrumentation/action_view/test/opentelemetry/instrumentation/action_view/instrumentation_test.rb delete mode 100644 instrumentation/action_view/test/test_helper.rb delete mode 100644 instrumentation/active_job/.rubocop.yml delete mode 100644 instrumentation/active_job/.yardopts delete mode 100644 instrumentation/active_job/Appraisals delete mode 100644 instrumentation/active_job/CHANGELOG.md delete mode 100644 instrumentation/active_job/Gemfile delete mode 100644 instrumentation/active_job/LICENSE delete mode 100644 instrumentation/active_job/README.md delete mode 100644 instrumentation/active_job/Rakefile delete mode 100644 instrumentation/active_job/example/Gemfile delete mode 100644 instrumentation/active_job/example/active_job.rb delete mode 100644 instrumentation/active_job/lib/opentelemetry-instrumentation-active_job.rb delete mode 100644 instrumentation/active_job/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/active_job/lib/opentelemetry/instrumentation/active_job.rb delete mode 100644 instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/instrumentation.rb delete mode 100644 instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/patches/active_job_callbacks.rb delete mode 100644 instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/patches/base.rb delete mode 100644 instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/version.rb delete mode 100644 instrumentation/active_job/opentelemetry-instrumentation-active_job.gemspec delete mode 100644 instrumentation/active_job/test/.rubocop.yml delete mode 100644 instrumentation/active_job/test/instrumentation/active_job/instrumentation_test.rb delete mode 100644 instrumentation/active_job/test/instrumentation/active_job/patches/active_job_callbacks_test.rb delete mode 100644 instrumentation/active_job/test/instrumentation/active_job/patches/base_test.rb delete mode 100644 instrumentation/active_job/test/test_helper.rb delete mode 100644 instrumentation/active_model_serializers/.rubocop.yml delete mode 100644 instrumentation/active_model_serializers/.yardopts delete mode 100644 instrumentation/active_model_serializers/Appraisals delete mode 100644 instrumentation/active_model_serializers/CHANGELOG.md delete mode 100644 instrumentation/active_model_serializers/Gemfile delete mode 100644 instrumentation/active_model_serializers/LICENSE delete mode 100644 instrumentation/active_model_serializers/README.md delete mode 100644 instrumentation/active_model_serializers/Rakefile delete mode 100644 instrumentation/active_model_serializers/example/Gemfile delete mode 100644 instrumentation/active_model_serializers/example/active_model_serializers.rb delete mode 100644 instrumentation/active_model_serializers/lib/opentelemetry-instrumentation-active_model_serializers.rb delete mode 100644 instrumentation/active_model_serializers/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/active_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers.rb delete mode 100644 instrumentation/active_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers/event_handler.rb delete mode 100644 instrumentation/active_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers/instrumentation.rb delete mode 100644 instrumentation/active_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers/version.rb delete mode 100644 instrumentation/active_model_serializers/opentelemetry-instrumentation-active_model_serializers.gemspec delete mode 100644 instrumentation/active_model_serializers/test/.rubocop.yml delete mode 100644 instrumentation/active_model_serializers/test/opentelemetry/instrumentation/active_model_serializers/event_handler_test.rb delete mode 100644 instrumentation/active_model_serializers/test/opentelemetry/instrumentation/active_model_serializers_test.rb delete mode 100644 instrumentation/active_model_serializers/test/test_helper.rb delete mode 100644 instrumentation/active_record/.rubocop.yml delete mode 100644 instrumentation/active_record/.yardopts delete mode 100644 instrumentation/active_record/Appraisals delete mode 100644 instrumentation/active_record/CHANGELOG.md delete mode 100644 instrumentation/active_record/Gemfile delete mode 100644 instrumentation/active_record/LICENSE delete mode 100644 instrumentation/active_record/README.md delete mode 100644 instrumentation/active_record/Rakefile delete mode 100644 instrumentation/active_record/example/trace_demonstration.rb delete mode 100644 instrumentation/active_record/lib/opentelemetry-instrumentation-active_record.rb delete mode 100644 instrumentation/active_record/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/active_record/lib/opentelemetry/instrumentation/active_record.rb delete mode 100644 instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/instrumentation.rb delete mode 100644 instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/persistence.rb delete mode 100644 instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/persistence_class_methods.rb delete mode 100644 instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/persistence_insert_class_methods.rb delete mode 100644 instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/querying.rb delete mode 100644 instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/relation_persistence.rb delete mode 100644 instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/transactions_class_methods.rb delete mode 100644 instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/validations.rb delete mode 100644 instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/version.rb delete mode 100644 instrumentation/active_record/opentelemetry-instrumentation-active_record.gemspec delete mode 100644 instrumentation/active_record/test/.rubocop.yml delete mode 100644 instrumentation/active_record/test/instrumentation/active_record/instrumentation_test.rb delete mode 100644 instrumentation/active_record/test/instrumentation/active_record/patches/persistence_class_methods_test.rb delete mode 100644 instrumentation/active_record/test/instrumentation/active_record/patches/persistence_insert_class_methods_test.rb delete mode 100644 instrumentation/active_record/test/instrumentation/active_record/patches/persistence_test.rb delete mode 100644 instrumentation/active_record/test/instrumentation/active_record/patches/querying_test.rb delete mode 100644 instrumentation/active_record/test/instrumentation/active_record/patches/relation_persistence_test.rb delete mode 100644 instrumentation/active_record/test/instrumentation/active_record/patches/transactions_class_methods_test.rb delete mode 100644 instrumentation/active_record/test/test_helper.rb delete mode 100644 instrumentation/active_support/.rubocop.yml delete mode 100644 instrumentation/active_support/.yardopts delete mode 100644 instrumentation/active_support/Appraisals delete mode 100644 instrumentation/active_support/CHANGELOG.md delete mode 100644 instrumentation/active_support/Gemfile delete mode 100644 instrumentation/active_support/LICENSE delete mode 100644 instrumentation/active_support/README.md delete mode 100644 instrumentation/active_support/Rakefile delete mode 100644 instrumentation/active_support/example/Gemfile delete mode 100644 instrumentation/active_support/example/trace_demonstration.rb delete mode 100644 instrumentation/active_support/lib/opentelemetry-instrumentation-active_support.rb delete mode 100644 instrumentation/active_support/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/active_support/lib/opentelemetry/instrumentation/active_support.rb delete mode 100644 instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/instrumentation.rb delete mode 100644 instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/span_subscriber.rb delete mode 100644 instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/version.rb delete mode 100644 instrumentation/active_support/opentelemetry-instrumentation-active_support.gemspec delete mode 100644 instrumentation/active_support/test/.rubocop.yml delete mode 100644 instrumentation/active_support/test/opentelemetry/instrumentation/active_support/instrumentation_test.rb delete mode 100644 instrumentation/active_support/test/opentelemetry/instrumentation/active_support/span_subscriber_test.rb delete mode 100644 instrumentation/active_support/test/test_helper.rb delete mode 100644 instrumentation/all/.rubocop.yml delete mode 100644 instrumentation/all/.yardopts delete mode 100644 instrumentation/all/CHANGELOG.md delete mode 100644 instrumentation/all/Gemfile delete mode 100644 instrumentation/all/LICENSE delete mode 100644 instrumentation/all/README.md delete mode 100644 instrumentation/all/Rakefile delete mode 100644 instrumentation/all/lib/opentelemetry-instrumentation-all.rb delete mode 100644 instrumentation/all/lib/opentelemetry/instrumentation/all.rb delete mode 100644 instrumentation/all/lib/opentelemetry/instrumentation/all/version.rb delete mode 100644 instrumentation/all/opentelemetry-instrumentation-all.gemspec delete mode 100644 instrumentation/all/test/.rubocop.yml delete mode 100644 instrumentation/all/test/opentelemetry/instrumentation/all_test.rb delete mode 100644 instrumentation/all/test/test_helper.rb delete mode 100644 instrumentation/aws_sdk/.rubocop.yml delete mode 100644 instrumentation/aws_sdk/.yardopts delete mode 100644 instrumentation/aws_sdk/Appraisals delete mode 100644 instrumentation/aws_sdk/CHANGELOG.md delete mode 100644 instrumentation/aws_sdk/Gemfile delete mode 100644 instrumentation/aws_sdk/LICENSE delete mode 100644 instrumentation/aws_sdk/README.md delete mode 100644 instrumentation/aws_sdk/Rakefile delete mode 100644 instrumentation/aws_sdk/example/Gemfile delete mode 100755 instrumentation/aws_sdk/example/trace_demonstration.rb delete mode 100644 instrumentation/aws_sdk/lib/opentelemetry-instrumentation-aws_sdk.rb delete mode 100644 instrumentation/aws_sdk/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk.rb delete mode 100644 instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/handler.rb delete mode 100644 instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/instrumentation.rb delete mode 100644 instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/message_attributes.rb delete mode 100644 instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/messaging_helper.rb delete mode 100644 instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/services.rb delete mode 100644 instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/version.rb delete mode 100644 instrumentation/aws_sdk/opentelemetry-instrumentation-aws_sdk.gemspec delete mode 100644 instrumentation/aws_sdk/test/.rubocop.yml delete mode 100644 instrumentation/aws_sdk/test/opentelemetry/instrumentation_test.rb delete mode 100644 instrumentation/aws_sdk/test/test_helper.rb delete mode 100644 instrumentation/base/.rubocop.yml delete mode 100644 instrumentation/base/.yardopts delete mode 100644 instrumentation/base/CHANGELOG.md delete mode 100644 instrumentation/base/Gemfile delete mode 100644 instrumentation/base/LICENSE delete mode 100644 instrumentation/base/README.md delete mode 100644 instrumentation/base/Rakefile delete mode 100644 instrumentation/base/lib/opentelemetry-instrumentation-base.rb delete mode 100644 instrumentation/base/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/base/lib/opentelemetry/instrumentation/base.rb delete mode 100644 instrumentation/base/lib/opentelemetry/instrumentation/version.rb delete mode 100644 instrumentation/base/opentelemetry-instrumentation-base.gemspec delete mode 100644 instrumentation/base/test/.rubocop.yml delete mode 100644 instrumentation/base/test/instrumentation/base_test.rb delete mode 100644 instrumentation/base/test/instrumentation_test.rb delete mode 100644 instrumentation/base/test/test_helper.rb delete mode 100644 instrumentation/bunny/.rubocop.yml delete mode 100644 instrumentation/bunny/.yardopts delete mode 100644 instrumentation/bunny/Appraisals delete mode 100644 instrumentation/bunny/CHANGELOG.md delete mode 100644 instrumentation/bunny/Gemfile delete mode 100644 instrumentation/bunny/LICENSE delete mode 100644 instrumentation/bunny/README.md delete mode 100644 instrumentation/bunny/Rakefile delete mode 100644 instrumentation/bunny/example/Gemfile delete mode 100644 instrumentation/bunny/example/bunny.rb delete mode 100644 instrumentation/bunny/lib/opentelemetry-instrumentation-bunny.rb delete mode 100644 instrumentation/bunny/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/bunny/lib/opentelemetry/instrumentation/bunny.rb delete mode 100644 instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/instrumentation.rb delete mode 100644 instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/patch_helpers.rb delete mode 100644 instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/patches/channel.rb delete mode 100644 instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/patches/consumer.rb delete mode 100644 instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/patches/queue.rb delete mode 100644 instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/patches/reader_loop.rb delete mode 100644 instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/version.rb delete mode 100644 instrumentation/bunny/opentelemetry-instrumentation-bunny.gemspec delete mode 100644 instrumentation/bunny/test/.rubocop.yml delete mode 100644 instrumentation/bunny/test/opentelemetry/instrumentation/bunny/instrumentation_test.rb delete mode 100644 instrumentation/bunny/test/opentelemetry/instrumentation/bunny/patches/channel_test.rb delete mode 100644 instrumentation/bunny/test/opentelemetry/instrumentation/bunny/patches/consumer_test.rb delete mode 100644 instrumentation/bunny/test/opentelemetry/instrumentation/bunny/patches/queue_test.rb delete mode 100644 instrumentation/bunny/test/test_helper.rb delete mode 100644 instrumentation/concurrent_ruby/.rubocop.yml delete mode 100644 instrumentation/concurrent_ruby/.yardopts delete mode 100644 instrumentation/concurrent_ruby/Appraisals delete mode 100644 instrumentation/concurrent_ruby/CHANGELOG.md delete mode 100644 instrumentation/concurrent_ruby/Gemfile delete mode 100644 instrumentation/concurrent_ruby/LICENSE delete mode 100644 instrumentation/concurrent_ruby/README.md delete mode 100644 instrumentation/concurrent_ruby/Rakefile delete mode 100644 instrumentation/concurrent_ruby/example/Gemfile delete mode 100644 instrumentation/concurrent_ruby/example/concurrent_ruby.rb delete mode 100644 instrumentation/concurrent_ruby/lib/opentelemetry-instrumentation-concurrent_ruby.rb delete mode 100644 instrumentation/concurrent_ruby/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/concurrent_ruby/lib/opentelemetry/instrumentation/concurrent_ruby.rb delete mode 100644 instrumentation/concurrent_ruby/lib/opentelemetry/instrumentation/concurrent_ruby/instrumentation.rb delete mode 100644 instrumentation/concurrent_ruby/lib/opentelemetry/instrumentation/concurrent_ruby/patches/thread_pool_executor.rb delete mode 100644 instrumentation/concurrent_ruby/lib/opentelemetry/instrumentation/concurrent_ruby/version.rb delete mode 100644 instrumentation/concurrent_ruby/opentelemetry-instrumentation-concurrent_ruby.gemspec delete mode 100644 instrumentation/concurrent_ruby/test/.rubocop.yml delete mode 100644 instrumentation/concurrent_ruby/test/opentelemetry/instrumentation/concurrent-ruby/instrumentation_test.rb delete mode 100644 instrumentation/concurrent_ruby/test/test_helper.rb delete mode 100644 instrumentation/dalli/.rubocop.yml delete mode 100644 instrumentation/dalli/.yardopts delete mode 100644 instrumentation/dalli/Appraisals delete mode 100644 instrumentation/dalli/CHANGELOG.md delete mode 100644 instrumentation/dalli/Gemfile delete mode 100644 instrumentation/dalli/LICENSE delete mode 100644 instrumentation/dalli/README.md delete mode 100644 instrumentation/dalli/Rakefile delete mode 100644 instrumentation/dalli/example/Gemfile delete mode 100644 instrumentation/dalli/example/dalli.rb delete mode 100644 instrumentation/dalli/lib/opentelemetry-instrumentation-dalli.rb delete mode 100644 instrumentation/dalli/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/dalli/lib/opentelemetry/instrumentation/dalli.rb delete mode 100644 instrumentation/dalli/lib/opentelemetry/instrumentation/dalli/instrumentation.rb delete mode 100644 instrumentation/dalli/lib/opentelemetry/instrumentation/dalli/patches/server.rb delete mode 100644 instrumentation/dalli/lib/opentelemetry/instrumentation/dalli/utils.rb delete mode 100644 instrumentation/dalli/lib/opentelemetry/instrumentation/dalli/version.rb delete mode 100644 instrumentation/dalli/opentelemetry-instrumentation-dalli.gemspec delete mode 100644 instrumentation/dalli/test/.rubocop.yml delete mode 100644 instrumentation/dalli/test/opentelemetry/instrumentation/dalli/instrumentation_test.rb delete mode 100644 instrumentation/dalli/test/test_helper.rb delete mode 100644 instrumentation/datadog-porting-guide.md delete mode 100644 instrumentation/delayed_job/.rubocop.yml delete mode 100644 instrumentation/delayed_job/.yardopts delete mode 100644 instrumentation/delayed_job/Appraisals delete mode 100644 instrumentation/delayed_job/CHANGELOG.md delete mode 100644 instrumentation/delayed_job/Gemfile delete mode 100644 instrumentation/delayed_job/LICENSE delete mode 100644 instrumentation/delayed_job/README.md delete mode 100644 instrumentation/delayed_job/Rakefile delete mode 100644 instrumentation/delayed_job/example/Gemfile delete mode 100644 instrumentation/delayed_job/example/delayed_job.rb delete mode 100644 instrumentation/delayed_job/lib/opentelemetry-instrumentation-delayed_job.rb delete mode 100644 instrumentation/delayed_job/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job.rb delete mode 100644 instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job/instrumentation.rb delete mode 100644 instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin.rb delete mode 100644 instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job/version.rb delete mode 100644 instrumentation/delayed_job/opentelemetry-instrumentation-delayed_job.gemspec delete mode 100644 instrumentation/delayed_job/test/.rubocop.yml delete mode 100644 instrumentation/delayed_job/test/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin_test.rb delete mode 100644 instrumentation/delayed_job/test/opentelemetry/instrumentation/delayed_job_test.rb delete mode 100644 instrumentation/delayed_job/test/test_helper.rb delete mode 100644 instrumentation/ethon/.rubocop.yml delete mode 100644 instrumentation/ethon/.yardopts delete mode 100644 instrumentation/ethon/Appraisals delete mode 100644 instrumentation/ethon/CHANGELOG.md delete mode 100644 instrumentation/ethon/Gemfile delete mode 100644 instrumentation/ethon/LICENSE delete mode 100644 instrumentation/ethon/README.md delete mode 100644 instrumentation/ethon/Rakefile delete mode 100644 instrumentation/ethon/example/Gemfile delete mode 100644 instrumentation/ethon/example/ethon.rb delete mode 100644 instrumentation/ethon/lib/opentelemetry-instrumentation-ethon.rb delete mode 100644 instrumentation/ethon/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/ethon/lib/opentelemetry/instrumentation/ethon.rb delete mode 100644 instrumentation/ethon/lib/opentelemetry/instrumentation/ethon/instrumentation.rb delete mode 100644 instrumentation/ethon/lib/opentelemetry/instrumentation/ethon/patches/easy.rb delete mode 100644 instrumentation/ethon/lib/opentelemetry/instrumentation/ethon/patches/multi.rb delete mode 100644 instrumentation/ethon/lib/opentelemetry/instrumentation/ethon/version.rb delete mode 100644 instrumentation/ethon/opentelemetry-instrumentation-ethon.gemspec delete mode 100644 instrumentation/ethon/test/.rubocop.yml delete mode 100644 instrumentation/ethon/test/opentelemetry/instrumentation/ethon/instrumentation_test.rb delete mode 100644 instrumentation/ethon/test/test_helper.rb delete mode 100644 instrumentation/excon/.rubocop.yml delete mode 100644 instrumentation/excon/.yardopts delete mode 100644 instrumentation/excon/Appraisals delete mode 100644 instrumentation/excon/CHANGELOG.md delete mode 100644 instrumentation/excon/Gemfile delete mode 100644 instrumentation/excon/LICENSE delete mode 100644 instrumentation/excon/README.md delete mode 100644 instrumentation/excon/Rakefile delete mode 100644 instrumentation/excon/example/Gemfile delete mode 100644 instrumentation/excon/example/excon.rb delete mode 100644 instrumentation/excon/lib/opentelemetry-instrumentation-excon.rb delete mode 100644 instrumentation/excon/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/excon/lib/opentelemetry/instrumentation/excon.rb delete mode 100644 instrumentation/excon/lib/opentelemetry/instrumentation/excon/instrumentation.rb delete mode 100644 instrumentation/excon/lib/opentelemetry/instrumentation/excon/middlewares/tracer_middleware.rb delete mode 100644 instrumentation/excon/lib/opentelemetry/instrumentation/excon/version.rb delete mode 100644 instrumentation/excon/opentelemetry-instrumentation-excon.gemspec delete mode 100644 instrumentation/excon/test/.rubocop.yml delete mode 100644 instrumentation/excon/test/opentelemetry/instrumentation/excon/instrumentation_test.rb delete mode 100644 instrumentation/excon/test/test_helper.rb delete mode 100644 instrumentation/faraday/.rubocop.yml delete mode 100644 instrumentation/faraday/.yardopts delete mode 100644 instrumentation/faraday/Appraisals delete mode 100644 instrumentation/faraday/CHANGELOG.md delete mode 100644 instrumentation/faraday/Gemfile delete mode 100644 instrumentation/faraday/LICENSE delete mode 100644 instrumentation/faraday/README.md delete mode 100644 instrumentation/faraday/Rakefile delete mode 100644 instrumentation/faraday/example/Gemfile delete mode 100644 instrumentation/faraday/example/faraday.rb delete mode 100644 instrumentation/faraday/lib/opentelemetry-instrumentation-faraday.rb delete mode 100644 instrumentation/faraday/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/faraday/lib/opentelemetry/instrumentation/faraday.rb delete mode 100644 instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/instrumentation.rb delete mode 100644 instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/middlewares/tracer_middleware.rb delete mode 100644 instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/patches/rack_builder.rb delete mode 100644 instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/version.rb delete mode 100644 instrumentation/faraday/opentelemetry-instrumentation-faraday.gemspec delete mode 100644 instrumentation/faraday/test/.rubocop.yml delete mode 100644 instrumentation/faraday/test/opentelemetry/instrumentation/faraday/middlewares/tracer_middleware_test.rb delete mode 100644 instrumentation/faraday/test/opentelemetry/instrumentation/faraday_test.rb delete mode 100644 instrumentation/faraday/test/test_helper.rb delete mode 100644 instrumentation/graphql/.rubocop.yml delete mode 100644 instrumentation/graphql/.yardopts delete mode 100644 instrumentation/graphql/Appraisals delete mode 100644 instrumentation/graphql/CHANGELOG.md delete mode 100644 instrumentation/graphql/Gemfile delete mode 100644 instrumentation/graphql/LICENSE delete mode 100644 instrumentation/graphql/README.md delete mode 100644 instrumentation/graphql/Rakefile delete mode 100644 instrumentation/graphql/example/Gemfile delete mode 100644 instrumentation/graphql/example/graphql.rb delete mode 100644 instrumentation/graphql/lib/opentelemetry-instrumentation-graphql.rb delete mode 100644 instrumentation/graphql/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/graphql/lib/opentelemetry/instrumentation/graphql.rb delete mode 100644 instrumentation/graphql/lib/opentelemetry/instrumentation/graphql/instrumentation.rb delete mode 100644 instrumentation/graphql/lib/opentelemetry/instrumentation/graphql/tracers/graphql_tracer.rb delete mode 100644 instrumentation/graphql/lib/opentelemetry/instrumentation/graphql/version.rb delete mode 100644 instrumentation/graphql/opentelemetry-instrumentation-graphql.gemspec delete mode 100644 instrumentation/graphql/test/.rubocop.yml delete mode 100644 instrumentation/graphql/test/instrumentation/graphql/instrumentation_test.rb delete mode 100644 instrumentation/graphql/test/instrumentation/graphql/tracers/graphql_tracer_test.rb delete mode 100644 instrumentation/graphql/test/test_helper.rb delete mode 100644 instrumentation/http/.rubocop.yml delete mode 100644 instrumentation/http/.yardopts delete mode 100644 instrumentation/http/Appraisals delete mode 100644 instrumentation/http/CHANGELOG.md delete mode 100644 instrumentation/http/Gemfile delete mode 100644 instrumentation/http/LICENSE delete mode 100644 instrumentation/http/README.md delete mode 100644 instrumentation/http/Rakefile delete mode 100644 instrumentation/http/example/trace_demonstration.rb delete mode 100644 instrumentation/http/lib/opentelemetry-instrumentation-http.rb delete mode 100644 instrumentation/http/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/http/lib/opentelemetry/instrumentation/http.rb delete mode 100644 instrumentation/http/lib/opentelemetry/instrumentation/http/instrumentation.rb delete mode 100644 instrumentation/http/lib/opentelemetry/instrumentation/http/patches/client.rb delete mode 100644 instrumentation/http/lib/opentelemetry/instrumentation/http/patches/connection.rb delete mode 100644 instrumentation/http/lib/opentelemetry/instrumentation/http/version.rb delete mode 100644 instrumentation/http/opentelemetry-instrumentation-http.gemspec delete mode 100644 instrumentation/http/test/.rubocop.yml delete mode 100644 instrumentation/http/test/instrumentation/http/instrumentation_test.rb delete mode 100644 instrumentation/http/test/instrumentation/http/patches/client_test.rb delete mode 100644 instrumentation/http/test/instrumentation/http/patches/connection_test.rb delete mode 100644 instrumentation/http/test/test_helper.rb delete mode 100644 instrumentation/http_client/.rubocop.yml delete mode 100644 instrumentation/http_client/.yardopts delete mode 100644 instrumentation/http_client/Appraisals delete mode 100644 instrumentation/http_client/CHANGELOG.md delete mode 100644 instrumentation/http_client/Gemfile delete mode 100644 instrumentation/http_client/LICENSE delete mode 100644 instrumentation/http_client/README.md delete mode 100644 instrumentation/http_client/Rakefile delete mode 100644 instrumentation/http_client/example/Gemfile delete mode 100644 instrumentation/http_client/example/trace_demonstration.rb delete mode 100644 instrumentation/http_client/lib/opentelemetry-instrumentation-http_client.rb delete mode 100644 instrumentation/http_client/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/http_client/lib/opentelemetry/instrumentation/http_client.rb delete mode 100644 instrumentation/http_client/lib/opentelemetry/instrumentation/http_client/instrumentation.rb delete mode 100644 instrumentation/http_client/lib/opentelemetry/instrumentation/http_client/patches/client.rb delete mode 100644 instrumentation/http_client/lib/opentelemetry/instrumentation/http_client/patches/session.rb delete mode 100644 instrumentation/http_client/lib/opentelemetry/instrumentation/http_client/version.rb delete mode 100644 instrumentation/http_client/opentelemetry-instrumentation-http_client.gemspec delete mode 100644 instrumentation/http_client/test/.rubocop.yml delete mode 100644 instrumentation/http_client/test/instrumentation/http_client/instrumentation_test.rb delete mode 100644 instrumentation/http_client/test/instrumentation/http_client/patches/client_test.rb delete mode 100644 instrumentation/http_client/test/instrumentation/http_client/patches/session_test.rb delete mode 100644 instrumentation/http_client/test/test_helper.rb delete mode 100644 instrumentation/koala/.rubocop.yml delete mode 100644 instrumentation/koala/.yardopts delete mode 100644 instrumentation/koala/Appraisals delete mode 100644 instrumentation/koala/CHANGELOG.md delete mode 100644 instrumentation/koala/Gemfile delete mode 100644 instrumentation/koala/LICENSE delete mode 100644 instrumentation/koala/README.md delete mode 100644 instrumentation/koala/Rakefile delete mode 100644 instrumentation/koala/example/Gemfile delete mode 100644 instrumentation/koala/example/trace_demonstration.rb delete mode 100644 instrumentation/koala/lib/opentelemetry-instrumentation-koala.rb delete mode 100644 instrumentation/koala/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/koala/lib/opentelemetry/instrumentation/koala.rb delete mode 100644 instrumentation/koala/lib/opentelemetry/instrumentation/koala/instrumentation.rb delete mode 100644 instrumentation/koala/lib/opentelemetry/instrumentation/koala/patches/instrumentation.rb delete mode 100644 instrumentation/koala/lib/opentelemetry/instrumentation/koala/version.rb delete mode 100644 instrumentation/koala/opentelemetry-instrumentation-koala.gemspec delete mode 100644 instrumentation/koala/test/instrumentation/koala/instrumentation_test.rb delete mode 100644 instrumentation/koala/test/test_helper.rb delete mode 100644 instrumentation/lmdb/.rubocop.yml delete mode 100644 instrumentation/lmdb/.yardopts delete mode 100644 instrumentation/lmdb/Appraisals delete mode 100644 instrumentation/lmdb/CHANGELOG.md delete mode 100644 instrumentation/lmdb/Gemfile delete mode 100644 instrumentation/lmdb/LICENSE delete mode 100644 instrumentation/lmdb/README.md delete mode 100644 instrumentation/lmdb/Rakefile delete mode 100644 instrumentation/lmdb/lib/opentelemetry-instrumentation-lmdb.rb delete mode 100644 instrumentation/lmdb/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/lmdb/lib/opentelemetry/instrumentation/lmdb.rb delete mode 100644 instrumentation/lmdb/lib/opentelemetry/instrumentation/lmdb/instrumentation.rb delete mode 100644 instrumentation/lmdb/lib/opentelemetry/instrumentation/lmdb/patches/database.rb delete mode 100644 instrumentation/lmdb/lib/opentelemetry/instrumentation/lmdb/patches/environment.rb delete mode 100644 instrumentation/lmdb/lib/opentelemetry/instrumentation/lmdb/version.rb delete mode 100644 instrumentation/lmdb/opentelemetry-instrumentation-lmdb.gemspec delete mode 100644 instrumentation/lmdb/test/.rubocop.yml delete mode 100644 instrumentation/lmdb/test/instrumentation/lmdb/instrumentation_test.rb delete mode 100644 instrumentation/lmdb/test/instrumentation/lmdb/patches/database_test.rb delete mode 100644 instrumentation/lmdb/test/instrumentation/lmdb/patches/environment_test.rb delete mode 100644 instrumentation/lmdb/test/test_helper.rb delete mode 100644 instrumentation/mongo/.rubocop.yml delete mode 100644 instrumentation/mongo/.yardopts delete mode 100644 instrumentation/mongo/Appraisals delete mode 100644 instrumentation/mongo/CHANGELOG.md delete mode 100644 instrumentation/mongo/Gemfile delete mode 100644 instrumentation/mongo/LICENSE delete mode 100644 instrumentation/mongo/README.md delete mode 100644 instrumentation/mongo/Rakefile delete mode 100644 instrumentation/mongo/example/Gemfile delete mode 100755 instrumentation/mongo/example/mongo.rb delete mode 100644 instrumentation/mongo/lib/opentelemetry-instrumentation-mongo.rb delete mode 100644 instrumentation/mongo/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/mongo/lib/opentelemetry/instrumentation/mongo.rb delete mode 100644 instrumentation/mongo/lib/opentelemetry/instrumentation/mongo/command_serializer.rb delete mode 100644 instrumentation/mongo/lib/opentelemetry/instrumentation/mongo/instrumentation.rb delete mode 100644 instrumentation/mongo/lib/opentelemetry/instrumentation/mongo/subscriber.rb delete mode 100644 instrumentation/mongo/lib/opentelemetry/instrumentation/mongo/version.rb delete mode 100644 instrumentation/mongo/opentelemetry-instrumentation-mongo.gemspec delete mode 100644 instrumentation/mongo/test/.rubocop.yml delete mode 100644 instrumentation/mongo/test/opentelemetry/instrumentation/mongo/subscriber_test.rb delete mode 100644 instrumentation/mongo/test/opentelemetry/instrumentation/mongo_test.rb delete mode 100644 instrumentation/mongo/test/test_helper.rb delete mode 100644 instrumentation/mysql2/.rubocop.yml delete mode 100644 instrumentation/mysql2/.yardopts delete mode 100644 instrumentation/mysql2/Appraisals delete mode 100644 instrumentation/mysql2/CHANGELOG.md delete mode 100644 instrumentation/mysql2/Gemfile delete mode 100644 instrumentation/mysql2/LICENSE delete mode 100644 instrumentation/mysql2/README.md delete mode 100644 instrumentation/mysql2/Rakefile delete mode 100644 instrumentation/mysql2/example/Gemfile delete mode 100644 instrumentation/mysql2/example/mysql2.rb delete mode 100644 instrumentation/mysql2/lib/opentelemetry-instrumentation-mysql2.rb delete mode 100644 instrumentation/mysql2/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2.rb delete mode 100644 instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2/instrumentation.rb delete mode 100644 instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2/patches/client.rb delete mode 100644 instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2/version.rb delete mode 100644 instrumentation/mysql2/opentelemetry-instrumentation-mysql2.gemspec delete mode 100644 instrumentation/mysql2/test/.rubocop.yml delete mode 100644 instrumentation/mysql2/test/opentelemetry/instrumentation/mysql2/instrumentation_test.rb delete mode 100644 instrumentation/mysql2/test/test_helper.rb delete mode 100644 instrumentation/net_http/.rubocop.yml delete mode 100644 instrumentation/net_http/.yardopts delete mode 100644 instrumentation/net_http/CHANGELOG.md delete mode 100644 instrumentation/net_http/Gemfile delete mode 100644 instrumentation/net_http/LICENSE delete mode 100644 instrumentation/net_http/README.md delete mode 100644 instrumentation/net_http/Rakefile delete mode 100644 instrumentation/net_http/example/Gemfile delete mode 100644 instrumentation/net_http/example/net_http.rb delete mode 100644 instrumentation/net_http/lib/opentelemetry-instrumentation-net_http.rb delete mode 100644 instrumentation/net_http/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/net_http/lib/opentelemetry/instrumentation/net/http.rb delete mode 100644 instrumentation/net_http/lib/opentelemetry/instrumentation/net/http/instrumentation.rb delete mode 100644 instrumentation/net_http/lib/opentelemetry/instrumentation/net/http/patches/instrumentation.rb delete mode 100644 instrumentation/net_http/lib/opentelemetry/instrumentation/net/http/version.rb delete mode 100644 instrumentation/net_http/opentelemetry-instrumentation-net_http.gemspec delete mode 100644 instrumentation/net_http/test/.rubocop.yml delete mode 100644 instrumentation/net_http/test/opentelemetry/instrumentation/net/http/instrumentation_test.rb delete mode 100644 instrumentation/net_http/test/test_helper.rb delete mode 100644 instrumentation/pg/.rubocop.yml delete mode 100644 instrumentation/pg/.yardopts delete mode 100644 instrumentation/pg/Appraisals delete mode 100644 instrumentation/pg/CHANGELOG.md delete mode 100644 instrumentation/pg/Gemfile delete mode 100644 instrumentation/pg/LICENSE delete mode 100644 instrumentation/pg/README.md delete mode 100644 instrumentation/pg/Rakefile delete mode 100644 instrumentation/pg/example/Gemfile delete mode 100644 instrumentation/pg/example/pg.rb delete mode 100644 instrumentation/pg/lib/opentelemetry-instrumentation-pg.rb delete mode 100644 instrumentation/pg/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/pg/lib/opentelemetry/instrumentation/pg.rb delete mode 100644 instrumentation/pg/lib/opentelemetry/instrumentation/pg/constants.rb delete mode 100644 instrumentation/pg/lib/opentelemetry/instrumentation/pg/instrumentation.rb delete mode 100644 instrumentation/pg/lib/opentelemetry/instrumentation/pg/lru_cache.rb delete mode 100644 instrumentation/pg/lib/opentelemetry/instrumentation/pg/patches/connection.rb delete mode 100644 instrumentation/pg/lib/opentelemetry/instrumentation/pg/version.rb delete mode 100644 instrumentation/pg/opentelemetry-instrumentation-pg.gemspec delete mode 100644 instrumentation/pg/test/.rubocop.yml delete mode 100644 instrumentation/pg/test/opentelemetry/instrumentation/pg/instrumentation_test.rb delete mode 100644 instrumentation/pg/test/opentelemetry/instrumentation/pg/lru_cache_test.rb delete mode 100644 instrumentation/pg/test/test_helper.rb delete mode 100644 instrumentation/que/.gitignore delete mode 100644 instrumentation/que/.rubocop.yml delete mode 100644 instrumentation/que/.yardopts delete mode 100644 instrumentation/que/Appraisals delete mode 100644 instrumentation/que/CHANGELOG.md delete mode 100644 instrumentation/que/Gemfile delete mode 100644 instrumentation/que/LICENSE delete mode 100644 instrumentation/que/README.md delete mode 100644 instrumentation/que/Rakefile delete mode 100644 instrumentation/que/example/Gemfile delete mode 100755 instrumentation/que/example/example.rb delete mode 100755 instrumentation/que/example/run.sh delete mode 100644 instrumentation/que/lib/opentelemetry-instrumentation-que.rb delete mode 100644 instrumentation/que/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/que/lib/opentelemetry/instrumentation/que.rb delete mode 100644 instrumentation/que/lib/opentelemetry/instrumentation/que/instrumentation.rb delete mode 100644 instrumentation/que/lib/opentelemetry/instrumentation/que/middlewares/server_middleware.rb delete mode 100644 instrumentation/que/lib/opentelemetry/instrumentation/que/patches/poller.rb delete mode 100644 instrumentation/que/lib/opentelemetry/instrumentation/que/patches/que_job.rb delete mode 100644 instrumentation/que/lib/opentelemetry/instrumentation/que/tag_setter.rb delete mode 100644 instrumentation/que/lib/opentelemetry/instrumentation/que/version.rb delete mode 100644 instrumentation/que/opentelemetry-instrumentation-que.gemspec delete mode 100644 instrumentation/que/test/.rubocop.yml delete mode 100644 instrumentation/que/test/opentelemetry/instrumentation/que_test.rb delete mode 100644 instrumentation/que/test/test_helper.rb delete mode 100644 instrumentation/rack/.rubocop.yml delete mode 100644 instrumentation/rack/.yardopts delete mode 100644 instrumentation/rack/Appraisals delete mode 100644 instrumentation/rack/CHANGELOG.md delete mode 100644 instrumentation/rack/Gemfile delete mode 100644 instrumentation/rack/LICENSE delete mode 100644 instrumentation/rack/README.md delete mode 100644 instrumentation/rack/Rakefile delete mode 100644 instrumentation/rack/example/Gemfile delete mode 100644 instrumentation/rack/example/trace_demonstration.rb delete mode 100644 instrumentation/rack/example/trace_demonstration2.rb delete mode 100644 instrumentation/rack/lib/opentelemetry-instrumentation-rack.rb delete mode 100644 instrumentation/rack/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/rack/lib/opentelemetry/instrumentation/rack.rb delete mode 100644 instrumentation/rack/lib/opentelemetry/instrumentation/rack/instrumentation.rb delete mode 100644 instrumentation/rack/lib/opentelemetry/instrumentation/rack/middlewares/tracer_middleware.rb delete mode 100644 instrumentation/rack/lib/opentelemetry/instrumentation/rack/util/queue_time.rb delete mode 100644 instrumentation/rack/lib/opentelemetry/instrumentation/rack/version.rb delete mode 100644 instrumentation/rack/opentelemetry-instrumentation-rack.gemspec delete mode 100644 instrumentation/rack/test/.rubocop.yml delete mode 100644 instrumentation/rack/test/opentelemetry/instrumentation/rack/instrumentation_test.rb delete mode 100644 instrumentation/rack/test/opentelemetry/instrumentation/rack/middlewares/tracer_middleware_test.rb delete mode 100644 instrumentation/rack/test/opentelemetry/instrumentation/rack/util/queue_time_test.rb delete mode 100644 instrumentation/rack/test/opentelemetry/instrumentation/rack_test.rb delete mode 100644 instrumentation/rack/test/test_helper.rb delete mode 100644 instrumentation/rails/.rubocop.yml delete mode 100644 instrumentation/rails/.yardopts delete mode 100644 instrumentation/rails/Appraisals delete mode 100644 instrumentation/rails/CHANGELOG.md delete mode 100644 instrumentation/rails/Gemfile delete mode 100644 instrumentation/rails/LICENSE delete mode 100644 instrumentation/rails/README.md delete mode 100644 instrumentation/rails/Rakefile delete mode 100644 instrumentation/rails/example/trace_request_demonstration.ru delete mode 100644 instrumentation/rails/lib/opentelemetry-instrumentation-rails.rb delete mode 100644 instrumentation/rails/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/rails/lib/opentelemetry/instrumentation/rails.rb delete mode 100644 instrumentation/rails/lib/opentelemetry/instrumentation/rails/instrumentation.rb delete mode 100644 instrumentation/rails/lib/opentelemetry/instrumentation/rails/railtie.rb delete mode 100644 instrumentation/rails/lib/opentelemetry/instrumentation/rails/version.rb delete mode 100644 instrumentation/rails/opentelemetry-instrumentation-rails.gemspec delete mode 100644 instrumentation/rails/test/instrumentation/opentelemetry/instrumentation/rails/instrumentation_test.rb delete mode 100644 instrumentation/rails/test/instrumentation/opentelemetry/instrumentation/rails/patches/action_controller/metal_test.rb delete mode 100644 instrumentation/rails/test/instrumentation/test_helper.rb delete mode 100644 instrumentation/rails/test/instrumentation/test_helpers/app_config.rb delete mode 100644 instrumentation/rails/test/instrumentation/test_helpers/controllers.rb delete mode 100644 instrumentation/rails/test/instrumentation/test_helpers/controllers/example_controller.rb delete mode 100644 instrumentation/rails/test/instrumentation/test_helpers/controllers/exceptions_controller.rb delete mode 100644 instrumentation/rails/test/instrumentation/test_helpers/middlewares.rb delete mode 100644 instrumentation/rails/test/instrumentation/test_helpers/middlewares/exception_raising_middleware.rb delete mode 100644 instrumentation/rails/test/instrumentation/test_helpers/middlewares/redirect_middleware.rb delete mode 100644 instrumentation/rails/test/instrumentation/test_helpers/routes.rb delete mode 100644 instrumentation/rails/test/railtie/dummy/Rakefile delete mode 100644 instrumentation/rails/test/railtie/dummy/app/controllers/application_controller.rb delete mode 100644 instrumentation/rails/test/railtie/dummy/app/controllers/concerns/.keep delete mode 100755 instrumentation/rails/test/railtie/dummy/bin/rails delete mode 100755 instrumentation/rails/test/railtie/dummy/bin/rake delete mode 100755 instrumentation/rails/test/railtie/dummy/bin/setup delete mode 100644 instrumentation/rails/test/railtie/dummy/config.ru delete mode 100644 instrumentation/rails/test/railtie/dummy/config/application.rb delete mode 100644 instrumentation/rails/test/railtie/dummy/config/boot.rb delete mode 100644 instrumentation/rails/test/railtie/dummy/config/environment.rb delete mode 100644 instrumentation/rails/test/railtie/dummy/config/environments/development.rb delete mode 100644 instrumentation/rails/test/railtie/dummy/config/environments/production.rb delete mode 100644 instrumentation/rails/test/railtie/dummy/config/environments/test.rb delete mode 100644 instrumentation/rails/test/railtie/dummy/config/initializers/content_security_policy.rb delete mode 100644 instrumentation/rails/test/railtie/dummy/config/initializers/filter_parameter_logging.rb delete mode 100644 instrumentation/rails/test/railtie/dummy/config/initializers/inflections.rb delete mode 100644 instrumentation/rails/test/railtie/dummy/config/initializers/permissions_policy.rb delete mode 100644 instrumentation/rails/test/railtie/dummy/config/locales/en.yml delete mode 100644 instrumentation/rails/test/railtie/dummy/config/puma.rb delete mode 100644 instrumentation/rails/test/railtie/dummy/config/routes.rb delete mode 100644 instrumentation/rails/test/railtie/dummy/tmp/development_secret.txt delete mode 100644 instrumentation/rails/test/railtie/opentelemetry/instrumentation/rails/railtie_test.rb delete mode 100644 instrumentation/rails/test/railtie/test_helper.rb delete mode 100644 instrumentation/rdkafka/.rubocop.yml delete mode 100644 instrumentation/rdkafka/.yardopts delete mode 100644 instrumentation/rdkafka/Appraisals delete mode 100644 instrumentation/rdkafka/CHANGELOG.md delete mode 100644 instrumentation/rdkafka/Gemfile delete mode 100644 instrumentation/rdkafka/LICENSE delete mode 100644 instrumentation/rdkafka/README.md delete mode 100644 instrumentation/rdkafka/Rakefile delete mode 100644 instrumentation/rdkafka/example/rdkafka_trace_demonstration.rb delete mode 100644 instrumentation/rdkafka/lib/opentelemetry-instrumentation-rdkafka.rb delete mode 100644 instrumentation/rdkafka/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/rdkafka/lib/opentelemetry/instrumentation/rdkafka.rb delete mode 100644 instrumentation/rdkafka/lib/opentelemetry/instrumentation/rdkafka/instrumentation.rb delete mode 100644 instrumentation/rdkafka/lib/opentelemetry/instrumentation/rdkafka/patches/consumer.rb delete mode 100644 instrumentation/rdkafka/lib/opentelemetry/instrumentation/rdkafka/patches/producer.rb delete mode 100644 instrumentation/rdkafka/lib/opentelemetry/instrumentation/rdkafka/version.rb delete mode 100644 instrumentation/rdkafka/opentelemetry-instrumentation-rdkafka.gemspec delete mode 100644 instrumentation/rdkafka/test/.rubocop.yml delete mode 100644 instrumentation/rdkafka/test/opentelemetry/instrumentation/rdkafka/instrumentation_test.rb delete mode 100644 instrumentation/rdkafka/test/opentelemetry/instrumentation/rdkafka/patches/consumer_test.rb delete mode 100644 instrumentation/rdkafka/test/opentelemetry/instrumentation/rdkafka/patches/producer_test.rb delete mode 100644 instrumentation/rdkafka/test/test_helper.rb delete mode 100644 instrumentation/redis/.rubocop.yml delete mode 100644 instrumentation/redis/.yardopts delete mode 100644 instrumentation/redis/Appraisals delete mode 100644 instrumentation/redis/CHANGELOG.md delete mode 100644 instrumentation/redis/Gemfile delete mode 100644 instrumentation/redis/LICENSE delete mode 100644 instrumentation/redis/README.md delete mode 100644 instrumentation/redis/Rakefile delete mode 100644 instrumentation/redis/example/Gemfile delete mode 100644 instrumentation/redis/example/redis.rb delete mode 100644 instrumentation/redis/lib/opentelemetry-instrumentation-redis.rb delete mode 100644 instrumentation/redis/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/redis/lib/opentelemetry/instrumentation/redis.rb delete mode 100644 instrumentation/redis/lib/opentelemetry/instrumentation/redis/instrumentation.rb delete mode 100644 instrumentation/redis/lib/opentelemetry/instrumentation/redis/patches/client.rb delete mode 100644 instrumentation/redis/lib/opentelemetry/instrumentation/redis/version.rb delete mode 100644 instrumentation/redis/opentelemetry-instrumentation-redis.gemspec delete mode 100644 instrumentation/redis/test/.rubocop.yml delete mode 100644 instrumentation/redis/test/opentelemetry/instrumentation/redis/instrumentation_test.rb delete mode 100644 instrumentation/redis/test/opentelemetry/instrumentation/redis/patches/client_test.rb delete mode 100644 instrumentation/redis/test/opentelemetry/instrumentation/redis_test.rb delete mode 100644 instrumentation/redis/test/redis.conf delete mode 100644 instrumentation/redis/test/test_helper.rb delete mode 100644 instrumentation/resque/.rubocop.yml delete mode 100644 instrumentation/resque/.yardopts delete mode 100644 instrumentation/resque/Appraisals delete mode 100644 instrumentation/resque/CHANGELOG.md delete mode 100644 instrumentation/resque/Gemfile delete mode 100644 instrumentation/resque/LICENSE delete mode 100644 instrumentation/resque/README.md delete mode 100644 instrumentation/resque/Rakefile delete mode 100644 instrumentation/resque/example/trace_demonstration.rb delete mode 100644 instrumentation/resque/lib/opentelemetry-instrumentation-resque.rb delete mode 100644 instrumentation/resque/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/resque/lib/opentelemetry/instrumentation/resque.rb delete mode 100644 instrumentation/resque/lib/opentelemetry/instrumentation/resque/instrumentation.rb delete mode 100644 instrumentation/resque/lib/opentelemetry/instrumentation/resque/patches/resque_job.rb delete mode 100644 instrumentation/resque/lib/opentelemetry/instrumentation/resque/patches/resque_module.rb delete mode 100644 instrumentation/resque/lib/opentelemetry/instrumentation/resque/version.rb delete mode 100644 instrumentation/resque/opentelemetry-instrumentation-resque.gemspec delete mode 100644 instrumentation/resque/test/.rubocop.yml delete mode 100644 instrumentation/resque/test/opentelemetry/instrumentation/resque/instrumentation_test.rb delete mode 100644 instrumentation/resque/test/opentelemetry/instrumentation/resque/patches/resque_job_test.rb delete mode 100644 instrumentation/resque/test/opentelemetry/instrumentation/resque/patches/resque_test.rb delete mode 100644 instrumentation/resque/test/redis.conf delete mode 100644 instrumentation/resque/test/test_helper.rb delete mode 100644 instrumentation/restclient/.rubocop.yml delete mode 100644 instrumentation/restclient/.yardopts delete mode 100644 instrumentation/restclient/Appraisals delete mode 100644 instrumentation/restclient/CHANGELOG.md delete mode 100644 instrumentation/restclient/Gemfile delete mode 100644 instrumentation/restclient/LICENSE delete mode 100644 instrumentation/restclient/README.md delete mode 100644 instrumentation/restclient/Rakefile delete mode 100644 instrumentation/restclient/example/Gemfile delete mode 100644 instrumentation/restclient/example/restclient.rb delete mode 100644 instrumentation/restclient/lib/opentelemetry-instrumentation-restclient.rb delete mode 100644 instrumentation/restclient/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/restclient/lib/opentelemetry/instrumentation/restclient.rb delete mode 100644 instrumentation/restclient/lib/opentelemetry/instrumentation/restclient/instrumentation.rb delete mode 100644 instrumentation/restclient/lib/opentelemetry/instrumentation/restclient/patches/request.rb delete mode 100644 instrumentation/restclient/lib/opentelemetry/instrumentation/restclient/version.rb delete mode 100644 instrumentation/restclient/opentelemetry-instrumentation-restclient.gemspec delete mode 100644 instrumentation/restclient/test/.rubocop.yml delete mode 100644 instrumentation/restclient/test/opentelemetry/instrumentation/restclient/instrumentation_test.rb delete mode 100644 instrumentation/restclient/test/test_helper.rb delete mode 100644 instrumentation/rspec/.rubocop.yml delete mode 100644 instrumentation/rspec/.yardopts delete mode 100644 instrumentation/rspec/CHANGELOG.md delete mode 100644 instrumentation/rspec/Gemfile delete mode 100644 instrumentation/rspec/LICENSE delete mode 100644 instrumentation/rspec/README.md delete mode 100644 instrumentation/rspec/Rakefile delete mode 100644 instrumentation/rspec/example/Gemfile delete mode 100644 instrumentation/rspec/example/rspec_with_rspec_formatter_configuration.rb delete mode 100644 instrumentation/rspec/example/rspec_with_sdk_configure.rb delete mode 100644 instrumentation/rspec/lib/opentelemetry-instrumentation-rspec.rb delete mode 100644 instrumentation/rspec/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/rspec/lib/opentelemetry/instrumentation/rspec.rb delete mode 100644 instrumentation/rspec/lib/opentelemetry/instrumentation/rspec/formatter.rb delete mode 100644 instrumentation/rspec/lib/opentelemetry/instrumentation/rspec/instrumentation.rb delete mode 100644 instrumentation/rspec/lib/opentelemetry/instrumentation/rspec/version.rb delete mode 100644 instrumentation/rspec/opentelemetry-instrumentation-rspec.gemspec delete mode 100644 instrumentation/rspec/test/.rubocop.yml delete mode 100644 instrumentation/rspec/test/opentelemetry/instrumentation/rspec/formatter_test.rb delete mode 100644 instrumentation/rspec/test/opentelemetry/instrumentation/rspec/instrumentation_test.rb delete mode 100644 instrumentation/rspec/test/rspec_patches.rb delete mode 100644 instrumentation/rspec/test/test_helper.rb delete mode 100644 instrumentation/ruby_kafka/.rubocop.yml delete mode 100644 instrumentation/ruby_kafka/.yardopts delete mode 100644 instrumentation/ruby_kafka/Appraisals delete mode 100644 instrumentation/ruby_kafka/CHANGELOG.md delete mode 100644 instrumentation/ruby_kafka/Gemfile delete mode 100644 instrumentation/ruby_kafka/LICENSE delete mode 100644 instrumentation/ruby_kafka/README.md delete mode 100644 instrumentation/ruby_kafka/Rakefile delete mode 100644 instrumentation/ruby_kafka/docker-compose.yml delete mode 100644 instrumentation/ruby_kafka/example/Gemfile delete mode 100644 instrumentation/ruby_kafka/example/ruby_kafka.rb delete mode 100644 instrumentation/ruby_kafka/lib/opentelemetry-instrumentation-ruby_kafka.rb delete mode 100644 instrumentation/ruby_kafka/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka.rb delete mode 100644 instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka/instrumentation.rb delete mode 100644 instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka/patches/client.rb delete mode 100644 instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka/patches/consumer.rb delete mode 100644 instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka/patches/producer.rb delete mode 100644 instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka/utils.rb delete mode 100644 instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka/version.rb delete mode 100644 instrumentation/ruby_kafka/opentelemetry-instrumentation-ruby_kafka.gemspec delete mode 100644 instrumentation/ruby_kafka/test/.rubocop.yml delete mode 100644 instrumentation/ruby_kafka/test/opentelemetry/instrumentation/ruby-kafka/instrumentation_test.rb delete mode 100644 instrumentation/ruby_kafka/test/opentelemetry/instrumentation/ruby-kafka/patches/client_test.rb delete mode 100644 instrumentation/ruby_kafka/test/opentelemetry/instrumentation/ruby-kafka/patches/consumer_test.rb delete mode 100644 instrumentation/ruby_kafka/test/opentelemetry/instrumentation/ruby-kafka/patches/producer_test.rb delete mode 100644 instrumentation/ruby_kafka/test/opentelemetry/instrumentation/ruby-kafka/utils_test.rb delete mode 100644 instrumentation/ruby_kafka/test/test_helper.rb delete mode 100644 instrumentation/sidekiq/.rubocop.yml delete mode 100644 instrumentation/sidekiq/.yardopts delete mode 100644 instrumentation/sidekiq/Appraisals delete mode 100644 instrumentation/sidekiq/CHANGELOG.md delete mode 100644 instrumentation/sidekiq/Gemfile delete mode 100644 instrumentation/sidekiq/LICENSE delete mode 100644 instrumentation/sidekiq/README.md delete mode 100644 instrumentation/sidekiq/Rakefile delete mode 100644 instrumentation/sidekiq/example/Gemfile delete mode 100644 instrumentation/sidekiq/example/sidekiq.rb delete mode 100644 instrumentation/sidekiq/lib/opentelemetry-instrumentation-sidekiq.rb delete mode 100644 instrumentation/sidekiq/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq.rb delete mode 100644 instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/instrumentation.rb delete mode 100644 instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/middlewares/client/tracer_middleware.rb delete mode 100644 instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/middlewares/server/tracer_middleware.rb delete mode 100644 instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/patches/launcher.rb delete mode 100644 instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/patches/poller.rb delete mode 100644 instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/patches/processor.rb delete mode 100644 instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/version.rb delete mode 100644 instrumentation/sidekiq/opentelemetry-instrumentation-sidekiq.gemspec delete mode 100644 instrumentation/sidekiq/test/.rubocop.yml delete mode 100644 instrumentation/sidekiq/test/helpers/mock_loader.rb delete mode 100644 instrumentation/sidekiq/test/helpers/mock_loader_new_launcher.rb delete mode 100644 instrumentation/sidekiq/test/opentelemetry/instrumentation/sidekiq/instrumentation_test.rb delete mode 100644 instrumentation/sidekiq/test/opentelemetry/instrumentation/sidekiq/middlewares/client/tracer_middleware_test.rb delete mode 100644 instrumentation/sidekiq/test/opentelemetry/instrumentation/sidekiq/middlewares/server/tracer_middleware_test.rb delete mode 100644 instrumentation/sidekiq/test/opentelemetry/instrumentation/sidekiq/patches/launcher_test.rb delete mode 100644 instrumentation/sidekiq/test/opentelemetry/instrumentation/sidekiq/patches/poller_test.rb delete mode 100644 instrumentation/sidekiq/test/opentelemetry/instrumentation/sidekiq/patches/processor_test.rb delete mode 100644 instrumentation/sidekiq/test/redis.conf delete mode 100644 instrumentation/sidekiq/test/test_helper.rb delete mode 100644 instrumentation/sinatra/.rubocop.yml delete mode 100644 instrumentation/sinatra/.yardopts delete mode 100644 instrumentation/sinatra/Appraisals delete mode 100644 instrumentation/sinatra/CHANGELOG.md delete mode 100644 instrumentation/sinatra/Gemfile delete mode 100644 instrumentation/sinatra/LICENSE delete mode 100644 instrumentation/sinatra/README.md delete mode 100644 instrumentation/sinatra/Rakefile delete mode 100644 instrumentation/sinatra/example/Gemfile delete mode 100755 instrumentation/sinatra/example/server.rb delete mode 100644 instrumentation/sinatra/example/sinatra.rb delete mode 100755 instrumentation/sinatra/example/start_server.sh delete mode 100644 instrumentation/sinatra/lib/opentelemetry-instrumentation-sinatra.rb delete mode 100644 instrumentation/sinatra/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/sinatra/lib/opentelemetry/instrumentation/sinatra.rb delete mode 100644 instrumentation/sinatra/lib/opentelemetry/instrumentation/sinatra/extensions/tracer_extension.rb delete mode 100644 instrumentation/sinatra/lib/opentelemetry/instrumentation/sinatra/instrumentation.rb delete mode 100644 instrumentation/sinatra/lib/opentelemetry/instrumentation/sinatra/middlewares/tracer_middleware.rb delete mode 100644 instrumentation/sinatra/lib/opentelemetry/instrumentation/sinatra/version.rb delete mode 100644 instrumentation/sinatra/opentelemetry-instrumentation-sinatra.gemspec delete mode 100644 instrumentation/sinatra/test/.rubocop.yml delete mode 100644 instrumentation/sinatra/test/opentelemetry/instrumentation/sinatra_test.rb delete mode 100644 instrumentation/sinatra/test/test_helper.rb delete mode 100644 instrumentation/trilogy/.rubocop.yml delete mode 100644 instrumentation/trilogy/.yardopts delete mode 100644 instrumentation/trilogy/Appraisals delete mode 100644 instrumentation/trilogy/CHANGELOG.md delete mode 100644 instrumentation/trilogy/Gemfile delete mode 100644 instrumentation/trilogy/LICENSE delete mode 100644 instrumentation/trilogy/README.md delete mode 100644 instrumentation/trilogy/Rakefile delete mode 100644 instrumentation/trilogy/lib/opentelemetry-instrumentation-trilogy.rb delete mode 100644 instrumentation/trilogy/lib/opentelemetry/instrumentation.rb delete mode 100644 instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy.rb delete mode 100644 instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy/instrumentation.rb delete mode 100644 instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy/patches/client.rb delete mode 100644 instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy/version.rb delete mode 100644 instrumentation/trilogy/opentelemetry-instrumentation-trilogy.gemspec delete mode 100644 instrumentation/trilogy/test/.rubocop.yml delete mode 100644 instrumentation/trilogy/test/opentelemetry/instrumentation/trilogy/instrumentation_test.rb delete mode 100644 instrumentation/trilogy/test/test_helper.rb delete mode 100644 propagator/ottrace/.rubocop.yml delete mode 100644 propagator/ottrace/.yardopts delete mode 100644 propagator/ottrace/CHANGELOG.md delete mode 100644 propagator/ottrace/Gemfile delete mode 100644 propagator/ottrace/LICENSE delete mode 100644 propagator/ottrace/README.md delete mode 100644 propagator/ottrace/Rakefile delete mode 100644 propagator/ottrace/lib/opentelemetry-propagator-ottrace.rb delete mode 100644 propagator/ottrace/lib/opentelemetry/propagator/ottrace.rb delete mode 100644 propagator/ottrace/lib/opentelemetry/propagator/ottrace/text_map_propagator.rb delete mode 100644 propagator/ottrace/lib/opentelemetry/propagator/ottrace/version.rb delete mode 100644 propagator/ottrace/opentelemetry-propagator-ottrace.gemspec delete mode 100644 propagator/ottrace/test/opentelemetry/propagator/ottrace/text_map_propagator_test.rb delete mode 100644 propagator/ottrace/test/opentelemetry/propagator/ottrace_test.rb delete mode 100644 propagator/ottrace/test/test_helper.rb delete mode 100644 propagator/xray/.rubocop.yml delete mode 100644 propagator/xray/.yardopts delete mode 100644 propagator/xray/CHANGELOG.md delete mode 100644 propagator/xray/Gemfile delete mode 100644 propagator/xray/LICENSE delete mode 100644 propagator/xray/README.md delete mode 100644 propagator/xray/Rakefile delete mode 100644 propagator/xray/lib/opentelemetry-propagator-xray.rb delete mode 100644 propagator/xray/lib/opentelemetry/propagator/xray.rb delete mode 100644 propagator/xray/lib/opentelemetry/propagator/xray/id_generator.rb delete mode 100644 propagator/xray/lib/opentelemetry/propagator/xray/text_map_propagator.rb delete mode 100644 propagator/xray/lib/opentelemetry/propagator/xray/version.rb delete mode 100644 propagator/xray/opentelemetry-propagator-xray.gemspec delete mode 100644 propagator/xray/test/.rubocop.yml delete mode 100644 propagator/xray/test/aws_xray_trace_test.rb delete mode 100644 propagator/xray/test/test_helper.rb delete mode 100644 propagator/xray/test/text_map_propagator_test.rb delete mode 100644 propagator/xray/test/xray_test.rb delete mode 100644 resource_detectors/.rubocop.yml delete mode 100644 resource_detectors/.yardopts delete mode 100644 resource_detectors/CHANGELOG.md delete mode 100644 resource_detectors/Gemfile delete mode 100644 resource_detectors/LICENSE delete mode 100644 resource_detectors/README.md delete mode 100644 resource_detectors/Rakefile delete mode 100644 resource_detectors/lib/opentelemetry-resource_detectors.rb delete mode 100644 resource_detectors/lib/opentelemetry/resource/detectors.rb delete mode 100644 resource_detectors/lib/opentelemetry/resource/detectors/auto_detector.rb delete mode 100644 resource_detectors/lib/opentelemetry/resource/detectors/google_cloud_platform.rb delete mode 100644 resource_detectors/lib/opentelemetry/resource/detectors/version.rb delete mode 100644 resource_detectors/opentelemetry-resource_detectors.gemspec delete mode 100644 resource_detectors/test/opentelemetry/detectors/auto_detector_test.rb delete mode 100644 resource_detectors/test/opentelemetry/detectors/google_cloud_platform_test.rb delete mode 100644 resource_detectors/test/test_helper.rb diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 05e3c56f62..e9e9e79a0e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,6 @@ jobs: - opentelemetry-common - opentelemetry-metrics-api - opentelemetry-registry - - opentelemetry-resource_detectors - opentelemetry-sdk - opentelemetry-semantic_conventions - opentelemetry-test-helpers @@ -112,8 +111,6 @@ jobs: gem: - opentelemetry-propagator-b3 - opentelemetry-propagator-jaeger - - opentelemetry-propagator-ottrace - - opentelemetry-propagator-xray os: - ubuntu-latest - macos-latest @@ -148,228 +145,3 @@ jobs: with: gem: "${{ matrix.gem }}" ruby: "jruby" - - instrumentation: - strategy: - fail-fast: false - matrix: - gem: - - opentelemetry-instrumentation-action_pack - - opentelemetry-instrumentation-action_view - - opentelemetry-instrumentation-active_job - - opentelemetry-instrumentation-active_model_serializers - - opentelemetry-instrumentation-active_record - - opentelemetry-instrumentation-active_support - - opentelemetry-instrumentation-all - - opentelemetry-instrumentation-aws_sdk - - opentelemetry-instrumentation-base - - opentelemetry-instrumentation-concurrent_ruby - - opentelemetry-instrumentation-delayed_job - - opentelemetry-instrumentation-ethon - - opentelemetry-instrumentation-excon - - opentelemetry-instrumentation-faraday - - opentelemetry-instrumentation-graphql - - opentelemetry-instrumentation-http - - opentelemetry-instrumentation-http_client - - opentelemetry-instrumentation-koala - - opentelemetry-instrumentation-lmdb - - opentelemetry-instrumentation-net_http - - opentelemetry-instrumentation-rack - - opentelemetry-instrumentation-rails - - opentelemetry-instrumentation-restclient - - opentelemetry-instrumentation-rspec - - opentelemetry-instrumentation-sinatra - os: - - ubuntu-latest - - macos-latest - - windows-latest - exclude: - - os: windows-latest - gem: opentelemetry-instrumentation-ethon - - os: windows-latest - gem: opentelemetry-instrumentation-action_pack - - os: windows-latest - gem: opentelemetry-instrumentation-restclient - - os: windows-latest - gem: opentelemetry-instrumentation-rails - - os: macos-latest - gem: opentelemetry-instrumentation-lmdb - - name: ${{ matrix.gem }} / ${{ matrix.os }} - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v2 - - name: "Test Ruby 3.1" - uses: ./.github/actions/test_gem - with: - gem: "${{ matrix.gem }}" - ruby: "3.1" - - name: "Test Ruby 3.0" - if: "${{ matrix.os == 'ubuntu-latest' }}" - uses: ./.github/actions/test_gem - with: - gem: "${{ matrix.gem }}" - ruby: "3.0" - - name: "Test Ruby 2.7" - if: "${{ matrix.os == 'ubuntu-latest' }}" - uses: ./.github/actions/test_gem - with: - gem: "${{ matrix.gem }}" - ruby: "2.7" - yard: true - rubocop: true - build: true - - name: "JRuby Filter" - id: jruby_skip - shell: bash - run: | - echo "::set-output name=skip::false" - [[ "${{ matrix.gem }}" == "opentelemetry-instrumentation-action_pack" ]] && echo "::set-output name=skip::true" - [[ "${{ matrix.gem }}" == "opentelemetry-instrumentation-action_view" ]] && echo "::set-output name=skip::true" - [[ "${{ matrix.gem }}" == "opentelemetry-instrumentation-active_model_serializers" ]] && echo "::set-output name=skip::true" - [[ "${{ matrix.gem }}" == "opentelemetry-instrumentation-active_record" ]] && echo "::set-output name=skip::true" - [[ "${{ matrix.gem }}" == "opentelemetry-instrumentation-active_support" ]] && echo "::set-output name=skip::true" - [[ "${{ matrix.gem }}" == "opentelemetry-instrumentation-aws_sdk" ]] && echo "::set-output name=skip::true" - [[ "${{ matrix.gem }}" == "opentelemetry-instrumentation-delayed_job" ]] && echo "::set-output name=skip::true" - [[ "${{ matrix.gem }}" == "opentelemetry-instrumentation-graphql" ]] && echo "::set-output name=skip::true" - [[ "${{ matrix.gem }}" == "opentelemetry-instrumentation-http" ]] && echo "::set-output name=skip::true" - [[ "${{ matrix.gem }}" == "opentelemetry-instrumentation-http_client" ]] && echo "::set-output name=skip::true" - [[ "${{ matrix.gem }}" == "opentelemetry-instrumentation-koala" ]] && echo "::set-output name=skip::true" - [[ "${{ matrix.gem }}" == "opentelemetry-instrumentation-lmdb" ]] && echo "::set-output name=skip::true" - [[ "${{ matrix.gem }}" == "opentelemetry-instrumentation-rack" ]] && echo "::set-output name=skip::true" - [[ "${{ matrix.gem }}" == "opentelemetry-instrumentation-rails" ]] && echo "::set-output name=skip::true" - # This is essentially a bash script getting evaluated, so we need to return true or the whole job fails. - true - - - name: "Test JRuby" - if: "${{ matrix.os == 'ubuntu-latest' && steps.jruby_skip.outputs.skip == 'false' }}" - uses: ./.github/actions/test_gem - with: - gem: "${{ matrix.gem }}" - ruby: "jruby" - - # These builds require sidecar services (postgres, redis, etc) in order to run their test suites. - instrumentation_with_services: - strategy: - fail-fast: false - # We don't run on macos and windows since service containers aren't supported there. - matrix: - gem: - - opentelemetry-instrumentation-bunny - - opentelemetry-instrumentation-dalli - - opentelemetry-instrumentation-mongo - - opentelemetry-instrumentation-mysql2 - - opentelemetry-instrumentation-pg - - opentelemetry-instrumentation-que - - opentelemetry-instrumentation-rdkafka - - opentelemetry-instrumentation-redis - - opentelemetry-instrumentation-resque - - opentelemetry-instrumentation-ruby_kafka - - opentelemetry-instrumentation-sidekiq - - opentelemetry-instrumentation-trilogy - name: ${{ matrix.gem }} - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: "Test Ruby 3.1" - uses: ./.github/actions/test_gem - with: - gem: "${{ matrix.gem }}" - ruby: "3.1" - - name: "Test Ruby 3.0" - uses: ./.github/actions/test_gem - with: - gem: "${{ matrix.gem }}" - ruby: "3.0" - - name: "Test Ruby 2.7" - uses: ./.github/actions/test_gem - with: - gem: "${{ matrix.gem }}" - ruby: "2.7" - yard: true - rubocop: true - build: true - - name: "JRuby Filter" - id: jruby_skip - shell: bash - run: | - echo "::set-output name=skip::false" - [[ "${{ matrix.gem }}" == "opentelemetry-instrumentation-bunny" ]] && echo "::set-output name=skip::true" - [[ "${{ matrix.gem }}" == "opentelemetry-instrumentation-mysql2" ]] && echo "::set-output name=skip::true" - [[ "${{ matrix.gem }}" == "opentelemetry-instrumentation-pg" ]] && echo "::set-output name=skip::true" - [[ "${{ matrix.gem }}" == "opentelemetry-instrumentation-que" ]] && echo "::set-output name=skip::true" - [[ "${{ matrix.gem }}" == "opentelemetry-instrumentation-rdkafka" ]] && echo "::set-output name=skip::true" - [[ "${{ matrix.gem }}" == "opentelemetry-instrumentation-redis" ]] && echo "::set-output name=skip::true" - [[ "${{ matrix.gem }}" == "opentelemetry-instrumentation-resque" ]] && echo "::set-output name=skip::true" - [[ "${{ matrix.gem }}" == "opentelemetry-instrumentation-ruby_kafka" ]] && echo "::set-output name=skip::true" - [[ "${{ matrix.gem }}" == "opentelemetry-instrumentation-sidekiq" ]] && echo "::set-output name=skip::true" - [[ "${{ matrix.gem }}" == "opentelemetry-instrumentation-trilogy" ]] && echo "::set-output name=skip::true" - # This is essentially a bash script getting evaluated, so we need to return true or the whole job fails. - true - - - name: "Test JRuby" - if: "${{ steps.jruby_skip.outputs.skip == 'false' }}" - uses: ./.github/actions/test_gem - with: - gem: "${{ matrix.gem }}" - ruby: "jruby" - services: - zookeeper: - image: confluentinc/cp-zookeeper:latest - ports: - - 2181:2181 - env: - ZOOKEEPER_CLIENT_PORT: 2181 - ZOOKEEPER_TICK_TIME: 2000 - kafka: - image: confluentinc/cp-kafka:latest - ports: - - 9092:9092 - - 29092:29092 - env: - KAFKA_BROKER_ID: 1 - KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 - KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:29092,PLAINTEXT_HOST://localhost:9092 - KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT - KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT - KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 - memcached: - image: memcached:alpine - ports: - - 11211:11211 - mongodb: - image: mongo:4.4 - ports: - - 27017:27017 - redis: - image: bitnami/redis:6.2 - ports: - - 6379:6379 - options: >- - --health-cmd "redis-cli ping" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - env: - REDIS_PASSWORD: "passw0rd" - mysql: - image: mysql:5.6 - env: - MYSQL_DATABASE: mysql - MYSQL_ROOT_PASSWORD: root - MYSQL_PASSWORD: mysql - MYSQL_USER: mysql - ports: - - 3306:3306 - options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3 - rabbitmq: - image: rabbitmq:3.8-alpine - ports: - - "5672:5672" - postgres: - image: postgres:13 - env: - POSTGRES_PASSWORD: postgres - ports: - - 5432:5432 - options: --health-cmd="pg_isready" --health-interval=5s --health-timeout=2s --health-retries=3 diff --git a/.instrumentation_generator/instrumentation_generator.rb b/.instrumentation_generator/instrumentation_generator.rb deleted file mode 100644 index 286b92968a..0000000000 --- a/.instrumentation_generator/instrumentation_generator.rb +++ /dev/null @@ -1,90 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative '../api/lib/opentelemetry/version' -require_relative '../instrumentation/base/lib/opentelemetry/instrumentation/version' -require 'thor' - -class InstrumentationGenerator < Thor::Group - include Thor::Actions - - source_root File.dirname(__FILE__) - argument :instrumentation_name - - def root_files - template('templates/rubocop.yml.tt', "#{instrumentation_path}/.rubocop.yml") - template('templates/yardopts.tt', "#{instrumentation_path}/.yardopts") - template('templates/Appraisals', "#{instrumentation_path}/Appraisals") - template('templates/CHANGELOG.md.tt', "#{instrumentation_path}/CHANGELOG.md") - template('templates/Gemfile', "#{instrumentation_path}/Gemfile") - template('templates/LICENSE', "#{instrumentation_path}/LICENSE") - template('templates/gemspec.tt', "#{instrumentation_path}/#{instrumentation_gem_name}.gemspec") - template('templates/Rakefile', "#{instrumentation_path}/Rakefile") - template('templates/Readme.md.tt', "#{instrumentation_path}/README.md") - end - - def lib_files - template('templates/lib/entrypoint.rb', "#{instrumentation_path}/lib/#{instrumentation_gem_name}.rb") - template('templates/lib/instrumentation.rb.tt', "#{instrumentation_path}/lib/opentelemetry/instrumentation.rb") - template('templates/lib/instrumentation/instrumentation_name.rb.tt', "#{instrumentation_path}/lib/opentelemetry/instrumentation/#{instrumentation_name}.rb") - template('templates/lib/instrumentation/instrumentation_name/instrumentation.rb.tt', "#{instrumentation_path}/lib/opentelemetry/instrumentation/#{instrumentation_name}/instrumentation.rb") - template('templates/lib/instrumentation/instrumentation_name/version.rb.tt', "#{instrumentation_path}/lib/opentelemetry/instrumentation/#{instrumentation_name}/version.rb") - end - - def test_files - template('templates/test/.rubocop.yml', "#{instrumentation_path}/test/.rubocop.yml") - template('templates/test/test_helper.rb', "#{instrumentation_path}/test/test_helper.rb") - template('templates/test/instrumentation.rb', "#{instrumentation_path}/test/opentelemetry/#{instrumentation_path}/instrumentation_test.rb") - end - - def add_to_releases - release_details = <<-HEREDOC - - name: #{instrumentation_gem_name} - directory: #{instrumentation_path} - version_constant: [OpenTelemetry, Instrumentation, #{pascal_cased_instrumentation_name}, VERSION]\n - HEREDOC - - insert_into_file('.toys/.data/releases.yml', release_details, after: "gems:\n") - end - - def add_to_instrumentation_all - instrumentation_all_path = 'instrumentation/all' - gemfile_text = "\ngem '#{instrumentation_gem_name}', path: '../#{instrumentation_name}'" - insert_into_file("#{instrumentation_all_path}/Gemfile", gemfile_text, after: "gemspec\n") - - gemspec_text = "\n spec.add_dependency '#{instrumentation_gem_name}', '~> 0.0.0'" - insert_into_file("#{instrumentation_all_path}/opentelemetry-instrumentation-all.gemspec", gemspec_text, after: "spec.required_ruby_version = '>= 2.6.0'\n") - - all_rb_text = "\nrequire '#{instrumentation_gem_name}'" - insert_into_file("#{instrumentation_all_path}/lib/opentelemetry/instrumentation/all.rb", all_rb_text, after: "# SPDX-License-Identifier: Apache-2.0\n") - end - - private - - def opentelemetry_version - OpenTelemetry::VERSION - end - - def instrumentation_base_version - OpenTelemetry::Instrumentation::VERSION - end - - def instrumentation_path - "instrumentation/#{instrumentation_name}" - end - - def instrumentation_gem_name - "opentelemetry-instrumentation-#{instrumentation_name}" - end - - def pascal_cased_instrumentation_name - instrumentation_name.split('_').collect(&:capitalize).join - end - - def humanized_instrumentation_name - instrumentation_name.split('_').collect(&:capitalize).join(' ') - end -end diff --git a/.instrumentation_generator/templates/Appraisals b/.instrumentation_generator/templates/Appraisals deleted file mode 100644 index 0ee9909623..0000000000 --- a/.instrumentation_generator/templates/Appraisals +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -## TODO: Include the supported version to be tested here. -## Example: -# appraise 'rack-2.1' do -# gem 'rack', '~> 2.1.2' -# end - -# appraise 'rack-2.0' do -# gem 'rack', '2.0.8' -# end - diff --git a/.instrumentation_generator/templates/CHANGELOG.md.tt b/.instrumentation_generator/templates/CHANGELOG.md.tt deleted file mode 100644 index 1999d9469d..0000000000 --- a/.instrumentation_generator/templates/CHANGELOG.md.tt +++ /dev/null @@ -1 +0,0 @@ -# Release History: <%= instrumentation_gem_name %> diff --git a/.instrumentation_generator/templates/Gemfile b/.instrumentation_generator/templates/Gemfile deleted file mode 100644 index a952c5002d..0000000000 --- a/.instrumentation_generator/templates/Gemfile +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -# DO NOT ADD DEPENDENCIES HERE! -# Please declare a minimum development dependency in the gemspec, -# then target specific versions in the Appraisals file. - -gemspec - -group :test do - gem 'opentelemetry-instrumentation-base', path: '../base' -end diff --git a/.instrumentation_generator/templates/LICENSE b/.instrumentation_generator/templates/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/.instrumentation_generator/templates/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/.instrumentation_generator/templates/Rakefile b/.instrumentation_generator/templates/Rakefile deleted file mode 100644 index 1a64ba842e..0000000000 --- a/.instrumentation_generator/templates/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/.instrumentation_generator/templates/Readme.md.tt b/.instrumentation_generator/templates/Readme.md.tt deleted file mode 100644 index 6ae1a2b8bb..0000000000 --- a/.instrumentation_generator/templates/Readme.md.tt +++ /dev/null @@ -1,52 +0,0 @@ -# OpenTelemetry <%= pascal_cased_instrumentation_name %> Instrumentation - -Todo: Add a description. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-<%= instrumentation_name %> -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-<%= instrumentation_name %>` in your `Gemfile`. - -## Usage - -To use the instrumentation, call `use` with the name of the instrumentation: - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::<%= pascal_cased_instrumentation_name %>' -end -``` - -Alternatively, you can also call `use_all` to install all the available instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` - -## Examples - -Example usage can be seen in the `./example/trace_demonstration.rb` file [here](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/instrumentation/<%= instrumentation_name %>/example/trace_demonstration.rb) - -## How can I get involved? - -The `opentelemetry-instrumentation-<%= instrumentation_name %>` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -The `opentelemetry-instrumentation-<%= instrumentation_name %>` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information. - -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/.instrumentation_generator/templates/gemspec.tt b/.instrumentation_generator/templates/gemspec.tt deleted file mode 100644 index 61547a3b02..0000000000 --- a/.instrumentation_generator/templates/gemspec.tt +++ /dev/null @@ -1,49 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/<%= instrumentation_name %>/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-<%= instrumentation_name %>' - spec.version = OpenTelemetry::Instrumentation::<%= pascal_cased_instrumentation_name %>::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = '<%= pascal_cased_instrumentation_name %> instrumentation for the OpenTelemetry framework' - spec.description = '<%= pascal_cased_instrumentation_name %> instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> <%= opentelemetry_version %>' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> <%= instrumentation_base_version %>' - - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-sdk', '~> 1.0' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'rake', '~> 12.3.3' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'webmock', '~> 3.7.6' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-<%= instrumentation_name %>/v#{OpenTelemetry::Instrumentation::<%= pascal_cased_instrumentation_name %>::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/<%= instrumentation_name %>' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-<%= instrumentation_name %>/v#{OpenTelemetry::Instrumentation::<%= pascal_cased_instrumentation_name %>::VERSION}" - end -end diff --git a/.instrumentation_generator/templates/lib/entrypoint.rb b/.instrumentation_generator/templates/lib/entrypoint.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/.instrumentation_generator/templates/lib/entrypoint.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/.instrumentation_generator/templates/lib/instrumentation.rb.tt b/.instrumentation_generator/templates/lib/instrumentation.rb.tt deleted file mode 100644 index 24e7fac143..0000000000 --- a/.instrumentation_generator/templates/lib/instrumentation.rb.tt +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/<%= instrumentation_name %>' diff --git a/.instrumentation_generator/templates/lib/instrumentation/instrumentation_name.rb.tt b/.instrumentation_generator/templates/lib/instrumentation/instrumentation_name.rb.tt deleted file mode 100644 index 155e9b1f05..0000000000 --- a/.instrumentation_generator/templates/lib/instrumentation/instrumentation_name.rb.tt +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the <%= pascal_cased_instrumentation_name %> gem - module <%= pascal_cased_instrumentation_name %> - end - end -end - -require_relative './<%= instrumentation_name %>/instrumentation' -require_relative './<%= instrumentation_name %>/version' diff --git a/.instrumentation_generator/templates/lib/instrumentation/instrumentation_name/instrumentation.rb.tt b/.instrumentation_generator/templates/lib/instrumentation/instrumentation_name/instrumentation.rb.tt deleted file mode 100644 index 72c3ff815e..0000000000 --- a/.instrumentation_generator/templates/lib/instrumentation/instrumentation_name/instrumentation.rb.tt +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module <%= pascal_cased_instrumentation_name %> - # The Instrumentation class contains logic to detect and install the <%= pascal_cased_instrumentation_name %> instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - install do |_config| - require_dependencies - end - - present do - # TODO: Replace true with a definition check of the gem being instrumented - # Example: `defined?(::Rack)` - true - end - - private - - def require_dependencies - # TODO: Include instrumentation dependencies - end - end - end - end -end diff --git a/.instrumentation_generator/templates/lib/instrumentation/instrumentation_name/version.rb.tt b/.instrumentation_generator/templates/lib/instrumentation/instrumentation_name/version.rb.tt deleted file mode 100644 index b9ce36b2e1..0000000000 --- a/.instrumentation_generator/templates/lib/instrumentation/instrumentation_name/version.rb.tt +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module <%= pascal_cased_instrumentation_name %> - VERSION = '0.0.0' - end - end -end diff --git a/.instrumentation_generator/templates/rubocop.yml.tt b/.instrumentation_generator/templates/rubocop.yml.tt deleted file mode 100644 index 5dafa28231..0000000000 --- a/.instrumentation_generator/templates/rubocop.yml.tt +++ /dev/null @@ -1,5 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-<%= instrumentation_name %>.rb" diff --git a/.instrumentation_generator/templates/test/.rubocop.yml b/.instrumentation_generator/templates/test/.rubocop.yml deleted file mode 100644 index dd94258585..0000000000 --- a/.instrumentation_generator/templates/test/.rubocop.yml +++ /dev/null @@ -1,4 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false diff --git a/.instrumentation_generator/templates/test/instrumentation.rb.tt b/.instrumentation_generator/templates/test/instrumentation.rb.tt deleted file mode 100644 index 64531c357f..0000000000 --- a/.instrumentation_generator/templates/test/instrumentation.rb.tt +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../lib/opentelemetry/instrumentation/<%= instrumentation_name %>' - -describe OpenTelemetry::Instrumentation::<%= pascal_cased_instrumentation_name %> do - let(:instrumentation) { OpenTelemetry::Instrumentation::<%= pascal_cased_instrumentation_name %>::Instrumentation.instance } - - it 'has #name' do - _(instrumentation.name).must_equal 'OpenTelemetry::Instrumentation::<%= pascal_cased_instrumentation_name %>' - end - - it 'has #version' do - _(instrumentation.version).wont_be_nil - _(instrumentation.version).wont_be_empty - end - - describe '#install' do - it 'accepts argument' do - _(instrumentation.install({})).must_equal(true) - instrumentation.instance_variable_set(:@installed, false) - end - end -end diff --git a/.instrumentation_generator/templates/test/test_helper.rb b/.instrumentation_generator/templates/test/test_helper.rb deleted file mode 100644 index abc1435340..0000000000 --- a/.instrumentation_generator/templates/test/test_helper.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry/sdk' - -require 'minitest/autorun' -require 'webmock/minitest' - -# global opentelemetry-sdk setup: -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry::SDK.configure do |c| - c.add_span_processor span_processor -end diff --git a/.instrumentation_generator/templates/yardopts.tt b/.instrumentation_generator/templates/yardopts.tt deleted file mode 100644 index da083da395..0000000000 --- a/.instrumentation_generator/templates/yardopts.tt +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry <%= humanized_instrumentation_name %> Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/.toys/.data/releases.yml b/.toys/.data/releases.yml index bf7eac53fe..86685da7fc 100644 --- a/.toys/.data/releases.yml +++ b/.toys/.data/releases.yml @@ -31,71 +31,6 @@ commit_lint: # * changelog_path: Path to CHANGLEOG.md relative to the gem directory. # (Required only if it is not in the expected location.) gems: - - name: opentelemetry-instrumentation-rdkafka - directory: instrumentation/rdkafka - version_constant: [OpenTelemetry, Instrumentation, Rdkafka, VERSION] - - - name: opentelemetry-instrumentation-trilogy - directory: instrumentation/trilogy - version_constant: [OpenTelemetry, Instrumentation, Trilogy, VERSION] - - - name: opentelemetry-instrumentation-active_support - directory: instrumentation/active_support - version_constant: [OpenTelemetry, Instrumentation, ActiveSupport, VERSION] - - - name: opentelemetry-instrumentation-action_view - directory: instrumentation/action_view - version_constant: [OpenTelemetry, Instrumentation, ActionView, VERSION] - - - name: opentelemetry-instrumentation-action_pack - directory: instrumentation/action_pack - version_constant: [OpenTelemetry, Instrumentation, ActionPack, VERSION] - - - name: opentelemetry-instrumentation-active_job - directory: instrumentation/active_job - version_constant: [OpenTelemetry, Instrumentation, ActiveJob, VERSION] - - - name: opentelemetry-instrumentation-resque - directory: instrumentation/resque - version_constant: [OpenTelemetry, Instrumentation, Resque, VERSION] - - - name: opentelemetry-instrumentation-bunny - directory: instrumentation/bunny - version_constant: [OpenTelemetry, Instrumentation, Bunny, VERSION] - - - name: opentelemetry-instrumentation-base - directory: instrumentation/base - version_rb_path: lib/opentelemetry/instrumentation/version.rb - version_constant: [OpenTelemetry, Instrumentation, VERSION] - - - name: opentelemetry-instrumentation-active_record - directory: instrumentation/active_record - version_constant: [OpenTelemetry, Instrumentation, ActiveRecord, VERSION] - - - name: opentelemetry-instrumentation-aws_sdk - directory: instrumentation/aws_sdk - version_constant: [OpenTelemetry, Instrumentation, AwsSdk, VERSION] - - - name: opentelemetry-instrumentation-lmdb - directory: instrumentation/lmdb - version_constant: [OpenTelemetry, Instrumentation, LMDB, VERSION] - - - name: opentelemetry-instrumentation-http - directory: instrumentation/http - version_constant: [OpenTelemetry, Instrumentation, HTTP, VERSION] - - - name: opentelemetry-instrumentation-graphql - directory: instrumentation/graphql - version_constant: [OpenTelemetry, Instrumentation, GraphQL, VERSION] - - - name: opentelemetry-instrumentation-http_client - directory: instrumentation/http_client - version_constant: [OpenTelemetry, Instrumentation, HttpClient, VERSION] - - - name: opentelemetry-instrumentation-koala - directory: instrumentation/koala - version_constant: [OpenTelemetry, Instrumentation, Koala, VERSION] - - name: opentelemetry-api directory: api version_rb_path: lib/opentelemetry/version.rb @@ -131,87 +66,6 @@ gems: directory: instrumentation/active_model_serializers version_constant: [OpenTelemetry, Instrumentation, ActiveModelSerializers, VERSION] - - name: opentelemetry-instrumentation-all - directory: instrumentation/all - version_constant: [OpenTelemetry, Instrumentation, All, VERSION] - - - name: opentelemetry-instrumentation-concurrent_ruby - directory: instrumentation/concurrent_ruby - version_constant: [OpenTelemetry, Instrumentation, ConcurrentRuby, VERSION] - - - name: opentelemetry-instrumentation-dalli - directory: instrumentation/dalli - version_constant: [OpenTelemetry, Instrumentation, Dalli, VERSION] - - - name: opentelemetry-instrumentation-delayed_job - directory: instrumentation/delayed_job - version_constant: [OpenTelemetry, Instrumentation, DelayedJob, VERSION] - - - name: opentelemetry-instrumentation-ethon - directory: instrumentation/ethon - version_constant: [OpenTelemetry, Instrumentation, Ethon, VERSION] - - - name: opentelemetry-instrumentation-excon - directory: instrumentation/excon - version_constant: [OpenTelemetry, Instrumentation, Excon, VERSION] - - - name: opentelemetry-instrumentation-faraday - directory: instrumentation/faraday - version_constant: [OpenTelemetry, Instrumentation, Faraday, VERSION] - - - name: opentelemetry-instrumentation-mongo - directory: instrumentation/mongo - version_constant: [OpenTelemetry, Instrumentation, Mongo, VERSION] - - - name: opentelemetry-instrumentation-mysql2 - directory: instrumentation/mysql2 - version_constant: [OpenTelemetry, Instrumentation, Mysql2, VERSION] - - - name: opentelemetry-instrumentation-net_http - directory: instrumentation/net_http - version_rb_path: lib/opentelemetry/instrumentation/net/http/version.rb - version_constant: [OpenTelemetry, Instrumentation, Net, HTTP, VERSION] - - - name: opentelemetry-instrumentation-pg - directory: instrumentation/pg - version_constant: [OpenTelemetry, Instrumentation, PG, VERSION] - - - name: opentelemetry-instrumentation-que - directory: instrumentation/que - version_constant: [OpenTelemetry, Instrumentation, Que, VERSION] - - - name: opentelemetry-instrumentation-rack - directory: instrumentation/rack - version_constant: [OpenTelemetry, Instrumentation, Rack, VERSION] - - - name: opentelemetry-instrumentation-rails - directory: instrumentation/rails - version_constant: [OpenTelemetry, Instrumentation, Rails, VERSION] - - - name: opentelemetry-instrumentation-redis - directory: instrumentation/redis - version_constant: [OpenTelemetry, Instrumentation, Redis, VERSION] - - - name: opentelemetry-instrumentation-restclient - directory: instrumentation/restclient - version_constant: [OpenTelemetry, Instrumentation, RestClient, VERSION] - - - name: opentelemetry-instrumentation-rspec - directory: instrumentation/rspec - version_constant: [OpenTelemetry, Instrumentation, RSpec, VERSION] - - - name: opentelemetry-instrumentation-ruby_kafka - directory: instrumentation/ruby_kafka - version_constant: [OpenTelemetry, Instrumentation, RubyKafka, VERSION] - - - name: opentelemetry-instrumentation-sidekiq - directory: instrumentation/sidekiq - version_constant: [OpenTelemetry, Instrumentation, Sidekiq, VERSION] - - - name: opentelemetry-instrumentation-sinatra - directory: instrumentation/sinatra - version_constant: [OpenTelemetry, Instrumentation, Sinatra, VERSION] - - name: opentelemetry-propagator-b3 directory: propagator/b3 version_constant: [OpenTelemetry, Propagator, B3, VERSION] @@ -220,19 +74,6 @@ gems: directory: propagator/jaeger version_constant: [OpenTelemetry, Propagator, Jaeger, VERSION] - - name: opentelemetry-propagator-ottrace - directory: propagator/ottrace - version_constant: [OpenTelemetry, Propagator, OTTrace, VERSION] - - - name: opentelemetry-propagator-xray - directory: propagator/xray - version_constant: [OpenTelemetry, Propagator, XRay, VERSION] - - - name: opentelemetry-resource_detectors - directory: resource_detectors - version_rb_path: lib/opentelemetry/resource/detectors/version.rb - version_constant: [OpenTelemetry, Resource, Detectors, VERSION] - - name: opentelemetry-semantic_conventions directory: semantic_conventions version_rb_path: lib/opentelemetry/semantic_conventions/version.rb diff --git a/README.md b/README.md index 44912c3ee7..b633096fc5 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ The Ruby [OpenTelemetry](https://opentelemetry.io/) client. - [Getting Started][getting-started] - [Contributing](#contributing) -- [Instrumentation Libraries](#instrumentation-libraries) +- [Contrib Repository]](#contrib-repository) - [Versioning](#versioning) - [Useful links](#useful-links) - [License](#license) @@ -27,9 +27,10 @@ The Ruby special interest group (SIG) meets regularly. See the OpenTelemetry Approvers ([@open-telemetry/ruby-approvers](https://github.com/orgs/open-telemetry/teams/ruby-approvers)): -- [Eric Mustin](https://github.com/ericmustin) +- [Eric Mustin](https://github.com/ericmustin), Shopify - [Ariel Valentin](https://github.com/arielvalentin), GitHub -- [Andrew Hayworth](https://github.com/ahayworth) +- [Andrew Hayworth](https://github.com/ahayworth), Shopify +- [Sam Handler](https://github.com/plantfansam), Shopify *Find more about the approver role in [community repository](https://github.com/open-telemetry/community/blob/master/community-membership.md#approver).* @@ -42,12 +43,9 @@ Maintainers ([@open-telemetry/ruby-maintainers](https://github.com/orgs/open-tel *Find more about the maintainer role in [community repository](https://github.com/open-telemetry/community/blob/master/community-membership.md#maintainer).* -## Instrumentation Libraries +## Contrib Repository -This repository contains instrumentation libraries for many popular Ruby -gems, including Rails, Rack, Sinatra, and others, so you can start -using OpenTelemetry with minimal changes to your application. See the -[instrumentation README](instrumentation/) for more. +The contrib repository contains instrumentation libraries for many popular Ruby gems, including Rails, Rack, Sinatra, and others, so you can start using OpenTelemetry with minimal changes to your application. See the instrumentation [README][contrib-repo] for more details. ## Versioning @@ -63,6 +61,7 @@ OpenTelemetry Ruby follows the [versioning and stability document][otel-versioni Apache 2.0 - See [LICENSE][license-url] for more information. [ci-image]: https://github.com/open-telemetry/opentelemetry-ruby/workflows/CI/badge.svg?event=push +[contrib-repo]: https://github.com/open-telemetry/opentelemetry-ruby-contrib [examples-github]: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/examples [getting-started]: https://opentelemetry.io/docs/ruby/ [issues-good-first-issue]: https://github.com/open-telemetry/opentelemetry-ruby/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22 @@ -70,7 +69,6 @@ Apache 2.0 - See [LICENSE][license-url] for more information. [license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat [license-url]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE [ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[opentelemetry-instrumentation-all-publishing]: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/all#publishing [slack-image]: https://img.shields.io/badge/slack-@cncf/otel/ruby-brightgreen.svg?logo=slack [slack-url]: https://cloud-native.slack.com/archives/C01NWKKMKMY [discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/bin/instrumentation_generator b/bin/instrumentation_generator deleted file mode 100755 index 0efe29c72e..0000000000 --- a/bin/instrumentation_generator +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env ruby - -require_relative '../.instrumentation_generator/instrumentation_generator' - -puts <<-EOF - -🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 - - WARNING: Your gem will *NOT* be tested until you add it to the CI workflows in `.github/workflows/ci.yml`!! - -🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 - -EOF - -InstrumentationGenerator.start(ARGV) diff --git a/docker-compose.yml b/docker-compose.yml index 26d6713870..8a48f1a0d0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -24,195 +24,9 @@ services: context: . working_dir: /app - ex-instrumentation-bunny: - <<: *base - depends_on: - - rabbitmq - environment: - - RABBITMQ_URL=amqp://guest:guest@rabbitmq:5672 - working_dir: /app/instrumentation/bunny/example - - ex-instrumentation-concurrent-ruby: - <<: *base - working_dir: /app/instrumentation/concurrent_ruby/example - - ex-instrumentation-delayed_job: - <<: *base - working_dir: /app/instrumentation/delayed_job/example - - ex-instrumentation-ethon: - <<: *base - working_dir: /app/instrumentation/ethon/example - - ex-instrumentation-excon: - <<: *base - working_dir: /app/instrumentation/excon/example - - ex-instrumentation-faraday: - <<: *base - working_dir: /app/instrumentation/faraday/example - - ex-instrumentation-mysql2: - <<: *base - environment: - - TEST_MYSQL_USER=root - - TEST_MYSQL_ROOT_PASSWORD=root - - TEST_MYSQL_HOST=mysql - - TEST_MYSQL_PORT=3306 - - TEST_MYSQ_DB=mysql - depends_on: - - mysql - working_dir: /app/instrumentation/mysql2/example - - ex-instrumentation-mysql2-test: - <<: *base - environment: - - TEST_MYSQL_USER=root - - TEST_MYSQL_ROOT_PASSWORD=root - - TEST_MYSQL_HOST=mysql - - TEST_MYSQL_PORT=3306 - - TEST_MYSQ_DB=mysql - depends_on: - - mysql - working_dir: /app/instrumentation/mysql2/ - - ex-instrumentation-pg: - <<: *base - environment: - - TEST_POSTGRES_PASSWORD=postgres - - TEST_POSTGRES_USER=postgres - - TEST_POSTGRES_HOST=postgres - - TEST_POSTGRES_PORT=5432 - - TEST_POSTGRES_DB=postgres - - OTEL_TRACES_EXPORTER=console - depends_on: - - postgres - working_dir: /app/instrumentation/pg/example - - ex-instrumentation-pg-test: - <<: *base - environment: - - TEST_POSTGRES_PASSWORD=postgres - - TEST_POSTGRES_USER=postgres - - TEST_POSTGRES_HOST=postgres - - TEST_POSTGRES_PORT=5432 - - TEST_POSTGRES_DB=postgres - depends_on: - - postgres - working_dir: /app/instrumentation/pg/ - - ex-instrumentation-net-http: - <<: *base - working_dir: /app/instrumentation/net_http/example - - ex-instrumentation-que: - <<: *base - environment: - - TEST_POSTGRES_PASSWORD=postgres - - TEST_POSTGRES_USER=postgres - - TEST_POSTGRES_HOST=postgres - - TEST_POSTGRES_PORT=5432 - - TEST_POSTGRES_DB=postgres - depends_on: - - postgres - working_dir: /app/instrumentation/que - - ex-instrumentation-rack: - <<: *base - working_dir: /app/instrumentation/rack/example - - ex-instrumentation-dalli: - <<: *base - environment: - - MEMCACHED_URL=memcached:11211 - depends_on: - - memcached - working_dir: /app/instrumentation/dalli/example - - ex-instrumentation-restclient: - <<: *base - working_dir: /app/instrumentation/restclient/example - - ex-instrumentation-sinatra: - <<: *base - command: ./start_server.sh - working_dir: /app/instrumentation/sinatra/example - - mongo: - image: mongo:4.4 - expose: - - "27017" - ports: - - "27017:27017" - - mysql: - image: mysql:5.6 - environment: - - MYSQL_DATABASE=mysql - - MYSQL_ROOT_PASSWORD=root - - MYSQL_PASSWORD=mysql - - MYSQL_USER=mysql - expose: - - "3306" - ports: - - "3306:3306" - - postgres: - image: postgres:13 - environment: - - POSTGRES_PASSWORD=postgres - expose: - - "5432" - ports: - - "5432:5432" - - redis: - image: bitnami/redis:6.2 - environment: - - REDIS_PASSWORD=passw0rd - volumes: - - redis_data:/data - ports: - - "16379:6379" - - rabbitmq: - image: rabbitmq:3.8-alpine - ports: - - "5672:5672" - - memcached: - image: memcached:alpine - command: memcached -m 64 - ports: - - "11211:11211" - - zookeeper: - image: confluentinc/cp-zookeeper:latest - ports: - - 2181:2181 - environment: - ZOOKEEPER_CLIENT_PORT: 2181 - ZOOKEEPER_TICK_TIME: 2000 - - kafka: - image: confluentinc/cp-kafka:latest - ports: - - "9092:9092" - - "29092:29092" - environment: - KAFKA_BROKER_ID: 1 - KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 - KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:29092,PLAINTEXT_HOST://kafka:9092 - KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT - KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT - KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 - depends_on: - - zookeeper - sdk: <<: *base working_dir: /app/sdk volumes: bundle: - redis_data: diff --git a/instrumentation/.rubocop-examples.yml b/instrumentation/.rubocop-examples.yml deleted file mode 100644 index 40c85360f3..0000000000 --- a/instrumentation/.rubocop-examples.yml +++ /dev/null @@ -1,29 +0,0 @@ -AllCops: - TargetRubyVersion: "2.6.0" - -Bundler/OrderedGems: - Exclude: - - "**/gemfiles/**/*" -Lint/UnusedMethodArgument: - Enabled: false -Metrics/AbcSize: - Max: 18 - Exclude: - - "**/test/**/*" -Metrics/LineLength: - Enabled: false -Metrics/MethodLength: - Max: 20 - Exclude: - - "**/test/**/*" -Metrics/ParameterLists: - Enabled: false -Style/FrozenStringLiteralComment: - Exclude: - - "**/gemfiles/**/*" -Style/ModuleFunction: - Enabled: false -Style/StringLiterals: - Exclude: - - "**/gemfiles/**/*" - - "**/example/Gemfile" diff --git a/instrumentation/README.md b/instrumentation/README.md deleted file mode 100644 index 5ab2490c23..0000000000 --- a/instrumentation/README.md +++ /dev/null @@ -1,59 +0,0 @@ -# OpenTelemetry instrumentation libraries - -[OpenTelemetry](https://opentelemetry.io/) is an open source observability framework, providing a general-purpose API, SDK, and related tools required for the instrumentation of cloud-native software, frameworks, and libraries. - -Instrumentation libraries provide pre-built OpenTelemetry instrumentation for popular libraries: Examples include Rails, Rack, Sinatra, and others. This way you can start using OpenTelemetry with minimal changes to your application. - -## Which instrumentations already exist, and which are currently in progress? - -Released instrumentations can be found at the [OpenTelemetry registry](https://opentelemetry.io/registry/?language=ruby&component=instrumentation#). You can also look in this project's Github repository: Individual instrumentation libraries can be found in subdirectories under `/instrumentation`. - -In-progress instrumentations can be found [here](https://github.com/open-telemetry/opentelemetry-ruby/issues?q=is%3Aopen+label%3Ainstrumentation+-label%3A%22help+wanted%22+). - - -## How do I get started? - -### Individual instrumentation libraries - -To get started with a single instrumentation library, for example `opentelemetry-instrumentation-rack`: - -### 1. Install the gem - -``` -gem install opentelemetry-instrumentation-rack -``` - -### 2. Configure OpenTelemetry to use the instrumentation - -``` -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Rack' -end -``` - -Instrumentation-specific documentation can be found in each subdirectory's `README.md`. - -### `opentelemetry-instrumentation-all` - -You also have the option of installing all of the instrumentation libraries by installing `opentelemetry-instrumentation-all`. See that gem's [README](https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/all) for more. - -## How can I get involved? - -The source for all OpenTelemetry Ruby instrumentation gems is [on github](https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation), along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -If you are interested in helping out with an instrumentation, you can see instrumentations that have been requested but are not currently in-progress [here](https://github.com/open-telemetry/opentelemetry-ruby/issues?q=is%3Aopen+label%3Ainstrumentation+label%3A%22help+wanted%22). - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - - -## License - -All OpenTelemetry Ruby instrumentation gems are distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information. - - -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions - - diff --git a/instrumentation/action_pack/.rubocop.yml b/instrumentation/action_pack/.rubocop.yml deleted file mode 100644 index fb836f5210..0000000000 --- a/instrumentation/action_pack/.rubocop.yml +++ /dev/null @@ -1,5 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-action_pack.rb" diff --git a/instrumentation/action_pack/.yardopts b/instrumentation/action_pack/.yardopts deleted file mode 100644 index a4a8ccfbf7..0000000000 --- a/instrumentation/action_pack/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Action Pack Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/action_pack/Appraisals b/instrumentation/action_pack/Appraisals deleted file mode 100644 index d358e21c82..0000000000 --- a/instrumentation/action_pack/Appraisals +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# Rails 5.2 is incompatible with Ruby 3. -if RUBY_VERSION < '3' - appraise 'rails-5.2' do - gem 'rails', '~> 5.2.0' - end -end - -appraise 'rails-6.0' do - gem 'rails', '~> 6.0.0' -end - -appraise 'rails-6.1' do - gem 'rails', '~> 6.1.0' -end - -if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.0') - appraise 'rails-7.0' do - gem 'rails', '~> 7.0.0' - end -end diff --git a/instrumentation/action_pack/CHANGELOG.md b/instrumentation/action_pack/CHANGELOG.md deleted file mode 100644 index ea845312fd..0000000000 --- a/instrumentation/action_pack/CHANGELOG.md +++ /dev/null @@ -1,27 +0,0 @@ -# Release History: opentelemetry-instrumentation-action_pack - -### v0.2.0 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Broken test file requirements - -### v0.1.4 / 2022-05-02 - -* FIXED: Use rails request's filtered path as http.target attribute -* FIXED: RubyGems Fallback - -### v0.1.3 / 2021-12-01 - -* FIXED: Instrumentation of Rails 7 - -### v0.1.2 / 2021-10-06 - -* FIXED: Prevent high cardinality rack span name as a default - -### v0.1.1 / 2021-09-29 - -* (No significant changes) - -### v0.1.0 / 2021-08-12 - -* Initial release. diff --git a/instrumentation/action_pack/Gemfile b/instrumentation/action_pack/Gemfile deleted file mode 100644 index 43dee26524..0000000000 --- a/instrumentation/action_pack/Gemfile +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :test do - gem 'opentelemetry-instrumentation-base', path: '../../instrumentation/base' - gem 'pry-byebug' -end diff --git a/instrumentation/action_pack/LICENSE b/instrumentation/action_pack/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/action_pack/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/action_pack/README.md b/instrumentation/action_pack/README.md deleted file mode 100644 index a6ae1178e5..0000000000 --- a/instrumentation/action_pack/README.md +++ /dev/null @@ -1,63 +0,0 @@ -# OpenTelemetry ActionPack Instrumentation - -The Action Pack instrumentation is a community-maintained instrumentation for the Action Pack portion of the [Ruby on Rails][rails-home] web-application framework. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-action_pack -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-action_pack` in your `Gemfile`. - -## Usage - -To use the instrumentation, call `use` with the name of the instrumentation: - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::ActionPack' -end -``` - -Alternatively, you can also call `use_all` to install all the available instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` - -### Configuration options - -The `http.route` attribute is disabled by default because we use [.recognize](https://github.com/rails/rails/blob/v6.1.3/actionpack/lib/action_dispatch/journey/router.rb#L65) -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::ActionPack', { - enable_recognize_route: true - } -end -``` - -## Examples - -Example usage can be seen in the `./example/trace_demonstration.rb` file [here](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/instrumentation/action_pack/example/trace_demonstration.ru) - -## How can I get involved? - -The `opentelemetry-instrumentation-action_pack` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -The `opentelemetry-instrumentation-action_pack` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information. - -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/instrumentation/action_pack/Rakefile b/instrumentation/action_pack/Rakefile deleted file mode 100644 index 1a64ba842e..0000000000 --- a/instrumentation/action_pack/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/action_pack/example/trace_demonstration.ru b/instrumentation/action_pack/example/trace_demonstration.ru deleted file mode 100644 index 6e9f08c94b..0000000000 --- a/instrumentation/action_pack/example/trace_demonstration.ru +++ /dev/null @@ -1,44 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/inline' - -gemfile(true) do - source 'https://rubygems.org' - - gem 'rails' - gem 'opentelemetry-sdk' - gem 'opentelemetry-instrumentation-action_pack' -end - -require 'action_controller/railtie' - -# TraceRequestApp is a minimal Rails application inspired by the Rails -# bug report template for action controller. -# https://github.com/rails/rails/blob/v6.0.0/guides/bug_report_templates/action_controller_gem.rb -# The configuration is compatible with Rails 6.0 -class TraceRequestApp < Rails::Application - config.root = __dir__ - config.hosts << 'example.org' - secrets.secret_key_base = 'secret_key_base' - config.eager_load = false - config.logger = Logger.new($stdout) - Rails.logger = config.logger -end - -ENV['OTEL_TRACES_EXPORTER'] = 'console' -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::ActionPack' -end - -Rails.application.initialize! - -run Rails.application - -# To run this example run the `rackup` command with this file -# Example: rackup trace_request_demonstration.ru -# Navigate to http://localhost:9292/ -# Spans for the requests will appear in the console diff --git a/instrumentation/action_pack/lib/opentelemetry-instrumentation-action_pack.rb b/instrumentation/action_pack/lib/opentelemetry-instrumentation-action_pack.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/action_pack/lib/opentelemetry-instrumentation-action_pack.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/action_pack/lib/opentelemetry/instrumentation.rb b/instrumentation/action_pack/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index 86c6c63c05..0000000000 --- a/instrumentation/action_pack/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/action_pack' diff --git a/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack.rb b/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack.rb deleted file mode 100644 index 60e41f3f26..0000000000 --- a/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the ActionPack gem - module ActionPack - end - end -end - -require 'opentelemetry-instrumentation-rack' -require_relative './action_pack/instrumentation' -require_relative './action_pack/version' diff --git a/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/instrumentation.rb b/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/instrumentation.rb deleted file mode 100644 index 7164f42268..0000000000 --- a/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/instrumentation.rb +++ /dev/null @@ -1,50 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module ActionPack - # The Instrumentation class contains logic to detect and install the ActionPack instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - MINIMUM_VERSION = Gem::Version.new('5.2.0') - - install do |_config| - require_railtie - require_dependencies - patch - end - - present do - defined?(::ActionController) - end - - compatible do - gem_version >= MINIMUM_VERSION - end - - option :enable_recognize_route, default: false, validate: :boolean - - private - - def gem_version - ::ActionPack.version - end - - def patch - ::ActionController::Metal.prepend(Patches::ActionController::Metal) - end - - def require_dependencies - require_relative 'patches/action_controller/metal' - end - - def require_railtie - require_relative 'railtie' - end - end - end - end -end diff --git a/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/patches/action_controller/metal.rb b/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/patches/action_controller/metal.rb deleted file mode 100644 index 71215a149d..0000000000 --- a/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/patches/action_controller/metal.rb +++ /dev/null @@ -1,43 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module ActionPack - module Patches - module ActionController - # Module to prepend to ActionController::Metal for instrumentation - module Metal - def dispatch(name, request, response) - rack_span = OpenTelemetry::Instrumentation::Rack.current_span - if rack_span.recording? - rack_span.name = "#{self.class.name}##{name}" unless request.env['action_dispatch.exception'] - - add_rails_route(rack_span, request) if instrumentation_config[:enable_recognize_route] - - rack_span.set_attribute('http.target', request.filtered_path) if request.filtered_path != request.fullpath - end - - super(name, request, response) - end - - private - - def add_rails_route(rack_span, request) - ::Rails.application.routes.router.recognize(request) do |route, _params| - rack_span.set_attribute('http.route', route.path.spec.to_s) - end - end - - def instrumentation_config - ActionPack::Instrumentation.instance.config - end - end - end - end - end - end -end diff --git a/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/railtie.rb b/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/railtie.rb deleted file mode 100644 index 52c1a15d92..0000000000 --- a/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/railtie.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module ActionPack - # This Railtie installs Rack middleware to support Action Pack instrumentation - class Railtie < ::Rails::Railtie - config.before_initialize do |app| - OpenTelemetry::Instrumentation::Rack::Instrumentation.instance.install({}) - - app.middleware.insert_before( - 0, - OpenTelemetry::Instrumentation::Rack::Middlewares::TracerMiddleware - ) - end - end - end - end -end diff --git a/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/version.rb b/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/version.rb deleted file mode 100644 index 911f567ac6..0000000000 --- a/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module ActionPack - VERSION = '0.2.0' - end - end -end diff --git a/instrumentation/action_pack/opentelemetry-instrumentation-action_pack.gemspec b/instrumentation/action_pack/opentelemetry-instrumentation-action_pack.gemspec deleted file mode 100644 index 9afde89ff0..0000000000 --- a/instrumentation/action_pack/opentelemetry-instrumentation-action_pack.gemspec +++ /dev/null @@ -1,51 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/action_pack/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-action_pack' - spec.version = OpenTelemetry::Instrumentation::ActionPack::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'ActionPack instrumentation for the OpenTelemetry framework' - spec.description = 'ActionPack instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.21.0' - spec.add_dependency 'opentelemetry-instrumentation-rack', '~> 0.21.0' - - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'rails' - spec.add_development_dependency 'rake', '~> 12.3.3' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'webmock', '~> 3.7.6' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-action_pack/v#{OpenTelemetry::Instrumentation::ActionPack::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/action_pack' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-action_pack/v#{OpenTelemetry::Instrumentation::ActionPack::VERSION}" - end -end diff --git a/instrumentation/action_pack/test/.rubocop.yml b/instrumentation/action_pack/test/.rubocop.yml deleted file mode 100644 index dd94258585..0000000000 --- a/instrumentation/action_pack/test/.rubocop.yml +++ /dev/null @@ -1,4 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false diff --git a/instrumentation/action_pack/test/opentelemetry/instrumentation/action_pack/instrumentation_test.rb b/instrumentation/action_pack/test/opentelemetry/instrumentation/action_pack/instrumentation_test.rb deleted file mode 100644 index c3b0ee80a2..0000000000 --- a/instrumentation/action_pack/test/opentelemetry/instrumentation/action_pack/instrumentation_test.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../lib/opentelemetry/instrumentation/action_pack' - -describe OpenTelemetry::Instrumentation::ActionPack do - let(:instrumentation) { OpenTelemetry::Instrumentation::ActionPack::Instrumentation.instance } - - it 'has #name' do - _(instrumentation.name).must_equal 'OpenTelemetry::Instrumentation::ActionPack' - end - - it 'has #version' do - _(instrumentation.version).wont_be_nil - _(instrumentation.version).wont_be_empty - end - - describe '#install' do - it 'accepts argument' do - _(instrumentation.install({})).must_equal(true) - instrumentation.instance_variable_set(:@installed, false) - end - end -end diff --git a/instrumentation/action_pack/test/opentelemetry/instrumentation/action_pack/patches/action_controller/metal_test.rb b/instrumentation/action_pack/test/opentelemetry/instrumentation/action_pack/patches/action_controller/metal_test.rb deleted file mode 100644 index e82354d7ec..0000000000 --- a/instrumentation/action_pack/test/opentelemetry/instrumentation/action_pack/patches/action_controller/metal_test.rb +++ /dev/null @@ -1,124 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../../../lib/opentelemetry/instrumentation/action_pack' -require_relative '../../../../../../lib/opentelemetry/instrumentation/action_pack/patches/action_controller/metal' - -describe OpenTelemetry::Instrumentation::ActionPack::Patches::ActionController::Metal do - include Rack::Test::Methods - - let(:exporter) { EXPORTER } - let(:spans) { exporter.finished_spans } - let(:span) { exporter.finished_spans.last } - let(:rails_app) { DEFAULT_RAILS_APP } - - # Clear captured spans - before { exporter.reset } - - it 'sets the span name to ControllerName#action' do - get '/ok' - - _(last_response.body).must_equal 'actually ok' - _(last_response.ok?).must_equal true - _(span.name).must_equal 'ExampleController#ok' - _(span.kind).must_equal :server - _(span.status.ok?).must_equal true - - _(span.instrumentation_library.name).must_equal 'OpenTelemetry::Instrumentation::Rack' - _(span.instrumentation_library.version).must_equal OpenTelemetry::Instrumentation::Rack::VERSION - - _(span.attributes['http.method']).must_equal 'GET' - _(span.attributes['http.host']).must_equal 'example.org' - _(span.attributes['http.scheme']).must_equal 'http' - _(span.attributes['http.target']).must_equal '/ok' - _(span.attributes['http.status_code']).must_equal 200 - _(span.attributes['http.user_agent']).must_be_nil - _(span.attributes['http.route']).must_be_nil - end - - it 'sets the span name when the controller raises an exception' do - get 'internal_server_error' - - _(span.name).must_equal 'ExampleController#internal_server_error' - end - - it 'does not set the span name when an exception is raised in middleware' do - get '/ok?raise_in_middleware' - - _(span.name).must_equal 'HTTP GET' - end - - it 'does not set the span name when the request is redirected in middleware' do - get '/ok?redirect_in_middleware' - - _(span.name).must_equal 'HTTP GET' - end - - describe 'when the application has exceptions_app configured' do - let(:rails_app) { AppConfig.initialize_app(use_exceptions_app: true) } - - it 'does not overwrite the span name from the controller that raised' do - get 'internal_server_error' - - _(span.name).must_equal 'ExampleController#internal_server_error' - end - end - - describe 'when the application has enable_rails_route enabled' do - before do - OpenTelemetry::Instrumentation::ActionPack::Instrumentation.instance.config[:enable_recognize_route] = true - end - - after do - OpenTelemetry::Instrumentation::ActionPack::Instrumentation.instance.config[:enable_recognize_route] = false - end - - it 'sets the span name to ControllerName#action' do - get '/ok' - _(last_response.body).must_equal 'actually ok' - _(last_response.ok?).must_equal true - _(span.name).must_equal 'ExampleController#ok' - _(span.kind).must_equal :server - _(span.status.ok?).must_equal true - - _(span.instrumentation_library.name).must_equal 'OpenTelemetry::Instrumentation::Rack' - _(span.instrumentation_library.version).must_equal OpenTelemetry::Instrumentation::Rack::VERSION - - _(span.attributes['http.method']).must_equal 'GET' - _(span.attributes['http.host']).must_equal 'example.org' - _(span.attributes['http.scheme']).must_equal 'http' - _(span.attributes['http.target']).must_equal '/ok' - _(span.attributes['http.status_code']).must_equal 200 - _(span.attributes['http.user_agent']).must_be_nil - _(span.attributes['http.route']).must_equal '/ok(.:format)' - end - end - - it 'sets filters `http.target`' do - get '/ok?param_to_be_filtered=bar&unfiltered_param=baz', {} - _(last_response.body).must_equal 'actually ok' - _(last_response.ok?).must_equal true - _(span.attributes['http.target']).must_equal '/ok?param_to_be_filtered=[FILTERED]&unfiltered_param=baz' - end - - describe 'when the application does not have the tracing rack middleware' do - let(:rails_app) { AppConfig.initialize_app(remove_rack_tracer_middleware: true) } - - it 'does something' do - get '/ok' - - _(last_response.body).must_equal 'actually ok' - _(last_response.ok?).must_equal true - _(spans.size).must_equal(0) - end - end - - def app - rails_app - end -end diff --git a/instrumentation/action_pack/test/test_helper.rb b/instrumentation/action_pack/test/test_helper.rb deleted file mode 100644 index 057d872c13..0000000000 --- a/instrumentation/action_pack/test/test_helper.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'rails' - -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' - -require 'pry' -require 'minitest/autorun' -require 'rack/test' - -require 'test_helpers/app_config.rb' -require_relative '../lib/opentelemetry/instrumentation' - -# Global opentelemetry-sdk setup -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry::SDK.configure do |c| - c.logger = Logger.new('/dev/null') - c.use 'OpenTelemetry::Instrumentation::ActionPack' - c.add_span_processor span_processor -end - -# Create a globally available Rails app, this should be used in test unless -# specifically testing behaviour with different initialization configs. -DEFAULT_RAILS_APP = AppConfig.initialize_app -::Rails.application = DEFAULT_RAILS_APP diff --git a/instrumentation/action_pack/test/test_helpers/app_config.rb b/instrumentation/action_pack/test/test_helpers/app_config.rb deleted file mode 100644 index c20cd8a687..0000000000 --- a/instrumentation/action_pack/test/test_helpers/app_config.rb +++ /dev/null @@ -1,96 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -class Application < Rails::Application; end -require 'action_controller/railtie' -require_relative 'middlewares' -require_relative 'controllers' -require_relative 'routes' - -module AppConfig - extend self - - def initialize_app(use_exceptions_app: false, remove_rack_tracer_middleware: false) - new_app = Application.new - new_app.config.secret_key_base = 'secret_key_base' - - # Ensure we don't see this Rails warning when testing - new_app.config.eager_load = false - - # Prevent tests from creating log/*.log - new_app.config.logger = Logger.new(File::NULL) - - new_app.config.filter_parameters = [:param_to_be_filtered] - - case Rails.version - when /^6\.0/ - apply_rails_6_0_configs(new_app) - when /^6\.1/ - apply_rails_6_1_configs(new_app) - when /^7\./ - apply_rails_7_configs(new_app) - end - - remove_rack_middleware(new_app) if remove_rack_tracer_middleware - add_exceptions_app(new_app) if use_exceptions_app - add_middlewares(new_app) - - new_app.initialize! - - draw_routes(new_app) - - new_app - end - - private - - def remove_rack_middleware(application) - application.middleware.delete( - OpenTelemetry::Instrumentation::Rack::Middlewares::TracerMiddleware - ) - end - - def add_exceptions_app(application) - application.config.exceptions_app = lambda do |env| - ExceptionsController.action(:show).call(env) - end - end - - def add_middlewares(application) - application.middleware.insert_after( - ActionDispatch::DebugExceptions, - ExceptionRaisingMiddleware - ) - - application.middleware.insert_after( - ActionDispatch::DebugExceptions, - RedirectMiddleware - ) - end - - def apply_rails_6_0_configs(application) - # Required in Rails 6 - application.config.hosts << 'example.org' - # Creates a lot of deprecation warnings on subsequent app initializations if not explicitly set. - application.config.action_view.finalize_compiled_template_methods = ActionView::Railtie::NULL_OPTION - end - - def apply_rails_6_1_configs(application) - # Required in Rails 6 - application.config.hosts << 'example.org' - end - - def apply_rails_7_configs(application) - # Required in Rails 7 - application.config.hosts << 'example.org' - - # Unfreeze values which may have been frozen on previous initializations. - ActiveSupport::Dependencies.autoload_paths = - ActiveSupport::Dependencies.autoload_paths.dup - ActiveSupport::Dependencies.autoload_once_paths = - ActiveSupport::Dependencies.autoload_once_paths.dup - end -end diff --git a/instrumentation/action_pack/test/test_helpers/controllers.rb b/instrumentation/action_pack/test/test_helpers/controllers.rb deleted file mode 100644 index 1f58e148f2..0000000000 --- a/instrumentation/action_pack/test/test_helpers/controllers.rb +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative 'controllers/example_controller' -require_relative 'controllers/exceptions_controller' diff --git a/instrumentation/action_pack/test/test_helpers/controllers/example_controller.rb b/instrumentation/action_pack/test/test_helpers/controllers/example_controller.rb deleted file mode 100644 index 9bb5546555..0000000000 --- a/instrumentation/action_pack/test/test_helpers/controllers/example_controller.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -class ExampleController < ActionController::Base - include ::Rails.application.routes.url_helpers - - def ok - render plain: 'actually ok' - end - - def internal_server_error - raise :internal_server_error - end -end diff --git a/instrumentation/action_pack/test/test_helpers/controllers/exceptions_controller.rb b/instrumentation/action_pack/test/test_helpers/controllers/exceptions_controller.rb deleted file mode 100644 index 546698389c..0000000000 --- a/instrumentation/action_pack/test/test_helpers/controllers/exceptions_controller.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -class ExceptionsController < ActionController::Base - def show - render plain: 'oops', status: :internal_server_error - end -end diff --git a/instrumentation/action_pack/test/test_helpers/middlewares.rb b/instrumentation/action_pack/test/test_helpers/middlewares.rb deleted file mode 100644 index 2e09386fe6..0000000000 --- a/instrumentation/action_pack/test/test_helpers/middlewares.rb +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative 'middlewares/exception_raising_middleware' -require_relative 'middlewares/redirect_middleware' diff --git a/instrumentation/action_pack/test/test_helpers/middlewares/exception_raising_middleware.rb b/instrumentation/action_pack/test/test_helpers/middlewares/exception_raising_middleware.rb deleted file mode 100644 index 257cb69544..0000000000 --- a/instrumentation/action_pack/test/test_helpers/middlewares/exception_raising_middleware.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -class ExceptionRaisingMiddleware - def initialize(app, _options = {}) - @app = app - end - - def call(env) - raise 'a little hell' if should_raise?(env) - - @app.call(env) - end - - private - - def should_raise?(env) - env['PATH_INFO'] == '/exception' || env['QUERY_STRING'].include?('raise_in_middleware') - end -end diff --git a/instrumentation/action_pack/test/test_helpers/middlewares/redirect_middleware.rb b/instrumentation/action_pack/test/test_helpers/middlewares/redirect_middleware.rb deleted file mode 100644 index c531fe3dda..0000000000 --- a/instrumentation/action_pack/test/test_helpers/middlewares/redirect_middleware.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -class RedirectMiddleware - def initialize(app, _options = {}) - @app = app - end - - def call(env) - return [307, {}, 'Temporary Redirect'] if should_redirect?(env) - - @app.call(env) - end - - private - - def should_redirect?(env) - env['PATH_INFO'] == '/redirection' || env['QUERY_STRING'].include?('redirect_in_middleware') - end -end diff --git a/instrumentation/action_pack/test/test_helpers/routes.rb b/instrumentation/action_pack/test/test_helpers/routes.rb deleted file mode 100644 index 88f0565f21..0000000000 --- a/instrumentation/action_pack/test/test_helpers/routes.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -def draw_routes(rails_app) - rails_app.routes.draw do - get '/ok', to: 'example#ok' - get '/internal_server_error', to: 'example#internal_server_error' - end -end diff --git a/instrumentation/action_view/.rubocop.yml b/instrumentation/action_view/.rubocop.yml deleted file mode 100644 index 26d21d4644..0000000000 --- a/instrumentation/action_view/.rubocop.yml +++ /dev/null @@ -1,5 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-action_view.rb" diff --git a/instrumentation/action_view/.yardopts b/instrumentation/action_view/.yardopts deleted file mode 100644 index f46e2da66c..0000000000 --- a/instrumentation/action_view/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Action View Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/action_view/Appraisals b/instrumentation/action_view/Appraisals deleted file mode 100644 index d358e21c82..0000000000 --- a/instrumentation/action_view/Appraisals +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# Rails 5.2 is incompatible with Ruby 3. -if RUBY_VERSION < '3' - appraise 'rails-5.2' do - gem 'rails', '~> 5.2.0' - end -end - -appraise 'rails-6.0' do - gem 'rails', '~> 6.0.0' -end - -appraise 'rails-6.1' do - gem 'rails', '~> 6.1.0' -end - -if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.0') - appraise 'rails-7.0' do - gem 'rails', '~> 7.0.0' - end -end diff --git a/instrumentation/action_view/CHANGELOG.md b/instrumentation/action_view/CHANGELOG.md deleted file mode 100644 index 645a8056f4..0000000000 --- a/instrumentation/action_view/CHANGELOG.md +++ /dev/null @@ -1,31 +0,0 @@ -# Release History: opentelemetry-instrumentation-action_view - -### v0.3.0 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Broken test file requirements - -### v0.2.1 / 2022-05-02 - -* FIXED: RubyGems Fallback - -### v0.2.0 / 2021-12-01 - -* ADDED: Move activesupport notification subsciber out of action_view gem -* FIXED: Instrumentation of Rails 7 - -### v0.1.3 / 2021-10-06 - -* FIXED: Do not replace fanout - -### v0.1.2 / 2021-09-29 - -* (No significant changes) - -### v0.1.1 / 2021-09-09 - -* FIXED: Keep Active Support subscriptions intact when patching - -### v0.1.0 / 2021-08-12 - -* Initial release. diff --git a/instrumentation/action_view/Gemfile b/instrumentation/action_view/Gemfile deleted file mode 100644 index 416a65a35f..0000000000 --- a/instrumentation/action_view/Gemfile +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :test do - gem 'opentelemetry-instrumentation-active_support', path: '../active_support' - gem 'opentelemetry-instrumentation-base', path: '../base' - gem 'pry-byebug' -end diff --git a/instrumentation/action_view/LICENSE b/instrumentation/action_view/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/action_view/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/action_view/README.md b/instrumentation/action_view/README.md deleted file mode 100644 index baa657b7a6..0000000000 --- a/instrumentation/action_view/README.md +++ /dev/null @@ -1,71 +0,0 @@ -# OpenTelemetry ActionView Instrumentation - -The ActionView instrumentation is a community-maintained instrumentation for the ActionView portion of the [Ruby on Rails][rails-home] web-application framework. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-action_view -gem install opentelemetry-instrumentation-rails -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-action_view` in your `Gemfile`. - -## Usage - -To use the instrumentation, call `use` with the name of the instrumentation: - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Rails' - c.use 'OpenTelemetry::Instrumentation::ActionView' -end -``` - -Alternatively, you can also call `use_all` to install all the available instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` - -## Examples - -Example usage can be seen in the `./example/trace_request_demonstration.ru` file [here](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/instrumentation/action_view/example/trace_request_demonstration.ru) - -## Known issues - -ActionView instrumentation uses ActiveSupport notifications and in the case when a subscriber raises in start method an unclosed span would break successive spans ends. Example: - -```ruby -class CrashingEndSubscriber - def start(name, id, payload) - raise 'boom' - end - - def finish(name, id, payload) end -end - -::ActiveSupport::Notifications.subscribe('render_template.action_view', CrashingStartSubscriber.new) -``` - -## How can I get involved? - -The `opentelemetry-instrumentation-action_view` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -The `opentelemetry-instrumentation-action_view` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information. - -[rails-home]: https://github.com/rails/rails -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/instrumentation/action_view/Rakefile b/instrumentation/action_view/Rakefile deleted file mode 100644 index 1a64ba842e..0000000000 --- a/instrumentation/action_view/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/action_view/example/trace_request_demonstration.ru b/instrumentation/action_view/example/trace_request_demonstration.ru deleted file mode 100644 index 80e50c26b4..0000000000 --- a/instrumentation/action_view/example/trace_request_demonstration.ru +++ /dev/null @@ -1,67 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/inline' - -gemfile(true) do - source 'https://rubygems.org' - - gem 'rails' - gem 'opentelemetry-sdk' - gem 'opentelemetry-instrumentation-rails', path: '../../rails' - gem 'opentelemetry-instrumentation-action_view', path: '../' -end - -require 'active_support/railtie' -require 'action_controller/railtie' -require 'action_view/railtie' - -# TraceRequestApp is a minimal Rails application inspired by the Rails -# bug report template for action controller. -# The configuration is compatible with Rails 6.0 -class TraceRequestApp < Rails::Application - config.root = __dir__ - config.hosts << 'example.org' - secrets.secret_key_base = 'secret_key_base' - - config.eager_load = false - - config.logger = Logger.new($stdout) - Rails.logger = config.logger - - routes.draw do - get '/' => 'test#index' - end -end - -# A minimal test controller -class TestController < ActionController::Base - include Rails.application.routes.url_helpers - - def index; end -end - -# Simple setup for demonstration purposes, simple span processor should not be -# used in a production environment -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new( - OpenTelemetry::SDK::Trace::Export::ConsoleSpanExporter.new -) - -OpenTelemetry::SDK.configure do |c| - # At present, the Rails instrumentation is required. - c.use 'OpenTelemetry::Instrumentation::Rails' - c.use 'OpenTelemetry::Instrumentation::ActionView' - c.add_span_processor(span_processor) -end - -Rails.application.initialize! - -run Rails.application - -# To run this example run the `rackup` command with this file -# Example: rackup trace_request_demonstration.ru -# Navigate to http://localhost:9292/ -# Spans for the requests will appear in the console diff --git a/instrumentation/action_view/lib/opentelemetry-instrumentation-action_view.rb b/instrumentation/action_view/lib/opentelemetry-instrumentation-action_view.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/action_view/lib/opentelemetry-instrumentation-action_view.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/action_view/lib/opentelemetry/instrumentation.rb b/instrumentation/action_view/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index 37c26c3c1c..0000000000 --- a/instrumentation/action_view/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/action_view' diff --git a/instrumentation/action_view/lib/opentelemetry/instrumentation/action_view.rb b/instrumentation/action_view/lib/opentelemetry/instrumentation/action_view.rb deleted file mode 100644 index d2285b3d21..0000000000 --- a/instrumentation/action_view/lib/opentelemetry/instrumentation/action_view.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the ActionView gem - module ActionView - end - end -end - -require_relative './action_view/instrumentation' -require_relative './action_view/version' diff --git a/instrumentation/action_view/lib/opentelemetry/instrumentation/action_view/instrumentation.rb b/instrumentation/action_view/lib/opentelemetry/instrumentation/action_view/instrumentation.rb deleted file mode 100644 index 9124b27d4d..0000000000 --- a/instrumentation/action_view/lib/opentelemetry/instrumentation/action_view/instrumentation.rb +++ /dev/null @@ -1,40 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module ActionView - # The Instrumentation class contains logic to detect and install the ActionView instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - MINIMUM_VERSION = Gem::Version.new('5.2.0') - install do |_config| - require_dependencies - end - - present do - defined?(::ActionView) - end - - compatible do - gem_version >= MINIMUM_VERSION - end - - option :disallowed_notification_payload_keys, default: [], validate: :array - option :notification_payload_transform, default: nil, validate: :callable - - private - - def gem_version - ::ActionView.version - end - - def require_dependencies - require_relative 'railtie' - end - end - end - end -end diff --git a/instrumentation/action_view/lib/opentelemetry/instrumentation/action_view/railtie.rb b/instrumentation/action_view/lib/opentelemetry/instrumentation/action_view/railtie.rb deleted file mode 100644 index 8816a62359..0000000000 --- a/instrumentation/action_view/lib/opentelemetry/instrumentation/action_view/railtie.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module ActionView - SUBSCRIPTIONS = %w[ - render_template.action_view - render_partial.action_view - render_collection.action_view - ].freeze - - # This Railtie sets up subscriptions to relevant ActionView notifications - class Railtie < ::Rails::Railtie - config.after_initialize do - ::OpenTelemetry::Instrumentation::ActiveSupport::Instrumentation.instance.install({}) - - SUBSCRIPTIONS.each do |subscription_name| - config = ActionView::Instrumentation.instance.config - ::OpenTelemetry::Instrumentation::ActiveSupport.subscribe(ActionView::Instrumentation.instance.tracer, subscription_name, config[:notification_payload_transform], config[:disallowed_notification_payload_keys]) - end - end - end - end - end -end diff --git a/instrumentation/action_view/lib/opentelemetry/instrumentation/action_view/version.rb b/instrumentation/action_view/lib/opentelemetry/instrumentation/action_view/version.rb deleted file mode 100644 index fbbaac4e84..0000000000 --- a/instrumentation/action_view/lib/opentelemetry/instrumentation/action_view/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module ActionView - VERSION = '0.3.0' - end - end -end diff --git a/instrumentation/action_view/opentelemetry-instrumentation-action_view.gemspec b/instrumentation/action_view/opentelemetry-instrumentation-action_view.gemspec deleted file mode 100644 index 747552b150..0000000000 --- a/instrumentation/action_view/opentelemetry-instrumentation-action_view.gemspec +++ /dev/null @@ -1,51 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/action_view/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-action_view' - spec.version = OpenTelemetry::Instrumentation::ActionView::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'ActionView instrumentation for the OpenTelemetry framework' - spec.description = 'ActionView instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-instrumentation-active_support', '~> 0.1' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.20' - - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'rails' - spec.add_development_dependency 'rake', '~> 12.3.3' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'webmock', '~> 3.7.6' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-action_view/v#{OpenTelemetry::Instrumentation::ActionView::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/action_view' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-action_view/v#{OpenTelemetry::Instrumentation::ActionView::VERSION}" - end -end diff --git a/instrumentation/action_view/test/.rubocop.yml b/instrumentation/action_view/test/.rubocop.yml deleted file mode 100644 index dd94258585..0000000000 --- a/instrumentation/action_view/test/.rubocop.yml +++ /dev/null @@ -1,4 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false diff --git a/instrumentation/action_view/test/opentelemetry/instrumentation/action_view/instrumentation_test.rb b/instrumentation/action_view/test/opentelemetry/instrumentation/action_view/instrumentation_test.rb deleted file mode 100644 index ff05f4ab7c..0000000000 --- a/instrumentation/action_view/test/opentelemetry/instrumentation/action_view/instrumentation_test.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../lib/opentelemetry/instrumentation/action_view' - -describe OpenTelemetry::Instrumentation::ActionView do - let(:instrumentation) { OpenTelemetry::Instrumentation::ActionView::Instrumentation.instance } - - it 'has #name' do - _(instrumentation.name).must_equal 'OpenTelemetry::Instrumentation::ActionView' - end - - it 'has #version' do - _(instrumentation.version).wont_be_nil - _(instrumentation.version).wont_be_empty - end - - describe '#install' do - it 'accepts argument' do - _(instrumentation.install({})).must_equal(true) - instrumentation.instance_variable_set(:@installed, false) - end - end -end diff --git a/instrumentation/action_view/test/test_helper.rb b/instrumentation/action_view/test/test_helper.rb deleted file mode 100644 index 86a8b59f1c..0000000000 --- a/instrumentation/action_view/test/test_helper.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' - -require 'pry' -require 'minitest/autorun' -require 'webmock/minitest' - -require 'rails' -require 'action_view' -require 'opentelemetry-instrumentation-action_view' - -# global opentelemetry-sdk setup: -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::ActionView' - c.add_span_processor span_processor -end diff --git a/instrumentation/active_job/.rubocop.yml b/instrumentation/active_job/.rubocop.yml deleted file mode 100644 index b2af1c7877..0000000000 --- a/instrumentation/active_job/.rubocop.yml +++ /dev/null @@ -1,29 +0,0 @@ -AllCops: - Exclude: - - "example/active_job.rb" - TargetRubyVersion: "2.6.0" - -Bundler/OrderedGems: - Exclude: - - gemfiles/**/* -Lint/UnusedMethodArgument: - Enabled: false -Metrics/AbcSize: - Max: 18 -Metrics/LineLength: - Enabled: false -Metrics/MethodLength: - Max: 20 -Metrics/ParameterLists: - Enabled: false -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-active_job.rb" -Style/FrozenStringLiteralComment: - Exclude: - - gemfiles/**/* -Style/ModuleFunction: - Enabled: false -Style/StringLiterals: - Exclude: - - gemfiles/**/* diff --git a/instrumentation/active_job/.yardopts b/instrumentation/active_job/.yardopts deleted file mode 100644 index ec067e3493..0000000000 --- a/instrumentation/active_job/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Active Job Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/active_job/Appraisals b/instrumentation/active_job/Appraisals deleted file mode 100644 index 0d56e946d7..0000000000 --- a/instrumentation/active_job/Appraisals +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -appraise 'activejob-6.1' do - gem 'activejob', '~> 6.1.0' -end - -appraise 'activejob-6.0' do - gem 'activejob', '~> 6.0.0' -end - -# Rails 5.2 is not compatible with Ruby 3.0 -# https://github.com/rails/rails/issues/40938 -if RUBY_VERSION < '3' - appraise 'activejob-5.2' do - gem 'activejob', '~> 5.2.0' - end -end - -if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.0') - appraise 'rails-7.0' do - gem 'rails', '~> 7.0.0' - end -end diff --git a/instrumentation/active_job/CHANGELOG.md b/instrumentation/active_job/CHANGELOG.md deleted file mode 100644 index 679e28fa2c..0000000000 --- a/instrumentation/active_job/CHANGELOG.md +++ /dev/null @@ -1,37 +0,0 @@ -# Release History: opentelemetry-instrumentation-active_job - -### v0.3.0 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Broken test file requirements - -### v0.2.0 / 2022-05-02 - -* ADDED: Validate Using Enums -* ADDED: Make the context available in ActiveJob notifications -* FIXED: Fix deserialization of jobs that are missing metadata -* FIXED: RubyGems Fallback - -### v0.1.5 / 2021-12-02 - -* (No significant changes) - -### v0.1.4 / 2021-09-29 - -* (No significant changes) - -### v0.1.3 / 2021-08-12 - -* (No significant changes) - -### v0.1.2 / 2021-07-01 - -* FIXED: Support Active Jobs with keyword args across ruby versions - -### v0.1.1 / 2021-06-29 - -* FIXED: Compatibility with RC2 span status api changes [845](https://github.com/open-telemetry/opentelemetry-ruby/pull/845) - -### v0.1.0 / 2021-06-23 - -* Initial release. diff --git a/instrumentation/active_job/Gemfile b/instrumentation/active_job/Gemfile deleted file mode 100644 index 2baf57ac47..0000000000 --- a/instrumentation/active_job/Gemfile +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :test do - gem 'opentelemetry-instrumentation-base', path: '../base' -end diff --git a/instrumentation/active_job/LICENSE b/instrumentation/active_job/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/active_job/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/active_job/README.md b/instrumentation/active_job/README.md deleted file mode 100644 index 6470f64a68..0000000000 --- a/instrumentation/active_job/README.md +++ /dev/null @@ -1,53 +0,0 @@ -# OpenTelemetry ActiveJob Instrumentation - -The OpenTelemetry Active Job gem is a community maintained instrumentation for [ActiveJob][activejob-home]. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-active_job -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-active_job` in your `Gemfile`. - -## Usage - -To use the instrumentation, call `use` with the name of the instrumentation: - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::ActiveJob' -end -``` - -Alternatively, you can also call `use_all` to install all the available instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` - -## Examples - -Example usage can be seen in the `./example/active_job.rb` file [here](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/instrumentation/active_job/example/active_job.rb) - -## How can I get involved? - -The `opentelemetry-instrumentation-active_job` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -The `opentelemetry-instrumentation-active_job` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information. - -[activejob-home]: https://guides.rubyonrails.org/active_job_basics.html -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/instrumentation/active_job/Rakefile b/instrumentation/active_job/Rakefile deleted file mode 100644 index 1a64ba842e..0000000000 --- a/instrumentation/active_job/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/active_job/example/Gemfile b/instrumentation/active_job/example/Gemfile deleted file mode 100644 index 1038266125..0000000000 --- a/instrumentation/active_job/example/Gemfile +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -source 'https://rubygems.org' - -gem 'activejob' -gem 'opentelemetry-api' -gem 'opentelemetry-instrumentation-active_job' -gem 'opentelemetry-sdk' diff --git a/instrumentation/active_job/example/active_job.rb b/instrumentation/active_job/example/active_job.rb deleted file mode 100644 index 808a17b44e..0000000000 --- a/instrumentation/active_job/example/active_job.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'rubygems' -require 'bundler/setup' -require 'active_job' - -Bundler.require - -ENV['OTEL_TRACES_EXPORTER'] ||= 'console' -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::ActiveJob' -end - -class TestJob < ::ActiveJob::Base - def perform - puts <<~EOS - - -------------------------------------------------- - The computer is doing some work, beep beep boop. - -------------------------------------------------- - - EOS - end -end - -::ActiveJob::Base.queue_adapter = :async - -TestJob.perform_later -sleep 0.1 # To ensure we see both spans! diff --git a/instrumentation/active_job/lib/opentelemetry-instrumentation-active_job.rb b/instrumentation/active_job/lib/opentelemetry-instrumentation-active_job.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/active_job/lib/opentelemetry-instrumentation-active_job.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/active_job/lib/opentelemetry/instrumentation.rb b/instrumentation/active_job/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index 2c42ac24e5..0000000000 --- a/instrumentation/active_job/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/active_job' diff --git a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job.rb b/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job.rb deleted file mode 100644 index beebb469a8..0000000000 --- a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the ActiveJob gem - module ActiveJob - end - end -end - -require_relative './active_job/instrumentation' -require_relative './active_job/version' diff --git a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/instrumentation.rb b/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/instrumentation.rb deleted file mode 100644 index 2ed7c381a8..0000000000 --- a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/instrumentation.rb +++ /dev/null @@ -1,77 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module ActiveJob - # The Instrumentation class contains logic to detect and install the ActiveJob instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - MINIMUM_VERSION = Gem::Version.new('5.2.0') - - install do |_config| - require_dependencies - patch_activejob - end - - present do - defined?(::ActiveJob) - end - - compatible do - gem_version >= MINIMUM_VERSION - end - - ## Supported configuration keys for the install config hash: - # - # span_naming: when `:job_class`, the span names will be set to - # ' '. When `:queue`, the span names - # will be set to ' ' - # - # force_flush: when `true`, all completed spans will be synchronously flushed - # at the end of a job's execution (default: `false`). You will likely wish to - # enable this option for job systems that fork worker processes such as Resque. - # - # propagation_style: controls how the job's execution is traced and related - # to the trace where the job was enqueued. Can be one of: - # - # - :link (default) - the job will be executed in a separate trace. The - # initial span of the execution trace will be linked to the span that - # enqueued the job, via a Span Link. - # - :child - the job will be executed in the same logical trace, as a direct - # child of the span that enqueued the job. - # - :none - the job's execution will not be explicitly linked to the span that - # enqueued the job. - # - # Note that in all cases, we will store ActiveJob's Job ID as the `messaging.message_id` - # attribute, so out-of-band correlation may still be possible depending on your backend system. - # - # Note that when using the `:inline` ActiveJob queue adapter, then execution - # spans will always be children of the enqueueing spans. This is due to the way - # ActiveJob immediately executes jobs during the process of "enqueueing" jobs when - # using the `:inline` adapter. - option :propagation_style, default: :link, validate: %i[link child none] - option :force_flush, default: false, validate: :boolean - option :span_naming, default: :queue, validate: %i[job_class queue] - - private - - def gem_version - ::ActiveJob.version - end - - def require_dependencies - require_relative 'patches/base' - require_relative 'patches/active_job_callbacks' - end - - def patch_activejob - ::ActiveJob::Base.prepend(Patches::Base) - ::ActiveJob::Base.prepend(Patches::ActiveJobCallbacks) - end - end - end - end -end diff --git a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/patches/active_job_callbacks.rb b/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/patches/active_job_callbacks.rb deleted file mode 100644 index 69330642e7..0000000000 --- a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/patches/active_job_callbacks.rb +++ /dev/null @@ -1,94 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module ActiveJob - module Patches - # Module to prepend to ActiveJob::Base for instrumentation. - module ActiveJobCallbacks - def self.prepended(base) - base.class_eval do - around_enqueue do |job, block| - span_kind = job.class.queue_adapter_name == 'inline' ? :client : :producer - span_name = "#{otel_config[:span_naming] == :job_class ? job.class : job.queue_name} send" - span_attributes = job_attributes(job) - otel_tracer.in_span(span_name, attributes: span_attributes, kind: span_kind) do - OpenTelemetry.propagation.inject(job.metadata) - block.call - end - end - end - end - - def perform_now # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity - span_kind = self.class.queue_adapter_name == 'inline' ? :server : :consumer - span_name = "#{otel_config[:span_naming] == :job_class ? self.class : queue_name} process" - span_attributes = job_attributes(self).merge('messaging.operation' => 'process') - executions_count = (executions || 0) + 1 # because we run before the count is incremented in ActiveJob::Execution - - extracted_context = OpenTelemetry.propagation.extract(metadata) - OpenTelemetry::Context.with_current(extracted_context) do - if otel_config[:propagation_style] == :child - otel_tracer.in_span(span_name, attributes: span_attributes, kind: span_kind) do |span| - span.set_attribute('messaging.active_job.executions', executions_count) - super - end - else - span_links = [] - if otel_config[:propagation_style] == :link - span_context = OpenTelemetry::Trace.current_span(extracted_context).context - span_links << OpenTelemetry::Trace::Link.new(span_context) if span_context.valid? - end - - root_span = otel_tracer.start_root_span(span_name, attributes: span_attributes, links: span_links, kind: span_kind) - OpenTelemetry::Trace.with_span(root_span) do |span| - span.set_attribute('messaging.active_job.executions', executions_count) - super - rescue Exception => e # rubocop:disable Lint/RescueException - span.record_exception(e) - span.status = OpenTelemetry::Trace::Status.error("Unhandled exception of type: #{e.class}") - raise e - ensure - root_span.finish - end - end - end - ensure - # We may be in a job system (eg: resque) that forks and kills worker processes often. - # We don't want to lose spans by not flushing any span processors, so we optionally force it here. - OpenTelemetry.tracer_provider.force_flush if otel_config[:force_flush] - end - - private - - def job_attributes(job) - otel_attributes = { - 'messaging.destination_kind' => 'queue', - 'messaging.system' => job.class.queue_adapter_name, - 'messaging.destination' => job.queue_name, - 'messaging.message_id' => job.job_id, - 'messaging.active_job.scheduled_at' => job.scheduled_at, - 'messaging.active_job.priority' => job.priority - } - - otel_attributes['net.transport'] = 'inproc' if %w[async inline].include?(job.class.queue_adapter_name) - - otel_attributes.compact - end - - def otel_tracer - ActiveJob::Instrumentation.instance.tracer - end - - def otel_config - ActiveJob::Instrumentation.instance.config - end - end - end - end - end -end diff --git a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/patches/base.rb b/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/patches/base.rb deleted file mode 100644 index 42a3626d61..0000000000 --- a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/patches/base.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module ActiveJob - module Patches - # Module to prepend to ActiveJob::Core for context propagation. - module Base - def self.prepended(base) - base.class_eval do - attr_accessor :metadata - end - end - - def initialize(*args) - @metadata = {} - super - end - ruby2_keywords(:initialize) if respond_to?(:ruby2_keywords, true) - - def serialize - super.merge('metadata' => serialize_arguments(metadata)) - end - - def deserialize(job_data) - self.metadata = deserialize_arguments(job_data['metadata'] || []).to_h - super - end - end - end - end - end -end diff --git a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/version.rb b/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/version.rb deleted file mode 100644 index b06d76786d..0000000000 --- a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module ActiveJob - VERSION = '0.3.0' - end - end -end diff --git a/instrumentation/active_job/opentelemetry-instrumentation-active_job.gemspec b/instrumentation/active_job/opentelemetry-instrumentation-active_job.gemspec deleted file mode 100644 index bbe935a840..0000000000 --- a/instrumentation/active_job/opentelemetry-instrumentation-active_job.gemspec +++ /dev/null @@ -1,51 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/active_job/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-active_job' - spec.version = OpenTelemetry::Instrumentation::ActiveJob::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'ActiveJob instrumentation for the OpenTelemetry framework' - spec.description = 'ActiveJob instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.21.0' - - spec.add_development_dependency 'activejob', '>= 5.2.0' - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'pry' - spec.add_development_dependency 'rake', '~> 12.3.3' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'webmock', '~> 3.7.6' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-active_job/v#{OpenTelemetry::Instrumentation::ActiveJob::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/active_job' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-active_job/v#{OpenTelemetry::Instrumentation::ActiveJob::VERSION}" - end -end diff --git a/instrumentation/active_job/test/.rubocop.yml b/instrumentation/active_job/test/.rubocop.yml deleted file mode 100644 index dd94258585..0000000000 --- a/instrumentation/active_job/test/.rubocop.yml +++ /dev/null @@ -1,4 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false diff --git a/instrumentation/active_job/test/instrumentation/active_job/instrumentation_test.rb b/instrumentation/active_job/test/instrumentation/active_job/instrumentation_test.rb deleted file mode 100644 index 4cb9c80f42..0000000000 --- a/instrumentation/active_job/test/instrumentation/active_job/instrumentation_test.rb +++ /dev/null @@ -1,42 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../lib/opentelemetry/instrumentation/active_job' - -describe OpenTelemetry::Instrumentation::ActiveJob do - let(:instrumentation) { OpenTelemetry::Instrumentation::ActiveJob::Instrumentation.instance } - let(:minimum_version) { OpenTelemetry::Instrumentation::ActiveJob::Instrumentation::MINIMUM_VERSION } - - it 'has #name' do - _(instrumentation.name).must_equal 'OpenTelemetry::Instrumentation::ActiveJob' - end - - it 'has #version' do - _(instrumentation.version).wont_be_nil - _(instrumentation.version).wont_be_empty - end - - describe '#compatible' do - it 'returns false for unsupported gem versions' do - ::ActiveJob.stub(:version, Gem::Version.new('4.2.0')) do - _(instrumentation.compatible?).must_equal false - end - end - - it 'returns true for supported gem versions' do - _(instrumentation.compatible?).must_equal true - end - end - - describe '#install' do - it 'accepts argument' do - _(instrumentation.install({})).must_equal(true) - instrumentation.instance_variable_set(:@installed, false) - end - end -end diff --git a/instrumentation/active_job/test/instrumentation/active_job/patches/active_job_callbacks_test.rb b/instrumentation/active_job/test/instrumentation/active_job/patches/active_job_callbacks_test.rb deleted file mode 100644 index d64ccf34ab..0000000000 --- a/instrumentation/active_job/test/instrumentation/active_job/patches/active_job_callbacks_test.rb +++ /dev/null @@ -1,399 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../lib/opentelemetry/instrumentation/active_job' - -describe OpenTelemetry::Instrumentation::ActiveJob::Patches::ActiveJobCallbacks do - let(:instrumentation) { OpenTelemetry::Instrumentation::ActiveJob::Instrumentation.instance } - # Technically these are the defaults. But ActiveJob seems to act oddly if you re-install - # the instrumentation over and over again - so we manipulate instance variables to - # reset between tests, and that means we should set the defaults here. - let(:config) { { propagation_style: :link, force_flush: false, span_naming: :queue } } - let(:exporter) { EXPORTER } - let(:spans) { exporter.finished_spans } - let(:send_span) { spans.find { |s| s.name == 'default send' } } - let(:process_span) { spans.find { |s| s.name == 'default process' } } - - before do - instrumentation.instance_variable_set(:@config, config) - exporter.reset - - ::ActiveJob::Base.queue_adapter = :async - ::ActiveJob::Base.queue_adapter.immediate = true - end - - after do - begin - ::ActiveJob::Base.queue_adapter.shutdown - rescue StandardError - nil - end - ::ActiveJob::Base.queue_adapter = :inline - instrumentation.instance_variable_set(:@config, config) - end - - describe 'perform_later' do - it 'traces enqueuing and processing the job' do - TestJob.perform_later - - _(send_span).wont_be_nil - _(process_span).wont_be_nil - end - end - - describe 'perform_now' do - it 'only traces processing the job' do - TestJob.perform_now - - _(send_span).must_be_nil - _(process_span).wont_be_nil - end - end - - describe 'compatibility' do - it 'works with positional args' do - _(PositionalOnlyArgsJob.perform_now('arg1')).must_be_nil # Make sure this runs without raising an error - end - - it 'works with keyword args' do - _(KeywordOnlyArgsJob.perform_now(keyword2: :keyword2)).must_be_nil # Make sure this runs without raising an error - end - - it 'works with mixed args' do - _(MixedArgsJob.perform_now('arg1', 'arg2', keyword2: :keyword2)).must_be_nil # Make sure this runs without raising an error - end - end - - describe 'exception handling' do - it 'sets span status to error' do - _ { ExceptionJob.perform_now }.must_raise StandardError, 'This job raises an exception' - _(process_span.status.code).must_equal OpenTelemetry::Trace::Status::ERROR - _(process_span.status.description).must_equal 'Unhandled exception of type: StandardError' - end - - it 'records the exception' do - _ { ExceptionJob.perform_now }.must_raise StandardError, 'This job raises an exception' - _(process_span.events.first.name).must_equal 'exception' - _(process_span.events.first.attributes['exception.type']).must_equal 'StandardError' - _(process_span.events.first.attributes['exception.message']).must_equal 'This job raises an exception' - end - end - - describe 'span kind' do - it 'sets correct span kinds for inline jobs' do - begin - ::ActiveJob::Base.queue_adapter.shutdown - rescue StandardError - nil - end - ::ActiveJob::Base.queue_adapter = :inline - - TestJob.perform_later - - _(send_span.kind).must_equal(:client) - _(process_span.kind).must_equal(:server) - end - - it 'sets correct span kinds for all other jobs' do - TestJob.perform_later - - _(send_span.kind).must_equal(:producer) - _(process_span.kind).must_equal(:consumer) - end - end - - describe 'attributes' do - it 'sets the messaging.operation attribute only when processing the job' do - TestJob.perform_later - - _(send_span.attributes['messaging.operation']).must_be_nil - _(process_span.attributes['messaging.operation']).must_equal('process') - end - - describe 'net.transport' do - it 'is sets correctly for inline jobs' do - TestJob.perform_later - - [send_span, process_span].each do |span| - _(span.attributes['net.transport']).must_equal('inproc') - end - end - - it 'is set correctly for async jobs' do - TestJob.perform_later - - [send_span, process_span].each do |span| - _(span.attributes['net.transport']).must_equal('inproc') - end - end - end - - describe 'messaging.active_job.priority' do - it 'is unset for unprioritized jobs' do - TestJob.perform_later - - [send_span, process_span].each do |span| - _(span.attributes['messaging.active_job.priority']).must_be_nil - end - end - - it 'is set for jobs with a priority' do - TestJob.set(priority: 1).perform_later - - [send_span, process_span].each do |span| - _(span.attributes['messaging.active_job.priority']).must_equal(1) - end - end - end - - describe 'messaging.active_job.scheduled_at' do - it 'is unset for jobs that do not specify a wait time' do - TestJob.perform_later - - [send_span, process_span].each do |span| - _(span.attributes['messaging.active_job.scheduled_at']).must_be_nil - end - end - - it 'is set correctly for jobs that do wait' do - job = TestJob.set(wait: 0.second).perform_later - - # Only the sending span is a 'scheduled' thing - _(send_span.attributes['messaging.active_job.scheduled_at']).must_equal(job.scheduled_at) - assert(send_span.attributes['messaging.active_job.scheduled_at']) - - # The processing span isn't a 'scheduled' thing - _(process_span.attributes['messaging.active_job.scheduled_at']).must_be_nil - end - end - - describe 'messaging.system' do - it 'is set correctly for the inline adapter' do - begin - ::ActiveJob::Base.queue_adapter.shutdown - rescue StandardError - nil - end - - ::ActiveJob::Base.queue_adapter = :inline - TestJob.perform_later - - [send_span, process_span].each do |span| - _(span.attributes['messaging.system']).must_equal('inline') - end - end - - it 'is set correctly for the async adapter' do - TestJob.perform_later - - [send_span, process_span].each do |span| - _(span.attributes['messaging.system']).must_equal('async') - end - end - end - - describe 'messaging.active_job.executions' do - it 'is 1 for a normal job that does not retry' do - TestJob.perform_now - _(process_span.attributes['messaging.active_job.executions']).must_equal(1) - end - - it 'tracks correctly for jobs that do retry' do - begin - RetryJob.perform_later - rescue StandardError - nil - end - - executions = spans.filter { |s| s.kind == :consumer }.sum { |s| s.attributes['messaging.active_job.executions'] } - _(executions).must_equal(3) # total of 3 runs. The initial and 2 retries. - end - end - - it 'generally sets other attributes as expected' do - job = TestJob.perform_later - - [send_span, process_span].each do |span| - _(span.attributes['messaging.destination_kind']).must_equal('queue') - _(span.attributes['messaging.system']).must_equal('async') - _(span.attributes['messaging.message_id']).must_equal(job.job_id) - end - end - end - - describe 'span_naming option' do - describe 'when queue - default' do - it 'names spans according to the job queue' do - TestJob.set(queue: :foo).perform_later - send_span = exporter.finished_spans.find { |s| s.name == 'foo send' } - _(send_span).wont_be_nil - - process_span = exporter.finished_spans.find { |s| s.name == 'foo process' } - _(process_span).wont_be_nil - end - end - - describe 'when job_class' do - let(:config) { { propagation_style: :link, span_naming: :job_class } } - - it 'names span according to the job class' do - TestJob.set(queue: :foo).perform_later - send_span = exporter.finished_spans.find { |s| s.name == 'TestJob send' } - _(send_span).wont_be_nil - - process_span = exporter.finished_spans.find { |s| s.name == 'TestJob process' } - _(process_span).wont_be_nil - end - end - end - - describe 'force_flush option' do - let(:mock_tracer_provider) do - mock_tracer_provider = MiniTest::Mock.new - mock_tracer_provider.expect(:force_flush, true) - - mock_tracer_provider - end - - describe 'false - default' do - it 'does not forcibly flush the tracer' do - OpenTelemetry.stub(:tracer_provider, mock_tracer_provider) do - TestJob.perform_later - end - - # We *do not* actually force flush in this case, so we expect the mock - # to fail validation - we will not actually call the mocked force_flush method. - expect { mock_tracer_provider.verify }.must_raise MockExpectationError - end - end - - describe 'true' do - let(:config) { { propagation_style: :link, force_flush: true, span_naming: :job_class } } - it 'does forcibly flush the tracer' do - OpenTelemetry.stub(:tracer_provider, mock_tracer_provider) do - TestJob.perform_later - end - - # Nothing should raise, the mock should be successful, we should have flushed. - mock_tracer_provider.verify - end - end - end - - describe 'propagation_style option' do - describe 'link - default' do - # The inline job adapter executes the job immediately upon enqueuing it - # so we can't actually use that in these tests - the actual Context.current at time - # of execution *will* be the context where the job was enqueued, because rails - # ends up doing job.around_enqueue { job.around_perform { block } } inline. - it 'creates span links in separate traces' do - TestJob.perform_later - - _(send_span.trace_id).wont_equal(process_span.trace_id) - - _(process_span.total_recorded_links).must_equal(1) - _(process_span.links[0].span_context.trace_id).must_equal(send_span.trace_id) - _(process_span.links[0].span_context.span_id).must_equal(send_span.span_id) - end - - it 'propagates baggage' do - ctx = OpenTelemetry::Baggage.set_value('testing_baggage', 'it_worked') - OpenTelemetry::Context.with_current(ctx) do - BaggageJob.perform_later - end - - _(send_span.trace_id).wont_equal(process_span.trace_id) - - _(process_span.total_recorded_links).must_equal(1) - _(process_span.links[0].span_context.trace_id).must_equal(send_span.trace_id) - _(process_span.links[0].span_context.span_id).must_equal(send_span.span_id) - _(process_span.attributes['success']).must_equal(true) - end - end - - describe 'when configured to do parent/child spans' do - let(:config) { { propagation_style: :child, span_naming: :queue } } - - it 'creates a parent/child relationship' do - TestJob.perform_later - - _(process_span.total_recorded_links).must_equal(0) - - _(send_span.trace_id).must_equal(process_span.trace_id) - _(process_span.parent_span_id).must_equal(send_span.span_id) - end - - it 'propagates baggage' do - ctx = OpenTelemetry::Baggage.set_value('testing_baggage', 'it_worked') - OpenTelemetry::Context.with_current(ctx) do - BaggageJob.perform_later - end - _(process_span.total_recorded_links).must_equal(0) - - _(send_span.trace_id).must_equal(process_span.trace_id) - _(process_span.parent_span_id).must_equal(send_span.span_id) - _(process_span.attributes['success']).must_equal(true) - end - end - - describe 'when explicitly configure for no propagation' do - let(:config) { { propagation_style: :none, span_naming: :queue } } - - it 'skips link creation and does not create parent/child relationship' do - TestJob.perform_later - - _(process_span.total_recorded_links).must_equal(0) - - _(send_span.trace_id).wont_equal(process_span.trace_id) - _(process_span.parent_span_id).wont_equal(send_span.span_id) - end - - it 'still propagates baggage' do - ctx = OpenTelemetry::Baggage.set_value('testing_baggage', 'it_worked') - OpenTelemetry::Context.with_current(ctx) do - BaggageJob.perform_later - end - - _(process_span.total_recorded_links).must_equal(0) - - _(send_span.trace_id).wont_equal(process_span.trace_id) - _(process_span.parent_span_id).wont_equal(send_span.span_id) - _(process_span.attributes['success']).must_equal(true) - end - end - end - - describe 'active_job callbacks' do - it 'makes the tracing context available in before_perform callbacks' do - CallbacksJob.perform_now - - _(CallbacksJob.context_before).wont_be_nil - _(CallbacksJob.context_before).must_be :valid? - end - - it 'makes the tracing context available in after_perform callbacks' do - CallbacksJob.perform_now - - _(CallbacksJob.context_after).wont_be_nil - _(CallbacksJob.context_after).must_be :valid? - end - end - - describe 'perform.active_job notifications' do - it 'makes the tracing context available in notifications' do - context = nil - callback = proc { context = OpenTelemetry::Trace.current_span.context } - ActiveSupport::Notifications.subscribed(callback, 'perform.active_job') do - TestJob.perform_now - end - - _(context).wont_be_nil - _(context).must_be :valid? - end - end -end diff --git a/instrumentation/active_job/test/instrumentation/active_job/patches/base_test.rb b/instrumentation/active_job/test/instrumentation/active_job/patches/base_test.rb deleted file mode 100644 index c22dc0b8ac..0000000000 --- a/instrumentation/active_job/test/instrumentation/active_job/patches/base_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../lib/opentelemetry/instrumentation/active_job' - -describe OpenTelemetry::Instrumentation::ActiveJob::Patches::Base do - describe 'attr_accessor' do - it 'adds a "metadata" accessor' do - job = TestJob.new - - _(job).must_respond_to :metadata - _(job).must_respond_to :metadata= - end - end - - describe 'serialization / deserialization' do - it 'must handle metadata' do - job = TestJob.new - job.metadata = { 'foo' => 'bar' } - - serialized_job = job.serialize - _(serialized_job.keys).must_include 'metadata' - - job = TestJob.new - job.deserialize(serialized_job) - _(job.metadata).must_equal('foo' => 'bar') - end - - it 'handles jobs queued without instrumentation' do # e.g. during a rolling deployment - job = TestJob.new - serialized_job = job.serialize - serialized_job.delete('metadata') - - job = TestJob.new - job.deserialize(serialized_job) # should not raise an error - end - end -end diff --git a/instrumentation/active_job/test/test_helper.rb b/instrumentation/active_job/test/test_helper.rb deleted file mode 100644 index fadba9f411..0000000000 --- a/instrumentation/active_job/test/test_helper.rb +++ /dev/null @@ -1,82 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 -ENV['OTEL_LOG_LEVEL'] ||= 'fatal' - -require 'active_job' -require 'opentelemetry-instrumentation-active_job' -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' - -require 'minitest/autorun' -require 'webmock/minitest' - -require 'pry' - -class TestJob < ::ActiveJob::Base - def perform; end -end - -class RetryJob < ::ActiveJob::Base - retry_on StandardError, wait: 0, attempts: 2 - - def perform - raise StandardError - end -end - -class ExceptionJob < ::ActiveJob::Base - def perform - raise StandardError, 'This job raises an exception' - end -end - -class BaggageJob < ::ActiveJob::Base - def perform - OpenTelemetry::Trace.current_span['success'] = true if OpenTelemetry::Baggage.value('testing_baggage') == 'it_worked' - end -end - -class PositionalOnlyArgsJob < ::ActiveJob::Base - def perform(arg1, arg2 = 'default'); end -end -class KeywordOnlyArgsJob < ::ActiveJob::Base - def perform(keyword1: 'default', keyword2:); end -end - -class MixedArgsJob < ::ActiveJob::Base - def perform(arg1, arg2, keyword1: 'default', keyword2:); end -end - -class CallbacksJob < TestJob - class << self - attr_accessor :context_before, :context_after - end - - def initialize(*) - self.class.context_before = self.class.context_after = nil - super - end - - before_perform(prepend: true) do - self.class.context_before = OpenTelemetry::Trace.current_span.context - end - - after_perform do - self.class.context_after = OpenTelemetry::Trace.current_span.context - end -end - -::ActiveJob::Base.queue_adapter = :inline -::ActiveJob::Base.logger = Logger.new(File::NULL) - -# global opentelemetry-sdk setup: -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::ActiveJob' - c.add_span_processor span_processor -end diff --git a/instrumentation/active_model_serializers/.rubocop.yml b/instrumentation/active_model_serializers/.rubocop.yml deleted file mode 100644 index 988a7d25f0..0000000000 --- a/instrumentation/active_model_serializers/.rubocop.yml +++ /dev/null @@ -1,5 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-active_model_serializers.rb" diff --git a/instrumentation/active_model_serializers/.yardopts b/instrumentation/active_model_serializers/.yardopts deleted file mode 100644 index 5308b12871..0000000000 --- a/instrumentation/active_model_serializers/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Active Model Serializers Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/active_model_serializers/Appraisals b/instrumentation/active_model_serializers/Appraisals deleted file mode 100644 index a709833ce3..0000000000 --- a/instrumentation/active_model_serializers/Appraisals +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -appraise 'active_model_serializers_0.10' do - gem 'active_model_serializers', '~> 0.10.0' -end diff --git a/instrumentation/active_model_serializers/CHANGELOG.md b/instrumentation/active_model_serializers/CHANGELOG.md deleted file mode 100644 index 4e8f8068aa..0000000000 --- a/instrumentation/active_model_serializers/CHANGELOG.md +++ /dev/null @@ -1,74 +0,0 @@ -# Release History: opentelemetry-instrumentation-active_model_serializers - -### v0.19.0 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Broken test file requirements - -### v0.18.5 / 2022-05-02 - -* FIXED: `ActiveSupport` constant conflict in Active Model Serializers instrumentation -* FIXED: RubyGems Fallback - -### v0.18.4 / 2021-12-02 - -* (No significant changes) - -### v0.18.3 / 2021-09-29 - -* (No significant changes) - -### v0.18.2 / 2021-08-12 - -* (No significant changes) - -### v0.18.1 / 2021-06-23 - -* (No significant changes) - -### v0.18.0 / 2021-05-21 - -* ADDED: Updated API depedency for 1.0.0.rc1 - -### v0.17.0 / 2021-04-22 - -* FIXED: Refactor propagators to add #fields - -### v0.16.0 / 2021-03-17 - -* FIXED: Example scripts now reference local common lib -* DOCS: Replace Gitter with GitHub Discussions - -### v0.15.0 / 2021-02-18 - -* (No significant changes) - -### v0.14.0 / 2021-02-03 - -* BREAKING CHANGE: Replace getter and setter callables and remove rack specific propagators - -* ADDED: Replace getter and setter callables and remove rack specific propagators - -### v0.13.0 / 2021-01-29 - -* (No significant changes) - -### v0.12.0 / 2020-12-24 - -* (No significant changes) - -### v0.11.0 / 2020-12-11 - -* FIXED: Copyright comments to not reference year - -### v0.10.1 / 2020-12-09 - -* FIXED: Active_model_serializers installer - -### v0.10.0 / 2020-12-03 - -* (No significant changes) - -### v0.9.0 / 2020-11-03 - -* Initial release of Active Model Serializers instrumenter (ported from Datadog) diff --git a/instrumentation/active_model_serializers/Gemfile b/instrumentation/active_model_serializers/Gemfile deleted file mode 100644 index 2baf57ac47..0000000000 --- a/instrumentation/active_model_serializers/Gemfile +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :test do - gem 'opentelemetry-instrumentation-base', path: '../base' -end diff --git a/instrumentation/active_model_serializers/LICENSE b/instrumentation/active_model_serializers/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/active_model_serializers/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/active_model_serializers/README.md b/instrumentation/active_model_serializers/README.md deleted file mode 100644 index dc155c434f..0000000000 --- a/instrumentation/active_model_serializers/README.md +++ /dev/null @@ -1,53 +0,0 @@ -# OpenTelemetry Active Model Serializers Instrumentation - -The OpenTelemetry Active Model Serializers gem is a community maintained instrumentation for [Active Model Serializers][active_model_serializers-home]. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-active_model_serializers -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-active_model_serializers` in your `Gemfile`. - -## Usage - -To install the instrumentation, call `use` with the name of the instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::ActiveModelSerializers' -end -``` - -Alternatively, you can also call `use_all` to install all the available instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` - -## Examples - -Example usage of active_model_serializers can be seen in the `./example/active_model_serializers.rb` file [here](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/instrumentation/active_model_serializers/example/active_model_serializers.rb) - -## How can I get involved? - -The `opentelemetry-instrumentation-active_model_serializers` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -Apache 2.0 license. See [LICENSE][license-github] for more information. - -[active_model_serializers-home]: https://github.com/rails-api/active_model_serializers -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/instrumentation/active_model_serializers/Rakefile b/instrumentation/active_model_serializers/Rakefile deleted file mode 100644 index 1a64ba842e..0000000000 --- a/instrumentation/active_model_serializers/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/active_model_serializers/example/Gemfile b/instrumentation/active_model_serializers/example/Gemfile deleted file mode 100644 index f2e0691653..0000000000 --- a/instrumentation/active_model_serializers/example/Gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -source 'https://rubygems.org' - -gem 'active_model_serializers' -gem 'opentelemetry-api' -gem 'opentelemetry-common' -gem 'opentelemetry-instrumentation-active_model_serializers' -gem 'opentelemetry-sdk' diff --git a/instrumentation/active_model_serializers/example/active_model_serializers.rb b/instrumentation/active_model_serializers/example/active_model_serializers.rb deleted file mode 100644 index d145f240de..0000000000 --- a/instrumentation/active_model_serializers/example/active_model_serializers.rb +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'rubygems' -require 'bundler/setup' - -Bundler.require - -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::ActiveModelSerializers' -end - -class TestModel < ActiveModelSerializers::Model #:nodoc: - attr_accessor :name -end - -class TestModelSerializer < ActiveModel::Serializer #:nodoc: - attributes :name -end - -model = TestModel.new(name: 'test object') - -ActiveModelSerializers::SerializableResource.new(model).serializable_hash diff --git a/instrumentation/active_model_serializers/lib/opentelemetry-instrumentation-active_model_serializers.rb b/instrumentation/active_model_serializers/lib/opentelemetry-instrumentation-active_model_serializers.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/active_model_serializers/lib/opentelemetry-instrumentation-active_model_serializers.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/active_model_serializers/lib/opentelemetry/instrumentation.rb b/instrumentation/active_model_serializers/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index 950a398757..0000000000 --- a/instrumentation/active_model_serializers/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # "Instrumentation" are specified by - # https://github.com/open-telemetry/opentelemetry-specification/blob/784635d01d8690c8f5fcd1f55bdbc8a13cf2f4f2/specification/glossary.md#instrumentation-library - # - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/active_model_serializers' diff --git a/instrumentation/active_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers.rb b/instrumentation/active_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers.rb deleted file mode 100644 index 27a652aaa3..0000000000 --- a/instrumentation/active_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the ActiveModelSerializers gem - module ActiveModelSerializers - end - end -end - -require_relative './active_model_serializers/instrumentation' -require_relative './active_model_serializers/version' diff --git a/instrumentation/active_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers/event_handler.rb b/instrumentation/active_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers/event_handler.rb deleted file mode 100644 index 81bcfd9bbd..0000000000 --- a/instrumentation/active_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers/event_handler.rb +++ /dev/null @@ -1,48 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module ActiveModelSerializers - # Event handler singleton for ActiveModelSerializers - module EventHandler - extend self - - def handle(start_timestamp, end_timestamp, payload) - tracer.start_span(span_name(payload), - start_timestamp: start_timestamp, - attributes: build_attributes(payload), - kind: :internal) - .finish(end_timestamp: end_timestamp) - end - - protected - - def span_name(payload) - "#{demodulize(payload[:serializer].name)} render" - end - - def build_attributes(payload) - { - 'serializer.name' => payload[:serializer].name, - 'serializer.renderer' => 'active_model_serializers', - 'serializer.format' => payload[:adapter]&.class&.name || 'default' - } - end - - def tracer - ActiveModelSerializers::Instrumentation.instance.tracer - end - - def demodulize(string) - string = string.to_s - i = string.rindex('::') - i ? string[(i + 2)..-1] : string - end - end - end - end -end diff --git a/instrumentation/active_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers/instrumentation.rb b/instrumentation/active_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers/instrumentation.rb deleted file mode 100644 index 453f9e0926..0000000000 --- a/instrumentation/active_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers/instrumentation.rb +++ /dev/null @@ -1,49 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module ActiveModelSerializers - # Instrumentation class that detects and installs the ActiveModelSerializers instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - MINIMUM_VERSION = Gem::Version.new('0.10.0') - - install do |_config| - require_dependencies - register_event_handler - end - - present do - !defined?(::ActiveModelSerializers).nil? - end - - compatible do - !defined?(::ActiveSupport::Notifications).nil? && gem_version >= MINIMUM_VERSION - end - - private - - def gem_version - Gem::Version.new(::ActiveModel::Serializer::VERSION) - end - - def require_dependencies - require_relative 'event_handler' - end - - def register_event_handler - ::ActiveSupport::Notifications.subscribe(event_name) do |_name, start, finish, _id, payload| - EventHandler.handle(start, finish, payload) - end - end - - def event_name - 'render.active_model_serializers' - end - end - end - end -end diff --git a/instrumentation/active_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers/version.rb b/instrumentation/active_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers/version.rb deleted file mode 100644 index 6979d9ae11..0000000000 --- a/instrumentation/active_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module ActiveModelSerializers - VERSION = '0.19.0' - end - end -end diff --git a/instrumentation/active_model_serializers/opentelemetry-instrumentation-active_model_serializers.gemspec b/instrumentation/active_model_serializers/opentelemetry-instrumentation-active_model_serializers.gemspec deleted file mode 100644 index f8d83d38a6..0000000000 --- a/instrumentation/active_model_serializers/opentelemetry-instrumentation-active_model_serializers.gemspec +++ /dev/null @@ -1,50 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/active_model_serializers/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-active_model_serializers' - spec.version = OpenTelemetry::Instrumentation::ActiveModelSerializers::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'Active Model Serializers instrumentation for the OpenTelemetry framework' - spec.description = 'Active Model Serializers instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.21.0' - - spec.add_development_dependency 'active_model_serializers', '>= 0.10.0' - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'rspec-mocks' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'webmock', '~> 3.7.6' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-active_model_serializers/v#{OpenTelemetry::Instrumentation::ActiveModelSerializers::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/active_model_serializers' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-active_model_serializers/v#{OpenTelemetry::Instrumentation::ActiveModelSerializers::VERSION}" - end -end diff --git a/instrumentation/active_model_serializers/test/.rubocop.yml b/instrumentation/active_model_serializers/test/.rubocop.yml deleted file mode 100644 index dd94258585..0000000000 --- a/instrumentation/active_model_serializers/test/.rubocop.yml +++ /dev/null @@ -1,4 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false diff --git a/instrumentation/active_model_serializers/test/opentelemetry/instrumentation/active_model_serializers/event_handler_test.rb b/instrumentation/active_model_serializers/test/opentelemetry/instrumentation/active_model_serializers/event_handler_test.rb deleted file mode 100644 index d029af5d57..0000000000 --- a/instrumentation/active_model_serializers/test/opentelemetry/instrumentation/active_model_serializers/event_handler_test.rb +++ /dev/null @@ -1,63 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative '../../../test_helper' - -# require instrumentation so we do not have to depend on the install hook being called -require_relative '../../../../lib/opentelemetry/instrumentation/active_model_serializers/event_handler' - -describe OpenTelemetry::Instrumentation::ActiveModelSerializers::EventHandler do - let(:instrumentation) { OpenTelemetry::Instrumentation::ActiveModelSerializers::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:span) { exporter.finished_spans.first } - let(:model) { TestHelper::Model.new(name: 'test object') } - - before do - instrumentation.install - exporter.reset - - # this is currently a noop but this will future proof the test - @orig_propagation = OpenTelemetry.propagation - propagator = OpenTelemetry::Trace::Propagation::TraceContext.text_map_propagator - OpenTelemetry.propagation = propagator - end - - after do - OpenTelemetry.propagation = @orig_propagation - end - - describe 'when adapter is set' do - let(:render) { ActiveModelSerializers::SerializableResource.new(model).serializable_hash } - - it 'is expected to send a span' do - _(exporter.finished_spans).must_equal [] - render - _(exporter.finished_spans.size).must_equal 1 - - _(span).must_be_kind_of OpenTelemetry::SDK::Trace::SpanData - _(span.name).must_equal 'ModelSerializer render' - _(span.attributes['serializer.name']).must_equal 'TestHelper::ModelSerializer' - _(span.attributes['serializer.renderer']).must_equal 'active_model_serializers' - _(span.attributes['serializer.format']).must_equal 'ActiveModelSerializers::Adapter::Attributes' - end - end - - describe 'when adapter is nil' do - let(:render) { ActiveModelSerializers::SerializableResource.new(model, adapter: nil).serializable_hash } - - it 'is expected to send a span with adapter tag equal to the model name' do - _(exporter.finished_spans).must_equal [] - render - _(exporter.finished_spans.size).must_equal 1 - - _(span).must_be_kind_of OpenTelemetry::SDK::Trace::SpanData - _(span.name).must_equal 'ModelSerializer render' - _(span.attributes['serializer.name']).must_equal 'TestHelper::ModelSerializer' - _(span.attributes['serializer.renderer']).must_equal 'active_model_serializers' - _(span.attributes['serializer.format']).must_equal 'TestHelper::Model' - end - end -end diff --git a/instrumentation/active_model_serializers/test/opentelemetry/instrumentation/active_model_serializers_test.rb b/instrumentation/active_model_serializers/test/opentelemetry/instrumentation/active_model_serializers_test.rb deleted file mode 100644 index 6348a417da..0000000000 --- a/instrumentation/active_model_serializers/test/opentelemetry/instrumentation/active_model_serializers_test.rb +++ /dev/null @@ -1,47 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative '../../test_helper' - -describe OpenTelemetry::Instrumentation::ActiveModelSerializers do - let(:instrumentation) { OpenTelemetry::Instrumentation::ActiveModelSerializers::Instrumentation.instance } - let(:exporter) { EXPORTER } - - before do - instrumentation.install - exporter.reset - end - - describe 'present' do - it 'when active_model_serializers gem installed' do - _(instrumentation.present?).must_equal true - end - - it 'when active_model_serializers gem not installed' do - hide_const('::ActiveModelSerializers') - _(instrumentation.present?).must_equal false - end - end - - describe 'compatible' do - it 'when older gem version installed' do - stub_const('::ActiveModel::Serializer::VERSION', '0.9.4') - _(instrumentation.compatible?).must_equal false - end - - it 'when future gem version installed' do - _(instrumentation.compatible?).must_equal true - end - end - - describe 'install' do - it 'subscribes to ActiveSupport::Notifications' do - subscriptions = ActiveSupport::Notifications.notifier.instance_variable_get(:'@string_subscribers') - subscriptions = subscriptions['render.active_model_serializers'] - assert(subscriptions.detect { |s| s.is_a?(ActiveSupport::Notifications::Fanout::Subscribers::Timed) }) - end - end -end diff --git a/instrumentation/active_model_serializers/test/test_helper.rb b/instrumentation/active_model_serializers/test/test_helper.rb deleted file mode 100644 index a98b4ef4d4..0000000000 --- a/instrumentation/active_model_serializers/test/test_helper.rb +++ /dev/null @@ -1,38 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'active_support/all' -require 'active_model_serializers' - -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' - -require 'minitest/autorun' -require 'rspec/mocks/minitest_integration' -require 'webmock/minitest' - -require_relative '../lib/opentelemetry-instrumentation-active_model_serializers' - -# disable logging -ActiveModelSerializers.logger.level = Logger::Severity::UNKNOWN - -# global opentelemetry-sdk setup: -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry::SDK.configure do |c| - c.add_span_processor span_processor -end - -module TestHelper - class Model < ActiveModelSerializers::Model - attr_accessor :name - end - - class ModelSerializer < ActiveModel::Serializer - attributes :name - end -end diff --git a/instrumentation/active_record/.rubocop.yml b/instrumentation/active_record/.rubocop.yml deleted file mode 100644 index d4488cd153..0000000000 --- a/instrumentation/active_record/.rubocop.yml +++ /dev/null @@ -1,5 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-active_record.rb" diff --git a/instrumentation/active_record/.yardopts b/instrumentation/active_record/.yardopts deleted file mode 100644 index 8997874c3e..0000000000 --- a/instrumentation/active_record/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Active Record Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/active_record/Appraisals b/instrumentation/active_record/Appraisals deleted file mode 100644 index 5af31f8ff7..0000000000 --- a/instrumentation/active_record/Appraisals +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -appraise 'activerecord-6.1' do - gem 'activerecord', '~> 6.1.0' -end - -appraise 'activerecord-6.0' do - gem 'activerecord', '~> 6.0.0' -end - -# Rails 5.2 is not compatible with Ruby 3.0 -# https://github.com/rails/rails/issues/40938 -if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3') - appraise 'activerecord-5.2' do - gem 'activerecord', '~> 5.2.0' - end -end - -if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.0') - appraise 'activerecord-7.0' do - gem 'activerecord', '~> 7.0.0' - end -end diff --git a/instrumentation/active_record/CHANGELOG.md b/instrumentation/active_record/CHANGELOG.md deleted file mode 100644 index 9544e259e4..0000000000 --- a/instrumentation/active_record/CHANGELOG.md +++ /dev/null @@ -1,32 +0,0 @@ -# Release History: opentelemetry-instrumentation-active_record - -### v0.4.0 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Broken test file requirements - -### v0.3.0 / 2022-05-02 - -* ADDED: Make ActiveRecord 7 compatible -* FIXED: RubyGems Fallback - -### v0.2.2 / 2021-12-01 - -* FIXED: Add max supported version for active record - -### v0.2.1 / 2021-09-29 - -* (No significant changes) - -### v0.2.0 / 2021-09-29 - -* ADDED: Trace update_all and delete_all calls in ActiveRecord -* FIXED: Remove Active Record instantiation patch - -### v0.1.1 / 2021-08-12 - -* (No significant changes) - -### v0.1.0 / 2021-07-08 - -* Initial release, adds instrumentation patches to querying and persistence methods. diff --git a/instrumentation/active_record/Gemfile b/instrumentation/active_record/Gemfile deleted file mode 100644 index 2005841090..0000000000 --- a/instrumentation/active_record/Gemfile +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :test do - gem 'byebug' - gem 'opentelemetry-instrumentation-base', path: '../base' - gem 'pry-byebug' - gem 'sqlite3-ruby' -end diff --git a/instrumentation/active_record/LICENSE b/instrumentation/active_record/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/active_record/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/active_record/README.md b/instrumentation/active_record/README.md deleted file mode 100644 index 95529ed112..0000000000 --- a/instrumentation/active_record/README.md +++ /dev/null @@ -1,52 +0,0 @@ -# OpenTelemetry ActiveRecord Instrumentation - -The Active Record instrumentation is a community-maintained instrumentation for the Active Record portion of the [Ruby on Rails][rails-home] web-application framework. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-active_record -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-active_record` in your `Gemfile`. - -## Usage - -To use the instrumentation, call `use` with the name of the instrumentation: - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::ActiveRecord' -end -``` - -Alternatively, you can also call `use_all` to install all the available instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` - -## Examples - -Example usage can be seen in the `./example/trace_demonstration.rb` file [here](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/instrumentation/active_record/example/trace_demonstration.rb) - -## How can I get involved? - -The `opentelemetry-instrumentation-active_record` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -The `opentelemetry-instrumentation-active_record` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information. - -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/instrumentation/active_record/Rakefile b/instrumentation/active_record/Rakefile deleted file mode 100644 index 1a64ba842e..0000000000 --- a/instrumentation/active_record/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/active_record/example/trace_demonstration.rb b/instrumentation/active_record/example/trace_demonstration.rb deleted file mode 100644 index 0573d56a59..0000000000 --- a/instrumentation/active_record/example/trace_demonstration.rb +++ /dev/null @@ -1,49 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# Inspired by the bug report template for Active Record -# https://github.com/rails/rails/blob/v6.0.0/guides/bug_report_templates/active_record_gem.rb - -require 'bundler/inline' - -gemfile(true) do - source 'https://rubygems.org' - gem 'activerecord' - gem 'sqlite3' - gem 'opentelemetry-sdk' - gem 'opentelemetry-instrumentation-active_record' -end - -require 'active_record' - -ENV['OTEL_TRACES_EXPORTER'] = 'console' -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::ActiveRecord' -end - -ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:') -ActiveRecord::Base.logger = Logger.new(STDOUT) -ActiveRecord::Schema.define do - create_table :posts, force: true do |t| - end - - create_table :comments, force: true do |t| - t.integer :post_id - end -end - -# Simple AR model -class Post < ActiveRecord::Base - has_many :comments -end - -# Simple AR model -class Comment < ActiveRecord::Base - belongs_to :post -end - -Post.create -Comment.create diff --git a/instrumentation/active_record/lib/opentelemetry-instrumentation-active_record.rb b/instrumentation/active_record/lib/opentelemetry-instrumentation-active_record.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/active_record/lib/opentelemetry-instrumentation-active_record.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/active_record/lib/opentelemetry/instrumentation.rb b/instrumentation/active_record/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index 7c3b49a871..0000000000 --- a/instrumentation/active_record/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/active_record' diff --git a/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record.rb b/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record.rb deleted file mode 100644 index bbed1ee591..0000000000 --- a/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the ActiveRecord gem - module ActiveRecord - end - end -end - -require_relative './active_record/instrumentation' -require_relative './active_record/version' diff --git a/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/instrumentation.rb b/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/instrumentation.rb deleted file mode 100644 index 4561d9f065..0000000000 --- a/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/instrumentation.rb +++ /dev/null @@ -1,75 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module ActiveRecord - # The Instrumentation class contains logic to detect and install the ActiveRecord instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - MINIMUM_VERSION = Gem::Version.new('5.2.0') - MAX_MAJOR_VERSION = 7 - - install do |_config| - require_dependencies - patch - end - - present do - defined?(::ActiveRecord) - end - - compatible do - # We know that releases after MAX_MAJOR_VERSION are unstable so we - # check the major version number of the gem installed to make sure we - # do not install on a pre-release or full release of the latest - # if it exceeds the MAX_MAJOR_VERSION version. - gem_version >= MINIMUM_VERSION && gem_version.segments[0] <= MAX_MAJOR_VERSION - end - - private - - def insert_class_methods_supported? - gem_version >= Gem::Version.new('6.0.0') - end - - def gem_version - ::ActiveRecord.version - end - - def patch - # The original approach taken here was to patch each individual module of interest. - # However the patches are applied too late in some applications and as a result the - # Active Record models will not have the instrumentation patches applied. - # Prepending the ActiveRecord::Base class is more consistent in applying - # the patches regardless of initialization order. - # - # Modules to prepend to ActiveRecord::Base are still grouped by the source - # module that they are defined in. - # Example: Patches::PersistenceClassMethods refers to https://github.com/rails/rails/blob/v6.1.0/activerecord/lib/active_record/persistence.rb#L10 - ::ActiveRecord::Base.prepend(Patches::Querying) - ::ActiveRecord::Base.prepend(Patches::Persistence) - ::ActiveRecord::Base.prepend(Patches::PersistenceClassMethods) - ::ActiveRecord::Base.prepend(Patches::PersistenceInsertClassMethods) if insert_class_methods_supported? - ::ActiveRecord::Base.prepend(Patches::TransactionsClassMethods) - ::ActiveRecord::Base.prepend(Patches::Validations) - - ::ActiveRecord::Relation.prepend(Patches::RelationPersistence) - end - - def require_dependencies - require 'ruby2_keywords' - require_relative 'patches/querying' - require_relative 'patches/persistence' - require_relative 'patches/persistence_class_methods' - require_relative 'patches/persistence_insert_class_methods' if insert_class_methods_supported? - require_relative 'patches/transactions_class_methods' - require_relative 'patches/validations' - require_relative 'patches/relation_persistence' - end - end - end - end -end diff --git a/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/persistence.rb b/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/persistence.rb deleted file mode 100644 index ef57c2d068..0000000000 --- a/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/persistence.rb +++ /dev/null @@ -1,131 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module ActiveRecord - module Patches - # Module to prepend to ActiveRecord::Base for instrumentation - # contains the ActiveRecord::Persistence methods to be patched - module Persistence - def delete - tracer.in_span("#{self.class}#delete") do - super - end - end - - def destroy - tracer.in_span("#{self.class}#destroy") do - super - end - end - - def destroy! - tracer.in_span("#{self.class}#destroy!") do - super - end - end - - def becomes(klass) - tracer.in_span("#{self.class}#becomes") do - super - end - end - - def becomes!(klass) - tracer.in_span("#{self.class}#becomes!") do - super - end - end - - def update_attribute(name, value) - tracer.in_span("#{self.class}#update_attribute") do - super - end - end - - def update(attributes) - tracer.in_span("#{self.class}#update") do - super - end - end - - def update!(attributes) - tracer.in_span("#{self.class}#update!") do - super - end - end - - def update_column(name, value) - tracer.in_span("#{self.class}#update_column") do - super - end - end - - def update_columns(attributes) - tracer.in_span("#{self.class}#update_columns") do - super - end - end - - def increment(attribute, by = 1) - tracer.in_span("#{self.class}#increment") do - super - end - end - - def increment!(attribute, by = 1, touch: nil) - tracer.in_span("#{self.class}#increment!") do - super - end - end - - def decrement(attribute, by = 1) - tracer.in_span("#{self.class}#decrement") do - super - end - end - - def decrement!(attribute, by = 1, touch: nil) - tracer.in_span("#{self.class}#decrement!") do - super - end - end - - def toggle(attribute) - tracer.in_span("#{self.class}#toggle") do - super - end - end - - def toggle!(attribute) - tracer.in_span("#{self.class}#toggle!") do - super - end - end - - def reload(options = nil) - tracer.in_span("#{self.class}#reload") do - super - end - end - - def touch(*names, time: nil) - tracer.in_span("#{self.class}#touch") do - super - end - end - - private - - def tracer - ActiveRecord::Instrumentation.instance.tracer - end - end - end - end - end -end diff --git a/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/persistence_class_methods.rb b/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/persistence_class_methods.rb deleted file mode 100644 index f29b9d316c..0000000000 --- a/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/persistence_class_methods.rb +++ /dev/null @@ -1,61 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module ActiveRecord - module Patches - # Module to prepend to ActiveRecord::Base for instrumentation - module PersistenceClassMethods - def self.prepended(base) - class << base - prepend ClassMethods - end - end - - # Contains ActiveRecord::Persistence::ClassMethods to be patched - module ClassMethods - def create(attributes = nil, &block) - tracer.in_span("#{self}.create") do - super - end - end - - def create!(attributes = nil, &block) - tracer.in_span("#{self}.create!") do - super - end - end - - def update(id = :all, attributes) # rubocop:disable Style/OptionalArguments - tracer.in_span("#{self}.update") do - super - end - end - - def destroy(id) - tracer.in_span("#{self}.destroy") do - super - end - end - - def delete(id_or_array) - tracer.in_span("#{self}.delete") do - super - end - end - - private - - def tracer - ActiveRecord::Instrumentation.instance.tracer - end - end - end - end - end - end -end diff --git a/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/persistence_insert_class_methods.rb b/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/persistence_insert_class_methods.rb deleted file mode 100644 index 6354ee0bef..0000000000 --- a/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/persistence_insert_class_methods.rb +++ /dev/null @@ -1,67 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 -module OpenTelemetry - module Instrumentation - module ActiveRecord - module Patches - # Module to prepend to ActiveRecord::Base for instrumentating - # insert/upsert class methods added in Rails 6.0 - module PersistenceInsertClassMethods - def self.prepended(base) - class << base - prepend ClassMethods - end - end - - # Contains ActiveRecord::Persistence::ClassMethods to be patched - module ClassMethods - ruby2_keywords def insert(*args) - tracer.in_span("#{self}.insert") do - super(*args) - end - end - - ruby2_keywords def insert_all(*args) - tracer.in_span("#{self}.insert_all") do - super(*args) - end - end - - ruby2_keywords def insert!(*args) - tracer.in_span("#{self}.insert!") do - super(*args) - end - end - - ruby2_keywords def insert_all!(*args) - tracer.in_span("#{self}.insert_all!") do - super(*args) - end - end - - ruby2_keywords def upsert(*args) - tracer.in_span("#{self}.upsert") do - super(*args) - end - end - - ruby2_keywords def upsert_all(*args) - tracer.in_span("#{self}.upsert_all") do - super(*args) - end - end - - private - - def tracer - ActiveRecord::Instrumentation.instance.tracer - end - end - end - end - end - end -end diff --git a/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/querying.rb b/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/querying.rb deleted file mode 100644 index d359c31ffd..0000000000 --- a/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/querying.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module ActiveRecord - module Patches - # Module to prepend to ActiveRecord::Base for instrumentation - module Querying - def self.prepended(base) - class << base - prepend ClassMethods - end - end - - # Contains ActiveRecord::Querying to be patched - module ClassMethods - def find_by_sql(sql, binds = [], preparable: nil, &block) - tracer.in_span("#{self}.find_by_sql") do - super - end - end - - private - - def tracer - ActiveRecord::Instrumentation.instance.tracer - end - end - end - end - end - end -end diff --git a/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/relation_persistence.rb b/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/relation_persistence.rb deleted file mode 100644 index ceb445913d..0000000000 --- a/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/relation_persistence.rb +++ /dev/null @@ -1,34 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module ActiveRecord - module Patches - # Module to prepend to ActiveRecord::Relation for instrumentation - module RelationPersistence - def update_all(*) - tracer.in_span("#{model.name}.update_all") do - super - end - end - - def delete_all(*) - tracer.in_span("#{model.name}.delete_all") do - super - end - end - - private - - def tracer - ActiveRecord::Instrumentation.instance.tracer - end - end - end - end - end -end diff --git a/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/transactions_class_methods.rb b/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/transactions_class_methods.rb deleted file mode 100644 index 37b3b576ac..0000000000 --- a/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/transactions_class_methods.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module ActiveRecord - module Patches - # Module to prepend to ActiveRecord::Base for instrumentation - module TransactionsClassMethods - def self.prepended(base) - class << base - prepend ClassMethods - end - end - - # Contains ActiveRecord::Transactions::ClassMethods to be patched - module ClassMethods - def transaction(**options, &block) - tracer.in_span("#{self}.transaction") do - super - end - end - - private - - def tracer - ActiveRecord::Instrumentation.instance.tracer - end - end - end - end - end - end -end diff --git a/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/validations.rb b/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/validations.rb deleted file mode 100644 index 999997734a..0000000000 --- a/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/validations.rb +++ /dev/null @@ -1,38 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module ActiveRecord - module Patches - # Module to prepend to ActiveRecord::Base for instrumentation - # We patch these methods because they either raise, or call - # the super implementation in persistence.rb - # https://github.com/rails/rails/blob/v5.2.4.5/activerecord/lib/active_record/validations.rb#L42-L53 - # Contains the ActiveRecord::Validations methods to be patched - module Validations - def save(**options) - tracer.in_span("#{self.class}#save") do - super - end - end - - def save!(**options) - tracer.in_span("#{self.class}#save!") do - super - end - end - - private - - def tracer - ActiveRecord::Instrumentation.instance.tracer - end - end - end - end - end -end diff --git a/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/version.rb b/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/version.rb deleted file mode 100644 index 999a86b9c7..0000000000 --- a/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module ActiveRecord - VERSION = '0.4.0' - end - end -end diff --git a/instrumentation/active_record/opentelemetry-instrumentation-active_record.gemspec b/instrumentation/active_record/opentelemetry-instrumentation-active_record.gemspec deleted file mode 100644 index ee9a4ff0ae..0000000000 --- a/instrumentation/active_record/opentelemetry-instrumentation-active_record.gemspec +++ /dev/null @@ -1,51 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/active_record/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-active_record' - spec.version = OpenTelemetry::Instrumentation::ActiveRecord::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'ActiveRecord instrumentation for the OpenTelemetry framework' - spec.description = 'ActiveRecord instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.21.0' - spec.add_dependency 'ruby2_keywords' - - spec.add_development_dependency 'activerecord' - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'rake', '~> 12.3.3' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'webmock', '~> 3.7.6' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-active_record/v#{OpenTelemetry::Instrumentation::ActiveRecord::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/active_record' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-active_record/v#{OpenTelemetry::Instrumentation::ActiveRecord::VERSION}" - end -end diff --git a/instrumentation/active_record/test/.rubocop.yml b/instrumentation/active_record/test/.rubocop.yml deleted file mode 100644 index b8d2f198c3..0000000000 --- a/instrumentation/active_record/test/.rubocop.yml +++ /dev/null @@ -1,6 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false -Style/BracesAroundHashParameters: - Enabled: false diff --git a/instrumentation/active_record/test/instrumentation/active_record/instrumentation_test.rb b/instrumentation/active_record/test/instrumentation/active_record/instrumentation_test.rb deleted file mode 100644 index 546ac39a97..0000000000 --- a/instrumentation/active_record/test/instrumentation/active_record/instrumentation_test.rb +++ /dev/null @@ -1,54 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../lib/opentelemetry/instrumentation/active_record' - -describe OpenTelemetry::Instrumentation::ActiveRecord do - let(:instrumentation) { OpenTelemetry::Instrumentation::ActiveRecord::Instrumentation.instance } - let(:minimum_version) { OpenTelemetry::Instrumentation::ActiveRecord::Instrumentation::MINIMUM_VERSION } - - it 'has #name' do - _(instrumentation.name).must_equal 'OpenTelemetry::Instrumentation::ActiveRecord' - end - - it 'has #version' do - _(instrumentation.version).wont_be_nil - _(instrumentation.version).wont_be_empty - end - - describe 'compatible' do - it 'when a version below the minimum supported gem version is installed' do - ActiveRecord.stub(:version, Gem::Version.new('4.2.0')) do - _(instrumentation.compatible?).must_equal false - end - end - - it 'when a version above the maximum supported gem version is installed' do - ActiveRecord.stub(:version, Gem::Version.new('8.0.0')) do - _(instrumentation.compatible?).must_equal false - end - end - - it 'it treats pre releases as being equivalent to a full release' do - ActiveRecord.stub(:version, Gem::Version.new('8.0.0.alpha')) do - _(instrumentation.compatible?).must_equal false - end - end - - it 'when supported gem version installed' do - _(instrumentation.compatible?).must_equal true - end - end - - describe '#install' do - it 'accepts argument' do - _(instrumentation.install({})).must_equal(true) - instrumentation.instance_variable_set(:@installed, false) - end - end -end diff --git a/instrumentation/active_record/test/instrumentation/active_record/patches/persistence_class_methods_test.rb b/instrumentation/active_record/test/instrumentation/active_record/patches/persistence_class_methods_test.rb deleted file mode 100644 index e68fe96930..0000000000 --- a/instrumentation/active_record/test/instrumentation/active_record/patches/persistence_class_methods_test.rb +++ /dev/null @@ -1,70 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../lib/opentelemetry/instrumentation/active_record' -require_relative '../../../../lib/opentelemetry/instrumentation/active_record/patches/persistence_class_methods' - -describe OpenTelemetry::Instrumentation::ActiveRecord::Patches::PersistenceClassMethods do - let(:exporter) { EXPORTER } - let(:spans) { exporter.finished_spans } - - before { exporter.reset } - - describe '.create' do - it 'traces' do - User.create - create_span = spans.find { |s| s.name == 'User.create' } - _(create_span).wont_be_nil - end - end - - describe '.create!' do - it 'traces' do - User.create! - create_span = spans.find { |s| s.name == 'User.create!' } - _(create_span).wont_be_nil - end - - it 'adds an exception event if it raises' do - _(-> { User.create!(attreeboot: 1) }).must_raise(ActiveModel::UnknownAttributeError) - - create_span = spans.find { |s| s.name == 'User.create!' } - _(create_span).wont_be_nil - create_span_event = create_span.events.first - _(create_span_event.attributes['exception.type']).must_equal('ActiveModel::UnknownAttributeError') - _(create_span_event.attributes['exception.message']).must_include('unknown attribute \'attreeboot\' for User.') - end - end - - describe '.update' do - it 'traces' do - last_user = User.create - User.update(last_user.id, updated_at: Time.now) - update_span = spans.find { |s| s.name == 'User.update' } - _(update_span).wont_be_nil - end - end - - describe '.destroy' do - it 'traces' do - new_user = User.create - User.destroy(new_user.id) - destroy_span = spans.find { |s| s.name == 'User.destroy' } - _(destroy_span).wont_be_nil - end - end - - describe '.delete' do - it 'traces' do - new_user = User.create - User.delete(new_user.id) - delete_span = spans.find { |s| s.name == 'User.delete' } - _(delete_span).wont_be_nil - end - end -end diff --git a/instrumentation/active_record/test/instrumentation/active_record/patches/persistence_insert_class_methods_test.rb b/instrumentation/active_record/test/instrumentation/active_record/patches/persistence_insert_class_methods_test.rb deleted file mode 100644 index 6deb94fb10..0000000000 --- a/instrumentation/active_record/test/instrumentation/active_record/patches/persistence_insert_class_methods_test.rb +++ /dev/null @@ -1,68 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../lib/opentelemetry/instrumentation/active_record' -require_relative '../../../../lib/opentelemetry/instrumentation/active_record/patches/persistence_insert_class_methods' - -describe OpenTelemetry::Instrumentation::ActiveRecord::Patches::PersistenceInsertClassMethods do - let(:exporter) { EXPORTER } - let(:spans) { exporter.finished_spans } - - before do - exporter.reset - skip if Gem.loaded_specs['activerecord'].version < Gem::Version.new('6.0.0') - end - - describe '.insert' do - it 'traces' do - User.insert({ updated_at: Time.current, created_at: Time.current }) - insert_span = spans.find { |s| s.name == 'User.insert' } - _(insert_span).wont_be_nil - end - end - - describe '.insert_all' do - it 'traces' do - User.insert_all([{ updated_at: Time.current, created_at: Time.current }]) - insert_all_span = spans.find { |s| s.name == 'User.insert_all' } - _(insert_all_span).wont_be_nil - end - end - - describe '.insert!' do - it 'traces' do - User.insert!({ updated_at: Time.current, created_at: Time.current }) - insert_span = spans.find { |s| s.name == 'User.insert!' } - _(insert_span).wont_be_nil - end - end - - describe '.insert_all!' do - it 'traces' do - User.insert_all!([{ updated_at: Time.current, created_at: Time.current }]) - insert_all_span = spans.find { |s| s.name == 'User.insert_all!' } - _(insert_all_span).wont_be_nil - end - end - - describe '.upsert' do - it 'traces' do - User.upsert({ updated_at: Time.current, created_at: Time.current }) - upsert_span = spans.find { |s| s.name == 'User.upsert' } - _(upsert_span).wont_be_nil - end - end - - describe '.upsert_all' do - it 'traces' do - User.upsert_all([{ updated_at: Time.current, created_at: Time.current }]) - upsert_all_span = spans.find { |s| s.name == 'User.upsert_all' } - _(upsert_all_span).wont_be_nil - end - end -end diff --git a/instrumentation/active_record/test/instrumentation/active_record/patches/persistence_test.rb b/instrumentation/active_record/test/instrumentation/active_record/patches/persistence_test.rb deleted file mode 100644 index 6d47fbc491..0000000000 --- a/instrumentation/active_record/test/instrumentation/active_record/patches/persistence_test.rb +++ /dev/null @@ -1,200 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../lib/opentelemetry/instrumentation/active_record' -require_relative '../../../../lib/opentelemetry/instrumentation/active_record/patches/persistence' - -describe OpenTelemetry::Instrumentation::ActiveRecord::Patches::Persistence do - let(:exporter) { EXPORTER } - let(:spans) { exporter.finished_spans } - - before { exporter.reset } - - describe '#save' do - it 'traces' do - User.new.save - save_span = spans.find { |s| s.name == 'User#save' } - _(save_span).wont_be_nil - end - end - - describe '#save!' do - it 'traces' do - User.new.save! - save_span = spans.find { |s| s.name == 'User#save!' } - _(save_span).wont_be_nil - end - - it 'adds an exception event if it raises' do - _(-> { User.new(name: 'not otel').save! }).must_raise(ActiveRecord::RecordInvalid) - - save_span = spans.find { |s| s.name == 'User#save!' } - _(save_span).wont_be_nil - save_span_event = save_span.events.first - _(save_span_event.attributes['exception.type']).must_equal('ActiveRecord::RecordInvalid') - _(save_span_event.attributes['exception.message']).must_equal('Validation failed: must be otel') - end - end - - describe '#delete' do - it 'traces' do - User.new.delete - delete_span = spans.find { |s| s.name == 'User#delete' } - _(delete_span).wont_be_nil - end - end - - describe '#destroy' do - it 'traces' do - User.new.destroy - destroy_span = spans.find { |s| s.name == 'User#destroy' } - _(destroy_span).wont_be_nil - end - end - - describe '#destroy!' do - it 'traces' do - User.new.destroy! - destroy_span = spans.find { |s| s.name == 'User#destroy!' } - _(destroy_span).wont_be_nil - end - end - - describe '#becomes' do - it 'traces' do - User.new.becomes(SuperUser) - becomes_span = spans.find { |s| s.name == 'User#becomes' } - _(becomes_span).wont_be_nil - end - end - - describe '#becomes!' do - it 'traces' do - _(-> { User.new.becomes!(SuperUser) }).must_raise(NoMethodError) - - becomes_span = spans.find { |s| s.name == 'User#becomes!' } - _(becomes_span).wont_be_nil - becomes_span = becomes_span.events.first - _(becomes_span.attributes['exception.type']).must_equal('NoMethodError') - end - end - - describe '#update_attribute' do - it 'traces' do - User.new.update_attribute('updated_at', Time.current) - update_attribute_span = spans.find { |s| s.name == 'User#update_attribute' } - _(update_attribute_span).wont_be_nil - end - end - - describe '#update' do - it 'traces' do - User.new.update(updated_at: Time.current) - update_span = spans.find { |s| s.name == 'User#update' } - _(update_span).wont_be_nil - end - end - - describe '#update!' do - it 'traces' do - User.new.update!(updated_at: Time.current) - update_span = spans.find { |s| s.name == 'User#update!' } - _(update_span).wont_be_nil - end - end - - describe '#update_column' do - it 'traces' do - new_user = User.new - new_user.save - new_user.update_column(:updated_at, Time.current) - - update_column_span = spans.find { |s| s.name == 'User#update_column' } - _(update_column_span).wont_be_nil - end - end - - describe '#update_columns' do - it 'traces' do - new_user = User.new - new_user.save - new_user.update_columns(updated_at: Time.current, name: 'otel') - - update_column_span = spans.find { |s| s.name == 'User#update_columns' } - _(update_column_span).wont_be_nil - end - end - - describe '#increment' do - it 'traces' do - User.new.increment(:counter) - increment_span = spans.find { |s| s.name == 'User#increment' } - _(increment_span).wont_be_nil - end - end - - describe '#increment!' do - it 'traces' do - User.new.increment!(:counter) - increment_span = spans.find { |s| s.name == 'User#increment!' } - _(increment_span).wont_be_nil - end - end - - describe '#decrement' do - it 'traces' do - User.new.decrement(:counter) - decrement_span = spans.find { |s| s.name == 'User#decrement' } - _(decrement_span).wont_be_nil - end - end - - describe '#decrement!' do - it 'traces' do - User.new.decrement!(:counter) - decrement_span = spans.find { |s| s.name == 'User#decrement!' } - _(decrement_span).wont_be_nil - end - end - - describe '#toggle' do - it 'traces' do - User.new.toggle(:counter) - toggle_span = spans.find { |s| s.name == 'User#toggle' } - _(toggle_span).wont_be_nil - end - end - - describe '#toggle!' do - it 'traces' do - User.new.toggle!(:counter) - toggle_span = spans.find { |s| s.name == 'User#toggle!' } - _(toggle_span).wont_be_nil - end - end - - describe '#reload' do - it 'traces' do - new_user = User.new - new_user.save - new_user.reload - reload_span = spans.find { |s| s.name == 'User#reload' } - _(reload_span).wont_be_nil - end - end - - describe '#touch' do - it 'traces' do - new_user = User.new - new_user.save - new_user.touch - touch_span = spans.find { |s| s.name == 'User#touch' } - _(touch_span).wont_be_nil - end - end -end diff --git a/instrumentation/active_record/test/instrumentation/active_record/patches/querying_test.rb b/instrumentation/active_record/test/instrumentation/active_record/patches/querying_test.rb deleted file mode 100644 index 6da6205125..0000000000 --- a/instrumentation/active_record/test/instrumentation/active_record/patches/querying_test.rb +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../lib/opentelemetry/instrumentation/active_record' -require_relative '../../../../lib/opentelemetry/instrumentation/active_record/patches/querying' - -describe OpenTelemetry::Instrumentation::ActiveRecord::Patches::Querying do - let(:exporter) { EXPORTER } - let(:spans) { exporter.finished_spans } - - before { exporter.reset } - - describe 'find_by_sql' do - it 'traces' do - User.find_by_sql('SELECT * FROM users') - - find_span = spans.find { |s| s.name == 'User.find_by_sql' } - _(find_span).wont_be_nil - end - end -end diff --git a/instrumentation/active_record/test/instrumentation/active_record/patches/relation_persistence_test.rb b/instrumentation/active_record/test/instrumentation/active_record/patches/relation_persistence_test.rb deleted file mode 100644 index 96aa26c814..0000000000 --- a/instrumentation/active_record/test/instrumentation/active_record/patches/relation_persistence_test.rb +++ /dev/null @@ -1,49 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../lib/opentelemetry/instrumentation/active_record' -require_relative '../../../../lib/opentelemetry/instrumentation/active_record/patches/relation_persistence' - -describe OpenTelemetry::Instrumentation::ActiveRecord::Patches::RelationPersistence do - let(:exporter) { EXPORTER } - let(:spans) { exporter.finished_spans } - - before { exporter.reset } - - describe '.update_all' do - it 'traces' do - User.update_all(name: 'new name') - update_all_span = spans.find { |s| s.name == 'User.update_all' } - _(update_all_span).wont_be_nil - _(spans.count).must_equal(1) - end - - it 'traces scoped calls' do - User.recently_created.update_all(name: 'new name') - update_all_span = spans.find { |s| s.name == 'User.update_all' } - _(update_all_span).wont_be_nil - _(spans.count).must_equal(1) - end - end - - describe '.delete_all' do - it 'traces' do - User.delete_all - delete_all_span = spans.find { |s| s.name == 'User.delete_all' } - _(delete_all_span).wont_be_nil - _(spans.count).must_equal(1) - end - - it 'traces scoped calls' do - User.recently_created.delete_all - delete_all_span = spans.find { |s| s.name == 'User.delete_all' } - _(delete_all_span).wont_be_nil - _(spans.count).must_equal(1) - end - end -end diff --git a/instrumentation/active_record/test/instrumentation/active_record/patches/transactions_class_methods_test.rb b/instrumentation/active_record/test/instrumentation/active_record/patches/transactions_class_methods_test.rb deleted file mode 100644 index 98c27cd114..0000000000 --- a/instrumentation/active_record/test/instrumentation/active_record/patches/transactions_class_methods_test.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../lib/opentelemetry/instrumentation/active_record' -require_relative '../../../../lib/opentelemetry/instrumentation/active_record/patches/transactions_class_methods' - -describe OpenTelemetry::Instrumentation::ActiveRecord::Patches::TransactionsClassMethods do - let(:exporter) { EXPORTER } - let(:spans) { exporter.finished_spans } - - before { exporter.reset } - - describe '.transaction' do - it 'traces' do - User.transaction { User.create! } - - transaction_span = spans.find { |s| s.name == 'User.transaction' } - _(transaction_span).wont_be_nil - end - - it 'traces base transactions' do - ActiveRecord::Base.transaction { User.create! } - - transaction_span = spans.find { |s| s.name == 'ActiveRecord::Base.transaction' } - _(transaction_span).wont_be_nil - end - end -end diff --git a/instrumentation/active_record/test/test_helper.rb b/instrumentation/active_record/test/test_helper.rb deleted file mode 100644 index c386ba68d9..0000000000 --- a/instrumentation/active_record/test/test_helper.rb +++ /dev/null @@ -1,69 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 -require 'active_record' -require 'opentelemetry-instrumentation-active_record' -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' - -require 'minitest/autorun' -require 'webmock/minitest' -require 'pry' - -# Global opentelemetry-sdk setup: -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::ActiveRecord' - c.add_span_processor span_processor -end - -ActiveRecord::Base.establish_connection( - adapter: 'sqlite3', - database: 'db/development.sqlite3' -) - -# Create User model -class User < ActiveRecord::Base - validate :name_if_present - - scope :recently_created, -> { where('created_at > ?', Time.now - 3600) } - - def name_if_present - errors.add(:base, 'must be otel') if name.present? && name != 'otel' - end -end - -class SuperUser < ActiveRecord::Base; end - -# Get the current version so we can create a test table -segments = Gem.loaded_specs['activerecord'].version.segments -migration_version = "#{segments[0]}.#{segments[1]}".to_f - -# Simple migration to create a table to test against -class CreateUserTable < ActiveRecord::Migration[migration_version] - def change - create_table :users do |t| - t.string 'name' - t.integer 'counter' - t.timestamps - end - - create_table :super_users do |t| - t.string 'name' - t.integer 'counter' - t.timestamps - end - end -end - -begin - CreateUserTable.migrate(:up) -rescue ActiveRecord::StatementInvalid => e - raise e unless e.message == "Mysql2::Error: Table 'users' already exists" -end - -Minitest.after_run { CreateUserTable.migrate(:down) } diff --git a/instrumentation/active_support/.rubocop.yml b/instrumentation/active_support/.rubocop.yml deleted file mode 100644 index 0b104628c7..0000000000 --- a/instrumentation/active_support/.rubocop.yml +++ /dev/null @@ -1,5 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-active_support.rb" diff --git a/instrumentation/active_support/.yardopts b/instrumentation/active_support/.yardopts deleted file mode 100644 index 381c3c1117..0000000000 --- a/instrumentation/active_support/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Active Support Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/active_support/Appraisals b/instrumentation/active_support/Appraisals deleted file mode 100644 index d358e21c82..0000000000 --- a/instrumentation/active_support/Appraisals +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# Rails 5.2 is incompatible with Ruby 3. -if RUBY_VERSION < '3' - appraise 'rails-5.2' do - gem 'rails', '~> 5.2.0' - end -end - -appraise 'rails-6.0' do - gem 'rails', '~> 6.0.0' -end - -appraise 'rails-6.1' do - gem 'rails', '~> 6.1.0' -end - -if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.0') - appraise 'rails-7.0' do - gem 'rails', '~> 7.0.0' - end -end diff --git a/instrumentation/active_support/CHANGELOG.md b/instrumentation/active_support/CHANGELOG.md deleted file mode 100644 index d08a5a9b06..0000000000 --- a/instrumentation/active_support/CHANGELOG.md +++ /dev/null @@ -1,18 +0,0 @@ -# Release History: opentelemetry-instrumentation-active_support - -### v0.2.0 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Broken test file requirements - -### v0.1.2 / 2022-05-05 - -* (No significant changes) - -### v0.1.1 / 2021-12-02 - -* (No significant changes) - -### v0.1.0 / 2021-11-09 - -* Initial release. diff --git a/instrumentation/active_support/Gemfile b/instrumentation/active_support/Gemfile deleted file mode 100644 index 2baf57ac47..0000000000 --- a/instrumentation/active_support/Gemfile +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :test do - gem 'opentelemetry-instrumentation-base', path: '../base' -end diff --git a/instrumentation/active_support/LICENSE b/instrumentation/active_support/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/active_support/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/active_support/README.md b/instrumentation/active_support/README.md deleted file mode 100644 index cae849e420..0000000000 --- a/instrumentation/active_support/README.md +++ /dev/null @@ -1,57 +0,0 @@ -# OpenTelemetry ActiveSupport Instrumentation -The Active Support instrumentation is a community-maintained instrumentation for the Active Support portion of the [Ruby on Rails][rails-home] web-application framework. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-active_support -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-active_support` in your `Gemfile`. - -## Usage - -To use the instrumentation, call `use` with the name of the instrumentation and subscribe -to desired ActiveSupport notification: - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::ActiveSupport' -end - - -tracer = OpenTelemetry.tracer_provider.tracer('my_app_or_gem', '0.1.0') -::OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, 'bar.foo') -``` - -Alternatively, you can also call `use_all` to install all the available instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` - -## Examples - -Example usage can be seen in the `./example/trace_demonstration.rb` file [here](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/instrumentation/active_support/example/trace_demonstration.rb) - -## How can I get involved? - -The `opentelemetry-instrumentation-active_support` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -The `opentelemetry-instrumentation-active_support` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information. - -[rails-home]: https://rubyonrails.org -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/instrumentation/active_support/Rakefile b/instrumentation/active_support/Rakefile deleted file mode 100644 index 1a64ba842e..0000000000 --- a/instrumentation/active_support/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/active_support/example/Gemfile b/instrumentation/active_support/example/Gemfile deleted file mode 100644 index 4e93709da7..0000000000 --- a/instrumentation/active_support/example/Gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -source 'https://rubygems.org' - -gem 'activesupport' -gem 'opentelemetry-api' -gem 'opentelemetry-common' -gem 'opentelemetry-instrumentation-active_support' -gem 'opentelemetry-sdk' diff --git a/instrumentation/active_support/example/trace_demonstration.rb b/instrumentation/active_support/example/trace_demonstration.rb deleted file mode 100644 index 429d8810e0..0000000000 --- a/instrumentation/active_support/example/trace_demonstration.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -require 'rubygems' -require 'active_support' -require 'bundler/setup' - -Bundler.require - -ENV['OTEL_TRACES_EXPORTER'] = 'console' -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::ActiveSupport' -end - -tracer = OpenTelemetry.tracer_provider.tracer('my_app_or_gem', '0.1.0') - -::OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, 'bar.foo') - -::ActiveSupport::Notifications.instrument('bar.foo', extra: 'context') diff --git a/instrumentation/active_support/lib/opentelemetry-instrumentation-active_support.rb b/instrumentation/active_support/lib/opentelemetry-instrumentation-active_support.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/active_support/lib/opentelemetry-instrumentation-active_support.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/active_support/lib/opentelemetry/instrumentation.rb b/instrumentation/active_support/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index 0e9f39def5..0000000000 --- a/instrumentation/active_support/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/active_support' diff --git a/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support.rb b/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support.rb deleted file mode 100644 index 3b2e66b62d..0000000000 --- a/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the ActiveSupport gem - module ActiveSupport - end - end -end - -require_relative './active_support/instrumentation' -require_relative './active_support/version' diff --git a/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/instrumentation.rb b/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/instrumentation.rb deleted file mode 100644 index f5d91e2d39..0000000000 --- a/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/instrumentation.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module ActiveSupport - # The Instrumentation class contains logic to detect and install the ActiveSupport instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - install do |_config| - require_dependencies - end - - present do - defined?(::ActiveSupport) - end - - private - - def require_dependencies - require_relative 'span_subscriber' - end - end - end - end -end diff --git a/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/span_subscriber.rb b/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/span_subscriber.rb deleted file mode 100644 index 3bf94cb3fa..0000000000 --- a/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/span_subscriber.rb +++ /dev/null @@ -1,123 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - # rubocop:disable Style/Documentation - module ActiveSupport - # The SpanSubscriber is a special ActiveSupport::Notification subscription - # handler which turns notifications into generic spans, taking care to handle - # context appropriately. - - # A very hacky way to make sure that OpenTelemetry::Instrumentation::ActiveSupport::SpanSubscriber - # gets invoked first - # - def self.subscribe( # rubocop:disable Metrics/AbcSize - tracer, - pattern, - notification_payload_transform = nil, - disallowed_notification_payload_keys = [] - ) - subscriber = OpenTelemetry::Instrumentation::ActiveSupport::SpanSubscriber.new( - name: pattern, - tracer: tracer, - notification_payload_transform: notification_payload_transform, - disallowed_notification_payload_keys: disallowed_notification_payload_keys - ) - - subscriber_object = ::ActiveSupport::Notifications.subscribe(pattern, subscriber) - ::ActiveSupport::Notifications.notifier.synchronize do - if ::Rails::VERSION::MAJOR >= 6 - s = ::ActiveSupport::Notifications.notifier.instance_variable_get(:@string_subscribers)[pattern].pop - ::ActiveSupport::Notifications.notifier.instance_variable_get(:@string_subscribers)[pattern].unshift(s) - else - s = ::ActiveSupport::Notifications.notifier.instance_variable_get(:@subscribers).pop - ::ActiveSupport::Notifications.notifier.instance_variable_get(:@subscribers).unshift(s) - end - end - subscriber_object - end - - class SpanSubscriber - ALWAYS_VALID_PAYLOAD_TYPES = [TrueClass, FalseClass, String, Numeric, Symbol].freeze - - def initialize(name:, tracer:, notification_payload_transform: nil, disallowed_notification_payload_keys: []) - @span_name = name.split('.')[0..1].reverse.join(' ').freeze - @tracer = tracer - @notification_payload_transform = notification_payload_transform - @disallowed_notification_payload_keys = disallowed_notification_payload_keys - end - - def start(name, id, payload) - span = @tracer.start_span(@span_name, kind: :internal) - token = OpenTelemetry::Context.attach( - OpenTelemetry::Trace.context_with_span(span) - ) - payload.merge!( - __opentelemetry_span: span, - __opentelemetry_ctx_token: token - ) - - [span, token] - end - - def finish(name, id, payload) # rubocop:disable Metrics/AbcSize - span = payload.delete(:__opentelemetry_span) - token = payload.delete(:__opentelemetry_ctx_token) - return unless span && token - - payload = transform_payload(payload) - attrs = payload.map do |k, v| - [k.to_s, sanitized_value(v)] if valid_payload_key?(k) && valid_payload_value?(v) - end - span.add_attributes(attrs.compact.to_h) - - if (e = payload[:exception_object]) - span.record_exception(e) - span.status = OpenTelemetry::Trace::Status.error("Unhandled exception of type: #{e.class}") - end - - span.finish - OpenTelemetry::Context.detach(token) - end - - private - - def transform_payload(payload) - return payload if @notification_payload_transform.nil? - - @notification_payload_transform.call(payload) - end - - def valid_payload_key?(key) - %i[exception exception_object].none?(key) && @disallowed_notification_payload_keys.none?(key) - end - - def valid_payload_value?(value) - if value.is_a?(Array) - return true if value.empty? - - value.map(&:class).uniq.size == 1 && ALWAYS_VALID_PAYLOAD_TYPES.any? { |t| value.first.is_a?(t) } - else - ALWAYS_VALID_PAYLOAD_TYPES.any? { |t| value.is_a?(t) } - end - end - - # We'll accept symbols as values, but stringify them; and we'll stringify symbols within an array. - def sanitized_value(value) - if value.is_a?(Array) - value.map { |v| v.is_a?(Symbol) ? v.to_s : v } - elsif value.is_a?(Symbol) - value.to_s - else - value - end - end - end - end - end - # rubocop:enable Style/Documentation -end diff --git a/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/version.rb b/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/version.rb deleted file mode 100644 index 018f24abc4..0000000000 --- a/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module ActiveSupport - VERSION = '0.2.0' - end - end -end diff --git a/instrumentation/active_support/opentelemetry-instrumentation-active_support.gemspec b/instrumentation/active_support/opentelemetry-instrumentation-active_support.gemspec deleted file mode 100644 index f3c85455e6..0000000000 --- a/instrumentation/active_support/opentelemetry-instrumentation-active_support.gemspec +++ /dev/null @@ -1,52 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/active_support/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-active_support' - spec.version = OpenTelemetry::Instrumentation::ActiveSupport::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'ActiveSupport instrumentation for the OpenTelemetry framework' - spec.description = 'ActiveSupport instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.21.0' - - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-sdk' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'pry' - spec.add_development_dependency 'pry-byebug' - spec.add_development_dependency 'rails' - spec.add_development_dependency 'rake', '~> 12.3.3' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'webmock', '~> 3.7.6' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-active_support/v#{OpenTelemetry::Instrumentation::ActiveSupport::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/active_support' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-active_support/v#{OpenTelemetry::Instrumentation::ActiveSupport::VERSION}" - end -end diff --git a/instrumentation/active_support/test/.rubocop.yml b/instrumentation/active_support/test/.rubocop.yml deleted file mode 100644 index dd94258585..0000000000 --- a/instrumentation/active_support/test/.rubocop.yml +++ /dev/null @@ -1,4 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false diff --git a/instrumentation/active_support/test/opentelemetry/instrumentation/active_support/instrumentation_test.rb b/instrumentation/active_support/test/opentelemetry/instrumentation/active_support/instrumentation_test.rb deleted file mode 100644 index 4e537d8b0b..0000000000 --- a/instrumentation/active_support/test/opentelemetry/instrumentation/active_support/instrumentation_test.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../lib/opentelemetry/instrumentation/active_support' - -describe OpenTelemetry::Instrumentation::ActiveSupport do - let(:instrumentation) { OpenTelemetry::Instrumentation::ActiveSupport::Instrumentation.instance } - - it 'has #name' do - _(instrumentation.name).must_equal 'OpenTelemetry::Instrumentation::ActiveSupport' - end - - it 'has #version' do - _(instrumentation.version).wont_be_nil - _(instrumentation.version).wont_be_empty - end - - describe '#install' do - it 'accepts argument' do - _(instrumentation.install({})).must_equal(true) - instrumentation.instance_variable_set(:@installed, false) - end - end -end diff --git a/instrumentation/active_support/test/opentelemetry/instrumentation/active_support/span_subscriber_test.rb b/instrumentation/active_support/test/opentelemetry/instrumentation/active_support/span_subscriber_test.rb deleted file mode 100644 index 91bd842a46..0000000000 --- a/instrumentation/active_support/test/opentelemetry/instrumentation/active_support/span_subscriber_test.rb +++ /dev/null @@ -1,243 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -describe OpenTelemetry::Instrumentation::ActiveSupport::SpanSubscriber do - let(:instrumentation) { OpenTelemetry::Instrumentation::ActiveSupport::Instrumentation.instance } - let(:tracer) { instrumentation.tracer } - let(:exporter) { EXPORTER } - let(:last_span) { exporter.finished_spans.last } - let(:subscriber) do - OpenTelemetry::Instrumentation::ActiveSupport::SpanSubscriber.new( - name: 'bar.foo', - tracer: tracer - ) - end - - class CrashingEndSubscriber - def start(name, id, payload) end - - def finish(name, id, payload) - raise 'boom' - end - end - - before do - exporter.reset - instrumentation.instance_variable_set(:@installed, false) - instrumentation.install({}) - end - - it 'memoizes the span name' do - span, = subscriber.start('oh.hai', 'abc', {}) - _(span.name).must_equal('foo bar') - end - - it 'uses the provided tracer' do - subscriber = OpenTelemetry::Instrumentation::ActiveSupport::SpanSubscriber.new( - name: 'oh.hai', - tracer: OpenTelemetry.tracer_provider.tracer('foo') - ) - span, = subscriber.start('oh.hai', 'abc', {}) - _(span.instrumentation_library.name).must_equal('foo') - end - - it 'finishes the passed span' do - span, token = subscriber.start('hai', 'abc', {}) - subscriber.finish('hai', 'abc', __opentelemetry_span: span, __opentelemetry_ctx_token: token) - - # If it's in exporter.finished_spans ... it's finished. - _(last_span).wont_be_nil - end - - it 'sets attributes as expected' do - span, token = subscriber.start('hai', 'abc', {}) - # We only use the finished attributes - could change in the future, perhaps. - subscriber.finish( - 'hai', - 'abc', - __opentelemetry_span: span, - __opentelemetry_ctx_token: token, - string: 'keys_are_present', - numeric_is_fine: 1, - boolean_okay?: true, - symbols: :are_stringified, - empty_array_is_okay: [], - homogeneous_arrays_are_fine: %i[one two], - heterogeneous_arrays_are_not: [1, false], - exception: %w[Exception is_not_set_as_attribute], - exception_object: Exception.new('is_not_set_as_attribute'), - nil_values_are_rejected: nil, - complex_values_are_rejected: { foo: :bar } - ) - - _(last_span).wont_be_nil - _(last_span.attributes['string']).must_equal('keys_are_present') - _(last_span.attributes['numeric_is_fine']).must_equal(1) - _(last_span.attributes['boolean_okay?']).must_equal(true) - _(last_span.attributes['symbols']).must_equal('are_stringified') - _(last_span.attributes['empty_array_is_okay']).must_equal([]) - _(last_span.attributes['homogeneous_arrays_are_fine']).must_equal(%w[one two]) - _(last_span.attributes.key?('heterogeneous_arrays_are_not')).must_equal(false) - _(last_span.attributes.key?('exception')).must_equal(false) - _(last_span.attributes.key?('exception_object')).must_equal(false) - _(last_span.attributes.key?('nil_values_are_rejected')).must_equal(false) - _(last_span.attributes.key?('complex_values_are_rejected')).must_equal(false) - end - - it 'logs an exception_object correctly' do - span, token = subscriber.start('hai', 'abc', {}) - # We only use the finished attributes - could change in the future, perhaps. - subscriber.finish( - 'hai', - 'abc', - __opentelemetry_span: span, - __opentelemetry_ctx_token: token, - exception_object: Exception.new('boom') - ) - - status = last_span.status - _(status.code).must_equal(OpenTelemetry::Trace::Status::ERROR) - _(status.description).must_equal('Unhandled exception of type: Exception') - - event = last_span.events.first - _(event.name).must_equal('exception') - _(event.attributes['exception.message']).must_equal('boom') - end - - describe 'instrumentation option - disallowed_notification_payload_keys' do - let(:subscriber) do - OpenTelemetry::Instrumentation::ActiveSupport::SpanSubscriber.new( - name: 'bar.foo', - tracer: tracer, - notification_payload_transform: nil, - disallowed_notification_payload_keys: [:foo] - ) - end - - before do - instrumentation.instance_variable_set(:@installed, false) - instrumentation.install({}) - end - - after do - instrumentation.instance_variable_set(:@installed, false) - instrumentation.install({}) - end - - it 'does not set disallowed attributes from notification payloads' do - span, token = subscriber.start('hai', 'abc', {}) - subscriber.finish( - 'hai', - 'abc', - __opentelemetry_span: span, - __opentelemetry_ctx_token: token, - foo: 'bar', - baz: 'bat' - ) - - _(last_span).wont_be_nil - _(last_span.attributes.key?('foo')).must_equal(false) - _(last_span.attributes['baz']).must_equal('bat') - end - end - - describe 'instrumentation option - notification_payload_transform' do - let(:transformer_proc) { ->(v) { v.transform_values { 'optimus prime' } } } - let(:subscriber) do - OpenTelemetry::Instrumentation::ActiveSupport::SpanSubscriber.new( - name: 'bar.foo', - tracer: tracer, - notification_payload_transform: transformer_proc, - disallowed_notification_payload_keys: [:foo] - ) - end - - before do - instrumentation.instance_variable_set(:@installed, false) - instrumentation.install({}) - end - - after do - instrumentation.instance_variable_set(:@installed, false) - instrumentation.install({}) - end - - it 'allows a callable to transform all payload values' do - span, token = subscriber.start('hai', 'abc', {}) - subscriber.finish( - 'hai', - 'abc', - __opentelemetry_span: span, - __opentelemetry_ctx_token: token, - thing: 'a semi truck' - ) - - _(last_span).wont_be_nil - _(last_span.attributes['thing']).must_equal('optimus prime') - end - end - - describe 'instrument' do - before do - ::ActiveSupport::Notifications.unsubscribe('bar.foo') - end - - it 'does not trace an event by default' do - ::ActiveSupport::Notifications.subscribe('bar.foo') do - # pass - end - ::ActiveSupport::Notifications.instrument('bar.foo', extra: 'context') - _(last_span).must_be_nil - end - - it 'traces an event when a span subscriber is used' do - ::OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, 'bar.foo') - ::ActiveSupport::Notifications.instrument('bar.foo', extra: 'context') - - _(last_span).wont_be_nil - _(last_span.name).must_equal('foo bar') - _(last_span.attributes['extra']).must_equal('context') - end - - it 'finishes spans even when block subscribers blow up' do - ::ActiveSupport::Notifications.subscribe('bar.foo') { raise 'boom' } - ::OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, 'bar.foo') - - expect do - ::ActiveSupport::Notifications.instrument('bar.foo', extra: 'context') - end.must_raise RuntimeError - - _(last_span).wont_be_nil - _(last_span.name).must_equal('foo bar') - _(last_span.attributes['extra']).must_equal('context') - end - - it 'finishes spans even when complex subscribers blow up' do - ::ActiveSupport::Notifications.subscribe('bar.foo', CrashingEndSubscriber.new) - ::OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, 'bar.foo') - - expect do - ::ActiveSupport::Notifications.instrument('bar.foo', extra: 'context') - end.must_raise RuntimeError - - _(last_span).wont_be_nil - _(last_span.name).must_equal('foo bar') - _(last_span.attributes['extra']).must_equal('context') - end - - it 'supports unsubscribe' do - obj = ::OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, 'bar.foo') - ActiveSupport::Notifications.unsubscribe(obj) - - ::ActiveSupport::Notifications.instrument('bar.foo', extra: 'context') - - _(obj.class).must_equal(ActiveSupport::Notifications::Fanout::Subscribers::Evented) - _(last_span).must_be_nil - end - end -end diff --git a/instrumentation/active_support/test/test_helper.rb b/instrumentation/active_support/test/test_helper.rb deleted file mode 100644 index d9bd11ae78..0000000000 --- a/instrumentation/active_support/test/test_helper.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' - -require 'minitest/autorun' -require 'webmock/minitest' -require 'pry' - -require 'rails' - -require 'opentelemetry-instrumentation-active_support' - -# global opentelemetry-sdk setup: -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::ActiveSupport' - c.add_span_processor span_processor -end diff --git a/instrumentation/all/.rubocop.yml b/instrumentation/all/.rubocop.yml deleted file mode 100644 index a34cf3a303..0000000000 --- a/instrumentation/all/.rubocop.yml +++ /dev/null @@ -1,11 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -Metrics/BlockLength: - Exclude: - - "Gemfile" - - "*.gemspec" - - -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-all.rb" diff --git a/instrumentation/all/.yardopts b/instrumentation/all/.yardopts deleted file mode 100644 index cc6db29821..0000000000 --- a/instrumentation/all/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Instrumentation All-in-one ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/all/**/*.rb -./lib/opentelemetry/instrumentation/all.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/all/CHANGELOG.md b/instrumentation/all/CHANGELOG.md deleted file mode 100644 index 0a76b4188f..0000000000 --- a/instrumentation/all/CHANGELOG.md +++ /dev/null @@ -1,119 +0,0 @@ -# Release History: opentelemetry-instrumentation-all - -### v0.25.0 / 2022-06-09 - -* Bump all dependencies to use base 0.21.0 - -### v0.24.1 / 2022-05-05 - -* (No significant changes) - -### v0.24.0 / 2022-05-02 - -* ADDED: Adds instrumentation for rdkafka -* FIXED: Add rdkafka to all - -### v0.23.0 / 2022-01-26 - -* ADDED: Add Trilogy Auto Instrumentation -* FIXED: `ActiveSupport` constant conflict in Active Model Serializers instrumentation -* FIXED: add missing require for aws_sdk instrumentation #1054 - -### v0.22.0 / 2021-12-01 - -* ADDED: Move activesupport notification subsciber out of action_view gem - -### v0.21.3 / 2021-10-07 - -* (No significant changes) - -### v0.21.2 / 2021-09-29 - -* (No significant changes) - -### v0.21.1 / 2021-09-29 - -* (No significant changes) - -### v0.21.0 / 2021-09-15 - -* ADDED: Add Que instrumentation - -### v0.20.2 / 2021-09-09 - -* (No significant changes) - -### v0.20.1 / 2021-08-18 - -* FIXED: Instrumentation all sidekiq - -### v0.20.0 / 2021-08-12 - -* ADDED: Instrument active record -* ADDED: Add ActionView instrumentation via ActiveSupport::Notifications - -### v0.19.0 / 2021-06-25 - -* ADDED: Add resque instrumentation -* ADDED: Add ActiveJob instrumentation -* ADDED: Configuration option to enable or disable redis root spans [#777](https://github.com/open-telemetry/opentelemetry-ruby/pull/777) -* FIXED: Broken instrumentation all release - -### v0.18.0 / 2021-05-21 - -* ADDED: Add koala instrumentation - -### v0.17.0 / 2021-04-22 - -* ADDED: Add instrumentation for postgresql (pg gem) - -### v0.16.0 / 2021-03-17 - -* ADDED: Instrument http gem -* ADDED: Instrument lmdb gem -* FIXED: Example scripts now reference local common lib -* DOCS: Replace Gitter with GitHub Discussions - -### v0.15.0 / 2021-02-18 - -* ADDED: Instrument http client gem - -### v0.14.0 / 2021-02-03 - -* (No significant changes) - -### v0.13.0 / 2021-01-29 - -* (No significant changes) - -### v0.12.1 / 2021-01-13 - -* ADDED: Instrument RubyKafka - -### v0.12.0 / 2020-12-24 - -* ADDED: Instrument graphql - -### v0.11.0 / 2020-12-11 - -* FIXED: Copyright comments to not reference year - -### v0.10.0 / 2020-12-03 - -* FIXED: Otel-instrumentation-all not installing all - -### v0.9.0 / 2020-11-27 - -* ADDED: Add common helpers - -### v0.8.0 / 2020-10-27 - -* (No significant changes) - -### v0.7.0 / 2020-10-07 - -* DOCS: Standardize toplevel docs structure and readme - -### v0.6.0 / 2020-09-10 - -* Now depends on version 0.6.x of all the individual instrumentation gems. diff --git a/instrumentation/all/Gemfile b/instrumentation/all/Gemfile deleted file mode 100644 index f649e2f64a..0000000000 --- a/instrumentation/all/Gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec diff --git a/instrumentation/all/LICENSE b/instrumentation/all/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/all/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/all/README.md b/instrumentation/all/README.md deleted file mode 100644 index 9b5e8cfcdd..0000000000 --- a/instrumentation/all/README.md +++ /dev/null @@ -1,87 +0,0 @@ -# opentelemetry-instrumentation-all - -The `opentelemetry-instrumentation-all` gem is an all-in-one distribution of community maintained instrumentation. Instrumentation libraries are packaged as individual gems for flexibility and maintainability. Instead of having to require each instrumentation individually, applications can depend on this all-in-one gem as a convenient alternative. - -## What is OpenTelemetry? - -[OpenTelemetry][opentelemetry-home] is an open source observability framework, providing a general-purpose API, SDK, and related tools required for the instrumentation of cloud-native software, frameworks, and libraries. - -OpenTelemetry provides a single set of APIs, libraries, agents, and collector services to capture distributed traces and metrics from your application. You can analyze them using Prometheus, Jaeger, and other observability tools. - -## How does this gem fit in? - -This gem can be used with any OpenTelemetry SDK implementation. This can be the official `opentelemetry-sdk` gem or any other concrete implementation. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-all -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-all` in your `Gemfile`. - - -The `opentelemetry-api` has functionality to discover the instrumentation that an application depends on. It maintains a registry of discovered instrumentation which can be automatically installed by the SDK. These instructions pertain to the official `opentelemetry-sdk` implementation. Consult the documentation for your SDK if you are using an alternative implementation. - - -### Use All - -The `use_all` method will install all instrumentation present for an application, where the underlying, instrumented library is also present. Per library configuration can be passed in using an optional hash argument that has the instrumentation names as keys and configuration hashes as values. - - -```ruby -require 'opentelemetry/sdk' - -# install all compatible instrumentation with default configuration -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` - -```ruby -require 'opentelemetry/sdk' - -# install all compatible instrumentation with per instrumentation configuration overrides -OpenTelemetry::SDK.configure do |c| - c.use_all('OpenTelemetry::Instrumentation::SomeInstrumentation' => { opt: 'value' }) -end -``` - -### Selective Install - -Some users may want more fine grained control over what instrumentation they install for their application. Users can opt to selectively install instrumentation with the `use` method. Call `use` with the name of the instrumentation, and an optional configuration hash. - -```ruby -require 'opentelemetry/sdk' - -# install all compatible instrumentation with default configuration -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Sinatra' - c.use 'OpenTelemetry::Instrumentation::SomeInstrumentation', { opt: 'value' } -end -``` - -## Releasing - -Releasing opentelemetry-instrumentation-all requires that all gems it depends on exist on rubygems.org before publishing it. Because of this, it must be the last gem to be published in the release process. - -## How can I get involved? - -The `opentelemetry-instrumentation-all` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -The `opentelemetry-instrumentation-all` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information. - - -[opentelemetry-home]: https://opentelemetry.io -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/instrumentation/all/Rakefile b/instrumentation/all/Rakefile deleted file mode 100644 index 1a64ba842e..0000000000 --- a/instrumentation/all/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/all/lib/opentelemetry-instrumentation-all.rb b/instrumentation/all/lib/opentelemetry-instrumentation-all.rb deleted file mode 100644 index de7ef67b90..0000000000 --- a/instrumentation/all/lib/opentelemetry-instrumentation-all.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation/all' diff --git a/instrumentation/all/lib/opentelemetry/instrumentation/all.rb b/instrumentation/all/lib/opentelemetry/instrumentation/all.rb deleted file mode 100644 index fb941d2b24..0000000000 --- a/instrumentation/all/lib/opentelemetry/instrumentation/all.rb +++ /dev/null @@ -1,56 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry-instrumentation-trilogy' -require 'opentelemetry-instrumentation-active_support' -require 'opentelemetry-instrumentation-action_pack' -require 'opentelemetry-instrumentation-active_job' -require 'opentelemetry-instrumentation-active_record' -require 'opentelemetry-instrumentation-action_view' -require 'opentelemetry-instrumentation-aws_sdk' -require 'opentelemetry-instrumentation-bunny' -require 'opentelemetry-instrumentation-lmdb' -require 'opentelemetry-instrumentation-http' -require 'opentelemetry-instrumentation-koala' -require 'opentelemetry-instrumentation-active_model_serializers' -require 'opentelemetry-instrumentation-concurrent_ruby' -require 'opentelemetry-instrumentation-dalli' -require 'opentelemetry-instrumentation-delayed_job' -require 'opentelemetry-instrumentation-ethon' -require 'opentelemetry-instrumentation-excon' -require 'opentelemetry-instrumentation-faraday' -require 'opentelemetry-instrumentation-graphql' -require 'opentelemetry-instrumentation-http_client' -require 'opentelemetry-instrumentation-mongo' -require 'opentelemetry-instrumentation-mysql2' -require 'opentelemetry-instrumentation-net_http' -require 'opentelemetry-instrumentation-pg' -require 'opentelemetry-instrumentation-que' -require 'opentelemetry-instrumentation-rack' -require 'opentelemetry-instrumentation-rails' -require 'opentelemetry-instrumentation-rdkafka' -require 'opentelemetry-instrumentation-redis' -require 'opentelemetry-instrumentation-restclient' -require 'opentelemetry-instrumentation-resque' -require 'opentelemetry-instrumentation-ruby_kafka' -require 'opentelemetry-instrumentation-sidekiq' -require 'opentelemetry-instrumentation-sinatra' - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - module Instrumentation - # Namespace for the Opentelemetry all-in-one gem - module All - end - end -end - -require_relative './all/version' diff --git a/instrumentation/all/lib/opentelemetry/instrumentation/all/version.rb b/instrumentation/all/lib/opentelemetry/instrumentation/all/version.rb deleted file mode 100644 index 921c1d44c1..0000000000 --- a/instrumentation/all/lib/opentelemetry/instrumentation/all/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module All - VERSION = '0.25.0' - end - end -end diff --git a/instrumentation/all/opentelemetry-instrumentation-all.gemspec b/instrumentation/all/opentelemetry-instrumentation-all.gemspec deleted file mode 100644 index 02870f84d6..0000000000 --- a/instrumentation/all/opentelemetry-instrumentation-all.gemspec +++ /dev/null @@ -1,80 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) - -require 'opentelemetry/instrumentation/all/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-all' - spec.version = OpenTelemetry::Instrumentation::All::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'All-in-one instrumentation bundle for the OpenTelemetry framework' - spec.description = 'All-in-one instrumentation bundle for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-instrumentation-action_pack', '~> 0.2.0' - spec.add_dependency 'opentelemetry-instrumentation-action_view', '~> 0.3.0' - spec.add_dependency 'opentelemetry-instrumentation-active_job', '~> 0.3.0' - spec.add_dependency 'opentelemetry-instrumentation-active_model_serializers', '~> 0.19.0' - spec.add_dependency 'opentelemetry-instrumentation-active_record', '~> 0.4.0' - spec.add_dependency 'opentelemetry-instrumentation-active_support', '~> 0.2.0' - spec.add_dependency 'opentelemetry-instrumentation-aws_sdk', '~> 0.3.0' - spec.add_dependency 'opentelemetry-instrumentation-bunny', '~> 0.19.0' - spec.add_dependency 'opentelemetry-instrumentation-concurrent_ruby', '~> 0.20.0' - spec.add_dependency 'opentelemetry-instrumentation-dalli', '~> 0.22.0' - spec.add_dependency 'opentelemetry-instrumentation-delayed_job', '~> 0.19.0' - spec.add_dependency 'opentelemetry-instrumentation-ethon', '~> 0.20.0' - spec.add_dependency 'opentelemetry-instrumentation-excon', '~> 0.20.0' - spec.add_dependency 'opentelemetry-instrumentation-faraday', '~> 0.21.0' - spec.add_dependency 'opentelemetry-instrumentation-graphql', '~> 0.20.0' - spec.add_dependency 'opentelemetry-instrumentation-http', '~> 0.20.0' - spec.add_dependency 'opentelemetry-instrumentation-http_client', '~> 0.20.0' - spec.add_dependency 'opentelemetry-instrumentation-koala', '~> 0.19.0' - spec.add_dependency 'opentelemetry-instrumentation-lmdb', '~> 0.21.0' - spec.add_dependency 'opentelemetry-instrumentation-mongo', '~> 0.20.0' - spec.add_dependency 'opentelemetry-instrumentation-mysql2', '~> 0.21.0' - spec.add_dependency 'opentelemetry-instrumentation-net_http', '~> 0.20.0' - spec.add_dependency 'opentelemetry-instrumentation-pg', '~> 0.21.0' - spec.add_dependency 'opentelemetry-instrumentation-que', '~> 0.4.0' - spec.add_dependency 'opentelemetry-instrumentation-rack', '~> 0.21.0' - spec.add_dependency 'opentelemetry-instrumentation-rails', '~> 0.22.0' - spec.add_dependency 'opentelemetry-instrumentation-rdkafka', '~> 0.2.0' - spec.add_dependency 'opentelemetry-instrumentation-redis', '~> 0.23.0' - spec.add_dependency 'opentelemetry-instrumentation-resque', '~> 0.3.0' - spec.add_dependency 'opentelemetry-instrumentation-restclient', '~> 0.20.0' - spec.add_dependency 'opentelemetry-instrumentation-ruby_kafka', '~> 0.19.0' - spec.add_dependency 'opentelemetry-instrumentation-sidekiq', '~> 0.22.0' - spec.add_dependency 'opentelemetry-instrumentation-sinatra', '~> 0.20.0' - spec.add_dependency 'opentelemetry-instrumentation-trilogy', '~> 0.51.0' - - spec.add_development_dependency 'active_model_serializers' - spec.add_development_dependency 'activesupport' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'rake', '~> 12.0' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-all/v#{OpenTelemetry::Instrumentation::All::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/all' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-all/v#{OpenTelemetry::Instrumentation::All::VERSION}" - end -end diff --git a/instrumentation/all/test/.rubocop.yml b/instrumentation/all/test/.rubocop.yml deleted file mode 100644 index dd94258585..0000000000 --- a/instrumentation/all/test/.rubocop.yml +++ /dev/null @@ -1,4 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false diff --git a/instrumentation/all/test/opentelemetry/instrumentation/all_test.rb b/instrumentation/all/test/opentelemetry/instrumentation/all_test.rb deleted file mode 100644 index 9109957a8f..0000000000 --- a/instrumentation/all/test/opentelemetry/instrumentation/all_test.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative '../../test_helper' - -require 'active_support/all' -require 'active_model_serializers' - -# require Instrumentation so .install method is found: -require_relative '../../../lib/opentelemetry/instrumentation/all' - -describe OpenTelemetry::Instrumentation::All do - describe 'ActiveModelSerializers instrumentation' do - it 'does not conflict with ActiveSupport instrumentation' do - # Expected behavior is that the exception is not raised. - OpenTelemetry::Instrumentation::ActiveSupport::Instrumentation.instance.install - OpenTelemetry::Instrumentation::ActiveModelSerializers::Instrumentation.instance.install - end - end -end diff --git a/instrumentation/all/test/test_helper.rb b/instrumentation/all/test/test_helper.rb deleted file mode 100644 index 72adece2cc..0000000000 --- a/instrumentation/all/test/test_helper.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'minitest/autorun' diff --git a/instrumentation/aws_sdk/.rubocop.yml b/instrumentation/aws_sdk/.rubocop.yml deleted file mode 100644 index 345e3d10dc..0000000000 --- a/instrumentation/aws_sdk/.rubocop.yml +++ /dev/null @@ -1,5 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-aws_sdk.rb" diff --git a/instrumentation/aws_sdk/.yardopts b/instrumentation/aws_sdk/.yardopts deleted file mode 100644 index 9ebf430d7d..0000000000 --- a/instrumentation/aws_sdk/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry AWS SDK Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/aws_sdk/Appraisals b/instrumentation/aws_sdk/Appraisals deleted file mode 100644 index 5ecdbf591a..0000000000 --- a/instrumentation/aws_sdk/Appraisals +++ /dev/null @@ -1,61 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -appraise 'aws-sdk-3.1' do - gem 'aws-sdk', '~> 3.1' -end - -appraise 'aws-sdk-3.0' do - gem 'aws-sdk', '~> 3.0' -end - -appraise 'aws-sdk-2.11' do - gem 'aws-sdk', '~> 2.11' -end - -appraise 'aws-sdk-2.10' do - gem 'aws-sdk', '~> 2.10' -end - -appraise 'aws-sdk-2.9' do - gem 'aws-sdk', '~> 2.9' -end - -appraise 'aws-sdk-2.8' do - gem 'aws-sdk', '~> 2.8' -end - -appraise 'aws-sdk-2.7' do - gem 'aws-sdk', '~> 2.7' -end - -appraise 'aws-sdk-2.6' do - gem 'aws-sdk', '~> 2.6' -end - -appraise 'aws-sdk-2.5' do - gem 'aws-sdk', '~> 2.5' -end - -appraise 'aws-sdk-2.4' do - gem 'aws-sdk', '~> 2.4' -end - -appraise 'aws-sdk-2.3' do - gem 'aws-sdk', '~> 2.3' -end - -appraise 'aws-sdk-2.2' do - gem 'aws-sdk', '~> 2.2' -end - -appraise 'aws-sdk-2.1' do - gem 'aws-sdk', '~> 2.1' -end - -appraise 'aws-sdk-2.0' do - gem 'aws-sdk', '~> 2.0' -end diff --git a/instrumentation/aws_sdk/CHANGELOG.md b/instrumentation/aws_sdk/CHANGELOG.md deleted file mode 100644 index 3ec7cfeee7..0000000000 --- a/instrumentation/aws_sdk/CHANGELOG.md +++ /dev/null @@ -1,26 +0,0 @@ -# Release History: opentelemetry-instrumentation-aws_sdk - -### v0.3.0 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Broken test file requirements - -### v0.2.3 / 2022-05-02 - -* FIXED: RubyGems Fallback - -### v0.2.2 / 2022-01-26 - -* (No significant changes) - -### v0.2.1 / 2022-01-21 - -* ADDED: attach HTTP status code to AWS spans - -### v0.2.0 / 2022-01-20 - -* ADDED: SQS / SNS messaging attributes and context propagation - -### v0.1.0 / 2021-12-01 - -* Initial release. diff --git a/instrumentation/aws_sdk/Gemfile b/instrumentation/aws_sdk/Gemfile deleted file mode 100644 index a03fdb17e2..0000000000 --- a/instrumentation/aws_sdk/Gemfile +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :test do - gem 'opentelemetry-instrumentation-base', path: '../base' - gem 'webrick', '~> 1.7' -end diff --git a/instrumentation/aws_sdk/LICENSE b/instrumentation/aws_sdk/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/aws_sdk/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/aws_sdk/README.md b/instrumentation/aws_sdk/README.md deleted file mode 100644 index 5bcc3150a2..0000000000 --- a/instrumentation/aws_sdk/README.md +++ /dev/null @@ -1,65 +0,0 @@ -# OpenTelemetry AWS-SDK Instrumentation - -The OpenTelemetry `aws-sdk` gem is a community maintained instrumentation for [aws-sdk-ruby][aws-sdk-home]. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-aws_sdk -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-aws_sdk` in your `Gemfile`. - -## Usage - -To install the instrumentation, call `use` with the name of the instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::AwsSdk', { - inject_messaging_context: true, - suppress_internal_instrumentation: true - } -end -``` - -Alternatively, you can also call `use_all` to install all the available instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` - -## Example - -To run the example: - -1. `cd` to the examples directory and install gems - * `cd example` - * `bundle install` -2. Run the sample client script - * `ruby trace_demonstration.rb` - -This will run SNS publish command, printing OpenTelemetry traces to the console as it goes. - -## How can I get involved? - -The `opentelemetry-instrumentation-aws_sdk` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -Apache 2.0 license. See [LICENSE][license-github] for more information. - -[aws-sdk-home]: https://github.com/aws/aws-sdk-ruby -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions - diff --git a/instrumentation/aws_sdk/Rakefile b/instrumentation/aws_sdk/Rakefile deleted file mode 100644 index 4b0e9b5a8e..0000000000 --- a/instrumentation/aws_sdk/Rakefile +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] - t.warning = false -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/aws_sdk/example/Gemfile b/instrumentation/aws_sdk/example/Gemfile deleted file mode 100644 index eec14bbdb3..0000000000 --- a/instrumentation/aws_sdk/example/Gemfile +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -source 'https://rubygems.org' - -gem 'aws-sdk' -gem 'opentelemetry-api' -gem 'opentelemetry-instrumentation-aws_sdk' -gem 'opentelemetry-sdk' diff --git a/instrumentation/aws_sdk/example/trace_demonstration.rb b/instrumentation/aws_sdk/example/trace_demonstration.rb deleted file mode 100755 index 4d4eb22b2d..0000000000 --- a/instrumentation/aws_sdk/example/trace_demonstration.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'rubygems' -require 'bundler/setup' - -Bundler.require - -# Export traces to console by default -ENV['OTEL_TRACES_EXPORTER'] ||= 'console' - -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::AwsSdk', suppress_internal_instrumentation: false -end - -sns = Aws::SNS::Client.new -sns.publish message: 'ruby sending message to sns' diff --git a/instrumentation/aws_sdk/lib/opentelemetry-instrumentation-aws_sdk.rb b/instrumentation/aws_sdk/lib/opentelemetry-instrumentation-aws_sdk.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/aws_sdk/lib/opentelemetry-instrumentation-aws_sdk.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/aws_sdk/lib/opentelemetry/instrumentation.rb b/instrumentation/aws_sdk/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index a5144d281c..0000000000 --- a/instrumentation/aws_sdk/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # "Instrumentation" are specified by - # https://github.com/open-telemetry/opentelemetry-specification/blob/784635d01d8690c8f5fcd1f55bdbc8a13cf2f4f2/specification/glossary.md#instrumentation-library - # - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/aws_sdk' diff --git a/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk.rb b/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk.rb deleted file mode 100644 index 2d39f0fcd8..0000000000 --- a/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the Aws gem - module AwsSdk - end - end -end - -require_relative './aws_sdk/instrumentation' -require_relative './aws_sdk/version' diff --git a/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/handler.rb b/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/handler.rb deleted file mode 100644 index c570d71822..0000000000 --- a/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/handler.rb +++ /dev/null @@ -1,116 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module AwsSdk - # Generates Spans for all interactions with AwsSdk - class Handler < Seahorse::Client::Handler - SQS_SEND_MESSAGE = 'SQS.SendMessage' - SQS_SEND_MESSAGE_BATCH = 'SQS.SendMessageBatch' - SQS_RECEIVE_MESSAGE = 'SQS.ReceiveMessage' - SNS_PUBLISH = 'SNS.Publish' - - def call(context) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity - return super unless context - - service_name = service_name(context) - operation = context.operation&.name - client_method = "#{service_name}.#{operation}" - attributes = { - 'aws.region' => context.config.region, - OpenTelemetry::SemanticConventions::Trace::RPC_SYSTEM => 'aws-api', - OpenTelemetry::SemanticConventions::Trace::RPC_METHOD => operation, - OpenTelemetry::SemanticConventions::Trace::RPC_SERVICE => service_name - } - attributes[SemanticConventions::Trace::DB_SYSTEM] = 'dynamodb' if service_name == 'DynamoDB' - MessagingHelper.apply_sqs_attributes(attributes, context, client_method) if service_name == 'SQS' - MessagingHelper.apply_sns_attributes(attributes, context, client_method) if service_name == 'SNS' - - tracer.in_span(span_name(context, client_method), attributes: attributes, kind: span_kind(client_method)) do |span| - inject_context(context, client_method) - if instrumentation_config[:suppress_internal_instrumentation] - OpenTelemetry::Common::Utilities.untraced { super } - else - super - end.tap do |response| - span.set_attribute(OpenTelemetry::SemanticConventions::Trace::HTTP_STATUS_CODE, - context.http_response.status_code) - - if (err = response.error) - span.record_exception(err) - span.status = Trace::Status.error(err.to_s) - end - end - end - end - - private - - def tracer - AwsSdk::Instrumentation.instance.tracer - end - - def instrumentation_config - AwsSdk::Instrumentation.instance.config - end - - def service_name(context) # rubocop:disable Metrics/AbcSize - # Support aws-sdk v2.0.x, which 'metadata' has a setter method only - return context.client.class.to_s.split('::')[1] if ::Seahorse::Model::Api.instance_method(:metadata).parameters.length.positive? - - context.client.class.api.metadata['serviceId'] || context.client.class.to_s.split('::')[1] - end - - SEND_MESSAGE_CLIENT_METHODS = [SQS_SEND_MESSAGE, SQS_SEND_MESSAGE_BATCH, SNS_PUBLISH].freeze - def inject_context(context, client_method) - return unless SEND_MESSAGE_CLIENT_METHODS.include? client_method - return unless instrumentation_config[:inject_messaging_context] - - if client_method == SQS_SEND_MESSAGE_BATCH - context.params[:entries].each do |entry| - entry[:message_attributes] ||= {} - OpenTelemetry.propagation.inject(entry[:message_attributes], setter: MessageAttributeSetter) - end - else - context.params[:message_attributes] ||= {} - OpenTelemetry.propagation.inject(context.params[:message_attributes], setter: MessageAttributeSetter) - end - end - - def span_kind(client_method) - case client_method - when SQS_SEND_MESSAGE, SQS_SEND_MESSAGE_BATCH, SNS_PUBLISH - OpenTelemetry::Trace::SpanKind::PRODUCER - when SQS_RECEIVE_MESSAGE - OpenTelemetry::Trace::SpanKind::CONSUMER - else - OpenTelemetry::Trace::SpanKind::CLIENT - end - end - - def span_name(context, client_method) - case client_method - when SQS_SEND_MESSAGE, SQS_SEND_MESSAGE_BATCH, SNS_PUBLISH - "#{MessagingHelper.queue_name(context)} send" - when SQS_RECEIVE_MESSAGE - "#{MessagingHelper.queue_name(context)} receive" - else - client_method - end - end - end - - # A Seahorse::Client::Plugin that enables instrumentation for all AWS services - class Plugin < Seahorse::Client::Plugin - def add_handlers(handlers, config) - # run before Seahorse::Client::Plugin::ParamValidator (priority 50) - handlers.add Handler, step: :validate, priority: 49 - end - end - end - end -end diff --git a/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/instrumentation.rb b/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/instrumentation.rb deleted file mode 100644 index 07b4075f2e..0000000000 --- a/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/instrumentation.rb +++ /dev/null @@ -1,72 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module AwsSdk - # Instrumentation class that detects and installs the AwsSdk instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - MINIMUM_VERSION = Gem::Version.new('2.0.0') - - install do |_config| - require_dependencies - add_plugin(Seahorse::Client::Base, *loaded_constants) - end - - present do - !defined?(::Seahorse::Client::Base).nil? - end - - compatible do - !gem_version.nil? && gem_version >= MINIMUM_VERSION - end - - option :inject_messaging_context, default: false, validate: :boolean - option :suppress_internal_instrumentation, default: false, validate: :boolean - - def gem_version - if Gem.loaded_specs['aws-sdk'] - Gem.loaded_specs['aws-sdk'].version - elsif Gem.loaded_specs['aws-sdk-core'] - Gem.loaded_specs['aws-sdk-core'].version - elsif defined?(::Aws::CORE_GEM_VERSION) - Gem::Version.new(::Aws::CORE_GEM_VERSION) - end - end - - private - - def require_dependencies - require_relative 'handler' - require_relative 'services' - require_relative 'message_attributes' - require_relative 'messaging_helper' - end - - def add_plugin(*targets) - targets.each { |klass| klass.add_plugin(AwsSdk::Plugin) } - end - - def loaded_constants - # Cross-check services against loaded AWS constants - # Module#const_get can return a constant from ancestors when there's a miss. - # If this conincidentally matches another constant, it will attempt to patch - # the wrong constant, resulting in patch failure. - available_services = ::Aws.constants & SERVICES.map(&:to_sym) - available_services.each_with_object([]) do |service, constants| - next if ::Aws.autoload?(service) - - begin - constants << ::Aws.const_get(service, false).const_get(:Client, false) - rescue StandardError => e - OpenTelemetry.logger.warn("Constant could not be loaded: #{e}") - end - end - end - end - end - end -end diff --git a/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/message_attributes.rb b/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/message_attributes.rb deleted file mode 100644 index b5b5777f16..0000000000 --- a/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/message_attributes.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module AwsSdk - # The MessageAttributeSetter class provides methods for writing tracing information to - # SNS / SQS messages. - # - # @example - # OpenTelemetry.propagation.inject(context.params[:message_attributes], setter: MessageAttributeSetter) - class MessageAttributeSetter - def self.set(carrier, key, value) - # https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-quotas.html - if carrier.length < 10 - carrier[key] = { string_value: value, data_type: 'String' } - else - OpenTelemetry.logger.warn('aws-sdk instrumentation: cannot set context propagation on SQS/SNS message due to maximum amount of MessageAttributes') - end - end - end - - # The MessageAttributeGetter class provides methods for getting tracing information from SQS message. - # - # @example - # OpenTelemetry.propagation.extract(message, getter: MessageAttributeGetter) - class MessageAttributeGetter - def self.get(carrier, key) - return carrier[key][:string_value] if carrier[key][:data_type] == 'String' - end - end - end - end -end diff --git a/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/messaging_helper.rb b/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/messaging_helper.rb deleted file mode 100644 index d49c8b331c..0000000000 --- a/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/messaging_helper.rb +++ /dev/null @@ -1,52 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module AwsSdk - # MessagingHelper class provides methods for calculating messaging span attributes - class MessagingHelper - class << self - def queue_name(context) - topic_arn = context.params[:topic_arn] - target_arn = context.params[:target_arn] - - if topic_arn || target_arn - arn = topic_arn || target_arn - return arn.split(':')[-1] - end - - phone_number = context.params[:phone_number] - return 'phone_number' if phone_number - - queue_url = context.params[:queue_url] - return queue_url.split('/')[-1] if queue_url - - 'unknown' - end - - def apply_sqs_attributes(attributes, context, client_method) - attributes[SemanticConventions::Trace::MESSAGING_SYSTEM] = 'aws.sqs' - attributes[SemanticConventions::Trace::MESSAGING_DESTINATION_KIND] = 'queue' - attributes[SemanticConventions::Trace::MESSAGING_DESTINATION] = queue_name(context) - attributes[SemanticConventions::Trace::MESSAGING_URL] = context.params[:queue_url] - - attributes[SemanticConventions::Trace::MESSAGING_OPERATION] = 'receive' if client_method == 'SQS.ReceiveMessage' - end - - def apply_sns_attributes(attributes, context, client_method) - attributes[SemanticConventions::Trace::MESSAGING_SYSTEM] = 'aws.sns' - - return unless client_method == 'SNS.Publish' - - attributes[SemanticConventions::Trace::MESSAGING_DESTINATION_KIND] = 'topic' - attributes[SemanticConventions::Trace::MESSAGING_DESTINATION] = queue_name(context) - end - end - end - end - end -end diff --git a/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/services.rb b/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/services.rb deleted file mode 100644 index d0bacb75f3..0000000000 --- a/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/services.rb +++ /dev/null @@ -1,121 +0,0 @@ -# frozen_string_literal: true - -module OpenTelemetry - module Instrumentation - # rubocop:disable Metrics/ModuleLength: - module AwsSdk - SERVICES = %w[ - ACM - APIGateway - AppStream - ApplicationAutoScaling - ApplicationDiscoveryService - Athena - AutoScaling - Batch - Budgets - CloudDirectory - CloudFormation - CloudFront - CloudHSM - CloudHSMV2 - CloudSearch - CloudSearchDomain - CloudTrail - CloudWatch - CloudWatchEvents - CloudWatchLogs - CodeBuild - CodeCommit - CodeDeploy - CodePipeline - CodeStar - CognitoIdentity - CognitoIdentityProvider - CognitoSync - ConfigService - CostandUsageReportService - DAX - DataPipeline - DatabaseMigrationService - DeviceFarm - DirectConnect - DirectoryService - DynamoDB - DynamoDBStreams - EC2 - ECR - ECS - EFS - EMR - ElastiCache - ElasticBeanstalk - ElasticLoadBalancing - ElasticLoadBalancingV2 - ElasticTranscoder - ElasticsearchService - EventBridge - Firehose - GameLift - Glacier - Glue - Greengrass - Health - IAM - ImportExport - Inspector - IoT - IoTDataPlane - KMS - Kinesis - KinesisAnalytics - Lambda - LambdaPreview - Lex - LexModelBuildingService - Lightsail - MTurk - MachineLearning - MarketplaceCommerceAnalytics - MarketplaceEntitlementService - MarketplaceMetering - MigrationHub - Mobile - OpsWorks - OpsWorksCM - Organizations - Pinpoint - Polly - RDS - Redshift - Rekognition - ResourceGroupsTaggingAPI - Route53 - Route53Domains - S3 - SES - SMS - SNS - SQS - SSM - STS - SWF - ServiceCatalog - Schemas - Shield - SimpleDB - Snowball - States - StorageGateway - Support - Textract - WAF - WAFRegional - WorkDocs - WorkSpaces - XRay - ].freeze - end - # rubocop:enable Metrics/ModuleLength: - end -end diff --git a/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/version.rb b/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/version.rb deleted file mode 100644 index 4a7027970d..0000000000 --- a/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module AwsSdk - VERSION = '0.3.0' - end - end -end diff --git a/instrumentation/aws_sdk/opentelemetry-instrumentation-aws_sdk.gemspec b/instrumentation/aws_sdk/opentelemetry-instrumentation-aws_sdk.gemspec deleted file mode 100644 index cbc05522f1..0000000000 --- a/instrumentation/aws_sdk/opentelemetry-instrumentation-aws_sdk.gemspec +++ /dev/null @@ -1,52 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/aws_sdk/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-aws_sdk' - spec.version = OpenTelemetry::Instrumentation::AwsSdk::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'AWS SDK instrumentation for the OpenTelemetry framework' - spec.description = 'AWS SDK instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.21.0' - - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'aws-sdk', '>= 2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'pry' - spec.add_development_dependency 'pry-byebug' unless RUBY_ENGINE == 'jruby' - spec.add_development_dependency 'rspec-mocks' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'webmock', '~> 3.7.6' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-aws_sdk/v#{OpenTelemetry::Instrumentation::AwsSdk::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/aws_sdk' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-aws_sdk/v#{OpenTelemetry::Instrumentation::AwsSdk::VERSION}" - end -end diff --git a/instrumentation/aws_sdk/test/.rubocop.yml b/instrumentation/aws_sdk/test/.rubocop.yml deleted file mode 100644 index e97eda560f..0000000000 --- a/instrumentation/aws_sdk/test/.rubocop.yml +++ /dev/null @@ -1,6 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false -Style/MultilineIfModifier: - Enabled: false diff --git a/instrumentation/aws_sdk/test/opentelemetry/instrumentation_test.rb b/instrumentation/aws_sdk/test/opentelemetry/instrumentation_test.rb deleted file mode 100644 index c14c960017..0000000000 --- a/instrumentation/aws_sdk/test/opentelemetry/instrumentation_test.rb +++ /dev/null @@ -1,238 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -describe OpenTelemetry::Instrumentation::AwsSdk do - let(:instrumentation) { OpenTelemetry::Instrumentation::AwsSdk::Instrumentation.instance } - let(:minimum_version) { OpenTelemetry::Instrumentation::AwsSdk::Instrumentation::MINIMUM_VERSION } - let(:exporter) { EXPORTER } - let(:last_span) { exporter.finished_spans.last } - - it 'has #name' do - _(instrumentation.name).must_equal 'OpenTelemetry::Instrumentation::AwsSdk' - end - - it 'has #version' do - _(instrumentation.version).wont_be_nil - _(instrumentation.version).wont_be_empty - end - - describe '#compatible' do - it 'returns false for unsupported gem versions' do - Gem.stub(:loaded_specs, 'aws-sdk-core' => nil, 'aws-sdk' => nil) do - hide_const('::Aws::CORE_GEM_VERSION') - _(instrumentation.compatible?).must_equal false - end - - Gem.stub(:loaded_specs, 'aws-sdk-core' => nil, 'aws-sdk' => Gem::Specification.new { |s| s.version = '1.0.0' }) do - hide_const('::Aws::CORE_GEM_VERSION') - _(instrumentation.compatible?).must_equal false - end - - Gem.stub(:loaded_specs, 'aws-sdk-core' => Gem::Specification.new { |s| s.version = '1.0.0' }, 'aws-sdk' => nil) do - hide_const('::Aws::CORE_GEM_VERSION') - _(instrumentation.compatible?).must_equal false - end - - Gem.stub(:loaded_specs, 'aws-sdk-core' => nil, 'aws-sdk' => nil) do - stub_const('::Aws::CORE_GEM_VERSION', '1.9.9') - _(instrumentation.compatible?).must_equal false - end - end - - it 'returns true for supported gem versions' do - _(instrumentation.compatible?).must_equal true - end - end - - describe '#install' do - it 'accepts argument' do - _(instrumentation.install({})).must_equal(true) - instrumentation.instance_variable_set(:@installed, false) - end - end - - describe 'validate_spans' do - describe 'SNS' do - it 'should have correct attributes' do - sns = Aws::SNS::Client.new(stub_responses: true) - sns.stub_responses(:publish) - - sns.publish message: 'msg' - - _(last_span.attributes['rpc.system']).must_equal 'aws-api' - _(last_span.attributes['rpc.service']).must_equal 'SNS' - _(last_span.attributes['rpc.method']).must_equal 'Publish' - _(last_span.attributes['aws.region']).must_include 'stubbed' - _(last_span.attributes['db.system']).must_be_nil - - _(last_span.attributes[OpenTelemetry::SemanticConventions::Trace::HTTP_STATUS_CODE]).must_equal 200 - - _(last_span.status.code).must_equal OpenTelemetry::Trace::Status::UNSET - end - end - - describe 'S3' do - it 'should have correct attributes when success' do - s3 = Aws::S3::Client.new(stub_responses: { list_buckets: { buckets: [{ name: 'bucket1' }] } }) - - s3.list_buckets - - _(last_span.attributes['rpc.system']).must_equal 'aws-api' - _(last_span.attributes['rpc.service']).must_equal 'S3' - _(last_span.attributes['rpc.method']).must_equal 'ListBuckets' - _(last_span.attributes['aws.region']).must_include 'stubbed' - _(last_span.attributes['db.system']).must_be_nil - - _(last_span.attributes[OpenTelemetry::SemanticConventions::Trace::HTTP_STATUS_CODE]).must_equal 200 - - _(last_span.status.code).must_equal OpenTelemetry::Trace::Status::UNSET - end - - it 'should have correct attributes when error' do - s3 = Aws::S3::Client.new(stub_responses: true) - s3.stub_responses(:list_buckets, 'NotFound') - - begin - s3.list_buckets - rescue StandardError - _(last_span.attributes['rpc.system']).must_equal 'aws-api' - _(last_span.attributes['rpc.service']).must_equal 'S3' - _(last_span.attributes['rpc.method']).must_equal 'ListBuckets' - _(last_span.attributes['aws.region']).must_include 'stubbed' - _(last_span.attributes['db.system']).must_be_nil - end - - _(last_span.attributes[OpenTelemetry::SemanticConventions::Trace::HTTP_STATUS_CODE]).must_equal 400 - - _(last_span.status.code).must_equal OpenTelemetry::Trace::Status::ERROR - end - end - - describe 'dynamodb' do - it 'should have db.system attribute' do - dynamodb_client = Aws::DynamoDB::Client.new(stub_responses: true) - - dynamodb_client.list_tables - - _(last_span.attributes['rpc.system']).must_equal 'aws-api' - _(last_span.attributes['db.system']).must_equal 'dynamodb' - - _(last_span.attributes[OpenTelemetry::SemanticConventions::Trace::HTTP_STATUS_CODE]).must_equal 200 - end - end - - describe 'sqs' do - it 'should have messaging attributes for send_message' do - sqs_client = Aws::SQS::Client.new(stub_responses: true) - - sqs_client.send_message message_body: 'msg', queue_url: 'https://sqs.fake.amazonaws.com/1/queue-name' - - _(last_span.attributes['rpc.system']).must_equal 'aws-api' - _(last_span.attributes['messaging.system']).must_equal 'aws.sqs' - _(last_span.attributes['messaging.destination_kind']).must_equal 'queue' - _(last_span.attributes['messaging.destination']).must_equal 'queue-name' - _(last_span.attributes['messaging.url']).must_equal 'https://sqs.fake.amazonaws.com/1/queue-name' - end - - it 'should have messaging attributes for send_message_batch' do - sqs_client = Aws::SQS::Client.new(stub_responses: true) - - entries = [ - { - id: 'Message1', - message_body: 'This is the first message.' - }, - { - id: 'Message2', - message_body: 'This is the second message.', - message_attributes: { - "attr1": { - "data_type": 'String', - "string_value": 'value1' - } - } - } - ] - - sqs_client.send_message_batch( - queue_url: 'https://sqs.fake.amazonaws.com/1/queue-name', - entries: entries - ) - - _(last_span.attributes['rpc.system']).must_equal 'aws-api' - _(last_span.attributes['messaging.system']).must_equal 'aws.sqs' - _(last_span.attributes['messaging.destination_kind']).must_equal 'queue' - _(last_span.attributes['messaging.destination']).must_equal 'queue-name' - _(last_span.attributes['messaging.url']).must_equal 'https://sqs.fake.amazonaws.com/1/queue-name' - end - end - - describe 'sns' do - it 'should have messaging attributes for publish' do - sns_client = Aws::SNS::Client.new(stub_responses: true) - - sns_client.publish message: 'msg', topic_arn: 'arn:aws:sns:fake:123:topic-name' - - _(last_span.attributes['rpc.system']).must_equal 'aws-api' - _(last_span.attributes['messaging.system']).must_equal 'aws.sns' - _(last_span.attributes['messaging.destination_kind']).must_equal 'topic' - _(last_span.attributes['messaging.destination']).must_equal 'topic-name' - end - - it 'should handle phone numbers' do - # skip if using aws-sdk version before phone_number supported (v2.3.18) - return if Gem::Version.new('2.3.18') > instrumentation.gem_version - - sns_client = Aws::SNS::Client.new(stub_responses: true) - - sns_client.publish message: 'msg', phone_number: '123456' - - _(last_span.attributes['messaging.destination']).must_equal 'phone_number' - _(last_span.name).must_equal 'phone_number send' - end - end - end - - describe 'MessageAttributeSetter' do - it 'set when hash length is lower than 10' do - key = 'foo' - value = 'bar' - metadata_attributes = {} - OpenTelemetry::Instrumentation::AwsSdk::MessageAttributeSetter.set(metadata_attributes, key, value) - _(metadata_attributes[key]).must_equal(string_value: value, data_type: 'String') - end - - it 'should keep existing attributes' do - key = 'foo' - value = 'bar' - metadata_attributes = { - 'existingKey' => { string_value: 'existingValue', data_type: 'String' } - } - OpenTelemetry::Instrumentation::AwsSdk::MessageAttributeSetter.set(metadata_attributes, key, value) - _(metadata_attributes[key]).must_equal(string_value: value, data_type: 'String') - _(metadata_attributes['existingKey']).must_equal(string_value: 'existingValue', data_type: 'String') - end - - it 'should not add if there are 10 or more existing attributes' do - metadata_attributes = { - 'existingKey0' => { string_value: 'existingValue', data_type: 'String' }, - 'existingKey1' => { string_value: 'existingValue', data_type: 'String' }, - 'existingKey2' => { string_value: 'existingValue', data_type: 'String' }, - 'existingKey3' => { string_value: 'existingValue', data_type: 'String' }, - 'existingKey4' => { string_value: 'existingValue', data_type: 'String' }, - 'existingKey5' => { string_value: 'existingValue', data_type: 'String' }, - 'existingKey6' => { string_value: 'existingValue', data_type: 'String' }, - 'existingKey7' => { string_value: 'existingValue', data_type: 'String' }, - 'existingKey8' => { string_value: 'existingValue', data_type: 'String' }, - 'existingKey9' => { string_value: 'existingValue', data_type: 'String' } - } - OpenTelemetry::Instrumentation::AwsSdk::MessageAttributeSetter.set(metadata_attributes, 'new10', 'value') - _(metadata_attributes.keys).must_equal(%w[existingKey0 existingKey1 existingKey2 existingKey3 existingKey4 existingKey5 existingKey6 existingKey7 existingKey8 existingKey9]) - end - end -end diff --git a/instrumentation/aws_sdk/test/test_helper.rb b/instrumentation/aws_sdk/test/test_helper.rb deleted file mode 100644 index c2733e3d6a..0000000000 --- a/instrumentation/aws_sdk/test/test_helper.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'aws-sdk' -require 'opentelemetry-instrumentation-aws_sdk' -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' - -require 'minitest/autorun' -require 'rspec/mocks/minitest_integration' - -# global opentelemetry-sdk setup: -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry.logger = Logger.new(File::NULL) - -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::AwsSdk' - c.add_span_processor span_processor -end diff --git a/instrumentation/base/.rubocop.yml b/instrumentation/base/.rubocop.yml deleted file mode 100644 index f87cd8c853..0000000000 --- a/instrumentation/base/.rubocop.yml +++ /dev/null @@ -1,27 +0,0 @@ -AllCops: - TargetRubyVersion: "2.6.0" - -Bundler/OrderedGems: - Exclude: - - gemfiles/**/* -Lint/UnusedMethodArgument: - Enabled: false -Metrics/AbcSize: - Max: 18 -Metrics/LineLength: - Enabled: false -Metrics/MethodLength: - Max: 20 -Metrics/ParameterLists: - Enabled: false -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-base.rb" -Style/FrozenStringLiteralComment: - Exclude: - - gemfiles/**/* -Style/ModuleFunction: - Enabled: false -Style/StringLiterals: - Exclude: - - gemfiles/**/* diff --git a/instrumentation/base/.yardopts b/instrumentation/base/.yardopts deleted file mode 100644 index a483c57630..0000000000 --- a/instrumentation/base/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Base Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/base/CHANGELOG.md b/instrumentation/base/CHANGELOG.md deleted file mode 100644 index d950a628dc..0000000000 --- a/instrumentation/base/CHANGELOG.md +++ /dev/null @@ -1,36 +0,0 @@ -# Release History: opentelemetry-instrumentation-base - -### v0.21.0 / 2022-05-26 - -* BREAKING CHANGE: This requires upgrading both the SDK and Instrumentation gem in tandem - - -### v0.20.0 / 2022-05-02 - -* ADDED: Validate Using Enums -* FIXED: RubyGems Fallback - -### v0.19.0 / 2021-12-01 - -* ADDED: Add default options config helper + env var config option support - -### v0.18.3 / 2021-09-29 - -* (No significant changes) - -### v0.18.2 / 2021-08-12 - -* (No significant changes) - -### v0.18.1 / 2021-06-23 - -* (No significant changes) - -### v0.18.0 / 2021-05-21 - -* ADDED: Updated API depedency for 1.0.0.rc1 -* FIXED: Missing instrumentation classes during configuration - -### v0.17.0 / 2021-04-22 - -* Initial release. diff --git a/instrumentation/base/Gemfile b/instrumentation/base/Gemfile deleted file mode 100644 index f649e2f64a..0000000000 --- a/instrumentation/base/Gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec diff --git a/instrumentation/base/LICENSE b/instrumentation/base/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/base/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/base/README.md b/instrumentation/base/README.md deleted file mode 100644 index 394ad19c8b..0000000000 --- a/instrumentation/base/README.md +++ /dev/null @@ -1,154 +0,0 @@ -# OpenTelemetry Instrumentation Base - -The `opentelemetry-instrumentation-base` gem contains the instrumentation base class, and the instrumentation registry. These modules provide a common interface to support the installation of auto instrumentation libraries. The instrumentation base is responsible for adding itself to the instrumentation registry as well as providing convenience hooks for the installation process. The instrumentation registry contains all the instrumentation to be installed during the SDK configuration process. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-base -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-base` in your `Gemfile`. - -### For SDK Authors - -The following is a simplified demonstration of how the `OpenTelemetry::Instrumentation.registry` can be used by an SDK to install auto-instrumentation gems as part of its configuration. This should not be used as an example of how to implement an SDK as there are large omissions. For an example of a complete implementation see the `opentelemetry-sdk` gem. - -```ruby -require 'bundler/inline' - -gemfile(true) do - source 'https://rubygems.org' - gem 'opentelemetry-api' - gem 'opentelemetry-instrumentation-base' - gem 'opentelemetry-instrumentation-net_http' -end - -require 'opentelemetry-api' -require 'opentelemetry-instrumentation-base' - -# Setup a noop custom tracer for our SDK -class MyCustomTracer < OpenTelemetry::Trace::Tracer - def initialize(name, version) - @name = name - @version = version - end -end - -# Setup a tracer provider for our SDK -class MyCustomTracerProvider < OpenTelemetry::Trace::TracerProvider - def tracer(name = nil, version = nil) - MyCustomTracer.new(name, version) - end -end - -class MyCustomSDK - def self.configure(config = {}) - # It is important that we upgrade the API tracer provider to - # our SDK tracer provider so that when the install hook is - # called that our instrumentation libraries receive an - # SDK tracer instead of the noop API tracer. - OpenTelemetry.tracer_provider = MyCustomTracerProvider.new - OpenTelemetry::Instrumentation.registry.install_all(config) - end -end - -# The config option being passed to through to the registry install_all method. -# This is not a valid configuration option for this instrumentation library -# so the Opentelemetry logger will receive a warning message. -config = { 'OpenTelemetry::Instrumentation::Net::HTTP' => { foo: 'bar' } } -MyCustomSDK.configure(config) - -# The purpose of this line is to demonstrate that the instrumentation -# library has received the SDK tracer and is not using the default -# API noop tracer. -puts OpenTelemetry::Instrumentation::Net::HTTP::Instrumentation.instance.tracer.inspect - -#### Output -# Fetching gem metadata from https://rubygems.org/.. -# Resolving dependencies... -# Using bundler 1.17.3 -# Using opentelemetry-api 0.16.0 -# Using opentelemetry-common 0.16.0 -# Using opentelemetry-instrumentation-base 0.16.0 -# Using opentelemetry-instrumentation-net_http 0.16.0 -# W, [2021-04-08T17:28:04.430002 #8425] WARN -- : Instrumentation OpenTelemetry::Instrumentation::Net::HTTP ignored the following unknown configuration options [:foo] -# I, [2021-04-08T17:28:04.430697 #8425] INFO -- : Instrumentation: OpenTelemetry::Instrumentation::Net::HTTP was successfully installed -# # -``` - -### For auto-instrumentation authors - -The following is a simplified demonstration of how the `OpenTelemetry::Instrumentation::Base` class can be used to hook into the instrumentation registry, and the basic functionality provided. - -```ruby -# A simple class to instrument -class SimpleClass - def greeting - puts "hello" - end -end - -# Our instrumentation patch -class SimplePatch - def greeting - tracer.in_span('SimpleClass#greeting') { super } - end - - private - - # We can gain access to the instrumentation tracer using - # the instance method available on the class inheriting - # from the instrumentation base. - def tracer - CustomAutoInstrumentation.instance.tracer - end -end - -# The OpenTelemetry::Instrumentation::Base class will implicitly add -# any class that inherits from it to the registry. -# Note that the name of the instrumentation in the registry will match -# the class name and its namespace. In this example the registry -# will contain 'CustomAutoInstrumentation', if it was within -# a module named `Legacy`, it would take the form `Legacy::CustomAutoInstrumentation`. -class CustomAutoInstrumentation < OpenTelemetry::Instrumentation::Base - # The install hook is provided to apply patches through prepending - # or using library hooks if available. - install do |_config| - patch - end - - # The presence check provides a hook so that we can - # test for the presence of the class we intend to patch. - # If the presence check returns false, we will not - # proceed with the installation hook. - present do - defined?(SimpleClass) - end - - private - - def patch - SimpleClass.prepend(SimplePatch) - end -end -``` - -## How can I get involved? - -The `opentelemetry-instrumentation-base` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -The `opentelemetry-instrumentation-base` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information. - -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/instrumentation/base/Rakefile b/instrumentation/base/Rakefile deleted file mode 100644 index 1a64ba842e..0000000000 --- a/instrumentation/base/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/base/lib/opentelemetry-instrumentation-base.rb b/instrumentation/base/lib/opentelemetry-instrumentation-base.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/base/lib/opentelemetry-instrumentation-base.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/base/lib/opentelemetry/instrumentation.rb b/instrumentation/base/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index c02712b64e..0000000000 --- a/instrumentation/base/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry-registry' -require 'opentelemetry/instrumentation/base' - -module OpenTelemetry - # The instrumentation module contains functionality to register and install - # instrumentation - module Instrumentation - end -end diff --git a/instrumentation/base/lib/opentelemetry/instrumentation/base.rb b/instrumentation/base/lib/opentelemetry/instrumentation/base.rb deleted file mode 100644 index 0fdee7356e..0000000000 --- a/instrumentation/base/lib/opentelemetry/instrumentation/base.rb +++ /dev/null @@ -1,368 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - # The Base class holds all metadata and configuration for an - # instrumentation. All instrumentation packages should - # include a subclass of +Instrumentation::Base+ that will register - # it with +OpenTelemetry.instrumentation_registry+ and make it available for - # discovery and installation by an SDK. - # - # A typical subclass of Base will provide an install block, a present - # block, and possibly a compatible block. Below is an - # example: - # - # module OpenTelemetry - # module Instrumentation - # module Sinatra - # class Instrumentation < OpenTelemetry::Instrumentation::Base - # install do |config| - # # install instrumentation, either by library hook or applying - # # a monkey patch - # end - # - # # determine if the target library is present - # present do - # defined?(::Sinatra) - # end - # - # # if the target library is present, is it compatible? - # compatible do - # Gem::Version.new(Sinatra::VERSION)) > MIN_VERSION - # end - # end - # end - # end - # end - # - # The instrumentation name and version will be inferred from the namespace of the - # class. In this example, they'd be 'OpenTelemetry::Instrumentation::Sinatra' and - # OpenTelemetry::Instrumentation::Sinatra::VERSION, but can be explicitly set using - # the +instrumentation_name+ and +instrumetation_version+ methods if necessary. - # - # All subclasses of OpenTelemetry::Instrumentation::Base are automatically - # registered with OpenTelemetry.instrumentation_registry which is used by - # SDKs for instrumentation discovery and installation. - # - # Instrumentation libraries can use the instrumentation subclass to easily gain - # a reference to its named tracer. For example: - # - # OpenTelemetry::Instrumentation::Sinatra.instance.tracer - # - # The instrumention class establishes a convention for disabling an instrumentation - # by environment variable and local configuration. An instrumentation disabled - # by environment variable will take precedence over local config. The - # convention for environment variable name is the library name, upcased with - # '::' replaced by underscores, OPENTELEMETRY shortened to OTEL_{LANG}, and '_ENABLED' appended. - # For example: OTEL_RUBY_INSTRUMENTATION_SINATRA_ENABLED = false. - class Base # rubocop:disable Metrics/ClassLength - class << self - NAME_REGEX = /^(?:(?[a-zA-Z0-9_:]+):{2})?(?[a-zA-Z0-9_]+)$/.freeze - VALIDATORS = { - array: ->(v) { v.is_a?(Array) }, - boolean: ->(v) { v == true || v == false }, # rubocop:disable Style/MultipleComparison - callable: ->(v) { v.respond_to?(:call) }, - integer: ->(v) { v.is_a?(Integer) }, - string: ->(v) { v.is_a?(String) } - }.freeze - - private_constant :NAME_REGEX, :VALIDATORS - - private :new # rubocop:disable Style/AccessModifierDeclarations - - def inherited(subclass) - OpenTelemetry::Instrumentation.registry.register(subclass) - end - - # Optionally set the name of this instrumentation. If not - # explicitly set, the name will default to the namespace of the class, - # or the class name if it does not have a namespace. If there is not - # a namespace, or a class name, it will default to 'unknown'. - # - # @param [String] instrumentation_name The full name of the instrumentation package - def instrumentation_name(instrumentation_name = nil) - if instrumentation_name - @instrumentation_name = instrumentation_name - else - @instrumentation_name ||= infer_name || 'unknown' - end - end - - # Optionally set the version of this instrumentation. If not explicitly set, - # the version will default to the VERSION constant under namespace of - # the class, or the VERSION constant under the class name if it does not - # have a namespace. If a VERSION constant cannot be found, it defaults - # to '0.0.0'. - # - # @param [String] instrumentation_version The version of the instrumentation package - def instrumentation_version(instrumentation_version = nil) - if instrumentation_version - @instrumentation_version = instrumentation_version - else - @instrumentation_version ||= infer_version || '0.0.0' - end - end - - # The install block for this instrumentation. This will be where you install - # instrumentation, either by framework hook or applying a monkey patch. - # - # @param [Callable] blk The install block for this instrumentation - # @yieldparam [Hash] config The instrumentation config will be yielded to the - # install block - def install(&blk) - @install_blk = blk - end - - # The present block for this instrumentation. This block is used to detect if - # target library is present on the system. Typically this will involve - # checking to see if the target gem spec was loaded or if expected - # constants from the target library are present. - # - # @param [Callable] blk The present block for this instrumentation - def present(&blk) - @present_blk = blk - end - - # The compatible block for this instrumentation. This check will be run if the - # target library is present to determine if it's compatible. It's not - # required, but a common use case will be to check to target library - # version for compatibility. - # - # @param [Callable] blk The compatibility block for this instrumentation - def compatible(&blk) - @compatible_blk = blk - end - - # The option method is used to define default configuration options - # for the instrumentation library. It requires a name, default value, - # and a validation callable to be provided. - # @param [String] name The name of the configuration option - # @param default The default value to be used, or to used if validation fails - # @param [Callable, Symbol] validate Accepts a callable or a symbol that matches - # a key in the VALIDATORS hash. The supported keys are, :array, :boolean, - # :callable, :integer, :string. - def option(name, default:, validate:) - validator = VALIDATORS[validate] || validate - raise ArgumentError, "validate must be #{VALIDATORS.keys.join(', ')}, or a callable" unless validator.respond_to?(:call) || validator.respond_to?(:include?) - - @options ||= [] - - validation_type = if VALIDATORS[validate] - validate - elsif validate.respond_to?(:include?) - :enum - else - :callable - end - - @options << { name: name, default: default, validator: validator, validation_type: validation_type } - end - - def instance - @instance ||= new(instrumentation_name, instrumentation_version, install_blk, - present_blk, compatible_blk, options) - end - - private - - attr_reader :install_blk, :present_blk, :compatible_blk, :options - - def infer_name - @inferred_name ||= if (md = name.match(NAME_REGEX)) # rubocop:disable Naming/MemoizedInstanceVariableName - md['namespace'] || md['classname'] - end - end - - def infer_version - return unless (inferred_name = infer_name) - - mod = inferred_name.split('::').map(&:to_sym).inject(Object) do |object, const| - object.const_get(const) - end - mod.const_get(:VERSION) - rescue NameError - nil - end - end - - attr_reader :name, :version, :config, :installed, :tracer - - alias installed? installed - - def initialize(name, version, install_blk, present_blk, - compatible_blk, options) - @name = name - @version = version - @install_blk = install_blk - @present_blk = present_blk - @compatible_blk = compatible_blk - @config = {} - @installed = false - @options = options - @tracer = OpenTelemetry::Trace::Tracer.new - end - - # Install instrumentation with the given config. The present? and compatible? - # will be run first, and install will return false if either fail. Will - # return true if install was completed successfully. - # - # @param [Hash] config The config for this instrumentation - def install(config = {}) - return true if installed? - return false unless installable?(config) - - @config = config_options(config) - instance_exec(@config, &@install_blk) - @tracer = OpenTelemetry.tracer_provider.tracer(name, version) - @installed = true - end - - # Whether or not this instrumentation is installable in the current process. Will - # be true when the instrumentation defines an install block, is not disabled - # by environment or config, and the target library present and compatible. - # - # @param [Hash] config The config for this instrumentation - def installable?(config = {}) - @install_blk && enabled?(config) && present? && compatible? - end - - # Calls the present block of the Instrumentation subclasses, if no block is provided - # it's assumed the instrumentation is not present - def present? - return false unless @present_blk - - instance_exec(&@present_blk) - end - - # Calls the compatible block of the Instrumentation subclasses, if no block is provided - # it's assumed to be compatible - def compatible? - return true unless @compatible_blk - - instance_exec(&@compatible_blk) - end - - # Whether this instrumentation is enabled. It first checks to see if it's enabled - # by an environment variable and will proceed to check if it's enabled - # by local config, if given. - # - # @param [optional Hash] config The local config - def enabled?(config = nil) - return false unless enabled_by_env_var? - return config[:enabled] if config&.key?(:enabled) - - true - end - - private - - # The config_options method is responsible for validating that the user supplied - # config hash is valid. - # Unknown configuration keys are not included in the final config hash. - # Invalid configuration values are logged, and replaced by the default. - # - # @param [Hash] user_config The user supplied configuration hash - def config_options(user_config) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity - @options ||= {} - user_config ||= {} - config_overrides = config_overrides_from_env - validated_config = @options.each_with_object({}) do |option, h| - option_name = option[:name] - config_value = user_config[option_name] - config_override = coerce_env_var(config_overrides[option_name], option[:validation_type]) if config_overrides[option_name] - - value = if config_value.nil? && config_override.nil? - option[:default] - elsif option[:validator].respond_to?(:include?) && option[:validator].include?(config_override) - config_override - elsif option[:validator].respond_to?(:include?) && option[:validator].include?(config_value) - config_value - elsif option[:validator].respond_to?(:call) && option[:validator].call(config_override) - config_override - elsif option[:validator].respond_to?(:call) && option[:validator].call(config_value) - config_value - else - OpenTelemetry.logger.warn( - "Instrumentation #{name} configuration option #{option_name} value=#{config_value} " \ - "failed validation, falling back to default value=#{option[:default]}" - ) - option[:default] - end - - h[option_name] = value - rescue StandardError => e - OpenTelemetry.handle_error(exception: e, message: "Instrumentation #{name} unexpected configuration error") - h[option_name] = option[:default] - end - - dropped_config_keys = user_config.keys - validated_config.keys - OpenTelemetry.logger.warn("Instrumentation #{name} ignored the following unknown configuration options #{dropped_config_keys}") unless dropped_config_keys.empty? - - validated_config - end - - # Checks to see if this instrumentation is enabled by env var. By convention, the - # environment variable will be the instrumentation name upper cased, with '::' - # replaced by underscores, OPENTELEMETRY shortened to OTEL_{LANG} and _ENABLED appended. - # For example, the, environment variable name for OpenTelemetry::Instrumentation::Sinatra - # will be OTEL_RUBY_INSTRUMENTATION_SINATRA_ENABLED. A value of 'false' will disable - # the instrumentation, all other values will enable it. - def enabled_by_env_var? - var_name = name.dup.tap do |n| - n.upcase! - n.gsub!('::', '_') - n.gsub!('OPENTELEMETRY_', 'OTEL_RUBY_') - n << '_ENABLED' - end - ENV[var_name] != 'false' - end - - def config_overrides_from_env - var_name = name.dup.tap do |n| - n.upcase! - n.gsub!('::', '_') - n.gsub!('OPENTELEMETRY_', 'OTEL_RUBY_') - n << '_CONFIG_OPTS' - end - - environment_config_overrides = {} - env_config_options = ENV[var_name]&.split(';') - - return environment_config_overrides if env_config_options.nil? - - env_config_options.each_with_object(environment_config_overrides) do |env_config_option, eco| - parts = env_config_option.split('=') - option_name = parts[0].to_sym - eco[option_name] = parts[1] - end - - environment_config_overrides - end - - def coerce_env_var(env_var, validation_type) # rubocop:disable Metrics/CyclomaticComplexity - case validation_type - when :array - env_var.split(',').map(&:strip) - when :boolean - env_var.to_s.strip.downcase == 'true' - when :integer - env_var.to_i - when :string - env_var.to_s.strip - when :enum - env_var.to_s.strip.to_sym - when :callable - OpenTelemetry.logger.warn( - "Instrumentation #{name} options that accept a callable are not " \ - "configurable using environment variables. Ignoring raw value: #{env_var}" - ) - nil - end - end - end - end -end diff --git a/instrumentation/base/lib/opentelemetry/instrumentation/version.rb b/instrumentation/base/lib/opentelemetry/instrumentation/version.rb deleted file mode 100644 index 5b1d0f0ab3..0000000000 --- a/instrumentation/base/lib/opentelemetry/instrumentation/version.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - VERSION = '0.21.0' - end -end diff --git a/instrumentation/base/opentelemetry-instrumentation-base.gemspec b/instrumentation/base/opentelemetry-instrumentation-base.gemspec deleted file mode 100644 index 0d5f08eac3..0000000000 --- a/instrumentation/base/opentelemetry-instrumentation-base.gemspec +++ /dev/null @@ -1,46 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-base' - spec.version = OpenTelemetry::Instrumentation::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'Instrumentation Base for the OpenTelemetry framework' - spec.description = 'Instrumentation Base for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-registry', '~> 0.1' - - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'rake', '~> 12.3.3' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-base/v#{OpenTelemetry::Instrumentation::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/base' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-base/v#{OpenTelemetry::Instrumentation::VERSION}" - end -end diff --git a/instrumentation/base/test/.rubocop.yml b/instrumentation/base/test/.rubocop.yml deleted file mode 100644 index dd94258585..0000000000 --- a/instrumentation/base/test/.rubocop.yml +++ /dev/null @@ -1,4 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false diff --git a/instrumentation/base/test/instrumentation/base_test.rb b/instrumentation/base/test/instrumentation/base_test.rb deleted file mode 100644 index c58bbe5003..0000000000 --- a/instrumentation/base/test/instrumentation/base_test.rb +++ /dev/null @@ -1,456 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -describe OpenTelemetry::Instrumentation::Base do - after { OpenTelemetry::Instrumentation.instance_variable_set(:@registry, nil) } - - let(:instrumentation) do - Class.new(OpenTelemetry::Instrumentation::Base) do - instrumentation_name 'test_instrumentation' - instrumentation_version '0.1.1' - end - end - - let(:instrumentation_with_callbacks) do - Class.new(OpenTelemetry::Instrumentation::Base) do - attr_writer :present, :compatible - attr_reader :present_called, :compatible_called, :install_called, - :config_yielded - - instrumentation_name 'test_instrumentation' - instrumentation_version '0.1.1' - - present do - @present_called = true - @present - end - - compatible do - @compatible_called = true - @compatible - end - - install do |config| - @config_yielded = config - @install_called = true - end - - option :max_count, default: 5, validate: ->(v) { v.is_a?(Integer) } - - def initialize(*args) - super - @present = true - @compatible = true - @present_called = false - @compatible_called = false - @install_called = false - end - end - end - - it 'is auto-registered' do - instance = instrumentation.instance - _(OpenTelemetry::Instrumentation.registry.lookup('test_instrumentation')).must_equal(instance) - end - - describe '.instance' do - it 'returns an instance' do - _(instrumentation.instance).must_be_instance_of(instrumentation) - end - end - - describe '.option' do - let(:instrumentation) do - Class.new(OpenTelemetry::Instrumentation::Base) do - instrumentation_name 'test_buggy_instrumentation' - instrumentation_version '0.0.1' - - option :a, default: 'b', validate: true - end - end - - it 'raises argument errors when validate does not receive a callable or valid symbol' do - _(-> { instrumentation.instance }).must_raise(ArgumentError) - end - end - - describe '#name' do - it 'returns instrumentation name' do - _(instrumentation.instance.name).must_equal('test_instrumentation') - end - end - - describe '#version' do - it 'returns instrumentation version' do - _(instrumentation.instance.version).must_equal('0.1.1') - end - end - - describe '#present?' do - describe 'with present block' do - it 'calls the present block' do - instance = instrumentation_with_callbacks.instance - _(instance.present?).must_equal(true) - _(instance.present_called).must_equal(true) - end - end - - describe 'without present block' do - it 'defaults to false' do - instance = instrumentation.instance - _(instance.present?).must_equal(false) - end - end - end - - describe '#compatible?' do - describe 'with compatible block' do - it 'calls the compatible block' do - instance = instrumentation_with_callbacks.instance - _(instance.compatible?).must_equal(true) - _(instance.compatible_called).must_equal(true) - end - end - - describe 'without compatible block' do - it 'defaults to true' do - instance = instrumentation.instance - _(instance.compatible?).must_equal(true) - end - end - end - - describe '#install' do - describe 'when installable' do - it 'calls the install block' do - instance = instrumentation_with_callbacks.instance - _(instance.install).must_equal(true) - _(instance.install_called).must_equal(true) - end - - it 'yields and sets config' do - instance = instrumentation_with_callbacks.instance - config = { max_count: 3 } - - instance.install(config) - _(instance.config_yielded).must_equal(config) - _(instance.config).must_equal(config) - end - - it 'drops and logs unknown config keys before yielding and setting' do - instance = instrumentation_with_callbacks.instance - config = { max_count: 3, unknown_config_option: 500 } - expected_config = { max_count: 3 } - - OpenTelemetry::TestHelpers.with_test_logger do |log_stream| - instance.install(config) - _(log_stream.string).must_match(/Instrumentation test_instrumentation ignored the following unknown configuration options \[:unknown_config_option\]/) - end - - _(instance.config_yielded).must_equal(expected_config) - _(instance.config).must_equal(expected_config) - end - - it 'uses the default config options when not provided' do - instance = instrumentation_with_callbacks.instance - config = {} - expected_config = { max_count: 5 } - - instance.install(config) - _(instance.config_yielded).must_equal(expected_config) - _(instance.config).must_equal(expected_config) - end - - it 'uses the default config options and logs when validation fails' do - instance = instrumentation_with_callbacks.instance - config = { max_count: 'three' } - expected_config = { max_count: 5 } - - OpenTelemetry::TestHelpers.with_test_logger do |log_stream| - instance.install(config) - _(log_stream.string).must_match(/Instrumentation test_instrumentation configuration option max_count value=three failed validation, falling back to default value=5/) - end - - _(instance.config_yielded).must_equal(expected_config) - _(instance.config).must_equal(expected_config) - end - - describe 'when environment variables are used to set configuration options' do - after do - # Force re-install of instrumentation - instance.instance_variable_set(:@installed, false) - end - - let(:env_controlled_instrumentation) do - Class.new(OpenTelemetry::Instrumentation::Base) do - instrumentation_name 'opentelemetry_instrumentation_env_controlled' - instrumentation_version '0.0.2' - - present { true } - compatible { true } - install { true } - - option(:first, default: 'first_default', validate: :string) - option(:second, default: :no, validate: %I[yes no maybe]) - option(:third, default: 1, validate: ->(v) { v <= 10 }) - option(:forth, default: false, validate: :boolean) - option(:fifth, default: true, validate: :boolean) - end - end - - let(:instance) { env_controlled_instrumentation.instance } - - it 'installs options defined by environment variable and overrides defaults' do - OpenTelemetry::TestHelpers.with_env('OTEL_RUBY_INSTRUMENTATION_ENV_CONTROLLED_CONFIG_OPTS' => 'first=non_default_value') do - instance.install - _(instance.config).must_equal(first: 'non_default_value', second: :no, third: 1, forth: false, fifth: true) - end - end - - it 'installs boolean type options defined by environment variable and only evalutes the lowercase string "true" to be truthy' do - OpenTelemetry::TestHelpers.with_env('OTEL_RUBY_INSTRUMENTATION_ENV_CONTROLLED_CONFIG_OPTS' => 'first=non_default_value;forth=true;fifth=truthy') do - instance.install - _(instance.config).must_equal(first: 'non_default_value', second: :no, third: 1, forth: true, fifth: false) - end - end - - it 'installs only enum options defined by environment variable that accept a symbol' do - OpenTelemetry::TestHelpers.with_env('OTEL_RUBY_INSTRUMENTATION_ENV_CONTROLLED_CONFIG_OPTS' => 'second=maybe') do - instance.install - _(instance.config).must_equal(first: 'first_default', second: :maybe, third: 1, forth: false, fifth: true) - end - end - - it 'installs options defined by environment variable and overrides local configuration' do - OpenTelemetry::TestHelpers.with_env('OTEL_RUBY_INSTRUMENTATION_ENV_CONTROLLED_CONFIG_OPTS' => 'first=non_default_value') do - instance.install(first: 'another_default') - _(instance.config).must_equal(first: 'non_default_value', second: :no, third: 1, forth: false, fifth: true) - end - end - - it 'installs multiple options defined by environment variable' do - OpenTelemetry::TestHelpers.with_env('OTEL_RUBY_INSTRUMENTATION_ENV_CONTROLLED_CONFIG_OPTS' => 'first=non_default_value;second=maybe') do - instance.install(first: 'another_default', second: :yes) - _(instance.config).must_equal(first: 'non_default_value', second: :maybe, third: 1, forth: false, fifth: true) - end - end - - it 'does not install callable options defined by environment variable' do - OpenTelemetry::TestHelpers.with_env('OTEL_RUBY_INSTRUMENTATION_ENV_CONTROLLED_CONFIG_OPTS' => 'first=non_default_value;second=maybe;third=5') do - instance.install(first: 'another_default', second: :yes) - _(instance.config).must_equal(first: 'non_default_value', second: :maybe, third: 1, forth: false, fifth: true) - end - end - end - - describe 'when there is an option with a raising validate callable' do - after do - # Force re-install of instrumentation - instance.instance_variable_set(:@installed, false) - end - - let(:buggy_instrumentation) do - Class.new(OpenTelemetry::Instrumentation::Base) do - instrumentation_name 'test_buggy_instrumentation' - instrumentation_version '0.0.2' - - present { true } - compatible { true } - install { true } - - option :first, default: 'first_default', validate: ->(_v) { raise 'hell' } - option :second, default: 'second_default', validate: ->(v) { v.is_a?(String) } - end - end - - let(:instance) { buggy_instrumentation.instance } - - it 'falls back to the default' do - instance.install(first: 'value', second: 'user_value') - _(instance.config).must_equal(first: 'first_default', second: 'user_value') - end - end - - describe 'when there is an option with an enum validation type' do - after do - # Force re-install of instrumentation - instance.instance_variable_set(:@installed, false) - end - - let(:enum_instrumentation) do - Class.new(OpenTelemetry::Instrumentation::Base) do - instrumentation_name 'opentelemetry_instrumentation_enum' - instrumentation_version '0.0.2' - - present { true } - compatible { true } - install { true } - - option(:first, default: :no, validate: %I[yes no maybe]) - option(:second, default: :no, validate: %I[yes no maybe]) - end - end - - let(:instance) { enum_instrumentation.instance } - - it 'falls back to the default if user option is not an enumerable option' do - instance.install(first: :yes, second: :perhaps) - _(instance.config).must_equal(first: :yes, second: :no) - end - - it 'installs options defined by environment variable and overrides defaults and user config' do - OpenTelemetry::TestHelpers.with_env('OTEL_RUBY_INSTRUMENTATION_ENUM_CONFIG_OPTS' => 'first=yes') do - instance.install(first: :maybe, second: :no) - _(instance.config).must_equal(first: :yes, second: :no) - end - end - - it 'falls back to install options defined by user config when environment variable fails validation' do - OpenTelemetry::TestHelpers.with_env('OTEL_RUBY_INSTRUMENTATION_ENUM_CONFIG_OPTS' => 'first=perhaps') do - instance.install(first: :maybe, second: :no) - _(instance.config).must_equal(first: :maybe, second: :no) - end - end - end - end - - describe 'when uninstallable' do - it 'returns false' do - instance = instrumentation_with_callbacks.instance - instance.compatible = false - _(instance.install).must_equal(false) - _(instance.install_called).must_equal(false) - end - end - - describe 'without install block defined' do - it 'returns false' do - instance = instrumentation.instance - _(instance.install).must_equal(false) - end - end - end - - describe '#installed?' do - it 'reflects install state' do - instance = instrumentation_with_callbacks.instance - _(instance.installed?).must_equal(false) - _(instance.install).must_equal(true) - _(instance.installed?).must_equal(true) - end - end - - describe '#enabled?' do - describe 'with env var' do - it 'is disabled when false' do - OpenTelemetry::TestHelpers.with_env('TEST_INSTRUMENTATION_ENABLED' => 'false') do - _(instrumentation.instance.enabled?).must_equal(false) - end - end - - it 'is enabled when true' do - OpenTelemetry::TestHelpers.with_env('TEST_INSTRUMENTATION_ENABLED' => 'true') do - _(instrumentation.instance.enabled?).must_equal(true) - end - end - - it 'overrides local config value' do - OpenTelemetry::TestHelpers.with_env('TEST_INSTRUMENTATION_ENABLED' => 'false') do - instrumentation.instance.enabled?(enabled: true) - _(instrumentation.instance.enabled?).must_equal(false) - end - end - - describe 'local config' do - it 'is disabled when false' do - _(instrumentation.instance.enabled?(enabled: false)).must_equal(false) - end - - it 'is enabled when true' do - _(instrumentation.instance.enabled?(enabled: true)).must_equal(true) - end - end - - describe 'without env var or config' do - it 'returns true' do - _(instrumentation.instance.enabled?).must_equal(true) - end - end - end - end - - describe 'minimal_instrumentation' do - before do - MinimalBase = Class.new(OpenTelemetry::Instrumentation::Base) - end - - after do - Object.send(:remove_const, :MinimalBase) - end - - describe '#name' do - it 'is the class name stringified' do - _(MinimalBase.instance.name).must_equal('MinimalBase') - end - end - - describe '#version' do - it 'defaults to 0.0.0' do - _(MinimalBase.instance.version).must_equal('0.0.0') - end - end - end - - describe '#tracer' do - it 'returns a noop api tracer if not installed' do - _(instrumentation_with_callbacks.instance.tracer).must_be_kind_of(OpenTelemetry::Trace::Tracer) - end - - it 'returns named tracer if installed' do - instance = instrumentation_with_callbacks.instance - instance.install - _(instance.tracer).must_be_kind_of(OpenTelemetry::Trace::Tracer) - end - end - - describe 'namespaced instrumentation' do - before do - define_instrumentation_subclass('OTel::Instrumentation::Sinatra::Instrumentation', '2.1.0') - end - - after do - Object.send(:remove_const, :OTel) - end - - describe '#name' do - it 'defaults to the namespace' do - instance = OTel::Instrumentation::Sinatra::Instrumentation.instance - _(instance.name).must_equal('OTel::Instrumentation::Sinatra') - end - end - - describe '#version' do - it 'defaults to the version constant' do - instance = OTel::Instrumentation::Sinatra::Instrumentation.instance - _(instance.version).must_equal(OTel::Instrumentation::Sinatra::VERSION) - end - end - end - - def define_instrumentation_subclass(name, version = nil) - names = name.split('::').map(&:to_sym) - names.inject(Object) do |object, const| - if const == names[-1] - object.const_set(:VERSION, version) if version - object.const_set(const, Class.new(OpenTelemetry::Instrumentation::Base)) - else - object.const_set(const, Module.new) - end - end - end -end diff --git a/instrumentation/base/test/instrumentation_test.rb b/instrumentation/base/test/instrumentation_test.rb deleted file mode 100644 index 38dfe4f8f8..0000000000 --- a/instrumentation/base/test/instrumentation_test.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -describe OpenTelemetry::Instrumentation do - describe '.registry' do - it 'returns an instance of Instrumentation::Registry' do - _(OpenTelemetry::Instrumentation.registry).must_be_instance_of( - OpenTelemetry::Instrumentation::Registry - ) - end - end -end diff --git a/instrumentation/base/test/test_helper.rb b/instrumentation/base/test/test_helper.rb deleted file mode 100644 index 0899bd024f..0000000000 --- a/instrumentation/base/test/test_helper.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'simplecov' -SimpleCov.start -SimpleCov.minimum_coverage 85 - -require 'opentelemetry/instrumentation' -require 'opentelemetry-test-helpers' -require 'minitest/autorun' - -OpenTelemetry.logger = Logger.new(File::NULL) diff --git a/instrumentation/bunny/.rubocop.yml b/instrumentation/bunny/.rubocop.yml deleted file mode 100644 index 6d61ed7d31..0000000000 --- a/instrumentation/bunny/.rubocop.yml +++ /dev/null @@ -1,29 +0,0 @@ -AllCops: - TargetRubyVersion: "2.6.0" - -Bundler/OrderedGems: - Exclude: - - gemfiles/**/* -Lint/UnusedMethodArgument: - Enabled: false -Metrics/AbcSize: - Max: 18 -Metrics/LineLength: - Enabled: false -Metrics/MethodLength: - Max: 20 -Metrics/ParameterLists: - Enabled: false -Naming/FileName: - Exclude: - - "example/bunny.rb" - - "lib/opentelemetry-instrumentation-bunny.rb" - - "lib/opentelemetry/instrumentation/bunny.rb" -Style/FrozenStringLiteralComment: - Exclude: - - gemfiles/**/* -Style/ModuleFunction: - Enabled: false -Style/StringLiterals: - Exclude: - - gemfiles/**/* diff --git a/instrumentation/bunny/.yardopts b/instrumentation/bunny/.yardopts deleted file mode 100644 index 5443887654..0000000000 --- a/instrumentation/bunny/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Bunny Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/bunny/Appraisals b/instrumentation/bunny/Appraisals deleted file mode 100644 index a6810ee3fb..0000000000 --- a/instrumentation/bunny/Appraisals +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -appraise 'bunny-2' do - gem 'bunny', '~> 2' -end diff --git a/instrumentation/bunny/CHANGELOG.md b/instrumentation/bunny/CHANGELOG.md deleted file mode 100644 index a12c67bee2..0000000000 --- a/instrumentation/bunny/CHANGELOG.md +++ /dev/null @@ -1,30 +0,0 @@ -# Release History: opentelemetry-instrumentation-bunny - -### v0.19.0 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Broken test file requirements - -### v0.18.5 / 2022-05-05 - -* (No significant changes) - -### v0.18.4 / 2021-12-02 - -* (No significant changes) - -### v0.18.3 / 2021-09-29 - -* (No significant changes) - -### v0.18.2 / 2021-08-12 - -* DOCS: Update docs to rely more on environment variable configuration - -### v0.18.1 / 2021-06-23 - -* FIXED: Add missing require to bunny instrumentation - -### v0.18.0 / 2021-05-21 - -* Initial release. diff --git a/instrumentation/bunny/Gemfile b/instrumentation/bunny/Gemfile deleted file mode 100644 index 5b7d54b645..0000000000 --- a/instrumentation/bunny/Gemfile +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :test do - gem 'opentelemetry-instrumentation-base', path: '../base' - gem 'pry-byebug' -end diff --git a/instrumentation/bunny/LICENSE b/instrumentation/bunny/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/bunny/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/bunny/README.md b/instrumentation/bunny/README.md deleted file mode 100644 index f0fa7909da..0000000000 --- a/instrumentation/bunny/README.md +++ /dev/null @@ -1,53 +0,0 @@ -# OpenTelemetry bunny Instrumentation - -The bunny instrumentation is a community-maintained instrumentation for [bunny][bunny-home], a client library for RabbitMQ. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-bunny -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-bunny` in your `Gemfile`. - -## Usage - -To use the instrumentation, call `use` with the name of the instrumentation: - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Bunny' -end -``` - -Alternatively, you can also call `use_all` to install all the available instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` - -## Examples - -Example usage can be seen in the `./example/bunny.rb` file [here](https://github.com/open-telemetry/opentelemetry-ruby/blob/master/instrumentation/bunny/example/bunny.rb) - -## How can I get involved? - -The `opentelemetry-instrumentation-bunny` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us on our [gitter channel][ruby-gitter] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -The `opentelemetry-instrumentation-bunny` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information. - -[bunny-home]: https://github.com/ruby-amqp/bunny -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/master/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[ruby-gitter]: https://gitter.im/open-telemetry/opentelemetry-ruby diff --git a/instrumentation/bunny/Rakefile b/instrumentation/bunny/Rakefile deleted file mode 100644 index 1a64ba842e..0000000000 --- a/instrumentation/bunny/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/bunny/example/Gemfile b/instrumentation/bunny/example/Gemfile deleted file mode 100644 index 29a2ac901b..0000000000 --- a/instrumentation/bunny/example/Gemfile +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -source 'https://rubygems.org' - -gem 'bunny' -gem 'opentelemetry-api' -gem 'opentelemetry-instrumentation-bunny' -gem 'opentelemetry-sdk' diff --git a/instrumentation/bunny/example/bunny.rb b/instrumentation/bunny/example/bunny.rb deleted file mode 100644 index a959a0973d..0000000000 --- a/instrumentation/bunny/example/bunny.rb +++ /dev/null @@ -1,40 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'rubygems' -require 'bundler/setup' - -Bundler.require - -require 'bunny' - -ENV['OTEL_TRACES_EXPORTER'] = 'console' -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Bunny' -end - -# Start a communication session with RabbitMQ -conn = Bunny.new -conn.start - -# open a channel -ch = conn.create_channel - -# declare a queue -q = ch.queue('opentelemetry-ruby-demonstration') - -# publish a message to the default exchange which then gets routed to this queue -q.publish('Hello, opentelemetry!') - -# fetch a message from the queue -q.pop do |delivery_info, metadata, payload| - puts "Message: #{payload}" - puts "Delivery info: #{delivery_info}" - puts "Metadata: #{metadata}" -end - -# close the connection -conn.stop diff --git a/instrumentation/bunny/lib/opentelemetry-instrumentation-bunny.rb b/instrumentation/bunny/lib/opentelemetry-instrumentation-bunny.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/bunny/lib/opentelemetry-instrumentation-bunny.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/bunny/lib/opentelemetry/instrumentation.rb b/instrumentation/bunny/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index ce47bfc0d2..0000000000 --- a/instrumentation/bunny/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/bunny' diff --git a/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny.rb b/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny.rb deleted file mode 100644 index 658e4a50cd..0000000000 --- a/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the bunny gem - module Bunny - end - end -end - -require_relative './bunny/instrumentation' -require_relative './bunny/version' diff --git a/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/instrumentation.rb b/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/instrumentation.rb deleted file mode 100644 index 3e772534cc..0000000000 --- a/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/instrumentation.rb +++ /dev/null @@ -1,43 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - module Bunny - # The Instrumentation class contains logic to detect and install the - # bunny instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - install do |_config| - require_patches - patch - end - - present do - defined?(::Bunny) - end - - private - - def require_patches - require_relative 'patch_helpers' - require_relative 'patches/channel' - require_relative 'patches/consumer' - require_relative 'patches/queue' - require_relative 'patches/reader_loop' - end - - def patch - ::Bunny::Channel.prepend(Patches::Channel) - ::Bunny::Consumer.prepend(Patches::Consumer) - ::Bunny::Queue.prepend(Patches::Queue) - ::Bunny::ReaderLoop.prepend(Patches::ReaderLoop) - end - end - end - end -end diff --git a/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/patch_helpers.rb b/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/patch_helpers.rb deleted file mode 100644 index 8e2d0f4e67..0000000000 --- a/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/patch_helpers.rb +++ /dev/null @@ -1,94 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Bunny - # The PatchHelper module provides functionality shared between patches. - # - # For additional details around trace messaging semantics - # See https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/messaging.md#messaging-attributes - module PatchHelpers - def self.with_send_span(channel, tracer, exchange, routing_key, &block) - attributes = basic_attributes(channel, channel.connection, exchange, routing_key) - destination = destination_name(exchange, routing_key) - - tracer.in_span("#{destination} send", attributes: attributes, kind: :producer, &block) - end - - def self.with_process_span(channel, tracer, delivery_info, properties, &block) - destination = destination_name(delivery_info[:exchange], delivery_info[:routing_key]) - parent_context, links = extract_context(properties) - - OpenTelemetry::Context.with_current(parent_context) do - tracer.in_span("#{destination} process", links: links, kind: :consumer, &block) - end - end - - def self.destination_name(exchange, routing_key) - [exchange, routing_key].compact.join('.') - end - - def self.extract_context(properties) - # use the receive span as parent context - parent_context = OpenTelemetry.propagation.extract(properties[:tracer_receive_headers]) - - # link to the producer context - producer_context = OpenTelemetry.propagation.extract(properties[:headers]) - producer_span_context = OpenTelemetry::Trace.current_span(producer_context).context - links = [OpenTelemetry::Trace::Link.new(producer_span_context)] if producer_span_context.valid? - - [parent_context, links] - end - - def self.inject_context_into_property(properties, key) - properties[key] ||= {} - OpenTelemetry.propagation.inject(properties[key]) - end - - def self.trace_enrich_receive_span(span, channel, delivery_info, properties) - exchange = delivery_info.exchange - routing_key = delivery_info.routing_key - destination = OpenTelemetry::Instrumentation::Bunny::PatchHelpers.destination_name(exchange, routing_key) - destination_kind = OpenTelemetry::Instrumentation::Bunny::PatchHelpers.destination_kind(channel, exchange) - span.name = "#{destination} receive" - span['messaging.destination'] = exchange - span['messaging.destination_kind'] = destination_kind - span['messaging.rabbitmq.routing_key'] = routing_key if routing_key - span['messaging.operation'] = 'receive' - - inject_context_into_property(properties, :tracer_receive_headers) - end - - def self.basic_attributes(channel, transport, exchange, routing_key) - attributes = { - 'messaging.system' => 'rabbitmq', - 'messaging.destination' => exchange, - 'messaging.destination_kind' => destination_kind(channel, exchange), - 'messaging.protocol' => 'AMQP', - 'messaging.protocol_version' => ::Bunny.protocol_version, - 'net.peer.name' => transport.host, - 'net.peer.port' => transport.port - } - attributes['messaging.rabbitmq.routing_key'] = routing_key if routing_key - attributes - end - - def self.destination_kind(channel, exchange) - # The default exchange with no name is always a direct exchange - # https://github.com/ruby-amqp/bunny/blob/master/lib/bunny/exchange.rb#L33 - return 'queue' if exchange == '' - - # All exchange types https://www.rabbitmq.com/tutorials/amqp-concepts.html#exchanges - # except direct exchanges are mapped to topic - return 'queue' if channel.find_exchange(exchange)&.type == :direct - - 'topic' - end - end - end - end -end diff --git a/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/patches/channel.rb b/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/patches/channel.rb deleted file mode 100644 index 4f75ace1ab..0000000000 --- a/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/patches/channel.rb +++ /dev/null @@ -1,51 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Bunny - module Patches - # The Channel module contains the instrumentation patch the Channel#basic_get, Channel#basic_publish and Channel#handle_frameset methods - module Channel - def basic_get(queue, opts = { manual_ack: false }) - attributes = OpenTelemetry::Instrumentation::Bunny::PatchHelpers.basic_attributes(self, connection, '', nil) - - tracer.in_span("#{queue} receive", attributes: attributes, kind: :consumer) do |span, _ctx| - delivery_info, properties, payload = super - - return [delivery_info, properties, payload] unless delivery_info - - OpenTelemetry::Instrumentation::Bunny::PatchHelpers.trace_enrich_receive_span(span, self, delivery_info, properties) - - [delivery_info, properties, payload] - end - end - - def basic_publish(payload, exchange, routing_key, opts = {}) - OpenTelemetry::Instrumentation::Bunny::PatchHelpers.with_send_span(self, tracer, exchange, routing_key) do - OpenTelemetry::Instrumentation::Bunny::PatchHelpers.inject_context_into_property(opts, :headers) - - super(payload, exchange, routing_key, opts) - end - end - - # This method is called when rabbitmq pushes messages to subscribed consumers - def handle_frameset(basic_deliver, properties, content) - OpenTelemetry::Instrumentation::Bunny::PatchHelpers.trace_enrich_receive_span(OpenTelemetry::Trace.current_span, self, basic_deliver, properties) if basic_deliver - - super - end - - private - - def tracer - Bunny::Instrumentation.instance.tracer - end - end - end - end - end -end diff --git a/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/patches/consumer.rb b/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/patches/consumer.rb deleted file mode 100644 index 26beb4c0c8..0000000000 --- a/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/patches/consumer.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Bunny - module Patches - # The Consumer module contains the instrumentation patch for the Consumer class - module Consumer - def call(delivery_info, properties, payload) - OpenTelemetry::Instrumentation::Bunny::PatchHelpers.with_process_span(queue.channel, tracer, delivery_info, properties) do - super - end - end - - private - - def tracer - Bunny::Instrumentation.instance.tracer - end - end - end - end - end -end diff --git a/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/patches/queue.rb b/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/patches/queue.rb deleted file mode 100644 index 4d73bbdbc0..0000000000 --- a/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/patches/queue.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Bunny - module Patches - # The Queue module contains the instrumentation patch the Queue#pop method. - module Queue - def pop(opts = { manual_ack: false }, &block) - return super unless block - - super do |delivery_info, properties, payload| - OpenTelemetry::Instrumentation::Bunny::PatchHelpers.with_process_span(channel, tracer, delivery_info, properties) do - yield delivery_info, properties, payload - end - end - end - - private - - def tracer - Bunny::Instrumentation.instance.tracer - end - end - end - end - end -end diff --git a/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/patches/reader_loop.rb b/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/patches/reader_loop.rb deleted file mode 100644 index 68690c5bcb..0000000000 --- a/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/patches/reader_loop.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Bunny - module Patches - # The ReaderLoop module contains the instrumentation patch the ReaderLoop#run_once method - module ReaderLoop - def run_once - attributes = OpenTelemetry::Instrumentation::Bunny::PatchHelpers.basic_attributes(nil, @transport, '', nil) - tracer.in_span('Bunny::ReaderLoop#run_once', attributes: attributes, kind: :consumer) do - super - end - end - - private - - def tracer - Bunny::Instrumentation.instance.tracer - end - end - end - end - end -end diff --git a/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/version.rb b/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/version.rb deleted file mode 100644 index 22a58e8290..0000000000 --- a/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Bunny - VERSION = '0.19.0' - end - end -end diff --git a/instrumentation/bunny/opentelemetry-instrumentation-bunny.gemspec b/instrumentation/bunny/opentelemetry-instrumentation-bunny.gemspec deleted file mode 100644 index df0525c4ec..0000000000 --- a/instrumentation/bunny/opentelemetry-instrumentation-bunny.gemspec +++ /dev/null @@ -1,48 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/bunny/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-bunny' - spec.version = OpenTelemetry::Instrumentation::Bunny::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'Bunny instrumentation for the OpenTelemetry framework' - spec.description = 'Bunny instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.21.0' - - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'bunny' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-bunny/v#{OpenTelemetry::Instrumentation::Bunny::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/master/instrumentation/bunny' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-bunny/v#{OpenTelemetry::Instrumentation::Bunny::VERSION}" - end -end diff --git a/instrumentation/bunny/test/.rubocop.yml b/instrumentation/bunny/test/.rubocop.yml deleted file mode 100644 index e97eda560f..0000000000 --- a/instrumentation/bunny/test/.rubocop.yml +++ /dev/null @@ -1,6 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false -Style/MultilineIfModifier: - Enabled: false diff --git a/instrumentation/bunny/test/opentelemetry/instrumentation/bunny/instrumentation_test.rb b/instrumentation/bunny/test/opentelemetry/instrumentation/bunny/instrumentation_test.rb deleted file mode 100644 index 35c2b85e46..0000000000 --- a/instrumentation/bunny/test/opentelemetry/instrumentation/bunny/instrumentation_test.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../lib/opentelemetry/instrumentation/bunny' - -describe OpenTelemetry::Instrumentation::Bunny::Instrumentation do - let(:instrumentation) { OpenTelemetry::Instrumentation::Bunny::Instrumentation.instance } - - it 'has #name' do - _(instrumentation.name).must_equal 'OpenTelemetry::Instrumentation::Bunny' - end - - it 'has #version' do - _(instrumentation.version).wont_be_nil - _(instrumentation.version).wont_be_empty - end - - describe '#install' do - it 'accepts arguments' do - instrumentation.instance_variable_set(:@installed, false) - _(instrumentation.install({})).must_equal(true) - end - end -end diff --git a/instrumentation/bunny/test/opentelemetry/instrumentation/bunny/patches/channel_test.rb b/instrumentation/bunny/test/opentelemetry/instrumentation/bunny/patches/channel_test.rb deleted file mode 100644 index 6c42e55320..0000000000 --- a/instrumentation/bunny/test/opentelemetry/instrumentation/bunny/patches/channel_test.rb +++ /dev/null @@ -1,84 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../../lib/opentelemetry/instrumentation/bunny' -require_relative '../../../../../lib/opentelemetry/instrumentation/bunny/patch_helpers' -require_relative '../../../../../lib/opentelemetry/instrumentation/bunny/patches/channel' - -describe OpenTelemetry::Instrumentation::Bunny::Patches::Channel do - let(:instrumentation) { OpenTelemetry::Instrumentation::Bunny::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:spans) { exporter.finished_spans } - let(:host) { ENV.fetch('TEST_RABBITMQ_HOST') { 'localhost' } } - let(:port) { ENV.fetch('TEST_RABBITMQ_PORT') { '5672' } } - let(:url) { ENV.fetch('TEST_RABBITMQ_URL') { "amqp://guest:guest@#{host}:#{port}" } } - let(:bunny) { Bunny.new(url) } - let(:topic) { "topic-#{SecureRandom.uuid}" } - let(:channel) { bunny.create_channel } - let(:exchange) { channel.topic(topic, auto_delete: true) } - - before do - bunny.start - - # Clear spans - exporter.reset - - instrumentation.install - end - - after do - # Force re-install of instrumentation - instrumentation.instance_variable_set(:@installed, false) - - # Clean up - bunny.close - end - - it 'traces produce and consuming' do - queue = channel.queue('', exclusive: true).bind(exchange, routing_key: 'ruby.#') - - exchange.publish('San Diego update', routing_key: 'ruby.news') - - queue.pop { |_msg| break } - - _(spans.size >= 3).must_equal(true) - - send_span = spans.find { |span| span.name == "#{topic}.ruby.news send" } - _(send_span).wont_be_nil - _(send_span.kind).must_equal(:producer) - _(send_span.attributes['messaging.system']).must_equal('rabbitmq') - _(send_span.attributes['messaging.destination']).must_equal(topic) - _(send_span.attributes['messaging.destination_kind']).must_equal('topic') - _(send_span.attributes['messaging.protocol']).must_equal('AMQP') - _(send_span.attributes['messaging.protocol_version']).must_equal('0.9.1') - _(send_span.attributes['messaging.rabbitmq.routing_key']).must_equal('ruby.news') - _(send_span.attributes['net.peer.name']).must_equal(host) - _(send_span.attributes['net.peer.port']).must_equal(port.to_i) - - receive_span = spans.find { |span| span.name == "#{topic}.ruby.news receive" } - _(receive_span).wont_be_nil - _(receive_span.kind).must_equal(:consumer) - _(receive_span.attributes['messaging.system']).must_equal('rabbitmq') - _(receive_span.attributes['messaging.destination']).must_equal(topic) - _(receive_span.attributes['messaging.destination_kind']).must_equal('topic') - _(receive_span.attributes['messaging.protocol']).must_equal('AMQP') - _(receive_span.attributes['messaging.protocol_version']).must_equal('0.9.1') - _(receive_span.attributes['messaging.rabbitmq.routing_key']).must_equal('ruby.news') - _(receive_span.attributes['net.peer.name']).must_equal(host) - _(receive_span.attributes['net.peer.port']).must_equal(port.to_i) - - process_span = spans.find { |span| span.name == "#{topic}.ruby.news process" } - _(process_span).wont_be_nil - _(process_span.kind).must_equal(:consumer) - _(process_span.trace_id).must_equal(receive_span.trace_id) - - linked_span_context = process_span.links.first.span_context - _(linked_span_context.trace_id).must_equal(send_span.trace_id) - _(linked_span_context.span_id).must_equal(send_span.span_id) - end -end unless ENV['OMIT_SERVICES'] diff --git a/instrumentation/bunny/test/opentelemetry/instrumentation/bunny/patches/consumer_test.rb b/instrumentation/bunny/test/opentelemetry/instrumentation/bunny/patches/consumer_test.rb deleted file mode 100644 index 239af8d293..0000000000 --- a/instrumentation/bunny/test/opentelemetry/instrumentation/bunny/patches/consumer_test.rb +++ /dev/null @@ -1,74 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../../lib/opentelemetry/instrumentation/bunny' -require_relative '../../../../../lib/opentelemetry/instrumentation/bunny/patch_helpers' -require_relative '../../../../../lib/opentelemetry/instrumentation/bunny/patches/consumer' - -describe OpenTelemetry::Instrumentation::Bunny::Patches::Consumer do - let(:instrumentation) { OpenTelemetry::Instrumentation::Bunny::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:spans) { exporter.finished_spans } - let(:host) { ENV.fetch('TEST_RABBITMQ_HOST') { 'localhost' } } - let(:port) { ENV.fetch('TEST_RABBITMQ_PORT') { '5672' } } - let(:url) { ENV.fetch('TEST_RABBITMQ_URL') { "amqp://guest:guest@#{host}:#{port}" } } - let(:bunny) { Bunny.new(url) } - let(:topic) { "topic-#{SecureRandom.uuid}" } - let(:channel) { bunny.create_channel } - let(:exchange) { channel.topic(topic, auto_delete: true) } - - before do - bunny.start - - # Clear spans - exporter.reset - - instrumentation.install - end - - after do - # Force re-install of instrumentation - instrumentation.instance_variable_set(:@installed, false) - - # Clean up - bunny.close - end - - it 'traces produce and consuming' do - queue = channel.queue('', exclusive: true).bind(exchange, routing_key: 'ruby.#') - - consumer = queue.subscribe(manual_ack: true) { |_delivery_info, _properties, _payload| } - - exchange.publish('San Diego update', routing_key: 'ruby.news') - - # Wait until the publish message reached the consumer - sleep 1.0 - - consumer.cancel - - _(spans.size >= 3).must_equal(true) - - send_span = spans.find { |span| span.name == "#{topic}.ruby.news send" } - _(send_span).wont_be_nil - _(send_span.kind).must_equal(:producer) - - receive_span = spans.find { |span| span.name == "#{topic}.ruby.news receive" } - _(receive_span).wont_be_nil - _(receive_span.name).must_equal("#{topic}.ruby.news receive") - _(receive_span.kind).must_equal(:consumer) - - process_span = spans.find { |span| span.name == "#{topic}.ruby.news process" } - _(process_span).wont_be_nil - _(process_span.kind).must_equal(:consumer) - _(process_span.trace_id).must_equal(receive_span.trace_id) - - linked_span_context = process_span.links.first.span_context - _(linked_span_context.trace_id).must_equal(send_span.trace_id) - _(linked_span_context.span_id).must_equal(send_span.span_id) - end -end unless ENV['OMIT_SERVICES'] diff --git a/instrumentation/bunny/test/opentelemetry/instrumentation/bunny/patches/queue_test.rb b/instrumentation/bunny/test/opentelemetry/instrumentation/bunny/patches/queue_test.rb deleted file mode 100644 index a5812ae2e6..0000000000 --- a/instrumentation/bunny/test/opentelemetry/instrumentation/bunny/patches/queue_test.rb +++ /dev/null @@ -1,76 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../../lib/opentelemetry/instrumentation/bunny' -require_relative '../../../../../lib/opentelemetry/instrumentation/bunny/patch_helpers' -require_relative '../../../../../lib/opentelemetry/instrumentation/bunny/patches/queue' - -describe OpenTelemetry::Instrumentation::Bunny::Patches::Queue do - let(:instrumentation) { OpenTelemetry::Instrumentation::Bunny::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:spans) { exporter.finished_spans } - - let(:host) { ENV.fetch('TEST_RABBITMQ_HOST') { 'localhost' } } - let(:port) { ENV.fetch('TEST_RABBITMQ_PORT') { '5672' } } - let(:url) { ENV.fetch('TEST_RABBITMQ_URL') { "amqp://guest:guest@#{host}:#{port}" } } - let(:bunny) { Bunny.new(url) } - let(:topic) { "topic-#{SecureRandom.uuid}" } - let(:channel) { bunny.create_channel } - let(:queue_name) { "opentelemetry-ruby-#{SecureRandom.uuid}" } - let(:queue) { channel.queue(queue_name) } - - before do - bunny.start - - # Clear spans - exporter.reset - - instrumentation.install - end - - after do - # Force re-install of instrumentation - instrumentation.instance_variable_set(:@installed, false) - - # Clean up - bunny.close - end - - describe 'pop' do - it 'traces messages handled in a block' do - queue.publish('Hello, opentelemetry!') - - queue.pop { |_delivery_info, _metadata, _payload| break } - - send_span = spans.find { |span| span.name == ".#{queue_name} send" } - _(send_span).wont_be_nil - - receive_span = spans.find { |span| span.name == ".#{queue_name} receive" } - _(receive_span).wont_be_nil - - process_span = spans.find { |span| span.name == ".#{queue_name} process" } - _(process_span).wont_be_nil - _(process_span.kind).must_equal(:consumer) - - linked_span_context = process_span.links.first.span_context - _(linked_span_context.trace_id).must_equal(send_span.trace_id) - end - - it 'traces messages returned' do - queue.publish('Hello, opentelemetry!') - - queue.pop - - receive_span = spans.find { |span| span.name == ".#{queue_name} receive" } - _(receive_span).wont_be_nil - - process_span = spans.find { |span| span.name == ".#{queue_name} process" } - _(process_span).must_be_nil - end - end -end unless ENV['OMIT_SERVICES'] diff --git a/instrumentation/bunny/test/test_helper.rb b/instrumentation/bunny/test/test_helper.rb deleted file mode 100644 index 3d5361524a..0000000000 --- a/instrumentation/bunny/test/test_helper.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'securerandom' -require 'bunny' - -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' - -require 'pry' -require 'minitest/autorun' - -# global opentelemetry-sdk setup: -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -SPAN_PROCESSOR = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry::SDK.configure do |c| - c.add_span_processor SPAN_PROCESSOR -end diff --git a/instrumentation/concurrent_ruby/.rubocop.yml b/instrumentation/concurrent_ruby/.rubocop.yml deleted file mode 100644 index ebf717a486..0000000000 --- a/instrumentation/concurrent_ruby/.rubocop.yml +++ /dev/null @@ -1,7 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -Naming/FileName: - Exclude: - - "example/concurrent_ruby.rb" - - "lib/opentelemetry-instrumentation-concurrent_ruby.rb" - - "lib/opentelemetry/instrumentation/concurrent_ruby.rb" diff --git a/instrumentation/concurrent_ruby/.yardopts b/instrumentation/concurrent_ruby/.yardopts deleted file mode 100644 index b3f1d4ffb3..0000000000 --- a/instrumentation/concurrent_ruby/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Concurrent Ruby Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/concurrent_ruby/Appraisals b/instrumentation/concurrent_ruby/Appraisals deleted file mode 100644 index 34b214900c..0000000000 --- a/instrumentation/concurrent_ruby/Appraisals +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -appraise 'concurrent-ruby-1.1' do - gem 'concurrent-ruby', '~> 1.1.6' -end - -appraise 'concurrent-ruby-1.0' do - gem 'concurrent-ruby', '~> 1.0.5' -end diff --git a/instrumentation/concurrent_ruby/CHANGELOG.md b/instrumentation/concurrent_ruby/CHANGELOG.md deleted file mode 100644 index 517ae7be35..0000000000 --- a/instrumentation/concurrent_ruby/CHANGELOG.md +++ /dev/null @@ -1,88 +0,0 @@ -# Release History: opentelemetry-instrumentation-concurrent_ruby - -### v0.20.0 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Broken test file requirements - -### v0.19.3 / 2022-05-05 - -* (No significant changes) - -### v0.19.2 / 2021-12-02 - -* (No significant changes) - -### v0.19.1 / 2021-09-29 - -* (No significant changes) - -### v0.19.0 / 2021-09-29 - -* ADDED: Add suport for `Concurrent::Promises::Future` - -### v0.18.2 / 2021-08-12 - -* DOCS: Update docs to rely more on environment variable configuration - -### v0.18.1 / 2021-06-23 - -* (No significant changes) - -### v0.18.0 / 2021-05-21 - -* ADDED: Updated API depedency for 1.0.0.rc1 - -### v0.17.0 / 2021-04-22 - -* (No significant changes) - -### v0.16.0 / 2021-03-17 - -* FIXED: Example scripts now reference local common lib -* DOCS: Replace Gitter with GitHub Discussions - -### v0.15.0 / 2021-02-18 - -* (No significant changes) - -### v0.14.0 / 2021-02-03 - -* (No significant changes) - -### v0.13.0 / 2021-01-29 - -* (No significant changes) - -### v0.12.0 / 2020-12-24 - -* (No significant changes) - -### v0.11.0 / 2020-12-11 - -* FIXED: Copyright comments to not reference year - -### v0.10.0 / 2020-12-03 - -* (No significant changes) - -### v0.9.0 / 2020-11-27 - -* BREAKING CHANGE: Add timeout for force_flush and shutdown - -* ADDED: Add timeout for force_flush and shutdown - -### v0.8.0 / 2020-10-27 - -* BREAKING CHANGE: Move context/span methods to Trace module - -* FIXED: Move context/span methods to Trace module - -### v0.7.0 / 2020-10-07 - -* DOCS: Added README for concurrent ruby -* DOCS: Standardize toplevel docs structure and readme - -### v0.6.0 / 2020-09-10 - -* (No significant changes) diff --git a/instrumentation/concurrent_ruby/Gemfile b/instrumentation/concurrent_ruby/Gemfile deleted file mode 100644 index 2baf57ac47..0000000000 --- a/instrumentation/concurrent_ruby/Gemfile +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :test do - gem 'opentelemetry-instrumentation-base', path: '../base' -end diff --git a/instrumentation/concurrent_ruby/LICENSE b/instrumentation/concurrent_ruby/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/concurrent_ruby/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/concurrent_ruby/README.md b/instrumentation/concurrent_ruby/README.md deleted file mode 100644 index 96f1b8fa6d..0000000000 --- a/instrumentation/concurrent_ruby/README.md +++ /dev/null @@ -1,49 +0,0 @@ -# OpenTelemetry Concurrent Ruby Instrumentation - -The OpenTelemetry Concurrent Ruby gem is a community maintained instrumentation for the [Concurrent Ruby][concurrent-ruby-home]. This is a concurrency toolkit inspired from various languages and classic concurrency patterns. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-concurrent_ruby -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-concurrent_ruby` in your `Gemfile`. - -## Usage - -To install the instrumentation, call `use` with the name of the instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::ConcurrentRuby' -end -``` - -Alternatively, you can also call `use_all` to install all the available instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` - -## How can I get involved? - -The `opentelemetry-instrumentation-concurrent_ruby` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -Apache 2.0 license. See [LICENSE][license-github] for more information. - -[concurrent-ruby-home]: https://github.com/ruby-concurrency/concurrent-ruby -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/instrumentation/concurrent_ruby/Rakefile b/instrumentation/concurrent_ruby/Rakefile deleted file mode 100644 index 1a64ba842e..0000000000 --- a/instrumentation/concurrent_ruby/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/concurrent_ruby/example/Gemfile b/instrumentation/concurrent_ruby/example/Gemfile deleted file mode 100644 index 45ab861f42..0000000000 --- a/instrumentation/concurrent_ruby/example/Gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -source 'https://rubygems.org' - -gem 'concurrent-ruby' -gem 'opentelemetry-api' -gem 'opentelemetry-common' -gem 'opentelemetry-instrumentation-concurrent_ruby' -gem 'opentelemetry-sdk' diff --git a/instrumentation/concurrent_ruby/example/concurrent_ruby.rb b/instrumentation/concurrent_ruby/example/concurrent_ruby.rb deleted file mode 100644 index fce667d417..0000000000 --- a/instrumentation/concurrent_ruby/example/concurrent_ruby.rb +++ /dev/null @@ -1,47 +0,0 @@ -# frozen_string_literal: true - -require 'rubygems' -require 'bundler/setup' - -Bundler.require - -ENV['OTEL_TRACES_EXPORTER'] = 'console' -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::ConcurrentRuby' -end - -tracer = OpenTelemetry.tracer_provider.tracer('default') - -tracer.in_span('outer_span') do - future = Concurrent::Future.new do - tracer.in_span('inner_span') {} - end - future.execute - future.wait -end - -tracer.in_span('outer_span') do - future = Concurrent::Promises.future do - tracer.in_span('inner_span') {} - end - future.result -end - -# Worker: an example Async worker -class Worker - include Concurrent::Async - def initialize(tracer) - @tracer = tracer - end - - def action - @tracer.in_span('async:inner_span') {} - end -end - -worker = Worker.new(tracer) - -tracer.in_span('async:outer_span') do - worker.await.action - worker.async.action.wait -end diff --git a/instrumentation/concurrent_ruby/lib/opentelemetry-instrumentation-concurrent_ruby.rb b/instrumentation/concurrent_ruby/lib/opentelemetry-instrumentation-concurrent_ruby.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/concurrent_ruby/lib/opentelemetry-instrumentation-concurrent_ruby.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/concurrent_ruby/lib/opentelemetry/instrumentation.rb b/instrumentation/concurrent_ruby/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index 6ab522ac0f..0000000000 --- a/instrumentation/concurrent_ruby/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # "Instrumentation" are specified by - # https://github.com/open-telemetry/opentelemetry-specification/blob/784635d01d8690c8f5fcd1f55bdbc8a13cf2f4f2/specification/glossary.md#instrumentation-library - # - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/concurrent_ruby' diff --git a/instrumentation/concurrent_ruby/lib/opentelemetry/instrumentation/concurrent_ruby.rb b/instrumentation/concurrent_ruby/lib/opentelemetry/instrumentation/concurrent_ruby.rb deleted file mode 100644 index 5fbf59ced9..0000000000 --- a/instrumentation/concurrent_ruby/lib/opentelemetry/instrumentation/concurrent_ruby.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the ConcurrentRuby gem - module ConcurrentRuby - end - end -end - -require_relative './concurrent_ruby/instrumentation' -require_relative './concurrent_ruby/version' diff --git a/instrumentation/concurrent_ruby/lib/opentelemetry/instrumentation/concurrent_ruby/instrumentation.rb b/instrumentation/concurrent_ruby/lib/opentelemetry/instrumentation/concurrent_ruby/instrumentation.rb deleted file mode 100644 index eae17508ca..0000000000 --- a/instrumentation/concurrent_ruby/lib/opentelemetry/instrumentation/concurrent_ruby/instrumentation.rb +++ /dev/null @@ -1,34 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module ConcurrentRuby - # The Instrumentation class contains logic to detect and install the - # ConcurrentRuby instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - install do |_config| - require_dependencies - patch - end - - present do - defined?(::Concurrent::ThreadPoolExecutor) - end - - private - - def require_dependencies - require_relative 'patches/thread_pool_executor' - end - - def patch - ::Concurrent::ThreadPoolExecutor.prepend Patches::ThreadPoolExecutor - end - end - end - end -end diff --git a/instrumentation/concurrent_ruby/lib/opentelemetry/instrumentation/concurrent_ruby/patches/thread_pool_executor.rb b/instrumentation/concurrent_ruby/lib/opentelemetry/instrumentation/concurrent_ruby/patches/thread_pool_executor.rb deleted file mode 100644 index 5b7f1e5e75..0000000000 --- a/instrumentation/concurrent_ruby/lib/opentelemetry/instrumentation/concurrent_ruby/patches/thread_pool_executor.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module ConcurrentRuby - module Patches - # Concurrent::ThreadPoolExecutor patch for instrumentation - module ThreadPoolExecutor - # @see Concurrent::ExecutorService#post - def post(*args, **kwargs, &task) - context = OpenTelemetry::Context.current - return super unless context - - super(*args, **kwargs) do - OpenTelemetry::Context.with_current(context) do - task.call(*args, **kwargs) - end - end - end - end - end - end - end -end diff --git a/instrumentation/concurrent_ruby/lib/opentelemetry/instrumentation/concurrent_ruby/version.rb b/instrumentation/concurrent_ruby/lib/opentelemetry/instrumentation/concurrent_ruby/version.rb deleted file mode 100644 index 70ac704850..0000000000 --- a/instrumentation/concurrent_ruby/lib/opentelemetry/instrumentation/concurrent_ruby/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module ConcurrentRuby - VERSION = '0.20.0' - end - end -end diff --git a/instrumentation/concurrent_ruby/opentelemetry-instrumentation-concurrent_ruby.gemspec b/instrumentation/concurrent_ruby/opentelemetry-instrumentation-concurrent_ruby.gemspec deleted file mode 100644 index 157cff26fe..0000000000 --- a/instrumentation/concurrent_ruby/opentelemetry-instrumentation-concurrent_ruby.gemspec +++ /dev/null @@ -1,48 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/concurrent_ruby/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-concurrent_ruby' - spec.version = OpenTelemetry::Instrumentation::ConcurrentRuby::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'ConcurrentRuby instrumentation for the OpenTelemetry framework' - spec.description = 'ConcurrentRuby instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.21.0' - - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'concurrent-ruby', '~> 1.1.6' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-concurrent_ruby/v#{OpenTelemetry::Instrumentation::ConcurrentRuby::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/concurrent_ruby' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-concurrent_ruby/v#{OpenTelemetry::Instrumentation::ConcurrentRuby::VERSION}" - end -end diff --git a/instrumentation/concurrent_ruby/test/.rubocop.yml b/instrumentation/concurrent_ruby/test/.rubocop.yml deleted file mode 100644 index dd94258585..0000000000 --- a/instrumentation/concurrent_ruby/test/.rubocop.yml +++ /dev/null @@ -1,4 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false diff --git a/instrumentation/concurrent_ruby/test/opentelemetry/instrumentation/concurrent-ruby/instrumentation_test.rb b/instrumentation/concurrent_ruby/test/opentelemetry/instrumentation/concurrent-ruby/instrumentation_test.rb deleted file mode 100644 index 994873c00f..0000000000 --- a/instrumentation/concurrent_ruby/test/opentelemetry/instrumentation/concurrent-ruby/instrumentation_test.rb +++ /dev/null @@ -1,101 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../lib/opentelemetry/instrumentation/concurrent_ruby' - -describe OpenTelemetry::Instrumentation::ConcurrentRuby::Instrumentation do - let(:instrumentation) { OpenTelemetry::Instrumentation::ConcurrentRuby::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:span) { exporter.finished_spans.first } - let(:tracer) { instrumentation.tracer } - let(:unmodified_future) { @unmodified_future } - - before do - exporter.reset - @unmodified_future = ::Concurrent::ThreadPoolExecutor.dup - end - - after do - # Force re-install of instrumentation - ::Concurrent.send(:remove_const, :ThreadPoolExecutor) - ::Concurrent.const_set('ThreadPoolExecutor', unmodified_future) - instrumentation.instance_variable_set(:@installed, false) - end - - describe 'tracing' do - before do - instrumentation.install - end - - it 'propagates context in Future threads' do - outer_span = tracer.start_span('outer_span') - inner_span = nil - OpenTelemetry::Trace.with_span(outer_span) do - future = ::Concurrent::Future.new do - inner_span = tracer.start_span('inner_span') - inner_span.finish - end - future.execute - - future.wait - end - outer_span.finish - - _(exporter.finished_spans.size).must_equal 2 - _(inner_span.parent_span_id).must_equal outer_span.context.span_id - end - - it 'propagates context in Promises' do - skip 'Concurrent::Promises is not defined' unless ::Concurrent.const_defined?(:Promises) - outer_span = tracer.start_span('outer_span') - inner_span = nil - OpenTelemetry::Trace.with_span(outer_span) do - future = ::Concurrent::Promises.future do - inner_span = tracer.start_span('inner_span') - inner_span.finish - end - future.value - end - outer_span.finish - - _(exporter.finished_spans.size).must_equal 2 - _(inner_span.parent_span_id).must_equal outer_span.context.span_id - end - - it 'propagates context in Async mixins' do - skip 'Concurrent::Async is not defined' unless ::Concurrent.const_defined?(:Async) - outer_span = tracer.start_span('outer_span') - async_inner_span = nil - await_inner_span = nil - - worker = Class.new do - include Concurrent::Async - def initialize(tracer) - @tracer = tracer - end - - def action - inner_span = @tracer.start_span('inner_span') - inner_span.finish - end - end.new(tracer) - - OpenTelemetry::Trace.with_span(outer_span) do - result = worker.await.action - await_inner_span = result.value - result = worker.async.action - async_inner_span = result.value - end - outer_span.finish - - _(exporter.finished_spans.size).must_equal 3 - _(async_inner_span.parent_span_id).must_equal outer_span.context.span_id - _(await_inner_span.parent_span_id).must_equal outer_span.context.span_id - end - end -end diff --git a/instrumentation/concurrent_ruby/test/test_helper.rb b/instrumentation/concurrent_ruby/test/test_helper.rb deleted file mode 100644 index 082521e08a..0000000000 --- a/instrumentation/concurrent_ruby/test/test_helper.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'concurrent' - -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' - -require 'minitest/autorun' - -# global opentelemetry-sdk setup: -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry::SDK.configure do |c| - c.add_span_processor span_processor -end diff --git a/instrumentation/dalli/.rubocop.yml b/instrumentation/dalli/.rubocop.yml deleted file mode 100644 index bd6aae3e8b..0000000000 --- a/instrumentation/dalli/.rubocop.yml +++ /dev/null @@ -1,7 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-dalli.rb" -Naming/UncommunicativeMethodParamName: - Enabled: false diff --git a/instrumentation/dalli/.yardopts b/instrumentation/dalli/.yardopts deleted file mode 100644 index 19e0381ec8..0000000000 --- a/instrumentation/dalli/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Dalli Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/dalli/Appraisals b/instrumentation/dalli/Appraisals deleted file mode 100644 index 3b7d6a9137..0000000000 --- a/instrumentation/dalli/Appraisals +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -appraise 'dalli-2.7' do - gem 'dalli', '~> 2.7' -end - -appraise 'dalli-3.0' do - gem 'dalli', '~> 3.0' -end diff --git a/instrumentation/dalli/CHANGELOG.md b/instrumentation/dalli/CHANGELOG.md deleted file mode 100644 index 8e8b35ce79..0000000000 --- a/instrumentation/dalli/CHANGELOG.md +++ /dev/null @@ -1,85 +0,0 @@ -# Release History: opentelemetry-instrumentation-dalli - -### v0.22.0 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Broken test file requirements - -### v0.21.0 / 2022-05-02 - -* ADDED: Validate Using Enums - -### v0.20.0 / 2021-12-01 - -* ADDED: Add dalli obfuscation for db_statement -* FIXED: Resolve Dalli::Server deprecation in 3.0+ - -### v0.19.1 / 2021-09-29 - -* (No significant changes) - -### v0.19.0 / 2021-08-12 - -* ADDED: Add configuration options for dalli -* DOCS: Update docs to rely more on environment variable configuration - -### v0.18.1 / 2021-06-23 - -* (No significant changes) - -### v0.18.0 / 2021-05-21 - -* ADDED: Updated API depedency for 1.0.0.rc1 - -### v0.17.0 / 2021-04-22 - -* (No significant changes) - -### v0.16.0 / 2021-03-17 - -* FIXED: Example scripts now reference local common lib -* DOCS: Replace Gitter with GitHub Discussions - -### v0.15.0 / 2021-02-18 - -* ADDED: Add instrumentation config validation - -### v0.14.0 / 2021-02-03 - -* (No significant changes) - -### v0.13.0 / 2021-01-29 - -* (No significant changes) - -### v0.12.0 / 2020-12-24 - -* (No significant changes) - -### v0.11.0 / 2020-12-11 - -* ADDED: Add peer service config to dalli -* ADDED: Move utf8 encoding to common utils -* FIXED: Copyright comments to not reference year - -### v0.10.0 / 2020-12-03 - -* (No significant changes) - -### v0.9.0 / 2020-11-27 - -* BREAKING CHANGE: Add timeout for force_flush and shutdown - -* ADDED: Add timeout for force_flush and shutdown - -### v0.8.0 / 2020-10-27 - -* (No significant changes) - -### v0.7.0 / 2020-10-07 - -* DOCS: Standardize toplevel docs structure and readme - -### v0.6.0 / 2020-09-10 - -* Initial release. diff --git a/instrumentation/dalli/Gemfile b/instrumentation/dalli/Gemfile deleted file mode 100644 index 036a87b29f..0000000000 --- a/instrumentation/dalli/Gemfile +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :test do - gem 'opentelemetry-instrumentation-base', path: '../base' - gem 'pry' -end diff --git a/instrumentation/dalli/LICENSE b/instrumentation/dalli/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/dalli/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/dalli/README.md b/instrumentation/dalli/README.md deleted file mode 100644 index fb4b4c829d..0000000000 --- a/instrumentation/dalli/README.md +++ /dev/null @@ -1,49 +0,0 @@ -# OpenTelemetry Dalli Instrumentation - -The OpenTelemetry Dalli gem is a community maintained instrumentation for the [Dalli][dalli-home] Memcache client. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-dalli -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-dalli` in your `Gemfile`. - -## Usage - -To install the instrumentation, call `use` with the name of the instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Dalli' -end -``` - -Alternatively, you can also call `use_all` to install all the available instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` - -## How can I get involved? - -The `opentelemetry-instrumentation-dalli` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -Apache 2.0 license. See [LICENSE][license-github] for more information. - -[dalli-home]: https://github.com/petergoldstein/dalli -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/instrumentation/dalli/Rakefile b/instrumentation/dalli/Rakefile deleted file mode 100644 index 1a64ba842e..0000000000 --- a/instrumentation/dalli/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/dalli/example/Gemfile b/instrumentation/dalli/example/Gemfile deleted file mode 100644 index 1c593c16dc..0000000000 --- a/instrumentation/dalli/example/Gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -source 'https://rubygems.org' - -gem 'dalli' -gem 'opentelemetry-api' -gem 'opentelemetry-common' -gem 'opentelemetry-instrumentation-dalli' -gem 'opentelemetry-sdk' diff --git a/instrumentation/dalli/example/dalli.rb b/instrumentation/dalli/example/dalli.rb deleted file mode 100644 index 3107b0a256..0000000000 --- a/instrumentation/dalli/example/dalli.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -require 'rubygems' -require 'bundler/setup' - -Bundler.require - -ENV['OTEL_TRACES_EXPORTER'] = 'console' -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Dalli' -end - -Dalli.new(ENV['MEMCACHED_HOST'], {}).set('mykey', 'hello world') diff --git a/instrumentation/dalli/lib/opentelemetry-instrumentation-dalli.rb b/instrumentation/dalli/lib/opentelemetry-instrumentation-dalli.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/dalli/lib/opentelemetry-instrumentation-dalli.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/dalli/lib/opentelemetry/instrumentation.rb b/instrumentation/dalli/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index 000321a8d2..0000000000 --- a/instrumentation/dalli/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # "Instrumentation" are specified by - # https://github.com/open-telemetry/opentelemetry-specification/blob/784635d01d8690c8f5fcd1f55bdbc8a13cf2f4f2/specification/glossary.md#instrumentation-library - # - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/dalli' diff --git a/instrumentation/dalli/lib/opentelemetry/instrumentation/dalli.rb b/instrumentation/dalli/lib/opentelemetry/instrumentation/dalli.rb deleted file mode 100644 index 9ff4020e53..0000000000 --- a/instrumentation/dalli/lib/opentelemetry/instrumentation/dalli.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry/common' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the Dalli gem - module Dalli - end - end -end - -require_relative './dalli/instrumentation' -require_relative './dalli/version' diff --git a/instrumentation/dalli/lib/opentelemetry/instrumentation/dalli/instrumentation.rb b/instrumentation/dalli/lib/opentelemetry/instrumentation/dalli/instrumentation.rb deleted file mode 100644 index 014f38ccd5..0000000000 --- a/instrumentation/dalli/lib/opentelemetry/instrumentation/dalli/instrumentation.rb +++ /dev/null @@ -1,42 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Dalli - # The Instrumentation class contains logic to detect and install the Dalli - # instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - install do |_config| - require_dependencies - add_patches - end - - present do - defined?(::Dalli) - end - - option :peer_service, default: nil, validate: :string - option :db_statement, default: :include, validate: %I[omit obfuscate include] - - private - - def require_dependencies - require_relative 'utils' - require_relative 'patches/server' - end - - def add_patches - if Gem::Version.new(::Dalli::VERSION) < Gem::Version.new('3.0.0') - ::Dalli::Server.prepend(Patches::Server) - else - ::Dalli::Protocol::Binary.prepend(Patches::Server) - end - end - end - end - end -end diff --git a/instrumentation/dalli/lib/opentelemetry/instrumentation/dalli/patches/server.rb b/instrumentation/dalli/lib/opentelemetry/instrumentation/dalli/patches/server.rb deleted file mode 100644 index a6f8843bdc..0000000000 --- a/instrumentation/dalli/lib/opentelemetry/instrumentation/dalli/patches/server.rb +++ /dev/null @@ -1,45 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Dalli - module Patches - # Module to prepend to Dalli::Server (or Dalli::Protocol::Binary in 3.0+) for instrumentation - module Server - def request(op, *args) - operation = Utils.opname(op, multi?) - attributes = { - 'db.system' => 'memcached', - 'net.peer.name' => hostname, - 'net.peer.port' => port - } - if config[:db_statement] == :include - attributes['db.statement'] = Utils.format_command(operation, args) - elsif config[:db_statement] == :obfuscate - attributes['db.statement'] = "#{operation} ?" - end - - attributes['peer.service'] = config[:peer_service] if config[:peer_service] - tracer.in_span(operation, attributes: attributes, kind: :client) do - super - end - end - - private - - def tracer - Dalli::Instrumentation.instance.tracer - end - - def config - Dalli::Instrumentation.instance.config - end - end - end - end - end -end diff --git a/instrumentation/dalli/lib/opentelemetry/instrumentation/dalli/utils.rb b/instrumentation/dalli/lib/opentelemetry/instrumentation/dalli/utils.rb deleted file mode 100644 index d0f6251f77..0000000000 --- a/instrumentation/dalli/lib/opentelemetry/instrumentation/dalli/utils.rb +++ /dev/null @@ -1,65 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - # Utility functions - module Utils - extend self - - STRING_PLACEHOLDER = ''.encode(::Encoding::UTF_8).freeze - CMD_MAX_LEN = 500 - - OPNAME_MAPPING = { - 'get' => 'get', - 'cas' => 'get', - 'set' => 'set', - 'add' => 'add', - 'replace' => 'replace', - 'delete' => 'delete', - 'incr' => 'incr', - 'decr' => 'decr', - 'flush' => 'flush', - 'write_noop' => 'noop', - 'version' => 'version', - 'send_multiget' => 'getkq', - # TODO: add better support for PipelinedGetter - # In dalli 3.1, multiget has been refactored to use a more robust PipelinedGetter class. - # The `pipelined_get` method has been introduced to the Dalli::Server to support this new class. - # If PipelinedGetter makes instrumentation of multi operations easier, we should then migrate - # instrumentation to Dalli::Client, since it seems to be a more stable chokepoint. - # For now we're just ensuring we support this new Dalli::Server method. - 'pipelined_get' => 'getkq', - 'append' => 'append', - 'prepend' => 'prepend', - 'stats' => 'stat', - 'reset_stats' => 'stat', - 'multi_set' => 'setq', - 'multi_add' => 'addq', - 'multi_replace' => 'replaceq', - 'multi_delete' => 'deleteq', - 'touch' => 'touch' - # 'sasl_authentication' => 'auth_negotiation', - # 'sasl_authentication' => 'auth_request', - }.freeze - - def opname(operation, multi) - lookup_name = multi ? "multi_#{operation}" : operation.to_s - OPNAME_MAPPING[lookup_name] || operation.to_s - end - - def format_command(operation, args) - placeholder = "#{operation} BLOB (OMITTED)" - command = [operation, *args].join(' ').strip - command = OpenTelemetry::Common::Utilities.utf8_encode(command, binary: true, placeholder: placeholder) - OpenTelemetry::Common::Utilities.truncate(command, CMD_MAX_LEN) - rescue StandardError => e - OpenTelemetry.logger.debug("Error sanitizing Dalli operation: #{e}") - placeholder - end - end - end -end diff --git a/instrumentation/dalli/lib/opentelemetry/instrumentation/dalli/version.rb b/instrumentation/dalli/lib/opentelemetry/instrumentation/dalli/version.rb deleted file mode 100644 index 2da2baaf15..0000000000 --- a/instrumentation/dalli/lib/opentelemetry/instrumentation/dalli/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Dalli - VERSION = '0.22.0' - end - end -end diff --git a/instrumentation/dalli/opentelemetry-instrumentation-dalli.gemspec b/instrumentation/dalli/opentelemetry-instrumentation-dalli.gemspec deleted file mode 100644 index 27b37f8bce..0000000000 --- a/instrumentation/dalli/opentelemetry-instrumentation-dalli.gemspec +++ /dev/null @@ -1,49 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/dalli/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-dalli' - spec.version = OpenTelemetry::Instrumentation::Dalli::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'Dalli instrumentation for the OpenTelemetry framework' - spec.description = 'Dalli instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-common', '~> 0.19.3' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.21.0' - - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'dalli', '>= 2.7' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-dalli/v#{OpenTelemetry::Instrumentation::Dalli::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/dalli' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-dalli/v#{OpenTelemetry::Instrumentation::Dalli::VERSION}" - end -end diff --git a/instrumentation/dalli/test/.rubocop.yml b/instrumentation/dalli/test/.rubocop.yml deleted file mode 100644 index e97eda560f..0000000000 --- a/instrumentation/dalli/test/.rubocop.yml +++ /dev/null @@ -1,6 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false -Style/MultilineIfModifier: - Enabled: false diff --git a/instrumentation/dalli/test/opentelemetry/instrumentation/dalli/instrumentation_test.rb b/instrumentation/dalli/test/opentelemetry/instrumentation/dalli/instrumentation_test.rb deleted file mode 100644 index d69131cfdf..0000000000 --- a/instrumentation/dalli/test/opentelemetry/instrumentation/dalli/instrumentation_test.rb +++ /dev/null @@ -1,133 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../lib/opentelemetry/instrumentation/dalli' -require_relative '../../../../lib/opentelemetry/instrumentation/dalli/patches/server' - -describe OpenTelemetry::Instrumentation::Dalli::Instrumentation do - let(:instrumentation) { OpenTelemetry::Instrumentation::Dalli::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:span) { exporter.finished_spans.first } - let(:host) { ENV.fetch('TEST_MEMCACHED_HOST') { '127.0.0.1' } } - let(:port) { (ENV.fetch('TEST_MEMCACHED_PORT') { 11_211 }).to_i } - let(:dalli) { ::Dalli::Client.new("#{host}:#{port}", {}) } - - before do - exporter.reset - end - - after do - # Force re-install of instrumentation - instrumentation.instance_variable_set(:@installed, false) - end - - describe 'tracing' do - before do - instrumentation.install - end - - it 'accepts peer service name from config' do - instrumentation.instance_variable_set(:@installed, false) - instrumentation.install(peer_service: 'readonly:memcached') - dalli.set('foo', 'bar') - - _(span.attributes['peer.service']).must_equal 'readonly:memcached' - end - - it 'before request' do - _(exporter.finished_spans.size).must_equal 0 - end - - it 'after dalli#set' do - dalli.set('foo', 'bar') - - _(exporter.finished_spans.size).must_equal 1 - _(span.name).must_equal 'set' - _(span.attributes['db.system']).must_equal 'memcached' - _(span.attributes['db.statement']).must_equal 'set foo bar 0 0' - _(span.attributes['net.peer.name']).must_equal host - _(span.attributes['net.peer.port']).must_equal port - end - - it 'after dalli#set' do - dalli.get('foo') - - _(exporter.finished_spans.size).must_equal 1 - _(span.name).must_equal 'get' - _(span.attributes['db.system']).must_equal 'memcached' - _(span.attributes['db.statement']).must_equal 'get foo' - _(span.attributes['net.peer.name']).must_equal host - _(span.attributes['net.peer.port']).must_equal port - end - - it 'after dalli#get_multi' do - dalli.get_multi('foo', 'bar') - - _(exporter.finished_spans.size).must_equal 1 - _(span.name).must_equal 'getkq' - _(span.attributes['db.system']).must_equal 'memcached' - _(span.attributes['db.statement']).must_equal 'getkq foo bar' - _(span.attributes['net.peer.name']).must_equal host - _(span.attributes['net.peer.port']).must_equal port - end - - it 'after error' do - dalli.set('foo', 'bar') - exporter.reset - - dalli.instance_variable_get(:@ring).servers.first.stub(:write, ->(_bytes) { raise Dalli::NetworkError }) do - dalli.get_multi('foo', 'bar') - end - - if supports_retry_on_network_errors? - _(exporter.finished_spans.size).must_equal 2 - else - _(exporter.finished_spans.size).must_equal 1 - end - - _(span.name).must_equal 'getkq' - _(span.attributes['db.system']).must_equal 'memcached' - _(span.attributes['db.statement']).must_equal 'getkq foo bar' - _(span.attributes['net.peer.name']).must_equal host - _(span.attributes['net.peer.port']).must_equal port - - span_event = span.events.first - _(span_event.name).must_equal 'exception' - _(span_event.attributes['exception.type']).must_equal 'Dalli::NetworkError' - _(span_event.attributes['exception.message']).must_equal 'Dalli::NetworkError' - end - - it 'omits db.statement' do - instrumentation.instance_variable_set(:@installed, false) - instrumentation.install(db_statement: :omit) - - dalli.set('foo', 'bar') - - _(exporter.finished_spans.size).must_equal 1 - _(span.name).must_equal 'set' - _(span.attributes).wont_include 'db.statement' - end - - it 'obfuscates db.statement' do - instrumentation.instance_variable_set(:@installed, false) - instrumentation.install(db_statement: :obfuscate) - - dalli.set('foo', 'bar') - - _(exporter.finished_spans.size).must_equal 1 - _(span.name).must_equal 'set' - _(span.attributes['db.statement']).must_equal 'set ?' - end - end - - # Dalli 3.x has different behavior than 2.x versions and attempts to retry on network errors - # https://github.com/petergoldstein/dalli/pull/754 - def supports_retry_on_network_errors? - Gem.loaded_specs['dalli'].version >= Gem::Version.new('3.0.0') - end -end unless ENV['OMIT_SERVICES'] diff --git a/instrumentation/dalli/test/test_helper.rb b/instrumentation/dalli/test/test_helper.rb deleted file mode 100644 index ec21e106ea..0000000000 --- a/instrumentation/dalli/test/test_helper.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'dalli' - -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' - -require 'minitest/autorun' -require 'pry' - -# global opentelemetry-sdk setup: -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry::SDK.configure do |c| - c.add_span_processor span_processor -end diff --git a/instrumentation/datadog-porting-guide.md b/instrumentation/datadog-porting-guide.md deleted file mode 100644 index dc9c63c759..0000000000 --- a/instrumentation/datadog-porting-guide.md +++ /dev/null @@ -1,115 +0,0 @@ -# Porting Guide - -## Purpose - -Aid developers who wish to port existing datadog (dd-trace-rb) instrumentation to opentelemetry. - -## Interface - -* There should be a subclass of `OpenTelemetry::Instrumentation::Base` that implements its DSL: - * Implement `install` block, where all of the integration work happens - * Implement `present` block - * Optionally, implement `compatible` - * See `OpenTelemetry::Instrumentation::Base` API documentation for more details - -## Basic structure - -* Add Gemfile, opentelemetry-instrumentation-#{name}.gemspec -* Add runnable (docker) example (using its own Gemfile) -``` -$ docker-compose run ex-instrumentation-myinstrumentation bundle install -$ docker-compose run ex-instrumentation-myinstrumentation -bash-5.0$ ruby trace_demonstration.rb -``` -* Rakefile -* `tests/test_helper.rb` -* Integrate rubocop (see https://github.com/open-telemetry/opentelemetry-ruby/pull/172#pullrequestreview-349183775) - -## Examples and template instrumentation - -* `instrumentation/faraday` and `instrumentation/sinatra` were the earliest, simplest implementations - -## Implementation - -* It's ok to use `require_relative` for files that are internal to the project -* Don't load integration implementation (require file) until `install` ('patch')-time -* Most times, only want to run installation (via `#install`) once, but need to - consider being able to `reset` somehow for, e.g., testing - -### otel: tracer - -* `Tracer` `:name` and `:version` should come from instrumentation/base, not from the instrumented library - -### otel: span - -* Wrap instrumented-library operations in `span` (via `tracer.in_span` (block), or `tracer.start_span` (returns `Span`)) - * `Span.finish` should be called if using `tracer.start_span` -* Span `:with_parent` defaults to `current_span` - -### otel: span.name (dd-trace-rb: 'resource') - -* Prefer "low-cardinality" names (see https://github.com/open-telemetry/opentelemetry-specification/pull/416) - -### otel: span.attributes (dd-trace-rb: 'tags') - -* `Span` attribute keys should be strings, *not* symbols -* `Span` attribute values should be strings, *not* symbols -* Prefer to populate span attributes via method arguments (e.g., `tracer.in_span(attributes: ...`) instead of `span.set_attribute` -* Some `Span` attribute naming is based on [semantic conventions](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/data-semantic-conventions.md), for example [HTTP semantic conventions](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/data-http.md) - * When opening a PR, it would be useful to note which attributes come from which semantic conventions, and which ones could not be found -* `Span` `:kind` defaults to `:internal` (other available options include `:client` or `:server`) - -### Runnable example - -* Gemfile should include "opentelemetry-instrumentation-#{instrumentation_name}" - -### Runtime performance considerations - -Watch for "low hanging fruit" performance improvements including: -* reduce object allocations - move to a constant, or cache values that would be generated repeatedly -* look for "easy wins" vs. "complete redesigns" - -## Testing - -* Add tests via minitest (not rspec) -* Test against multiple versions of instrumented library via `appraisal` - * GOTCHA: appraisal-2.2.0 + bundler-2.1.x (at least 2.1.4) -* Configure `.circleci/config.yml` -* Try to preserve all applicable tests from dd-trace-rb - * Skip tests datadog-specific configurations - * Skip tests for things that are not being ported - -## Context propagation - -* For client-only libraries, just `inject` -* For server-side libraries, `extract` remote span context from request headers, then start a new span using parent context (e.g., `tracer.in_span(with_parent_context: ...`) -* Use the plain `http_text_format` rather than `rack_http_text_format` - -## Dependencies - -* Allow instrumentation to function when underlying dependency (e.g., `faraday` gem) isn't present - * Don't create a hard-dependency on instrumented libraries -* `opentelemetry-sdk` is only needed for tests - -## Translation hints - -* `span.set_tag` => `span.set_attribute` -* `Datadog::Logger.log.debug` => `OpenTelemetry.logger.debug` -* `span.resource` => ?? possibly `span.attributes[:url]`, etc., possibly ignored -* `span.service` => `span.name` -* `span.span_type` => `span.attributes[:component]` -* `options[:tracer]` => `OpenTelemetry.tracer_factory.tracer` (then, e.g., `Instrumentation.tracer`) - -## Things to ignore (for now) - -* Pin ('patch info') -- probably deprecated in dd-trace-rb -* Configuration option for `:distributed_tracing` (should always be enabled) -* Deprecation paths -* Passing spans/information around ENV -* `Span#set_error` -* `Contrib::Analytics` -* Quantization - -## TBD (implementation differences) - -* set a tag (attribute) value only once (check if set already)? diff --git a/instrumentation/delayed_job/.rubocop.yml b/instrumentation/delayed_job/.rubocop.yml deleted file mode 100644 index eb0607b92f..0000000000 --- a/instrumentation/delayed_job/.rubocop.yml +++ /dev/null @@ -1,5 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-delayed_job.rb" diff --git a/instrumentation/delayed_job/.yardopts b/instrumentation/delayed_job/.yardopts deleted file mode 100644 index 4a7a2c9bcc..0000000000 --- a/instrumentation/delayed_job/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Delayed Job Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/delayed_job/Appraisals b/instrumentation/delayed_job/Appraisals deleted file mode 100644 index c3e9b24a24..0000000000 --- a/instrumentation/delayed_job/Appraisals +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -appraise 'delayed_job-4.1' do - gem 'delayed_job', '~> 4.1.0' -end diff --git a/instrumentation/delayed_job/CHANGELOG.md b/instrumentation/delayed_job/CHANGELOG.md deleted file mode 100644 index 1ccab5eab1..0000000000 --- a/instrumentation/delayed_job/CHANGELOG.md +++ /dev/null @@ -1,71 +0,0 @@ -# Release History: opentelemetry-instrumentation-delayed_job - -### v0.19.0 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Rails 7.0.3 test suite incompatibility -* FIXED: Broken test file requirements - -### v0.18.5 / 2022-05-02 - -* FIXED: RubyGems Fallback - -### v0.18.4 / 2021-12-02 - -* (No significant changes) - -### v0.18.3 / 2021-09-29 - -* (No significant changes) - -### v0.18.2 / 2021-08-12 - -* DOCS: Update docs to rely more on environment variable configuration - -### v0.18.1 / 2021-06-23 - -* (No significant changes) - -### v0.18.0 / 2021-05-21 - -* ADDED: Updated API depedency for 1.0.0.rc1 -* BREAKING CHANGE: Replace Time.now with Process.clock_gettime - -### v0.17.0 / 2021-04-22 - -* FIXED: Refactor propagators to add #fields - -### v0.16.0 / 2021-03-17 - -* FIXED: Example scripts now reference local common lib -* DOCS: Replace Gitter with GitHub Discussions - -### v0.15.0 / 2021-02-18 - -* (No significant changes) - -### v0.14.0 / 2021-02-03 - -* BREAKING CHANGE: Replace getter and setter callables and remove rack specific propagators - -* ADDED: Replace getter and setter callables and remove rack specific propagators - -### v0.13.0 / 2021-01-29 - -* FIXED: Coerce message ID to string in span payload - -### v0.12.0 / 2020-12-24 - -* (No significant changes) - -### v0.11.0 / 2020-12-11 - -* FIXED: Copyright comments to not reference year - -### v0.10.0 / 2020-12-03 - -* (No significant changes) - -### v0.9.0 / 2020-10-07 - -* Initial release of Delayed Job instrumentation (ported from Datadog) diff --git a/instrumentation/delayed_job/Gemfile b/instrumentation/delayed_job/Gemfile deleted file mode 100644 index 2baf57ac47..0000000000 --- a/instrumentation/delayed_job/Gemfile +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :test do - gem 'opentelemetry-instrumentation-base', path: '../base' -end diff --git a/instrumentation/delayed_job/LICENSE b/instrumentation/delayed_job/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/delayed_job/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/delayed_job/README.md b/instrumentation/delayed_job/README.md deleted file mode 100644 index 6dcf4204b5..0000000000 --- a/instrumentation/delayed_job/README.md +++ /dev/null @@ -1,53 +0,0 @@ -# OpenTelemetry DelayedJob Instrumentation - -The OpenTelemetry Delayed Job Ruby gem is a community maintained instrumentation for the [Delayed Job][delayedjob-home] Ruby jobs system. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-delayed_job -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-delayed_job` in your `Gemfile`. - -## Usage - -To install the instrumentation, call `use` with the name of the instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::DelayedJob' -end -``` - -Alternatively, you can also call `use_all` to install all the available instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` - -## Examples - -Example usage of delayed_job can be seen in the `./example/delayed_job.rb` file [here](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/instrumentation/delayed_job/example/delayed_job.rb) - -## How can I get involved? - -The `opentelemetry-instrumentation-delayed_job` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -Apache 2.0 license. See [LICENSE][license-github] for more information. - -[delayedjob-home]: https://github.com/collectiveidea/delayed_job -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/instrumentation/delayed_job/Rakefile b/instrumentation/delayed_job/Rakefile deleted file mode 100644 index 1a64ba842e..0000000000 --- a/instrumentation/delayed_job/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/delayed_job/example/Gemfile b/instrumentation/delayed_job/example/Gemfile deleted file mode 100644 index 2dca581023..0000000000 --- a/instrumentation/delayed_job/example/Gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -source 'https://rubygems.org' - -gem 'delayed_job' -gem 'opentelemetry-api' -gem 'opentelemetry-common' -gem 'opentelemetry-instrumentation-delayed_job' -gem 'opentelemetry-sdk' diff --git a/instrumentation/delayed_job/example/delayed_job.rb b/instrumentation/delayed_job/example/delayed_job.rb deleted file mode 100644 index 3adfff363c..0000000000 --- a/instrumentation/delayed_job/example/delayed_job.rb +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'rubygems' -require 'bundler/setup' - -Bundler.require - -ENV['OTEL_TRACES_EXPORTER'] = 'console' -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::DelayedJob' -end - -# A basic Delayed Job worker example -payload = Class.new do - def perform - puts "Workin'" - end -end - -job = Delayed::Job.enqueue(payload.new) - -Delayed::Worker.new.run(job) diff --git a/instrumentation/delayed_job/lib/opentelemetry-instrumentation-delayed_job.rb b/instrumentation/delayed_job/lib/opentelemetry-instrumentation-delayed_job.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/delayed_job/lib/opentelemetry-instrumentation-delayed_job.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/delayed_job/lib/opentelemetry/instrumentation.rb b/instrumentation/delayed_job/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index 159de2cfea..0000000000 --- a/instrumentation/delayed_job/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # "Instrumentation" are specified by - # https://github.com/open-telemetry/opentelemetry-specification/blob/784635d01d8690c8f5fcd1f55bdbc8a13cf2f4f2/specification/glossary.md#instrumentation-library - # - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/delayed_job' diff --git a/instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job.rb b/instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job.rb deleted file mode 100644 index 9c651cdd23..0000000000 --- a/instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the DelayedJob gem - module DelayedJob - end - end -end - -require_relative './delayed_job/instrumentation' -require_relative './delayed_job/version' diff --git a/instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job/instrumentation.rb b/instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job/instrumentation.rb deleted file mode 100644 index fac17e5bd4..0000000000 --- a/instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job/instrumentation.rb +++ /dev/null @@ -1,42 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module DelayedJob - # Instrumentation class that detects and installs the DelayedJob instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - MINIMUM_VERSION = Gem::Version.new('4.1') - - install do |_config| - require_dependencies - register_tracer_plugin - end - - present do - !defined?(::Delayed).nil? - end - - compatible do - # Version is hardcoded in the gemspec - # https://github.com/collectiveidea/delayed_job/blob/master/delayed_job.gemspec#L16 - gem_version = Gem.loaded_specs['delayed_job']&.version - gem_version && gem_version >= MINIMUM_VERSION - end - - private - - def require_dependencies - require_relative 'plugins/tracer_plugin' - end - - def register_tracer_plugin - ::Delayed::Worker.plugins << Plugins::TracerPlugin - end - end - end - end -end diff --git a/instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin.rb b/instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin.rb deleted file mode 100644 index 517b5b8b5c..0000000000 --- a/instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin.rb +++ /dev/null @@ -1,90 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'delayed/plugin' - -module OpenTelemetry - module Instrumentation - module DelayedJob - module Plugins - # Delayed Job plugin that instruments invoke_job and other hooks - class TracerPlugin < Delayed::Plugin - class << self - def instrument_enqueue(job, &block) - return block.call(job) unless enabled? - - attributes = build_attributes(job) - attributes['messaging.operation'] = 'send' - tracer.in_span("#{job_queue(job)} send", attributes: attributes, kind: :producer) do |span| - yield job - span.set_attribute('messaging.message_id', job.id.to_s) - add_events(span, job) - end - end - - def instrument_invoke(job, &block) - return block.call(job) unless enabled? - - attributes = build_attributes(job) - attributes['messaging.delayed_job.attempts'] = job.attempts if job.attempts - attributes['messaging.delayed_job.locked_by'] = job.locked_by if job.locked_by - attributes['messaging.operation'] = 'process' - attributes['messaging.message_id'] = job.id.to_s - tracer.in_span("#{job_queue(job)} process", attributes: attributes, kind: :consumer) do |span| - add_events(span, job) - yield job - end - end - - protected - - def build_attributes(job) - { - 'messaging.system' => 'delayed_job', - 'messaging.destination' => job_queue(job), - 'messaging.destination_kind' => 'queue', - 'messaging.delayed_job.name' => job_name(job), - 'messaging.delayed_job.priority' => job.priority - } - end - - def add_events(span, job) - span.add_event('created_at', timestamp: job.created_at) - span.add_event('run_at', timestamp: job.run_at) if job.run_at - span.add_event('locked_at', timestamp: job.locked_at) if job.locked_at - end - - def enabled? - DelayedJob::Instrumentation.instance.enabled? - end - - def tracer - DelayedJob::Instrumentation.instance.tracer - end - - def job_name(job) - # If Delayed Job is used via ActiveJob then get the job name from the payload - if job.payload_object.respond_to?(:job_data) - job.payload_object.job_data['job_class'] - else - job.name - end - end - - def job_queue(job) - job.queue || 'default' - end - end - - callbacks do |lifecycle| - lifecycle.around(:enqueue, &method(:instrument_enqueue)) - lifecycle.around(:invoke_job, &method(:instrument_invoke)) - end - end - end - end - end -end diff --git a/instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job/version.rb b/instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job/version.rb deleted file mode 100644 index 145ef61eec..0000000000 --- a/instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module DelayedJob - VERSION = '0.19.0' - end - end -end diff --git a/instrumentation/delayed_job/opentelemetry-instrumentation-delayed_job.gemspec b/instrumentation/delayed_job/opentelemetry-instrumentation-delayed_job.gemspec deleted file mode 100644 index 0253b1f0ba..0000000000 --- a/instrumentation/delayed_job/opentelemetry-instrumentation-delayed_job.gemspec +++ /dev/null @@ -1,52 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/delayed_job/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-delayed_job' - spec.version = OpenTelemetry::Instrumentation::DelayedJob::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'Delayed Job instrumentation for the OpenTelemetry framework' - spec.description = 'Delayed Job instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.21.0' - - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'delayed_job', '~> 4.1.0' - spec.add_development_dependency 'delayed_job_active_record' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'rspec-mocks' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'sqlite3' - spec.add_development_dependency 'webmock', '~> 3.7.6' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-delayed_job/v#{OpenTelemetry::Instrumentation::DelayedJob::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/delayed_job' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-delayed_job/v#{OpenTelemetry::Instrumentation::DelayedJob::VERSION}" - end -end diff --git a/instrumentation/delayed_job/test/.rubocop.yml b/instrumentation/delayed_job/test/.rubocop.yml deleted file mode 100644 index dd94258585..0000000000 --- a/instrumentation/delayed_job/test/.rubocop.yml +++ /dev/null @@ -1,4 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false diff --git a/instrumentation/delayed_job/test/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin_test.rb b/instrumentation/delayed_job/test/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin_test.rb deleted file mode 100644 index 17f1f93a70..0000000000 --- a/instrumentation/delayed_job/test/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin_test.rb +++ /dev/null @@ -1,192 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative '../../../../test_helper' - -# require Instrumentation so .install method is found: -require_relative '../../../../../lib/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin' - -describe OpenTelemetry::Instrumentation::DelayedJob::Plugins::TracerPlugin do - let(:instrumentation) { OpenTelemetry::Instrumentation::DelayedJob::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:finished_spans) { exporter.finished_spans } - let(:span) { exporter.finished_spans.last } - - before do - TestHelper.setup_active_record - - stub_const('BasicPayload', Class.new do - def perform; end - end) - @basic_payload = BasicPayload - - stub_const('ErrorPayload', Class.new do - def perform - raise ArgumentError, 'This job failed' - end - end) - @error_payload = ErrorPayload - - stub_const('ActiveJobPayload', Class.new do - def perform; end - - def job_data - { 'job_class' => 'UnderlyingJobClass' } - end - end) - @active_job_payload = ActiveJobPayload - - instrumentation.install - exporter.reset - - # this is currently a noop but this will future proof the test - @orig_propagation = OpenTelemetry.propagation - propagator = OpenTelemetry::Trace::Propagation::TraceContext.text_map_propagator - OpenTelemetry.propagation = propagator - end - - after do - OpenTelemetry.propagation = @orig_propagation - - TestHelper.teardown_active_record - end - - describe 'enqueue callback' do - let(:job_params) { {} } - let(:job_enqueue) { Delayed::Job.enqueue(@basic_payload.new, job_params) } - let(:span) { exporter.finished_spans.first } - - it 'creates an enqueue span' do - _(exporter.finished_spans).must_equal [] - job_enqueue - _(exporter.finished_spans.size).must_equal 1 - - _(span).must_be_kind_of OpenTelemetry::SDK::Trace::SpanData - _(span.name).must_equal 'default send' - _(span.attributes['messaging.system']).must_equal 'delayed_job' - _(span.attributes['messaging.destination']).must_equal 'default' - _(span.attributes['messaging.destination_kind']).must_equal 'queue' - _(span.attributes['messaging.delayed_job.name']).must_equal 'BasicPayload' - _(span.attributes['messaging.delayed_job.priority']).must_equal 0 - _(span.attributes['messaging.operation']).must_equal 'send' - _(span.attributes['messaging.message_id']).must_be_kind_of String - - _(span.events.size).must_equal 2 - _(span.events[0].name).must_equal 'created_at' - _(span.events[0].timestamp).must_be_kind_of Integer - _(span.events[1].name).must_equal 'run_at' - _(span.events[1].timestamp).must_be_kind_of Integer - end - - describe 'when queue name is set' do - let(:job_params) { { queue: 'foobar_queue' } } - - it 'span tags include queue name' do - job_enqueue - _(span.attributes['messaging.destination']).must_equal 'foobar_queue' - _(span.attributes['messaging.destination_kind']).must_equal 'queue' - end - end - - describe 'when priority is set' do - let(:job_params) { { priority: 123 } } - - it 'span tags include priority' do - job_enqueue - _(span.attributes['messaging.delayed_job.priority']).must_equal 123 - end - end - - describe 'when the job looks like Active Job' do - let(:job_enqueue) { Delayed::Job.enqueue(@active_job_payload.new, job_params) } - - it 'has resource name equal to underlying ActiveJob class name' do - job_enqueue - _(span.attributes['messaging.delayed_job.name']).must_equal 'UnderlyingJobClass' - end - end - end - - describe 'invoke_job callback' do - let(:job_params) { {} } - let(:job_enqueue) { Delayed::Job.enqueue(@basic_payload.new, job_params) } - let(:job_run) do - job_enqueue - Delayed::Worker.new.work_off - end - - it 'creates an invoke span' do - _(exporter.finished_spans).must_equal [] - job_enqueue - _(exporter.finished_spans.size).must_equal 1 - _(exporter.finished_spans.first.name).must_equal 'default send' - job_run - _(exporter.finished_spans.size).must_equal 2 - - _(span).must_be_kind_of OpenTelemetry::SDK::Trace::SpanData - _(span.name).must_equal 'default process' - _(span.attributes['messaging.system']).must_equal 'delayed_job' - _(span.attributes['messaging.destination']).must_equal 'default' - _(span.attributes['messaging.destination_kind']).must_equal 'queue' - _(span.attributes['messaging.delayed_job.name']).must_equal 'BasicPayload' - _(span.attributes['messaging.delayed_job.priority']).must_equal 0 - _(span.attributes['messaging.delayed_job.attempts']).must_equal 0 - _(span.attributes['messaging.delayed_job.locked_by']).must_be_kind_of String - _(span.attributes['messaging.operation']).must_equal 'process' - _(span.attributes['messaging.message_id']).must_be_kind_of String - - _(span.events.size).must_equal 3 - _(span.events[0].name).must_equal 'created_at' - _(span.events[0].timestamp).must_be_kind_of Integer - _(span.events[1].name).must_equal 'run_at' - _(span.events[1].timestamp).must_be_kind_of Integer - _(span.events[2].name).must_equal 'locked_at' - _(span.events[2].timestamp).must_be_kind_of Integer - end - - describe 'when queue name is set' do - let(:job_params) { { queue: 'foobar_queue' } } - - it 'span tags include queue name' do - job_run - _(span.attributes['messaging.destination']).must_equal 'foobar_queue' - _(span.attributes['messaging.destination_kind']).must_equal 'queue' - end - end - - describe 'when priority is set' do - let(:job_params) { { priority: 123 } } - - it 'span tags include priority' do - job_run - _(span.attributes['messaging.delayed_job.priority']).must_equal 123 - end - end - - describe 'when the job looks like Active Job' do - let(:job_enqueue) { Delayed::Job.enqueue(@active_job_payload.new, job_params) } - - it 'has resource name equal to underlying ActiveJob class name' do - job_run - _(span.attributes['messaging.delayed_job.name']).must_equal 'UnderlyingJobClass' - end - end - - describe 'when the job raises an error' do - let(:job_enqueue) { Delayed::Job.enqueue(@error_payload.new, job_params) } - - it 'has resource name equal to underlying ActiveJob class name' do - job_run - _(span.attributes['messaging.delayed_job.name']).must_equal 'ErrorPayload' - _(span.events.size).must_equal 4 - _(span.events[3].name).must_equal 'exception' - _(span.events[3].timestamp).must_be_kind_of Integer - _(span.events[3].attributes['exception.type']).must_equal 'ArgumentError' - _(span.events[3].attributes['exception.message']).must_equal 'This job failed' - end - end - end -end diff --git a/instrumentation/delayed_job/test/opentelemetry/instrumentation/delayed_job_test.rb b/instrumentation/delayed_job/test/opentelemetry/instrumentation/delayed_job_test.rb deleted file mode 100644 index 14f06ffa48..0000000000 --- a/instrumentation/delayed_job/test/opentelemetry/instrumentation/delayed_job_test.rb +++ /dev/null @@ -1,77 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative '../../test_helper' - -describe OpenTelemetry::Instrumentation::DelayedJob do - let(:instrumentation) { OpenTelemetry::Instrumentation::DelayedJob::Instrumentation.instance } - let(:exporter) { EXPORTER } - - before do - instrumentation.install - exporter.reset - end - - describe 'present' do - it 'when delayed_job gem installed' do - _(instrumentation.present?).must_equal true - end - - it 'when delayed_job gem not installed' do - hide_const('Delayed') - _(instrumentation.present?).must_equal false - end - end - - describe 'compatible' do - it 'when older gem version installed' do - Gem.stub(:loaded_specs, 'delayed_job' => Gem::Specification.new { |s| s.version = '4.0.3' }) do - _(instrumentation.compatible?).must_equal false - end - end - - it 'when future gem version installed' do - Gem.stub(:loaded_specs, 'delayed_job' => Gem::Specification.new { |s| s.version = '5.3.0' }) do - _(instrumentation.compatible?).must_equal true - end - end - end - - describe 'install' do - it 'installs the tracer plugin' do - klass = OpenTelemetry::Instrumentation::DelayedJob::Plugins::TracerPlugin - _(Delayed::Worker.plugins).must_include klass - end - end - - describe 'tracing' do - before do - TestHelper.setup_active_record - end - - after do - TestHelper.teardown_active_record - end - - it 'before job' do - _(exporter.finished_spans.size).must_equal 0 - end - - it 'after job' do - payload = Class.new do - def perform - true - end - end - - job = Delayed::Job.enqueue(payload.new) - _(exporter.finished_spans.size).must_equal 1 - - Delayed::Worker.new.run(job) - _(exporter.finished_spans.size).must_equal 2 - end - end -end diff --git a/instrumentation/delayed_job/test/test_helper.rb b/instrumentation/delayed_job/test/test_helper.rb deleted file mode 100644 index 69f8715b7a..0000000000 --- a/instrumentation/delayed_job/test/test_helper.rb +++ /dev/null @@ -1,53 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'active_support/core_ext/kernel/reporting' -require 'delayed_job' -require 'delayed_job_active_record' - -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' - -require 'minitest/autorun' -require 'rspec/mocks/minitest_integration' -require 'webmock/minitest' - -require_relative '../lib/opentelemetry-instrumentation-delayed_job' - -# global opentelemetry-sdk setup: -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry::SDK.configure do |c| - c.add_span_processor span_processor -end - -module TestHelper - extend self - - def setup_active_record - ::ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:') - ::ActiveRecord::Schema.define do - create_table 'delayed_jobs', force: :cascade do |t| - t.integer 'priority', default: 0, null: false - t.integer 'attempts', default: 0, null: false - t.text 'handler', null: false - t.text 'last_error' - t.datetime 'run_at' - t.datetime 'locked_at' - t.datetime 'failed_at' - t.string 'locked_by' - t.string 'queue' - t.datetime 'created_at' - t.datetime 'updated_at' - end - end - end - - def teardown_active_record - ::ActiveRecord::Base.connection.close - end -end diff --git a/instrumentation/ethon/.rubocop.yml b/instrumentation/ethon/.rubocop.yml deleted file mode 100644 index ae9981a2f1..0000000000 --- a/instrumentation/ethon/.rubocop.yml +++ /dev/null @@ -1,5 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-ethon.rb" diff --git a/instrumentation/ethon/.yardopts b/instrumentation/ethon/.yardopts deleted file mode 100644 index 8b83df78ec..0000000000 --- a/instrumentation/ethon/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Ethon Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/ethon/Appraisals b/instrumentation/ethon/Appraisals deleted file mode 100644 index 137aed805f..0000000000 --- a/instrumentation/ethon/Appraisals +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -appraise 'ethon-0.12' do - gem 'ethon', '~> 0.12.0' -end - -appraise 'ethon-0.11' do - gem 'ethon', '~> 0.11.0' -end diff --git a/instrumentation/ethon/CHANGELOG.md b/instrumentation/ethon/CHANGELOG.md deleted file mode 100644 index 8d83a493c4..0000000000 --- a/instrumentation/ethon/CHANGELOG.md +++ /dev/null @@ -1,96 +0,0 @@ -# Release History: opentelemetry-instrumentation-ethon - -### v0.20.0 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Broken test file requirements - -### v0.19.5 / 2022-05-05 - -* (No significant changes) - -### v0.19.4 / 2022-02-02 - -* FIXED: Excessive hash creation on context attr merging - -### v0.19.3 / 2021-12-02 - -* (No significant changes) - -### v0.19.2 / 2021-09-29 - -* (No significant changes) - -### v0.19.1 / 2021-08-12 - -* DOCS: Update docs to rely more on environment variable configuration - -### v0.19.0 / 2021-06-23 - -* BREAKING CHANGE: Total order constraint on span.status= - -* FIXED: Total order constraint on span.status= - -### v0.18.0 / 2021-05-21 - -* ADDED: Updated API depedency for 1.0.0.rc1 - -### v0.17.0 / 2021-04-22 - -* ADDED: Ethon instrumentation accepts peer service config attribute. -* FIXED: Refactor propagators to add #fields - -### v0.16.0 / 2021-03-17 - -* FIXED: Remove passwords from http.url -* FIXED: Example scripts now reference local common lib -* DOCS: Replace Gitter with GitHub Discussions - -### v0.15.0 / 2021-02-18 - -* (No significant changes) - -### v0.14.0 / 2021-02-03 - -* BREAKING CHANGE: Replace getter and setter callables and remove rack specific propagators - -* ADDED: Replace getter and setter callables and remove rack specific propagators - -### v0.13.0 / 2021-01-29 - -* (No significant changes) - -### v0.12.0 / 2020-12-24 - -* (No significant changes) - -### v0.11.0 / 2020-12-11 - -* FIXED: Copyright comments to not reference year - -### v0.10.0 / 2020-12-03 - -* (No significant changes) - -### v0.9.0 / 2020-11-27 - -* BREAKING CHANGE: Add timeout for force_flush and shutdown - -* ADDED: Add timeout for force_flush and shutdown - -### v0.8.0 / 2020-10-27 - -* BREAKING CHANGE: Move context/span methods to Trace module -* BREAKING CHANGE: Remove 'canonical' from status codes - -* FIXED: Move context/span methods to Trace module -* FIXED: Remove 'canonical' from status codes - -### v0.7.0 / 2020-10-07 - -* DOCS: Add README for Ethon -* DOCS: Standardize toplevel docs structure and readme - -### v0.6.0 / 2020-09-10 - -* (No significant changes) diff --git a/instrumentation/ethon/Gemfile b/instrumentation/ethon/Gemfile deleted file mode 100644 index 2baf57ac47..0000000000 --- a/instrumentation/ethon/Gemfile +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :test do - gem 'opentelemetry-instrumentation-base', path: '../base' -end diff --git a/instrumentation/ethon/LICENSE b/instrumentation/ethon/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/ethon/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/ethon/README.md b/instrumentation/ethon/README.md deleted file mode 100644 index 1d4bc97f88..0000000000 --- a/instrumentation/ethon/README.md +++ /dev/null @@ -1,54 +0,0 @@ -# Ethon Instrumentation - -The ethon instrumentation is a community-maintained instrumentation for the [ethon][ethon-home] HTTP library. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-ethon -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-ethon` to your `Gemfile`. - -## Usage - -To install the instrumentation, call `use` with the name of the instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Ethon' -end -``` - -Alternatively, you can also call `use_all` to install all the available instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` - -## Examples - -Example usage of faraday can be seen in the `./example/ethon.rb` file [here](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/instrumentation/ethon/example/ethon.rb) - -## How can I get involved? - -The `opentelemetry-instrumentation-ethon` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -The `opentelemetry-instrumentation-all` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information. - -[ethon]:https://github.com/typhoeus/ethon -[ethon-home]:https://github.com/typhoeus/ethon -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/instrumentation/ethon/Rakefile b/instrumentation/ethon/Rakefile deleted file mode 100644 index 1a64ba842e..0000000000 --- a/instrumentation/ethon/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/ethon/example/Gemfile b/instrumentation/ethon/example/Gemfile deleted file mode 100644 index 29ab5b38e1..0000000000 --- a/instrumentation/ethon/example/Gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -source 'https://rubygems.org' - -gem 'ethon' -gem 'opentelemetry-api' -gem 'opentelemetry-common' -gem 'opentelemetry-instrumentation-ethon' -gem 'opentelemetry-sdk' diff --git a/instrumentation/ethon/example/ethon.rb b/instrumentation/ethon/example/ethon.rb deleted file mode 100644 index e1772a3046..0000000000 --- a/instrumentation/ethon/example/ethon.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -require 'rubygems' -require 'bundler/setup' - -Bundler.require - -ENV['OTEL_TRACES_EXPORTER'] = 'console' -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Ethon' -end - -Ethon::Easy.new(url: 'http://example.com').perform diff --git a/instrumentation/ethon/lib/opentelemetry-instrumentation-ethon.rb b/instrumentation/ethon/lib/opentelemetry-instrumentation-ethon.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/ethon/lib/opentelemetry-instrumentation-ethon.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/ethon/lib/opentelemetry/instrumentation.rb b/instrumentation/ethon/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index 8d84d29010..0000000000 --- a/instrumentation/ethon/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # "Instrumentation" are specified by - # https://github.com/open-telemetry/opentelemetry-specification/blob/784635d01d8690c8f5fcd1f55bdbc8a13cf2f4f2/specification/glossary.md#instrumentation-library - # - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/ethon' diff --git a/instrumentation/ethon/lib/opentelemetry/instrumentation/ethon.rb b/instrumentation/ethon/lib/opentelemetry/instrumentation/ethon.rb deleted file mode 100644 index e928e4e2be..0000000000 --- a/instrumentation/ethon/lib/opentelemetry/instrumentation/ethon.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the Ethon gem - module Ethon - end - end -end - -require_relative './ethon/instrumentation' -require_relative './ethon/version' diff --git a/instrumentation/ethon/lib/opentelemetry/instrumentation/ethon/instrumentation.rb b/instrumentation/ethon/lib/opentelemetry/instrumentation/ethon/instrumentation.rb deleted file mode 100644 index 3af51a7ac4..0000000000 --- a/instrumentation/ethon/lib/opentelemetry/instrumentation/ethon/instrumentation.rb +++ /dev/null @@ -1,38 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Ethon - # The Instrumentation class contains logic to detect and install the Ethon - # instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - install do |_config| - require_dependencies - add_patches - end - - present do - defined?(::Ethon::Easy) - end - - option :peer_service, default: nil, validate: :string - - private - - def require_dependencies - require_relative 'patches/easy' - require_relative 'patches/multi' - end - - def add_patches - ::Ethon::Easy.prepend(Patches::Easy) - ::Ethon::Multi.prepend(Patches::Multi) - end - end - end - end -end diff --git a/instrumentation/ethon/lib/opentelemetry/instrumentation/ethon/patches/easy.rb b/instrumentation/ethon/lib/opentelemetry/instrumentation/ethon/patches/easy.rb deleted file mode 100644 index 2e3928582b..0000000000 --- a/instrumentation/ethon/lib/opentelemetry/instrumentation/ethon/patches/easy.rb +++ /dev/null @@ -1,104 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Ethon - module Patches - # Ethon::Easy patch for instrumentation - module Easy - ACTION_NAMES_TO_HTTP_METHODS = Hash.new do |h, k| - # #to_s is required because user input could be symbol or string - h[k] = k.to_s.upcase - end - HTTP_METHODS_TO_SPAN_NAMES = Hash.new { |h, k| h[k] = "HTTP #{k}" } - - def http_request(url, action_name, options = {}) - @otel_method = ACTION_NAMES_TO_HTTP_METHODS[action_name] - super - end - - def headers=(headers) - # Store headers to call this method again when span is ready - @otel_original_headers = headers - super - end - - def perform - otel_before_request - super - end - - def complete - begin - response_options = mirror.options - response_code = (response_options[:response_code] || response_options[:code]).to_i - if response_code.zero? - return_code = response_options[:return_code] - message = return_code ? ::Ethon::Curl.easy_strerror(return_code) : 'unknown reason' - @otel_span.status = OpenTelemetry::Trace::Status.error("Request has failed: #{message}") - else - @otel_span.set_attribute('http.status_code', response_code) - @otel_span.status = OpenTelemetry::Trace::Status.error unless (100..399).include?(response_code.to_i) - end - ensure - @otel_span&.finish - @otel_span = nil - end - super - end - - def reset - super - ensure - @otel_span = nil - @otel_method = nil - @otel_original_headers = nil - end - - def otel_before_request - method = 'N/A' # Could be GET or not HTTP at all - method = @otel_method if instance_variable_defined?(:@otel_method) && !@otel_method.nil? - - @otel_span = tracer.start_span( - HTTP_METHODS_TO_SPAN_NAMES[method], - attributes: span_creation_attributes(method), - kind: :client - ) - - @otel_original_headers ||= {} - OpenTelemetry::Trace.with_span(@otel_span) do - OpenTelemetry.propagation.inject(@otel_original_headers) - end - self.headers = @otel_original_headers - end - - def otel_span_started? - instance_variable_defined?(:@otel_span) && !@otel_span.nil? - end - - private - - def span_creation_attributes(method) - instrumentation_attrs = { - 'http.method' => method, - 'http.url' => OpenTelemetry::Common::Utilities.cleanse_url(url) - } - config = Ethon::Instrumentation.instance.config - instrumentation_attrs['peer.service'] = config[:peer_service] if config[:peer_service] - instrumentation_attrs.merge!( - OpenTelemetry::Common::HTTP::ClientContext.attributes - ) - end - - def tracer - Ethon::Instrumentation.instance.tracer - end - end - end - end - end -end diff --git a/instrumentation/ethon/lib/opentelemetry/instrumentation/ethon/patches/multi.rb b/instrumentation/ethon/lib/opentelemetry/instrumentation/ethon/patches/multi.rb deleted file mode 100644 index 13107bc0bc..0000000000 --- a/instrumentation/ethon/lib/opentelemetry/instrumentation/ethon/patches/multi.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Ethon - module Patches - # Ethon::Multi patch for instrumentation - module Multi - def perform - easy_handles.each do |easy| - easy.otel_before_request unless easy.otel_span_started? - end - - super - end - - def add(easy) - easy.otel_before_request unless easy.otel_span_started? - - super - end - end - end - end - end -end diff --git a/instrumentation/ethon/lib/opentelemetry/instrumentation/ethon/version.rb b/instrumentation/ethon/lib/opentelemetry/instrumentation/ethon/version.rb deleted file mode 100644 index 492d250545..0000000000 --- a/instrumentation/ethon/lib/opentelemetry/instrumentation/ethon/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Ethon - VERSION = '0.20.0' - end - end -end diff --git a/instrumentation/ethon/opentelemetry-instrumentation-ethon.gemspec b/instrumentation/ethon/opentelemetry-instrumentation-ethon.gemspec deleted file mode 100644 index 014afc03ab..0000000000 --- a/instrumentation/ethon/opentelemetry-instrumentation-ethon.gemspec +++ /dev/null @@ -1,49 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/ethon/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-ethon' - spec.version = OpenTelemetry::Instrumentation::Ethon::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'Ethon instrumentation for the OpenTelemetry framework' - spec.description = 'Ethon instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-common', '~> 0.19.3' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.21.0' - - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'ethon', '~> 0.12.0' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-ethon/v#{OpenTelemetry::Instrumentation::Ethon::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/ethon' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-ethon/v#{OpenTelemetry::Instrumentation::Ethon::VERSION}" - end -end diff --git a/instrumentation/ethon/test/.rubocop.yml b/instrumentation/ethon/test/.rubocop.yml deleted file mode 100644 index dd94258585..0000000000 --- a/instrumentation/ethon/test/.rubocop.yml +++ /dev/null @@ -1,4 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false diff --git a/instrumentation/ethon/test/opentelemetry/instrumentation/ethon/instrumentation_test.rb b/instrumentation/ethon/test/opentelemetry/instrumentation/ethon/instrumentation_test.rb deleted file mode 100644 index 01de856fe1..0000000000 --- a/instrumentation/ethon/test/opentelemetry/instrumentation/ethon/instrumentation_test.rb +++ /dev/null @@ -1,285 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../lib/opentelemetry/instrumentation/ethon' -require_relative '../../../../lib/opentelemetry/instrumentation/ethon/patches/easy' - -describe OpenTelemetry::Instrumentation::Ethon::Instrumentation do - let(:instrumentation) { OpenTelemetry::Instrumentation::Ethon::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:span) { exporter.finished_spans.first } - - before do - exporter.reset - - # this is currently a noop but this will future proof the test - @orig_propagation = OpenTelemetry.propagation - propagator = OpenTelemetry::Trace::Propagation::TraceContext.text_map_propagator - OpenTelemetry.propagation = propagator - end - - after do - # Force re-install of instrumentation - instrumentation.instance_variable_set(:@installed, false) - - OpenTelemetry.propagation = @orig_propagation - end - - describe 'tracing' do - before do - instrumentation.install - end - - it 'before request' do - _(exporter.finished_spans.size).must_equal 0 - end - - describe 'easy' do - let(:easy) { ::Ethon::Easy.new(url: 'http://username:password@example.com/test') } - - describe '#http_request' do - it 'preserves HTTP request method on easy instance' do - easy.http_request('example.com', 'POST') - _(easy.instance_eval { @otel_method }).must_equal 'POST' - end - end - - describe '#headers=' do - it 'preserves HTTP headers on easy instance' do - easy.headers = { key: 'value' } - _(easy.instance_eval { @otel_original_headers }).must_equal( - key: 'value' - ) - end - end - - describe '#perform' do - let(:span) { easy.instance_eval { @otel_span } } - - it 'creates a span' do - ::Ethon::Curl.stub(:easy_perform, 0) do - # Note: suppress call to #complete to isolate #perform functionality - easy.stub(:complete, nil) do - easy.perform - - _(span.name).must_equal 'HTTP N/A' - _(span.attributes['http.method']).must_equal 'N/A' - _(span.attributes['http.status_code']).must_be_nil - _(span.attributes['http.url']).must_equal 'http://example.com/test' - end - end - end - end - - describe '#complete' do - def stub_response(options) - easy.stub(:mirror, ::Ethon::Easy::Mirror.new(options)) do - easy.otel_before_request - # Note: perform calls complete - easy.complete - - yield - end - end - - it 'when response is successful' do - stub_response(response_code: 200) do - _(span.name).must_equal 'HTTP N/A' - _(span.attributes['http.method']).must_equal 'N/A' - _(span.attributes['http.status_code']).must_equal 200 - _(span.attributes['http.url']).must_equal 'http://example.com/test' - _(easy.instance_eval { @otel_span }).must_be_nil - _( - easy.instance_eval { @otel_original_headers['traceparent'] } - ).must_equal "00-#{span.hex_trace_id}-#{span.hex_span_id}-01" - end - end - - it 'when response is not successful' do - stub_response(response_code: 500) do - _(span.name).must_equal 'HTTP N/A' - _(span.attributes['http.method']).must_equal 'N/A' - _(span.attributes['http.status_code']).must_equal 500 - _(span.attributes['http.url']).must_equal 'http://example.com/test' - _(easy.instance_eval { @otel_span }).must_be_nil - _( - easy.instance_eval { @otel_original_headers['traceparent'] } - ).must_equal "00-#{span.hex_trace_id}-#{span.hex_span_id}-01" - end - end - - it 'when request times out' do - stub_response(response_code: 0, return_code: :operation_timedout) do - _(span.name).must_equal 'HTTP N/A' - _(span.attributes['http.method']).must_equal 'N/A' - _(span.attributes['http.status_code']).must_be_nil - _(span.attributes['http.url']).must_equal 'http://example.com/test' - _(span.status.code).must_equal( - OpenTelemetry::Trace::Status::ERROR - ) - _(span.status.description).must_equal( - 'Request has failed: Timeout was reached' - ) - _(easy.instance_eval { @otel_span }).must_be_nil - _( - easy.instance_eval { @otel_original_headers['traceparent'] } - ).must_equal "00-#{span.hex_trace_id}-#{span.hex_span_id}-01" - end - end - - it 'merges HTTP client context' do - client_context_attrs = { - 'test.attribute' => 'test.value', 'http.method' => 'OVERRIDE' - } - OpenTelemetry::Common::HTTP::ClientContext.with_attributes(client_context_attrs) do - stub_response(response_code: 200) do - _(span.attributes['http.method']).must_equal 'OVERRIDE' - _(span.attributes['test.attribute']).must_equal 'test.value' - _(span.attributes['http.url']).must_equal 'http://example.com/test' - end - end - end - - it 'accepts peer service name from config' do - instrumentation.instance_variable_set(:@installed, false) - instrumentation.install(peer_service: 'example:faraday') - - stub_response(response_code: 200) do - _(span.attributes['peer.service']).must_equal 'example:faraday' - end - end - - it 'prioritizes context attributes over config for peer service name' do - instrumentation.instance_variable_set(:@installed, false) - instrumentation.install(peer_service: 'example:faraday') - - client_context_attrs = { 'peer.service' => 'example:custom' } - OpenTelemetry::Common::HTTP::ClientContext.with_attributes(client_context_attrs) do - stub_response(response_code: 200) do - _(span.attributes['peer.service']).must_equal 'example:custom' - end - end - end - end - - describe '#reset' do - describe 'with headers set up' do - before do - easy.headers = { key: 'value' } - end - - it 'cleans up @otel_original_headers' do - _(easy.instance_eval { @otel_original_headers }).must_equal( - key: 'value' - ) - - easy.reset - - _(easy.instance_eval { @otel_original_headers }).must_be_nil - end - end - - describe 'with HTTP method set up' do - before do - easy.http_request('example.com', :put) - end - - it 'cleans up @otel_method' do - _(easy.instance_eval { @otel_method }).must_equal 'PUT' - - easy.reset - - _(easy.instance_eval { @otel_method }).must_be_nil - end - end - - describe 'with span initialized' do - before do - easy.otel_before_request - end - - it 'cleans up @otel_span' do - _(easy.instance_eval { @otel_span }).must_be_instance_of( - OpenTelemetry::SDK::Trace::Span - ) - - easy.reset - - _(easy.instance_eval { @otel_span }).must_be_nil - end - end - end - end - - describe 'multi' do - let(:easy) { ::Ethon::Easy.new } - let(:multi) { ::Ethon::Multi.new } - - describe '#perform' do - describe 'with no easy added to multi' do - it 'does not trace' do - multi.perform - - _(exporter.finished_spans.size).must_equal 0 - end - end - - describe 'with easy added to multi' do - before { multi.add(easy) } - - it 'creates a span' do - multi.perform - - _(exporter.finished_spans.size).must_equal 1 - end - end - - describe 'with multiple calls to perform' do - it 'does not create extra calls to perform without new easies' do - expect do - multi.add(easy) - multi.perform - multi.perform - - _(exporter.finished_spans.size).must_equal 1 - end - end - - it 'creates extra traces for each extra valid call to perform' do - multi.add(easy) - multi.perform - multi.add(easy) - multi.perform - - _(exporter.finished_spans.size).must_equal 2 - end - end - - describe 'with calls to add while running' do - it 'creates extra traces for each extra valid call to add' do - multi.add(easy) - - # local variables for the closure - other = ::Ethon::Easy.new(url: 'test') - m = multi - easy.send(:define_singleton_method, :complete) do - m.add(other) - super() - end - - multi.perform - - _(exporter.finished_spans.size).must_equal 2 - _(exporter.finished_spans[0].attributes['http.url']).must_equal nil - _(exporter.finished_spans[1].attributes['http.url']).must_equal 'test' - end - end - end - end - end -end diff --git a/instrumentation/ethon/test/test_helper.rb b/instrumentation/ethon/test/test_helper.rb deleted file mode 100644 index 2448ed1c86..0000000000 --- a/instrumentation/ethon/test/test_helper.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'ethon' - -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' - -require 'minitest/autorun' - -# global opentelemetry-sdk setup: -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry::SDK.configure do |c| - c.add_span_processor span_processor -end diff --git a/instrumentation/excon/.rubocop.yml b/instrumentation/excon/.rubocop.yml deleted file mode 100644 index 2cd92c0f42..0000000000 --- a/instrumentation/excon/.rubocop.yml +++ /dev/null @@ -1,5 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-excon.rb" diff --git a/instrumentation/excon/.yardopts b/instrumentation/excon/.yardopts deleted file mode 100644 index 4cfcb29d76..0000000000 --- a/instrumentation/excon/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Excon Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/excon/Appraisals b/instrumentation/excon/Appraisals deleted file mode 100644 index 675ab01fe5..0000000000 --- a/instrumentation/excon/Appraisals +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -appraise 'excon-0.71' do - gem 'excon', '~> 0.71.0' -end - -# Incompatible with Ruby 3.0.0 (https://bugs.ruby-lang.org/issues/10499) -if RUBY_VERSION < '3' - appraise 'excon-0.64' do - gem 'excon', '~> 0.64.0' - end -end diff --git a/instrumentation/excon/CHANGELOG.md b/instrumentation/excon/CHANGELOG.md deleted file mode 100644 index 0547bc7ce8..0000000000 --- a/instrumentation/excon/CHANGELOG.md +++ /dev/null @@ -1,95 +0,0 @@ -# Release History: opentelemetry-instrumentation-excon - -### v0.20.0 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Broken test file requirements - -### v0.19.5 / 2022-05-05 - -* (No significant changes) - -### v0.19.4 / 2022-02-02 - -* FIXED: Excessive hash creation on context attr merging - -### v0.19.3 / 2021-12-02 - -* (No significant changes) - -### v0.19.2 / 2021-09-29 - -* (No significant changes) - -### v0.19.1 / 2021-08-12 - -* DOCS: Update docs to rely more on environment variable configuration - -### v0.19.0 / 2021-06-23 - -* BREAKING CHANGE: Total order constraint on span.status= - -* FIXED: Total order constraint on span.status= - -### v0.18.0 / 2021-05-21 - -* ADDED: Updated API depedency for 1.0.0.rc1 -* FIXED: Removed http.status_text attribute #750 - -### v0.17.0 / 2021-04-22 - -* ADDED: Excon instrumentation accepts peer service config attribute. -* FIXED: Refactor propagators to add #fields - -### v0.16.0 / 2021-03-17 - -* FIXED: Example scripts now reference local common lib -* DOCS: Replace Gitter with GitHub Discussions - -### v0.15.0 / 2021-02-18 - -* (No significant changes) - -### v0.14.0 / 2021-02-03 - -* BREAKING CHANGE: Replace getter and setter callables and remove rack specific propagators - -* ADDED: Replace getter and setter callables and remove rack specific propagators - -### v0.13.0 / 2021-01-29 - -* (No significant changes) - -### v0.12.0 / 2020-12-24 - -* (No significant changes) - -### v0.11.0 / 2020-12-11 - -* FIXED: Copyright comments to not reference year - -### v0.10.0 / 2020-12-03 - -* (No significant changes) - -### v0.9.0 / 2020-11-27 - -* BREAKING CHANGE: Add timeout for force_flush and shutdown - -* ADDED: Add timeout for force_flush and shutdown - -### v0.8.0 / 2020-10-27 - -* BREAKING CHANGE: Move context/span methods to Trace module -* BREAKING CHANGE: Remove 'canonical' from status codes - -* FIXED: Move context/span methods to Trace module -* FIXED: Remove 'canonical' from status codes - -### v0.7.0 / 2020-10-07 - -* DOCS: Standardize toplevel docs structure and readme - -### v0.6.0 / 2020-09-10 - -* (No significant changes) diff --git a/instrumentation/excon/Gemfile b/instrumentation/excon/Gemfile deleted file mode 100644 index 2baf57ac47..0000000000 --- a/instrumentation/excon/Gemfile +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :test do - gem 'opentelemetry-instrumentation-base', path: '../base' -end diff --git a/instrumentation/excon/LICENSE b/instrumentation/excon/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/excon/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/excon/README.md b/instrumentation/excon/README.md deleted file mode 100644 index 72d94b7495..0000000000 --- a/instrumentation/excon/README.md +++ /dev/null @@ -1,50 +0,0 @@ -# Excon Instrumentation - -The excon instrumentation is a community-maintained instrumentation for the [excon][excon-home] HTTP library. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-excon -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-excon` to your `Gemfile`. - -## Usage - -To install the instrumentation, call `use` with the name of the instrumentation. - - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Excon' -end -``` - -Alternatively, you can also call `use_all` to install all the available instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` - -## How can I get involved? - -The `opentelemetry-instrumentation-excon` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -The `opentelemetry-instrumentation-all` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information. - -[excon-home]: https://github.com/excon/excon -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/instrumentation/excon/Rakefile b/instrumentation/excon/Rakefile deleted file mode 100644 index 1a64ba842e..0000000000 --- a/instrumentation/excon/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/excon/example/Gemfile b/instrumentation/excon/example/Gemfile deleted file mode 100644 index e2a842cff9..0000000000 --- a/instrumentation/excon/example/Gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -source 'https://rubygems.org' - -gem 'excon' -gem 'opentelemetry-api' -gem 'opentelemetry-common' -gem 'opentelemetry-instrumentation-excon' -gem 'opentelemetry-sdk' diff --git a/instrumentation/excon/example/excon.rb b/instrumentation/excon/example/excon.rb deleted file mode 100644 index ac1f119dad..0000000000 --- a/instrumentation/excon/example/excon.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -require 'rubygems' -require 'bundler/setup' - -Bundler.require - -ENV['OTEL_TRACES_EXPORTER'] = 'console' -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Excon' -end - -Excon.get('http://example.com') diff --git a/instrumentation/excon/lib/opentelemetry-instrumentation-excon.rb b/instrumentation/excon/lib/opentelemetry-instrumentation-excon.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/excon/lib/opentelemetry-instrumentation-excon.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/excon/lib/opentelemetry/instrumentation.rb b/instrumentation/excon/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index 50812be7c2..0000000000 --- a/instrumentation/excon/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # "Instrumentation" are specified by - # https://github.com/open-telemetry/opentelemetry-specification/blob/784635d01d8690c8f5fcd1f55bdbc8a13cf2f4f2/specification/glossary.md#instrumentation-library - # - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/excon' diff --git a/instrumentation/excon/lib/opentelemetry/instrumentation/excon.rb b/instrumentation/excon/lib/opentelemetry/instrumentation/excon.rb deleted file mode 100644 index 8490f1765f..0000000000 --- a/instrumentation/excon/lib/opentelemetry/instrumentation/excon.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the Excon gem - module Excon - end - end -end - -require_relative './excon/instrumentation' -require_relative './excon/version' diff --git a/instrumentation/excon/lib/opentelemetry/instrumentation/excon/instrumentation.rb b/instrumentation/excon/lib/opentelemetry/instrumentation/excon/instrumentation.rb deleted file mode 100644 index 1a8a4d3341..0000000000 --- a/instrumentation/excon/lib/opentelemetry/instrumentation/excon/instrumentation.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Excon - # The Instrumentation class contains logic to detect and install the Excon - # instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - install do |_config| - require_dependencies - add_middleware - end - - present do - defined?(::Excon) - end - - option :peer_service, default: nil, validate: :string - - private - - def require_dependencies - require_relative 'middlewares/tracer_middleware' - end - - def add_middleware - ::Excon.defaults[:middlewares] = - Middlewares::TracerMiddleware.around_default_stack - end - end - end - end -end diff --git a/instrumentation/excon/lib/opentelemetry/instrumentation/excon/middlewares/tracer_middleware.rb b/instrumentation/excon/lib/opentelemetry/instrumentation/excon/middlewares/tracer_middleware.rb deleted file mode 100644 index 6425e0c09b..0000000000 --- a/instrumentation/excon/lib/opentelemetry/instrumentation/excon/middlewares/tracer_middleware.rb +++ /dev/null @@ -1,115 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Excon - module Middlewares - # Excon middleware for instrumentation - class TracerMiddleware < ::Excon::Middleware::Base - HTTP_METHODS_TO_UPPERCASE = %w[connect delete get head options patch post put trace].each_with_object({}) do |method, hash| - uppercase_method = method.upcase - hash[method] = uppercase_method - hash[method.to_sym] = uppercase_method - hash[uppercase_method] = uppercase_method - end.freeze - - HTTP_METHODS_TO_SPAN_NAMES = HTTP_METHODS_TO_UPPERCASE.values.each_with_object({}) do |uppercase_method, hash| - hash[uppercase_method] ||= "HTTP #{uppercase_method}" - end.freeze - - def request_call(datum) - begin - unless datum.key?(:otel_span) - http_method = HTTP_METHODS_TO_UPPERCASE[datum[:method]] - attributes = span_creation_attributes(datum, http_method) - tracer.start_span( - HTTP_METHODS_TO_SPAN_NAMES[http_method], - attributes: attributes, - kind: :client - ).tap do |span| - datum[:otel_span] = span - OpenTelemetry::Trace.with_span(span) do - OpenTelemetry.propagation.inject(datum[:headers]) - end - end - end - rescue StandardError => e - OpenTelemetry.logger.debug(e.message) - end - - @stack.request_call(datum) - end - - def response_call(datum) - @stack.response_call(datum).tap do |d| - handle_response(d) - end - end - - def error_call(datum) - handle_response(datum) - @stack.error_call(datum) - end - - # Returns a copy of the default stack with the trace middleware injected - def self.around_default_stack - ::Excon.defaults[:middlewares].dup.tap do |default_stack| - # If the default stack contains a version of the trace middleware already... - existing_trace_middleware = default_stack.find { |m| m <= TracerMiddleware } - default_stack.delete(existing_trace_middleware) if existing_trace_middleware - - # Inject after the ResponseParser middleware - response_middleware_index = default_stack.index(::Excon::Middleware::ResponseParser).to_i - default_stack.insert(response_middleware_index + 1, self) - end - end - - private - - def handle_response(datum) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity: - if datum.key?(:otel_span) - datum[:otel_span].tap do |span| - return span if span.end_timestamp - - if datum.key?(:response) - response = datum[:response] - span.set_attribute('http.status_code', response[:status]) - span.status = OpenTelemetry::Trace::Status.error unless (100..399).include?(response[:status].to_i) - end - - span.status = OpenTelemetry::Trace::Status.error("Request has failed: #{datum[:error]}") if datum.key?(:error) - - span.finish - datum.delete(:otel_span) - end - end - rescue StandardError => e - OpenTelemetry.logger.debug(e.message) - end - - def span_creation_attributes(datum, http_method) - instrumentation_attrs = { - 'http.host' => datum[:host], - 'http.method' => http_method, - 'http.scheme' => datum[:scheme], - 'http.target' => datum[:path] - } - config = Excon::Instrumentation.instance.config - instrumentation_attrs['peer.service'] = config[:peer_service] if config[:peer_service] - instrumentation_attrs.merge!( - OpenTelemetry::Common::HTTP::ClientContext.attributes - ) - end - - def tracer - Excon::Instrumentation.instance.tracer - end - end - end - end - end -end diff --git a/instrumentation/excon/lib/opentelemetry/instrumentation/excon/version.rb b/instrumentation/excon/lib/opentelemetry/instrumentation/excon/version.rb deleted file mode 100644 index 43eda23127..0000000000 --- a/instrumentation/excon/lib/opentelemetry/instrumentation/excon/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Excon - VERSION = '0.20.0' - end - end -end diff --git a/instrumentation/excon/opentelemetry-instrumentation-excon.gemspec b/instrumentation/excon/opentelemetry-instrumentation-excon.gemspec deleted file mode 100644 index c7f28eecb9..0000000000 --- a/instrumentation/excon/opentelemetry-instrumentation-excon.gemspec +++ /dev/null @@ -1,50 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/excon/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-excon' - spec.version = OpenTelemetry::Instrumentation::Excon::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'Excon instrumentation for the OpenTelemetry framework' - spec.description = 'Excon instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-common', '~> 0.19.3' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.21.0' - - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'excon', '~> 0.71.0' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'webmock', '~> 3.7.6' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-excon/v#{OpenTelemetry::Instrumentation::Excon::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/excon' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-excon/v#{OpenTelemetry::Instrumentation::Excon::VERSION}" - end -end diff --git a/instrumentation/excon/test/.rubocop.yml b/instrumentation/excon/test/.rubocop.yml deleted file mode 100644 index dd94258585..0000000000 --- a/instrumentation/excon/test/.rubocop.yml +++ /dev/null @@ -1,4 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false diff --git a/instrumentation/excon/test/opentelemetry/instrumentation/excon/instrumentation_test.rb b/instrumentation/excon/test/opentelemetry/instrumentation/excon/instrumentation_test.rb deleted file mode 100644 index 71bc852d77..0000000000 --- a/instrumentation/excon/test/opentelemetry/instrumentation/excon/instrumentation_test.rb +++ /dev/null @@ -1,154 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../lib/opentelemetry/instrumentation/excon' -require_relative '../../../../lib/opentelemetry/instrumentation/excon/middlewares/tracer_middleware' - -describe OpenTelemetry::Instrumentation::Excon::Instrumentation do - let(:instrumentation) { OpenTelemetry::Instrumentation::Excon::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:span) { exporter.finished_spans.first } - - before do - exporter.reset - stub_request(:get, 'http://example.com/success').to_return(status: 200) - stub_request(:get, 'http://example.com/failure').to_return(status: 500) - stub_request(:get, 'http://example.com/timeout').to_timeout - - # this is currently a noop but this will future proof the test - @orig_propagation = OpenTelemetry.propagation - propagator = OpenTelemetry::Trace::Propagation::TraceContext.text_map_propagator - OpenTelemetry.propagation = propagator - end - - after do - # Force re-install of instrumentation - instrumentation.instance_variable_set(:@installed, false) - - OpenTelemetry.propagation = @orig_propagation - end - - describe 'tracing' do - before do - instrumentation.install - end - - it 'before request' do - _(exporter.finished_spans.size).must_equal 0 - end - - it 'after request with success code' do - ::Excon.get('http://example.com/success') - - _(exporter.finished_spans.size).must_equal 1 - _(span.name).must_equal 'HTTP GET' - _(span.attributes['http.method']).must_equal 'GET' - _(span.attributes['http.status_code']).must_equal 200 - _(span.attributes['http.scheme']).must_equal 'http' - _(span.attributes['http.host']).must_equal 'example.com' - _(span.attributes['http.target']).must_equal '/success' - assert_requested( - :get, - 'http://example.com/success', - headers: { 'Traceparent' => "00-#{span.hex_trace_id}-#{span.hex_span_id}-01" } - ) - end - - specify 'after request with capital-letters HTTP method' do - ::Excon.new('http://example.com/success') - .request(method: 'GET') - - _(span.attributes['http.method']).must_equal 'GET' - end - - it 'after request with failure code' do - ::Excon.get('http://example.com/failure') - - _(exporter.finished_spans.size).must_equal 1 - _(span.name).must_equal 'HTTP GET' - _(span.attributes['http.method']).must_equal 'GET' - _(span.attributes['http.status_code']).must_equal 500 - _(span.attributes['http.scheme']).must_equal 'http' - _(span.attributes['http.host']).must_equal 'example.com' - _(span.attributes['http.target']).must_equal '/failure' - assert_requested( - :get, - 'http://example.com/failure', - headers: { 'Traceparent' => "00-#{span.hex_trace_id}-#{span.hex_span_id}-01" } - ) - end - - it 'after request timeout' do - expect do - ::Excon.get('http://example.com/timeout') - end.must_raise Excon::Error::Timeout - - _(exporter.finished_spans.size).must_equal 1 - _(span.name).must_equal 'HTTP GET' - _(span.attributes['http.method']).must_equal 'GET' - _(span.attributes['http.scheme']).must_equal 'http' - _(span.attributes['http.host']).must_equal 'example.com' - _(span.attributes['http.target']).must_equal '/timeout' - _(span.status.code).must_equal( - OpenTelemetry::Trace::Status::ERROR - ) - _(span.status.description).must_equal( - 'Request has failed: Excon::Error::Timeout' - ) - assert_requested( - :get, - 'http://example.com/timeout', - headers: { 'Traceparent' => "00-#{span.hex_trace_id}-#{span.hex_span_id}-01" } - ) - end - - it 'merges HTTP client context' do - client_context_attrs = { - 'test.attribute' => 'test.value', 'http.method' => 'OVERRIDE' - } - OpenTelemetry::Common::HTTP::ClientContext.with_attributes(client_context_attrs) do - ::Excon.get('http://example.com/success') - end - - _(exporter.finished_spans.size).must_equal 1 - _(span.name).must_equal 'HTTP GET' - _(span.attributes['http.method']).must_equal 'OVERRIDE' - _(span.attributes['http.status_code']).must_equal 200 - _(span.attributes['http.scheme']).must_equal 'http' - _(span.attributes['http.host']).must_equal 'example.com' - _(span.attributes['http.target']).must_equal '/success' - _(span.attributes['test.attribute']).must_equal 'test.value' - assert_requested( - :get, - 'http://example.com/success', - headers: { 'Traceparent' => "00-#{span.hex_trace_id}-#{span.hex_span_id}-01" } - ) - end - - it 'accepts peer service name from config' do - instrumentation.instance_variable_set(:@installed, false) - instrumentation.install(peer_service: 'example:faraday') - - ::Excon.get('http://example.com/success') - - _(span.attributes['peer.service']).must_equal 'example:faraday' - end - - it 'prioritizes context attributes over config for peer service name' do - instrumentation.instance_variable_set(:@installed, false) - instrumentation.install(peer_service: 'example:faraday') - - client_context_attrs = { 'peer.service' => 'example:custom' } - OpenTelemetry::Common::HTTP::ClientContext.with_attributes(client_context_attrs) do - ::Excon.get('http://example.com/success') - end - - _(span.attributes['peer.service']).must_equal 'example:custom' - end - end -end diff --git a/instrumentation/excon/test/test_helper.rb b/instrumentation/excon/test/test_helper.rb deleted file mode 100644 index 7a279faa3e..0000000000 --- a/instrumentation/excon/test/test_helper.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'excon' - -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' - -require 'minitest/autorun' -require 'webmock/minitest' - -# global opentelemetry-sdk setup: -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry::SDK.configure do |c| - c.add_span_processor span_processor -end diff --git a/instrumentation/faraday/.rubocop.yml b/instrumentation/faraday/.rubocop.yml deleted file mode 100644 index 908d09bd70..0000000000 --- a/instrumentation/faraday/.rubocop.yml +++ /dev/null @@ -1,5 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-faraday.rb" diff --git a/instrumentation/faraday/.yardopts b/instrumentation/faraday/.yardopts deleted file mode 100644 index 878dbe67fb..0000000000 --- a/instrumentation/faraday/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Faraday Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/faraday/Appraisals b/instrumentation/faraday/Appraisals deleted file mode 100644 index 85ea5a891c..0000000000 --- a/instrumentation/faraday/Appraisals +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -appraise 'faraday-1.0' do - gem 'faraday', '~> 1.0.0' -end - -# Incompatible with Ruby 3.0.0 (https://bugs.ruby-lang.org/issues/10499) -if RUBY_VERSION < '3' - appraise 'faraday-0.17' do - gem 'faraday', '0.17.0' - end -end - -appraise 'faraday-0.16' do - gem 'faraday', '0.16.2' -end - -# Incompatible with Ruby 3.0.0 (https://bugs.ruby-lang.org/issues/10499) -if RUBY_VERSION < '3' - appraise 'faraday-0.13' do - gem 'faraday', '0.13.1' - end -end diff --git a/instrumentation/faraday/CHANGELOG.md b/instrumentation/faraday/CHANGELOG.md deleted file mode 100644 index 7565ac5db9..0000000000 --- a/instrumentation/faraday/CHANGELOG.md +++ /dev/null @@ -1,98 +0,0 @@ -# Release History: opentelemetry-instrumentation-faraday - -### v0.21.0 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Broken test file requirements - -### v0.20.1 / 2022-05-03 - -* (No significant changes) - -### v0.20.0 / 2022-02-02 - -* ADDED: Add net.peer.name to faraday instrumentation -* FIXED: Excessive hash creation on context attr merging - -### v0.19.3 / 2021-12-02 - -* (No significant changes) - -### v0.19.2 / 2021-09-29 - -* (No significant changes) - -### v0.19.1 / 2021-08-12 - -* DOCS: Update docs to rely more on environment variable configuration - -### v0.19.0 / 2021-06-23 - -* BREAKING CHANGE: Total order constraint on span.status= - -* FIXED: Total order constraint on span.status= - -### v0.18.1 / 2021-06-08 - -* FIXED: Missing require to common in faraday - -### v0.18.0 / 2021-05-21 - -* ADDED: Updated API depedency for 1.0.0.rc1 -* FIXED: Removed http.status_text attribute #750 - -### v0.17.0 / 2021-04-22 - -* FIXED: Fix Faraday gem dependencies. -* FIXED: Refactor propagators to add #fields - -### v0.16.0 / 2021-03-17 - -* FIXED: Remove passwords from http.url -* FIXED: Example scripts now reference local common lib -* DOCS: Replace Gitter with GitHub Discussions - -### v0.15.0 / 2021-02-18 - -* FIXED: Include http.status_text only if reason_phrase is in the response - -### v0.14.0 / 2021-02-03 - -* BREAKING CHANGE: Replace getter and setter callables and remove rack specific propagators - -* ADDED: Replace getter and setter callables and remove rack specific propagators - -### v0.13.0 / 2021-01-29 - -* (No significant changes) - -### v0.12.0 / 2020-12-24 - -* (No significant changes) - -### v0.11.0 / 2020-12-11 - -* FIXED: Copyright comments to not reference year - -### v0.10.0 / 2020-12-03 - -* (No significant changes) - -### v0.9.0 / 2020-11-27 - -* BREAKING CHANGE: Add timeout for force_flush and shutdown - -* ADDED: Add timeout for force_flush and shutdown - -### v0.8.0 / 2020-10-27 - -* (No significant changes) - -### v0.7.0 / 2020-10-07 - -* DOCS: Faraday documentation -* DOCS: Standardize toplevel docs structure and readme - -### v0.6.0 / 2020-09-10 - -* (No significant changes) diff --git a/instrumentation/faraday/Gemfile b/instrumentation/faraday/Gemfile deleted file mode 100644 index 2baf57ac47..0000000000 --- a/instrumentation/faraday/Gemfile +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :test do - gem 'opentelemetry-instrumentation-base', path: '../base' -end diff --git a/instrumentation/faraday/LICENSE b/instrumentation/faraday/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/faraday/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/faraday/README.md b/instrumentation/faraday/README.md deleted file mode 100644 index afbcbe2c6e..0000000000 --- a/instrumentation/faraday/README.md +++ /dev/null @@ -1,53 +0,0 @@ -# OpenTelemetry Faraday Instrumentation - -The OpenTelemetry Faraday Ruby gem is a community maintained instrumentation for [Faraday][faraday-home]. This is an HTTP client library that provides a common interface over many adaptors, such as Net::HTTP. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-faraday -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-faraday` in your `Gemfile`. - -## Usage - -To install the instrumentation, call `use` with the name of the instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Faraday' -end -``` - -Alternatively, you can also call `use_all` to install all the available instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` - -## Examples - -Example usage of faraday can be seen in the `./example/faraday.rb` file [here](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/instrumentation/faraday/example/faraday.rb) - -## How can I get involved? - -The `opentelemetry-instrumentation-faraday` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -Apache 2.0 license. See [LICENSE][license-github] for more information. - -[faraday-home]: https://github.com/lostisland/faraday -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/instrumentation/faraday/Rakefile b/instrumentation/faraday/Rakefile deleted file mode 100644 index 1a64ba842e..0000000000 --- a/instrumentation/faraday/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/faraday/example/Gemfile b/instrumentation/faraday/example/Gemfile deleted file mode 100644 index c61e85720e..0000000000 --- a/instrumentation/faraday/example/Gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -source 'https://rubygems.org' - -gem 'faraday' -gem 'opentelemetry-api' -gem 'opentelemetry-common' -gem 'opentelemetry-instrumentation-faraday' -gem 'opentelemetry-sdk' diff --git a/instrumentation/faraday/example/faraday.rb b/instrumentation/faraday/example/faraday.rb deleted file mode 100644 index 43ebcf7486..0000000000 --- a/instrumentation/faraday/example/faraday.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'rubygems' -require 'bundler/setup' - -Bundler.require - -ENV['OTEL_TRACES_EXPORTER'] = 'console' -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Faraday' -end - -conn = Faraday.new('http://example.com') -conn.get '/' diff --git a/instrumentation/faraday/lib/opentelemetry-instrumentation-faraday.rb b/instrumentation/faraday/lib/opentelemetry-instrumentation-faraday.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/faraday/lib/opentelemetry-instrumentation-faraday.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/faraday/lib/opentelemetry/instrumentation.rb b/instrumentation/faraday/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index 05b46a0a2d..0000000000 --- a/instrumentation/faraday/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # "Instrumentation" are specified by - # https://github.com/open-telemetry/opentelemetry-specification/blob/784635d01d8690c8f5fcd1f55bdbc8a13cf2f4f2/specification/glossary.md#instrumentation-library - # - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/faraday' diff --git a/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday.rb b/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday.rb deleted file mode 100644 index 4e7de61208..0000000000 --- a/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry/common' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the Faraday gem - module Faraday - end - end -end - -require_relative './faraday/instrumentation' -require_relative './faraday/version' diff --git a/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/instrumentation.rb b/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/instrumentation.rb deleted file mode 100644 index 0c98ea8f5d..0000000000 --- a/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/instrumentation.rb +++ /dev/null @@ -1,44 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Faraday - # The Instrumentation class contains logic to detect and install the Faraday - # instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - install do |_config| - require_dependencies - register_tracer_middleware - use_middleware_by_default - end - - present do - defined?(::Faraday) - end - - option :peer_service, default: nil, validate: :string - - private - - def require_dependencies - require_relative 'middlewares/tracer_middleware' - require_relative 'patches/rack_builder' - end - - def register_tracer_middleware - ::Faraday::Middleware.register_middleware( - open_telemetry: Middlewares::TracerMiddleware - ) - end - - def use_middleware_by_default - ::Faraday::RackBuilder.prepend(Patches::RackBuilder) - end - end - end - end -end diff --git a/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/middlewares/tracer_middleware.rb b/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/middlewares/tracer_middleware.rb deleted file mode 100644 index 5760fe9287..0000000000 --- a/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/middlewares/tracer_middleware.rb +++ /dev/null @@ -1,69 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Faraday - module Middlewares - # TracerMiddleware propagates context and instruments Faraday requests - # by way of its middlware system - class TracerMiddleware < ::Faraday::Middleware - HTTP_METHODS_SYMBOL_TO_STRING = { - connect: 'CONNECT', - delete: 'DELETE', - get: 'GET', - head: 'HEAD', - options: 'OPTIONS', - patch: 'PATCH', - post: 'POST', - put: 'PUT', - trace: 'TRACE' - }.freeze - - def call(env) - http_method = HTTP_METHODS_SYMBOL_TO_STRING[env.method] - attributes = span_creation_attributes( - http_method: http_method, url: env.url - ) - tracer.in_span( - "HTTP #{http_method}", attributes: attributes, kind: :client - ) do |span| - OpenTelemetry.propagation.inject(env.request_headers) - - app.call(env).on_complete { |resp| trace_response(span, resp) } - end - end - - private - - attr_reader :app - - def span_creation_attributes(http_method:, url:) - instrumentation_attrs = { - 'http.method' => http_method, - 'http.url' => url.to_s, - 'net.peer.name' => url.host - } - config = Faraday::Instrumentation.instance.config - instrumentation_attrs['peer.service'] = config[:peer_service] if config[:peer_service] - instrumentation_attrs.merge!( - OpenTelemetry::Common::HTTP::ClientContext.attributes - ) - end - - def tracer - Faraday::Instrumentation.instance.tracer - end - - def trace_response(span, response) - span.set_attribute('http.status_code', response.status) - span.status = OpenTelemetry::Trace::Status.error unless (100..399).include?(response.status.to_i) - end - end - end - end - end -end diff --git a/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/patches/rack_builder.rb b/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/patches/rack_builder.rb deleted file mode 100644 index 1b32a00dac..0000000000 --- a/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/patches/rack_builder.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Faraday - module Patches - # Module to be prepended to force Faraday to use the middleware by - # default so the user doesn't have to call `use` for every connection. - module RackBuilder - def adapter(*args) - use(:open_telemetry) unless @handlers.any? do |handler| - handler.klass == Faraday::Middlewares::TracerMiddleware - end - - super - end - end - end - end - end -end diff --git a/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/version.rb b/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/version.rb deleted file mode 100644 index 274e8cd938..0000000000 --- a/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Faraday - VERSION = '0.21.0' - end - end -end diff --git a/instrumentation/faraday/opentelemetry-instrumentation-faraday.gemspec b/instrumentation/faraday/opentelemetry-instrumentation-faraday.gemspec deleted file mode 100644 index 5044799606..0000000000 --- a/instrumentation/faraday/opentelemetry-instrumentation-faraday.gemspec +++ /dev/null @@ -1,50 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/faraday/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-faraday' - spec.version = OpenTelemetry::Instrumentation::Faraday::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'Faraday instrumentation for the OpenTelemetry framework' - spec.description = 'Faraday instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-common', '~> 0.19.3' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.21.0' - - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'faraday', '~> 0.17.0' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'webmock', '~> 3.7.6' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-faraday/v#{OpenTelemetry::Instrumentation::Faraday::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/faraday' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-faraday/v#{OpenTelemetry::Instrumentation::Faraday::VERSION}" - end -end diff --git a/instrumentation/faraday/test/.rubocop.yml b/instrumentation/faraday/test/.rubocop.yml deleted file mode 100644 index dd94258585..0000000000 --- a/instrumentation/faraday/test/.rubocop.yml +++ /dev/null @@ -1,4 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false diff --git a/instrumentation/faraday/test/opentelemetry/instrumentation/faraday/middlewares/tracer_middleware_test.rb b/instrumentation/faraday/test/opentelemetry/instrumentation/faraday/middlewares/tracer_middleware_test.rb deleted file mode 100644 index e1b8e43c62..0000000000 --- a/instrumentation/faraday/test/opentelemetry/instrumentation/faraday/middlewares/tracer_middleware_test.rb +++ /dev/null @@ -1,124 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -# require Instrumentation so .install method is found: -require_relative '../../../../../lib/opentelemetry/instrumentation/faraday/middlewares/tracer_middleware' - -describe OpenTelemetry::Instrumentation::Faraday::Middlewares::TracerMiddleware do - let(:instrumentation) { OpenTelemetry::Instrumentation::Faraday::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:span) { exporter.finished_spans.first } - - let(:client) do - ::Faraday.new('http://username:password@example.com') do |builder| - builder.adapter(:test) do |stub| - stub.get('/success') { |_| [200, {}, 'OK'] } - stub.get('/failure') { |_| [500, {}, 'OK'] } - stub.get('/not_found') { |_| [404, {}, 'OK'] } - end - end - end - - before do - exporter.reset - - # this is currently a noop but this will future proof the test - @orig_propagation = OpenTelemetry.propagation - propagator = OpenTelemetry::Trace::Propagation::TraceContext.text_map_propagator - OpenTelemetry.propagation = propagator - end - - after do - OpenTelemetry.propagation = @orig_propagation - end - - describe 'first span' do - before do - instrumentation.install - end - - it 'has http 200 attributes' do - response = client.get('/success') - - _(span.name).must_equal 'HTTP GET' - _(span.attributes['http.method']).must_equal 'GET' - _(span.attributes['http.status_code']).must_equal 200 - _(span.attributes['http.url']).must_equal 'http://example.com/success' - _(span.attributes['net.peer.name']).must_equal 'example.com' - _(response.env.request_headers['Traceparent']).must_equal( - "00-#{span.hex_trace_id}-#{span.hex_span_id}-01" - ) - end - - it 'has http.status_code 404' do - response = client.get('/not_found') - - _(span.name).must_equal 'HTTP GET' - _(span.attributes['http.method']).must_equal 'GET' - _(span.attributes['http.status_code']).must_equal 404 - _(span.attributes['http.url']).must_equal 'http://example.com/not_found' - _(span.attributes['net.peer.name']).must_equal 'example.com' - _(response.env.request_headers['Traceparent']).must_equal( - "00-#{span.hex_trace_id}-#{span.hex_span_id}-01" - ) - end - - it 'has http.status_code 500' do - response = client.get('/failure') - - _(span.name).must_equal 'HTTP GET' - _(span.attributes['http.method']).must_equal 'GET' - _(span.attributes['http.status_code']).must_equal 500 - _(span.attributes['http.url']).must_equal 'http://example.com/failure' - _(span.attributes['net.peer.name']).must_equal 'example.com' - _(response.env.request_headers['Traceparent']).must_equal( - "00-#{span.hex_trace_id}-#{span.hex_span_id}-01" - ) - end - - it 'merges http client attributes' do - client_context_attrs = { - 'test.attribute' => 'test.value', 'http.method' => 'OVERRIDE' - } - response = OpenTelemetry::Common::HTTP::ClientContext.with_attributes(client_context_attrs) do - client.get('/success') - end - - _(span.name).must_equal 'HTTP GET' - _(span.attributes['http.method']).must_equal 'OVERRIDE' - _(span.attributes['http.status_code']).must_equal 200 - _(span.attributes['http.url']).must_equal 'http://example.com/success' - _(span.attributes['net.peer.name']).must_equal 'example.com' - _(span.attributes['test.attribute']).must_equal 'test.value' - _(response.env.request_headers['Traceparent']).must_equal( - "00-#{span.hex_trace_id}-#{span.hex_span_id}-01" - ) - end - - it 'accepts peer service name from config' do - instrumentation.instance_variable_set(:@installed, false) - instrumentation.install(peer_service: 'example:faraday') - - client.get('/success') - - _(span.attributes['peer.service']).must_equal 'example:faraday' - end - - it 'prioritizes context attributes over config for peer service name' do - instrumentation.instance_variable_set(:@installed, false) - instrumentation.install(peer_service: 'example:faraday') - - client_context_attrs = { 'peer.service' => 'example:custom' } - OpenTelemetry::Common::HTTP::ClientContext.with_attributes(client_context_attrs) do - client.get('/success') - end - - _(span.attributes['peer.service']).must_equal 'example:custom' - end - end -end diff --git a/instrumentation/faraday/test/opentelemetry/instrumentation/faraday_test.rb b/instrumentation/faraday/test/opentelemetry/instrumentation/faraday_test.rb deleted file mode 100644 index a279356017..0000000000 --- a/instrumentation/faraday/test/opentelemetry/instrumentation/faraday_test.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -describe OpenTelemetry::Instrumentation::Faraday do - let(:instrumentation) { OpenTelemetry::Instrumentation::Faraday::Instrumentation.instance } - let(:exporter) { EXPORTER } - - before do - instrumentation.install - exporter.reset - end - - describe 'tracing' do - before do - stub_request(:any, 'example.com') - end - - it 'before request' do - _(exporter.finished_spans.size).must_equal 0 - end - - it 'after request' do - ::Faraday.new('http://example.com').get('/') - - _(exporter.finished_spans.size).must_equal 1 - end - end -end diff --git a/instrumentation/faraday/test/test_helper.rb b/instrumentation/faraday/test/test_helper.rb deleted file mode 100644 index ff6e188b1b..0000000000 --- a/instrumentation/faraday/test/test_helper.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'faraday' - -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' - -require 'minitest/autorun' -require 'webmock/minitest' - -require_relative '../lib/opentelemetry-instrumentation-faraday' - -# global opentelemetry-sdk setup: -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry::SDK.configure do |c| - c.add_span_processor span_processor -end diff --git a/instrumentation/graphql/.rubocop.yml b/instrumentation/graphql/.rubocop.yml deleted file mode 100644 index ea474672fa..0000000000 --- a/instrumentation/graphql/.rubocop.yml +++ /dev/null @@ -1,5 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-graphql.rb" diff --git a/instrumentation/graphql/.yardopts b/instrumentation/graphql/.yardopts deleted file mode 100644 index 46927889e0..0000000000 --- a/instrumentation/graphql/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry GraphQL Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/graphql/Appraisals b/instrumentation/graphql/Appraisals deleted file mode 100644 index 24efd5c125..0000000000 --- a/instrumentation/graphql/Appraisals +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -appraise 'graphql-1.11' do - gem 'graphql', '~> 1.11.0' -end - -appraise 'graphql-1.10' do - gem 'graphql', '~> 1.10.0' -end - -# Incompatible with Ruby 3.0.0 (https://bugs.ruby-lang.org/issues/10499) -if RUBY_VERSION < '3' - appraise 'graphql-1.9' do - gem 'graphql', '~> 1.9.0' - end -end diff --git a/instrumentation/graphql/CHANGELOG.md b/instrumentation/graphql/CHANGELOG.md deleted file mode 100644 index 5702df4d83..0000000000 --- a/instrumentation/graphql/CHANGELOG.md +++ /dev/null @@ -1,56 +0,0 @@ -# Release History: opentelemetry-instrumentation-graphql - -### v0.20.0 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Broken test file requirements - -### v0.19.3 / 2022-05-05 - -* (No significant changes) - -### v0.19.2 / 2021-12-02 - -* (No significant changes) - -### v0.19.1 / 2021-09-29 - -* (No significant changes) - -### v0.19.0 / 2021-08-12 - -* ADDED: Add support for graphql errors -* DOCS: Update docs to rely more on environment variable configuration - -### v0.18.1 / 2021-06-23 - -* (No significant changes) - -### v0.18.0 / 2021-05-21 - -* ADDED: Updated API depedency for 1.0.0.rc1 - -### v0.17.0 / 2021-04-22 - -* (No significant changes) - -### v0.16.0 / 2021-03-17 - -* FIXED: Example scripts now reference local common lib -* DOCS: Replace Gitter with GitHub Discussions - -### v0.15.0 / 2021-02-18 - -* ADDED: Add instrumentation config validation - -### v0.14.0 / 2021-02-03 - -* (No significant changes) - -### v0.13.0 / 2021-01-29 - -* (No significant changes) - -### v0.12.0 / 2020-12-24 - -* Initial release. diff --git a/instrumentation/graphql/Gemfile b/instrumentation/graphql/Gemfile deleted file mode 100644 index 5b7d54b645..0000000000 --- a/instrumentation/graphql/Gemfile +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :test do - gem 'opentelemetry-instrumentation-base', path: '../base' - gem 'pry-byebug' -end diff --git a/instrumentation/graphql/LICENSE b/instrumentation/graphql/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/graphql/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/graphql/README.md b/instrumentation/graphql/README.md deleted file mode 100644 index 3523247db3..0000000000 --- a/instrumentation/graphql/README.md +++ /dev/null @@ -1,76 +0,0 @@ -# OpenTelemetry GraphQL Instrumentation - -The OpenTelemetry GraphQL Ruby gem is a community maintained instrumentation for [GraphQL][graphql-home]. The GraphQL integration activates instrumentation for GraphQL queries. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-graphql -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-graphql` in your `Gemfile`. - -## Usage - -To use the instrumentation, call `use` with the name of the instrumentation: - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::GraphQL' -end -``` - -### Configuration options - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::GraphQL', { - # If this option is not provided the default behaviour is to instrument all - # schemas that extend GraphQL::Schema - schemas: [MyAppSchema], - - # The following options are disabled by default as they generate - # large traces, but can be enabled using the following keys to add - # spans that provide more detail. - # Further details about what these keys correspond can be found on the [platform_tracing.rb class](https://github.com/rmosolgo/graphql-ruby/blob/1.10.x/lib/graphql/tracing/platform_tracing.rb#L28-L73). - # enable_platform_field maps to the execute_field and execute_field_lazy keys - enable_platform_field: false, - # enable_platform_authorized maps to the authorized and authorized_lazy keys - enable_platform_authorized: false, - # enable_platform_resolve_type maps to the resolve_type and resolve_type_lazy keys - enable_platform_resolve_type: false - } -end -``` - -Alternatively, you can also call `use_all` to install all the available instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` - -## Examples - -An example of usage can be seen in [`example/graphql.rb`](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/instrumentation/graphql/example/graphql.rb). - -## How can I get involved? - -The `opentelemetry-instrumentation-graphql` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -The `opentelemetry-instrumentation-graphql` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information. - -[graphql-home]: https://github.com/rmosolgo/graphql-ruby -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/instrumentation/graphql/Rakefile b/instrumentation/graphql/Rakefile deleted file mode 100644 index 4b0e9b5a8e..0000000000 --- a/instrumentation/graphql/Rakefile +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] - t.warning = false -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/graphql/example/Gemfile b/instrumentation/graphql/example/Gemfile deleted file mode 100644 index a25bcc8269..0000000000 --- a/instrumentation/graphql/example/Gemfile +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gem 'graphql' -gem 'opentelemetry-api' -gem 'opentelemetry-common' -gem 'opentelemetry-instrumentation-graphql' -gem 'opentelemetry-sdk' diff --git a/instrumentation/graphql/example/graphql.rb b/instrumentation/graphql/example/graphql.rb deleted file mode 100644 index 54ab33a94e..0000000000 --- a/instrumentation/graphql/example/graphql.rb +++ /dev/null @@ -1,53 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'rubygems' -require 'bundler/setup' - -Bundler.require - -dummy_resolve = Class.new do - attr_accessor :id, :name - - def initialize(id = 1, name = 'bar') - @id = id - @name = name - end -end - -EpisodeType = GraphQL::ObjectType.define do - name 'Episode' - description 'An episode' - field :id, !types.ID - field :name, !types.String -end - -QueryType = GraphQL::ObjectType.define do - name 'Query' - description 'The query root of this schema' - - field :episode do - type EpisodeType - argument :episode_id, !types.ID - description 'Find an episode by its ID' - resolve ->(_obj, args, _ctx) { dummy_resolve.new(args.episode_id) } - end -end - -Schema = GraphQL::Schema.define do - query QueryType -end - -ENV['OTEL_TRACES_EXPORTER'] = 'console' -OpenTelemetry::SDK.configure do |c| - c.use_all('OpenTelemetry::Instrumentation::GraphQL' => { schemas: [Schema] }) -end - -result = Schema.execute('{ episode(episode_id: 5) { id name } }', variables: {}, context: {}, operation_name: nil) - -puts "episodes are #{result.inspect}" - -result diff --git a/instrumentation/graphql/lib/opentelemetry-instrumentation-graphql.rb b/instrumentation/graphql/lib/opentelemetry-instrumentation-graphql.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/graphql/lib/opentelemetry-instrumentation-graphql.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/graphql/lib/opentelemetry/instrumentation.rb b/instrumentation/graphql/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index 267e9c2aaf..0000000000 --- a/instrumentation/graphql/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/graphql' diff --git a/instrumentation/graphql/lib/opentelemetry/instrumentation/graphql.rb b/instrumentation/graphql/lib/opentelemetry/instrumentation/graphql.rb deleted file mode 100644 index c1085758e1..0000000000 --- a/instrumentation/graphql/lib/opentelemetry/instrumentation/graphql.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the GraphQL gem - module GraphQL - end - end -end - -require_relative './graphql/instrumentation' -require_relative './graphql/version' diff --git a/instrumentation/graphql/lib/opentelemetry/instrumentation/graphql/instrumentation.rb b/instrumentation/graphql/lib/opentelemetry/instrumentation/graphql/instrumentation.rb deleted file mode 100644 index fc9ae44441..0000000000 --- a/instrumentation/graphql/lib/opentelemetry/instrumentation/graphql/instrumentation.rb +++ /dev/null @@ -1,62 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' - -module OpenTelemetry - module Instrumentation - module GraphQL - # The Instrumentation class contains logic to detect and install the GraphQL instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - install do |config| - require_dependencies - install_tracer(config) - end - - present do - defined?(::GraphQL) - end - - ## Supported configuration keys for the install config hash: - # - # The enable_platform_field key expects a boolean value, - # and enables the tracing of "execute_field" and "execute_field_lazy". - # - # The enable_platform_authorized key expects a boolean value, - # and enables the tracing of "authorized" and "authorized_lazy". - # - # The enable_platform_resolve_type key expects a boolean value, - # and enables the tracing of "resolve_type" and "resolve_type_lazy". - # - # The schemas key expects an array of Schemas, and is used to specify - # which schemas are to be instrumented. If this value is not supplied - # the default behaviour is to instrument all schemas. - option :schemas, default: [], validate: :array - option :enable_platform_field, default: false, validate: :boolean - option :enable_platform_authorized, default: false, validate: :boolean - option :enable_platform_resolve_type, default: false, validate: :boolean - - private - - def require_dependencies - require_relative 'tracers/graphql_tracer' - end - - def install_tracer(config = {}) - if config[:schemas].empty? - ::GraphQL::Schema.tracer(Tracers::GraphQLTracer.new) - else - config[:schemas].each do |schema| - schema.use(Tracers::GraphQLTracer) - rescue StandardError => e - OpenTelemetry.logger.error("Unable to patch schema #{schema}: #{e.message}") - end - end - end - end - end - end -end diff --git a/instrumentation/graphql/lib/opentelemetry/instrumentation/graphql/tracers/graphql_tracer.rb b/instrumentation/graphql/lib/opentelemetry/instrumentation/graphql/tracers/graphql_tracer.rb deleted file mode 100644 index 8d8a487771..0000000000 --- a/instrumentation/graphql/lib/opentelemetry/instrumentation/graphql/tracers/graphql_tracer.rb +++ /dev/null @@ -1,87 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' - -module OpenTelemetry - module Instrumentation - module GraphQL - module Tracers - # GraphQLTracer contains the OpenTelemetry tracer implementation compatible with - # the GraphQL tracer API - class GraphQLTracer < ::GraphQL::Tracing::PlatformTracing - self.platform_keys = { - 'lex' => 'graphql.lex', - 'parse' => 'graphql.parse', - 'validate' => 'graphql.validate', - 'analyze_query' => 'graphql.analyze_query', - 'analyze_multiplex' => 'graphql.analyze_multiplex', - 'execute_query' => 'graphql.execute_query', - 'execute_query_lazy' => 'graphql.execute_query_lazy', - 'execute_multiplex' => 'graphql.execute_multiplex' - } - - def platform_trace(platform_key, key, data) - return yield if platform_key.nil? - - tracer.in_span(platform_key, attributes: attributes_for(key, data)) do |span| - yield.tap do |response| - errors = response[:errors]&.compact&.map { |e| e.to_h }&.to_json if key == 'validate' - unless errors.nil? - span.add_event( - 'graphql.validation.error', - attributes: { - 'message' => errors - } - ) - end - end - end - end - - def platform_field_key(type, field) - return unless config[:enable_platform_field] - - "#{type.graphql_name}.#{field.graphql_name}" - end - - def platform_authorized_key(type) - return unless config[:enable_platform_authorized] - - "#{type.graphql_name}.authorized" - end - - def platform_resolve_type_key(type) - return unless config[:enable_platform_resolve_type] - - "#{type.graphql_name}.resolve_type" - end - - private - - def tracer - GraphQL::Instrumentation.instance.tracer - end - - def config - GraphQL::Instrumentation.instance.config - end - - def attributes_for(key, data) - attributes = {} - case key - when 'execute_query' - attributes['selected_operation_name'] = data[:query].selected_operation_name if data[:query].selected_operation_name - attributes['selected_operation_type'] = data[:query].selected_operation.operation_type - attributes['query_string'] = data[:query].query_string - end - attributes - end - end - end - end - end -end diff --git a/instrumentation/graphql/lib/opentelemetry/instrumentation/graphql/version.rb b/instrumentation/graphql/lib/opentelemetry/instrumentation/graphql/version.rb deleted file mode 100644 index 09f179513f..0000000000 --- a/instrumentation/graphql/lib/opentelemetry/instrumentation/graphql/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module GraphQL - VERSION = '0.20.0' - end - end -end diff --git a/instrumentation/graphql/opentelemetry-instrumentation-graphql.gemspec b/instrumentation/graphql/opentelemetry-instrumentation-graphql.gemspec deleted file mode 100644 index 5a4e647f68..0000000000 --- a/instrumentation/graphql/opentelemetry-instrumentation-graphql.gemspec +++ /dev/null @@ -1,50 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/graphql/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-graphql' - spec.version = OpenTelemetry::Instrumentation::GraphQL::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'GraphQL instrumentation for the OpenTelemetry framework' - spec.description = 'GraphQL instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.21.0' - - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'graphql', '~> 1.11' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'rake', '~> 12.3.3' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'webmock', '~> 3.7.6' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-graphql/v#{OpenTelemetry::Instrumentation::GraphQL::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/graphql' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-graphql/v#{OpenTelemetry::Instrumentation::GraphQL::VERSION}" - end -end diff --git a/instrumentation/graphql/test/.rubocop.yml b/instrumentation/graphql/test/.rubocop.yml deleted file mode 100644 index dd94258585..0000000000 --- a/instrumentation/graphql/test/.rubocop.yml +++ /dev/null @@ -1,4 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false diff --git a/instrumentation/graphql/test/instrumentation/graphql/instrumentation_test.rb b/instrumentation/graphql/test/instrumentation/graphql/instrumentation_test.rb deleted file mode 100644 index b2d101d517..0000000000 --- a/instrumentation/graphql/test/instrumentation/graphql/instrumentation_test.rb +++ /dev/null @@ -1,51 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../lib/opentelemetry/instrumentation/graphql' -require_relative '../../../lib/opentelemetry/instrumentation/graphql/tracers/graphql_tracer' - -describe OpenTelemetry::Instrumentation::GraphQL do - let(:instrumentation) { OpenTelemetry::Instrumentation::GraphQL::Instrumentation.instance } - - after do - # Force re-install of instrumentation - instrumentation.instance_variable_set(:@installed, false) - - # Remove added tracers - ::GraphQL::Schema.instance_variable_set(:@own_tracers, []) - end - - it 'has #name' do - _(instrumentation.name).must_equal 'OpenTelemetry::Instrumentation::GraphQL' - end - - it 'has #version' do - _(instrumentation.version).wont_be_nil - _(instrumentation.version).wont_be_empty - end - - describe '#install' do - it 'installs the tracer' do - instrumentation.install({}) - _(::GraphQL::Schema.tracers[0]).must_be_instance_of(OpenTelemetry::Instrumentation::GraphQL::Tracers::GraphQLTracer) - end - - describe 'when a user supplies an invalid schema' do - let(:config) { { schemas: [Old::Truck] } } - - it 'fails gracefully and logs the error' do - mock_logger = Minitest::Mock.new - mock_logger.expect(:error, nil, [String]) - OpenTelemetry.stub :logger, mock_logger do - instrumentation.install(config) - end - mock_logger.verify - end - end - end -end diff --git a/instrumentation/graphql/test/instrumentation/graphql/tracers/graphql_tracer_test.rb b/instrumentation/graphql/test/instrumentation/graphql/tracers/graphql_tracer_test.rb deleted file mode 100644 index 8bef819032..0000000000 --- a/instrumentation/graphql/test/instrumentation/graphql/tracers/graphql_tracer_test.rb +++ /dev/null @@ -1,254 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../lib/opentelemetry/instrumentation/graphql' -require_relative '../../../../lib/opentelemetry/instrumentation/graphql/tracers/graphql_tracer' - -describe OpenTelemetry::Instrumentation::GraphQL::Tracers::GraphQLTracer do - let(:graphql_tracer) { OpenTelemetry::Instrumentation::GraphQL::Tracers::GraphQLTracer } - let(:instrumentation) { OpenTelemetry::Instrumentation::GraphQL::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:spans) { exporter.finished_spans } - let(:config) { {} } - - let(:query_string) do - <<-GRAPHQL - query($id: Int!){ - simpleField - resolvedField(id: $id) { - originalValue - uppercasedValue - } - } - GRAPHQL - end - - before do - exporter.reset - instrumentation.install(config) - end - - after do - # Force re-install of instrumentation - instrumentation.instance_variable_set(:@installed, false) - - # Reset various instance variables to clear state between tests - ::GraphQL::Schema.instance_variable_set(:@own_tracers, []) - - # Reseting @graphql_definition is needed for tests running against version `1.9.x` - SomeOtherGraphQLAppSchema.remove_instance_variable(:@graphql_definition) if SomeOtherGraphQLAppSchema.instance_variable_defined?(:@graphql_definition) - SomeGraphQLAppSchema.remove_instance_variable(:@graphql_definition) if SomeGraphQLAppSchema.instance_variable_defined?(:@graphql_definition) - end - - describe '#platform_trace' do - it 'traces platform keys' do - result = SomeGraphQLAppSchema.execute(query_string, variables: { 'id': 1 }) - - graphql_tracer.platform_keys.each do |_key, value| - span = spans.find { |s| s.name == value } - _(span).wont_be_nil - end - - _(result.to_h['data']).must_equal('simpleField' => 'Hello.', 'resolvedField' => { 'originalValue' => 'testing=1', 'uppercasedValue' => 'TESTING=1' }) - end - - it 'only traces known platform keys' do - graphql_tracer.new.trace('unknown_execute_key', nil) {} - - _(spans).must_be(:empty?) - end - - it 'includes operation attributes for execute_query' do - expected_attributes = { - 'selected_operation_name' => 'SimpleQuery', - 'selected_operation_type' => 'query', - 'query_string' => 'query SimpleQuery{ simpleField }' - } - - SomeGraphQLAppSchema.execute('query SimpleQuery{ simpleField }') - - span = spans.find { |s| s.name == 'graphql.execute_query' } - _(span).wont_be_nil - _(span.attributes.to_h).must_equal(expected_attributes) - end - - it 'omits nil attributes for execute_query' do - expected_attributes = { - 'selected_operation_type' => 'query', - 'query_string' => '{ simpleField }' - } - - SomeGraphQLAppSchema.execute('{ simpleField }') - - span = spans.find { |s| s.name == 'graphql.execute_query' } - _(span).wont_be_nil - _(span.attributes.to_h).must_equal(expected_attributes) - end - - describe 'when a set of schemas is provided' do - let(:config) { { schemas: [SomeOtherGraphQLAppSchema] } } - - after do - # Reset various instance variables to clear state between tests - SomeOtherGraphQLAppSchema.instance_variable_set(:@own_tracers, []) - SomeOtherGraphQLAppSchema.instance_variable_set(:@own_plugins, SomeOtherGraphQLAppSchema.plugins[0..1]) - end - - it 'traces the provided schemas' do - SomeOtherGraphQLAppSchema.execute('query SimpleQuery{ __typename }') - - graphql_tracer.platform_keys.each do |_key, value| - span = spans.find { |s| s.name == value } - _(span).wont_be_nil - end - - _(spans.size).must_equal(8) - end - - it 'does not trace all schemas' do - SomeGraphQLAppSchema.execute('query SimpleQuery{ __typename }') - - _(spans).must_be(:empty?) - end - end - - describe 'when platform_field is enabled' do - let(:config) { { enable_platform_field: true } } - - it 'traces execute_field' do - SomeGraphQLAppSchema.execute(query_string, variables: { 'id': 1 }) - - span = spans.find { |s| s.name == 'Query.resolvedField' } - _(span).wont_be_nil - end - end - - describe 'when platform_authorized is enabled' do - let(:config) { { enable_platform_authorized: true } } - - it 'traces .authorized' do - skip unless supports_authorized_and_resolved_types? - SomeGraphQLAppSchema.execute(query_string, variables: { 'id': 1 }) - - span = spans.find { |s| s.name == 'Query.authorized' } - _(span).wont_be_nil - - span = spans.find { |s| s.name == 'SlightlyComplex.authorized' } - _(span).wont_be_nil - end - end - - describe 'when platform_resolve_type is enabled' do - let(:config) { { enable_platform_resolve_type: true } } - - it 'traces .resolve_type' do - skip unless supports_authorized_and_resolved_types? - SomeGraphQLAppSchema.execute('{ vehicle { __typename } }') - - span = spans.find { |s| s.name == 'Vehicle.resolve_type' } - _(span).wont_be_nil - end - end - - it 'traces validate with events' do - SomeGraphQLAppSchema.execute( - <<-GRAPHQL - { - nonExistentField - } - GRAPHQL - ) - span = spans.find { |s| s.name == 'graphql.validate' } - event = span.events.find { |e| e.name == 'graphql.validation.error' } - _(event.attributes['message']).must_equal( - "[{\"message\":\"Field 'nonExistentField' doesn't exist on type 'Query'\",\"locations\":[{\"line\":2,\"column\":13}],\"path\":[\"query\",\"nonExistentField\"],\"extensions\":{\"code\":\"undefinedField\",\"typeName\":\"Query\",\"fieldName\":\"nonExistentField\"}}]" - ) - end - end - - private - - # These fields are only supported as of version 1.10.0 - # https://github.com/rmosolgo/graphql-ruby/blob/v1.10.0/CHANGELOG.md#new-features-1 - def supports_authorized_and_resolved_types? - Gem.loaded_specs['graphql'].version >= Gem::Version.new('1.10.0') - end - - module Old - Truck = Struct.new(:price) - end - - module Vehicle - include GraphQL::Schema::Interface - end - - class Car < ::GraphQL::Schema::Object - implements Vehicle - - field :price, Integer, null: true - end - - class SlightlyComplexType < ::GraphQL::Schema::Object - field :uppercased_value, String, null: false - field :original_value, String, null: false - - def uppercased_value - object.original_value.upcase - end - end - - class SimpleResolver < ::GraphQL::Schema::Resolver - type SlightlyComplexType, null: false - - argument :id, Integer, required: true - - def resolve(id:) - Struct.new(:original_value).new("testing=#{id}") - end - end - - class QueryType < ::GraphQL::Schema::Object - field :simple_field, String, null: false - field :resolved_field, resolver: SimpleResolver - - # Required for testing resolve_type - field :vehicle, Vehicle, null: true - - def vehicle - Old::Truck.new(50) - end - - def simple_field - 'Hello.' - end - end - - class OtherQueryType < ::GraphQL::Schema::Object - field :simple_field, String, null: false - def simple_field - 'Hello.' - end - end - - class SomeOtherGraphQLAppSchema < ::GraphQL::Schema - query(::OtherQueryType) - use GraphQL::Execution::Interpreter - use GraphQL::Analysis::AST - end - - class SomeGraphQLAppSchema < ::GraphQL::Schema - query(::QueryType) - use GraphQL::Execution::Interpreter - use GraphQL::Analysis::AST - orphan_types Car - - def self.resolve_type(_type, _obj, _ctx) - Car - end - end -end diff --git a/instrumentation/graphql/test/test_helper.rb b/instrumentation/graphql/test/test_helper.rb deleted file mode 100644 index e234ff4b69..0000000000 --- a/instrumentation/graphql/test/test_helper.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'graphql' - -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' - -require 'pry' -require 'minitest/autorun' -require 'webmock/minitest' - -# global opentelemetry-sdk setup: -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry::SDK.configure do |c| - c.add_span_processor span_processor -end diff --git a/instrumentation/http/.rubocop.yml b/instrumentation/http/.rubocop.yml deleted file mode 100644 index 35adf7ece6..0000000000 --- a/instrumentation/http/.rubocop.yml +++ /dev/null @@ -1,5 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-http.rb" diff --git a/instrumentation/http/.yardopts b/instrumentation/http/.yardopts deleted file mode 100644 index 5c2b824224..0000000000 --- a/instrumentation/http/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Http Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/http/Appraisals b/instrumentation/http/Appraisals deleted file mode 100644 index 5a6c74f7a4..0000000000 --- a/instrumentation/http/Appraisals +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -appraise 'http-4.4' do - gem 'http', '~> 4.4.0' -end - -appraise 'http-3.3.0' do - gem 'http', '~> 3.3.0' -end diff --git a/instrumentation/http/CHANGELOG.md b/instrumentation/http/CHANGELOG.md deleted file mode 100644 index 70d1b67b04..0000000000 --- a/instrumentation/http/CHANGELOG.md +++ /dev/null @@ -1,56 +0,0 @@ -# Release History: opentelemetry-instrumentation-http - -### v0.20.0 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Broken test file requirements - -### v0.19.6 / 2022-05-05 - -* (No significant changes) - -### v0.19.5 / 2022-05-02 - -* FIXED: RubyGems Fallback - -### v0.19.4 / 2022-02-02 - -* FIXED: Excessive hash creation on context attr merging - -### v0.19.3 / 2021-12-01 - -* FIXED: Change net attribute names to match the semantic conventions spec for http - -### v0.19.2 / 2021-09-29 - -* (No significant changes) - -### v0.19.1 / 2021-08-12 - -* (No significant changes) - -### v0.19.0 / 2021-06-23 - -* BREAKING CHANGE: Total order constraint on span.status= - -* FIXED: Total order constraint on span.status= - -### v0.18.0 / 2021-05-21 - -* ADDED: Updated API depedency for 1.0.0.rc1 - -### v0.17.0 / 2021-04-22 - -* FIXED: Refactor propagators to add #fields - -### v0.16.2 / 2021-03-29 - -* FIXED: HTTP instrumenter should check for gem presence - -### v0.16.1 / 2021-03-25 - -* FIXED: HTTP instrumentation missing require - -### v0.16.0 / 2021-03-17 - -* Initial release. diff --git a/instrumentation/http/Gemfile b/instrumentation/http/Gemfile deleted file mode 100644 index 5b7d54b645..0000000000 --- a/instrumentation/http/Gemfile +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :test do - gem 'opentelemetry-instrumentation-base', path: '../base' - gem 'pry-byebug' -end diff --git a/instrumentation/http/LICENSE b/instrumentation/http/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/http/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/http/README.md b/instrumentation/http/README.md deleted file mode 100644 index 6ad1c72f90..0000000000 --- a/instrumentation/http/README.md +++ /dev/null @@ -1,53 +0,0 @@ -# OpenTelemetry Http Instrumentation - -The HTTP instrumentation is a community-maintained instrumentation for the [HTTP][http-home] gem. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-http -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-http` in your `Gemfile`. - -## Usage - -To use the instrumentation, call `use` with the name of the instrumentation: - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::HTTP' -end -``` - -Alternatively, you can also call `use_all` to install all the available instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` - -## Examples - -Example usage can be seen in the `./example/trace_demonstration.rb` file [here](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/instrumentation/http/example/trace_demonstration.rb) - -## How can I get involved? - -The `opentelemetry-instrumentation-http` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -The `opentelemetry-instrumentation-http` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information. - -[http-home]: https://github.com/httprb/http -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/instrumentation/http/Rakefile b/instrumentation/http/Rakefile deleted file mode 100644 index 1a64ba842e..0000000000 --- a/instrumentation/http/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/http/example/trace_demonstration.rb b/instrumentation/http/example/trace_demonstration.rb deleted file mode 100644 index dd3f976e7b..0000000000 --- a/instrumentation/http/example/trace_demonstration.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -require 'bundler/inline' - -gemfile(true) do - source 'https://rubygems.org' - gem 'opentelemetry-api' - gem 'opentelemetry-instrumentation-base' - gem 'opentelemetry-instrumentation-http' - gem 'opentelemetry-sdk' - gem 'http' -end - -require 'opentelemetry-api' -require 'opentelemetry-sdk' -require 'opentelemetry-instrumentation-http' -require 'http' - -# Export traces to console by default -ENV['OTEL_TRACES_EXPORTER'] ||= 'console' - -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::HTTP' -end - -# A basic HTTP example -HTTP.get('https://github.com') diff --git a/instrumentation/http/lib/opentelemetry-instrumentation-http.rb b/instrumentation/http/lib/opentelemetry-instrumentation-http.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/http/lib/opentelemetry-instrumentation-http.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/http/lib/opentelemetry/instrumentation.rb b/instrumentation/http/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index 806bf875ef..0000000000 --- a/instrumentation/http/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/http' diff --git a/instrumentation/http/lib/opentelemetry/instrumentation/http.rb b/instrumentation/http/lib/opentelemetry/instrumentation/http.rb deleted file mode 100644 index 46b9104afd..0000000000 --- a/instrumentation/http/lib/opentelemetry/instrumentation/http.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the Http gem - module HTTP - end - end -end - -require_relative './http/instrumentation' -require_relative './http/version' diff --git a/instrumentation/http/lib/opentelemetry/instrumentation/http/instrumentation.rb b/instrumentation/http/lib/opentelemetry/instrumentation/http/instrumentation.rb deleted file mode 100644 index 3fb03fb0ad..0000000000 --- a/instrumentation/http/lib/opentelemetry/instrumentation/http/instrumentation.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module HTTP - # The Instrumentation class contains logic to detect and install the Http instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - install do |_config| - require_dependencies - patch - end - - present do - !(defined?(::HTTP::Client).nil? || defined?(::HTTP::Connection).nil?) - end - - def patch - ::HTTP::Client.prepend(Patches::Client) - ::HTTP::Connection.prepend(Patches::Connection) - end - - def require_dependencies - require_relative 'patches/client' - require_relative 'patches/connection' - end - end - end - end -end diff --git a/instrumentation/http/lib/opentelemetry/instrumentation/http/patches/client.rb b/instrumentation/http/lib/opentelemetry/instrumentation/http/patches/client.rb deleted file mode 100644 index 9a1b46aba6..0000000000 --- a/instrumentation/http/lib/opentelemetry/instrumentation/http/patches/client.rb +++ /dev/null @@ -1,51 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module HTTP - module Patches - # Module to prepend to HTTP::Client for instrumentation - module Client - def perform(req, options) # rubocop:disable Metrics/AbcSize - uri = req.uri - request_method = req.verb.to_s.upcase - - attributes = { - 'http.method' => request_method, - 'http.scheme' => uri.scheme, - 'http.target' => uri.path, - 'http.url' => "#{uri.scheme}://#{uri.host}", - 'net.peer.name' => uri.host, - 'net.peer.port' => uri.port - }.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes) - - tracer.in_span("HTTP #{request_method}", attributes: attributes, kind: :client) do |span| - OpenTelemetry.propagation.inject(req.headers) - super.tap do |response| - annotate_span_with_response!(span, response) - end - end - end - - private - - def annotate_span_with_response!(span, response) - return unless response&.status - - status_code = response.status.to_i - span.set_attribute('http.status_code', status_code) - span.status = OpenTelemetry::Trace::Status.error unless (100..399).include?(status_code.to_i) - end - - def tracer - HTTP::Instrumentation.instance.tracer - end - end - end - end - end -end diff --git a/instrumentation/http/lib/opentelemetry/instrumentation/http/patches/connection.rb b/instrumentation/http/lib/opentelemetry/instrumentation/http/patches/connection.rb deleted file mode 100644 index 6e162886fa..0000000000 --- a/instrumentation/http/lib/opentelemetry/instrumentation/http/patches/connection.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module HTTP - module Patches - # Module to prepend to HTTP::Connection for instrumentation - module Connection - def initialize(req, options) - attributes = { - 'net.peer.name' => req.uri.host, - 'net.peer.port' => req.uri.port - }.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes) - - tracer.in_span('HTTP CONNECT', attributes: attributes) do - super - end - end - - private - - def tracer - HTTP::Instrumentation.instance.tracer - end - end - end - end - end -end diff --git a/instrumentation/http/lib/opentelemetry/instrumentation/http/version.rb b/instrumentation/http/lib/opentelemetry/instrumentation/http/version.rb deleted file mode 100644 index 989a61fa89..0000000000 --- a/instrumentation/http/lib/opentelemetry/instrumentation/http/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module HTTP - VERSION = '0.20.0' - end - end -end diff --git a/instrumentation/http/opentelemetry-instrumentation-http.gemspec b/instrumentation/http/opentelemetry-instrumentation-http.gemspec deleted file mode 100644 index cbb58f1beb..0000000000 --- a/instrumentation/http/opentelemetry-instrumentation-http.gemspec +++ /dev/null @@ -1,51 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/http/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-http' - spec.version = OpenTelemetry::Instrumentation::HTTP::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'HTTP instrumentation for the OpenTelemetry framework' - spec.description = 'HTTP instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.21.0' - - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'http' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'rake', '~> 12.3.3' - spec.add_development_dependency 'rspec-mocks' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'webmock', '~> 3.7.6' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-http/v#{OpenTelemetry::Instrumentation::HTTP::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/http' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-http/v#{OpenTelemetry::Instrumentation::HTTP::VERSION}" - end -end diff --git a/instrumentation/http/test/.rubocop.yml b/instrumentation/http/test/.rubocop.yml deleted file mode 100644 index dd94258585..0000000000 --- a/instrumentation/http/test/.rubocop.yml +++ /dev/null @@ -1,4 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false diff --git a/instrumentation/http/test/instrumentation/http/instrumentation_test.rb b/instrumentation/http/test/instrumentation/http/instrumentation_test.rb deleted file mode 100644 index 302ac483d4..0000000000 --- a/instrumentation/http/test/instrumentation/http/instrumentation_test.rb +++ /dev/null @@ -1,39 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../lib/opentelemetry/instrumentation/http' - -describe OpenTelemetry::Instrumentation::HTTP do - let(:instrumentation) { OpenTelemetry::Instrumentation::HTTP::Instrumentation.instance } - - it 'has #name' do - _(instrumentation.name).must_equal 'OpenTelemetry::Instrumentation::HTTP' - end - - it 'has #version' do - _(instrumentation.version).wont_be_nil - _(instrumentation.version).wont_be_empty - end - - describe 'present' do - it 'when http gem installed' do - _(instrumentation.present?).must_equal(true) - end - - it 'when HTTP constant not present' do - hide_const('HTTP') - _(instrumentation.present?).must_equal(false) - end - end - - describe '#install' do - it 'accepts argument' do - _(instrumentation.install({})).must_equal(true) - end - end -end diff --git a/instrumentation/http/test/instrumentation/http/patches/client_test.rb b/instrumentation/http/test/instrumentation/http/patches/client_test.rb deleted file mode 100644 index 665c47e2b5..0000000000 --- a/instrumentation/http/test/instrumentation/http/patches/client_test.rb +++ /dev/null @@ -1,119 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../lib/opentelemetry/instrumentation/http' -require_relative '../../../../lib/opentelemetry/instrumentation/http/patches/client' - -describe OpenTelemetry::Instrumentation::HTTP::Patches::Client do - let(:instrumentation) { OpenTelemetry::Instrumentation::HTTP::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:span) { exporter.finished_spans.first } - - before do - exporter.reset - @orig_propagation = OpenTelemetry.propagation - propagator = OpenTelemetry::Trace::Propagation::TraceContext.text_map_propagator - OpenTelemetry.propagation = propagator - instrumentation.install({}) - stub_request(:get, 'http://example.com/success').to_return(status: 200) - stub_request(:post, 'http://example.com/failure').to_return(status: 500) - stub_request(:get, 'https://example.com/timeout').to_timeout - end - - after do - # Force re-install of instrumentation - instrumentation.instance_variable_set(:@installed, false) - - OpenTelemetry.propagation = @orig_propagation - end - - describe '#perform' do - it 'traces a simple request' do - ::HTTP.get('http://example.com/success') - - _(exporter.finished_spans.size).must_equal(1) - _(span.name).must_equal 'HTTP GET' - _(span.attributes['http.method']).must_equal 'GET' - _(span.attributes['http.scheme']).must_equal 'http' - _(span.attributes['http.status_code']).must_equal 200 - _(span.attributes['http.target']).must_equal '/success' - _(span.attributes['net.peer.name']).must_equal 'example.com' - _(span.attributes['net.peer.port']).must_equal 80 - assert_requested( - :get, - 'http://example.com/success', - headers: { 'Traceparent' => "00-#{span.hex_trace_id}-#{span.hex_span_id}-01" } - ) - end - - it 'after request with failure code' do - ::HTTP.post('http://example.com/failure') - - _(exporter.finished_spans.size).must_equal 1 - _(span.name).must_equal 'HTTP POST' - _(span.attributes['http.method']).must_equal 'POST' - _(span.attributes['http.scheme']).must_equal 'http' - _(span.attributes['http.status_code']).must_equal 500 - _(span.attributes['http.target']).must_equal '/failure' - _(span.attributes['net.peer.name']).must_equal 'example.com' - _(span.attributes['net.peer.port']).must_equal 80 - assert_requested( - :post, - 'http://example.com/failure', - headers: { 'Traceparent' => "00-#{span.hex_trace_id}-#{span.hex_span_id}-01" } - ) - end - - it 'after request timeout' do - expect do - ::HTTP.get('https://example.com/timeout') - end.must_raise HTTP::TimeoutError - - _(exporter.finished_spans.size).must_equal 1 - _(span.name).must_equal 'HTTP GET' - _(span.attributes['http.method']).must_equal 'GET' - _(span.attributes['http.scheme']).must_equal 'https' - _(span.attributes['http.status_code']).must_be_nil - _(span.attributes['http.target']).must_equal '/timeout' - _(span.attributes['net.peer.name']).must_equal 'example.com' - _(span.attributes['net.peer.port']).must_equal 443 - _(span.status.code).must_equal( - OpenTelemetry::Trace::Status::ERROR - ) - _(span.status.description).must_equal( - 'Unhandled exception of type: HTTP::TimeoutError' - ) - assert_requested( - :get, - 'https://example.com/timeout', - headers: { 'Traceparent' => "00-#{span.hex_trace_id}-#{span.hex_span_id}-01" } - ) - end - - it 'merges http client attributes' do - OpenTelemetry::Common::HTTP::ClientContext.with_attributes('peer.service' => 'foo') do - ::HTTP.get('http://example.com/success') - end - - _(exporter.finished_spans.size).must_equal 1 - _(span.name).must_equal 'HTTP GET' - _(span.attributes['http.method']).must_equal 'GET' - _(span.attributes['http.scheme']).must_equal 'http' - _(span.attributes['http.status_code']).must_equal 200 - _(span.attributes['http.target']).must_equal '/success' - _(span.attributes['net.peer.name']).must_equal 'example.com' - _(span.attributes['net.peer.port']).must_equal 80 - _(span.attributes['peer.service']).must_equal 'foo' - assert_requested( - :get, - 'http://example.com/success', - headers: { 'Traceparent' => "00-#{span.hex_trace_id}-#{span.hex_span_id}-01" } - ) - end - end -end diff --git a/instrumentation/http/test/instrumentation/http/patches/connection_test.rb b/instrumentation/http/test/instrumentation/http/patches/connection_test.rb deleted file mode 100644 index 1e3ca2a659..0000000000 --- a/instrumentation/http/test/instrumentation/http/patches/connection_test.rb +++ /dev/null @@ -1,45 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../lib/opentelemetry/instrumentation/http' -require_relative '../../../../lib/opentelemetry/instrumentation/http/patches/connection' - -describe OpenTelemetry::Instrumentation::HTTP::Patches::Connection do - let(:instrumentation) { OpenTelemetry::Instrumentation::HTTP::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:span) { exporter.finished_spans.first } - - before do - exporter.reset - instrumentation.install({}) - end - - # Force re-install of instrumentation - after { instrumentation.instance_variable_set(:@installed, false) } - - describe '#connect' do - it 'emits span on connect' do - WebMock.allow_net_connect! - TCPServer.open('localhost', 0) do |server| - Thread.start { server.accept } - port = server.addr[1] - - assert_raises(::HTTP::TimeoutError) do - ::HTTP.timeout(connect: 0.1, write: 0.1, read: 0.1).get("http://localhost:#{port}/example") - end - end - - _(exporter.finished_spans.size).must_equal(2) - _(span.name).must_equal 'HTTP CONNECT' - _(span.attributes['net.peer.name']).must_equal('localhost') - _(span.attributes['net.peer.port']).wont_be_nil - ensure - WebMock.disable_net_connect! - end - end -end diff --git a/instrumentation/http/test/test_helper.rb b/instrumentation/http/test/test_helper.rb deleted file mode 100644 index cd948e9657..0000000000 --- a/instrumentation/http/test/test_helper.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 -require 'http' - -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' - -require 'minitest/autorun' -require 'rspec/mocks/minitest_integration' -require 'webmock/minitest' -require 'pry' - -# global opentelemetry-sdk setup: -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry::SDK.configure do |c| - c.add_span_processor span_processor -end diff --git a/instrumentation/http_client/.rubocop.yml b/instrumentation/http_client/.rubocop.yml deleted file mode 100644 index 89896b6064..0000000000 --- a/instrumentation/http_client/.rubocop.yml +++ /dev/null @@ -1,5 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-http_client.rb" diff --git a/instrumentation/http_client/.yardopts b/instrumentation/http_client/.yardopts deleted file mode 100644 index 649811ecaf..0000000000 --- a/instrumentation/http_client/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Http Client Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/http_client/Appraisals b/instrumentation/http_client/Appraisals deleted file mode 100644 index 326ebd94c3..0000000000 --- a/instrumentation/http_client/Appraisals +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -appraise 'httpclient-2.8' do - gem 'httpclient', '~> 2.8.0' -end diff --git a/instrumentation/http_client/CHANGELOG.md b/instrumentation/http_client/CHANGELOG.md deleted file mode 100644 index 5f5b2d69e7..0000000000 --- a/instrumentation/http_client/CHANGELOG.md +++ /dev/null @@ -1,50 +0,0 @@ -# Release History: opentelemetry-instrumentation-http_client - -### v0.20.0 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Broken test file requirements - -### v0.19.5 / 2022-05-05 - -* (No significant changes) - -### v0.19.4 / 2022-02-02 - -* FIXED: Excessive hash creation on context attr merging - -### v0.19.3 / 2021-12-01 - -* FIXED: Change net attribute names to match the semantic conventions spec for http - -### v0.19.2 / 2021-09-29 - -* (No significant changes) - -### v0.19.1 / 2021-08-12 - -* DOCS: Update docs to rely more on environment variable configuration - -### v0.19.0 / 2021-06-23 - -* BREAKING CHANGE: Total order constraint on span.status= - -* FIXED: Total order constraint on span.status= - -### v0.18.0 / 2021-05-21 - -* ADDED: Updated API depedency for 1.0.0.rc1 - -### v0.17.0 / 2021-04-22 - -* FIXED: Refactor propagators to add #fields - -### v0.16.0 / 2021-03-17 - -* FIXED: Remove passwords from http.url -* FIXED: Example scripts now reference local common lib -* DOCS: Replace Gitter with GitHub Discussions - -### v0.15.0 / 2021-02-18 - -* Initial release. diff --git a/instrumentation/http_client/Gemfile b/instrumentation/http_client/Gemfile deleted file mode 100644 index 5b7d54b645..0000000000 --- a/instrumentation/http_client/Gemfile +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :test do - gem 'opentelemetry-instrumentation-base', path: '../base' - gem 'pry-byebug' -end diff --git a/instrumentation/http_client/LICENSE b/instrumentation/http_client/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/http_client/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/http_client/README.md b/instrumentation/http_client/README.md deleted file mode 100644 index 9614bcc612..0000000000 --- a/instrumentation/http_client/README.md +++ /dev/null @@ -1,53 +0,0 @@ -# OpenTelemetry HttpClient Instrumentation - -The HttpClient instrumentation is a community-maintained instrumentation for the [HttpClient][httpclient-home] gem. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-http_client -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-http_client` in your `Gemfile`. - -## Usage - -To use the instrumentation, call `use` with the name of the instrumentation: - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::HttpClient' -end -``` - -Alternatively, you can also call `use_all` to install all the available instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` - -## Examples - -Example usage can be seen in the `./example/trace_demonstration.rb` file [here](https://github.com/open-telemetry/opentelemetry-ruby/blob/master/instrumentation/http_client/example/trace_demonstration.rb) - -## How can I get involved? - -The `opentelemetry-instrumentation-http_client` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -The `opentelemetry-instrumentation-http_client` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information. - -[httpclient-home]: https://github.com/nahi/httpclient -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/master/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/instrumentation/http_client/Rakefile b/instrumentation/http_client/Rakefile deleted file mode 100644 index 197514f1d4..0000000000 --- a/instrumentation/http_client/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright 2020 OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/http_client/example/Gemfile b/instrumentation/http_client/example/Gemfile deleted file mode 100644 index 525a382f54..0000000000 --- a/instrumentation/http_client/example/Gemfile +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -source 'https://rubygems.org' - -gem 'opentelemetry-api' -gem 'opentelemetry-common' -gem 'opentelemetry-instrumentation-http_client' -gem 'opentelemetry-sdk' diff --git a/instrumentation/http_client/example/trace_demonstration.rb b/instrumentation/http_client/example/trace_demonstration.rb deleted file mode 100644 index 06d945eaa5..0000000000 --- a/instrumentation/http_client/example/trace_demonstration.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -require 'rubygems' -require 'bundler/setup' -require 'httpclient' - -Bundler.require - -ENV['OTEL_TRACES_EXPORTER'] = 'console' -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::HttpClient' -end - -http = HTTPClient.new -http.receive_timeout = 1 -http.get('http://example.com') diff --git a/instrumentation/http_client/lib/opentelemetry-instrumentation-http_client.rb b/instrumentation/http_client/lib/opentelemetry-instrumentation-http_client.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/http_client/lib/opentelemetry-instrumentation-http_client.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/http_client/lib/opentelemetry/instrumentation.rb b/instrumentation/http_client/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index b7983af3ca..0000000000 --- a/instrumentation/http_client/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/http_client' diff --git a/instrumentation/http_client/lib/opentelemetry/instrumentation/http_client.rb b/instrumentation/http_client/lib/opentelemetry/instrumentation/http_client.rb deleted file mode 100644 index 708d2599a9..0000000000 --- a/instrumentation/http_client/lib/opentelemetry/instrumentation/http_client.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the HttpClient gem - module HttpClient - end - end -end - -require_relative './http_client/instrumentation' -require_relative './http_client/version' diff --git a/instrumentation/http_client/lib/opentelemetry/instrumentation/http_client/instrumentation.rb b/instrumentation/http_client/lib/opentelemetry/instrumentation/http_client/instrumentation.rb deleted file mode 100644 index 8b57fd2671..0000000000 --- a/instrumentation/http_client/lib/opentelemetry/instrumentation/http_client/instrumentation.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' - -module OpenTelemetry - module Instrumentation - module HttpClient - # The Instrumentation class contains logic to detect and install the HttpClient instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - install do |_config| - require_dependencies - patch - end - - present do - defined?(::HTTPClient) - end - - private - - def patch - ::HTTPClient.prepend(Patches::Client) - ::HTTPClient::Session.prepend(Patches::Session) - end - - def require_dependencies - require_relative 'patches/client' - require_relative 'patches/session' - end - end - end - end -end diff --git a/instrumentation/http_client/lib/opentelemetry/instrumentation/http_client/patches/client.rb b/instrumentation/http_client/lib/opentelemetry/instrumentation/http_client/patches/client.rb deleted file mode 100644 index 4029f7423b..0000000000 --- a/instrumentation/http_client/lib/opentelemetry/instrumentation/http_client/patches/client.rb +++ /dev/null @@ -1,55 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module HttpClient - module Patches - # Module to prepend to HTTPClient for instrumentation - module Client - private - - def do_get_block(req, proxy, conn, &block) # rubocop:disable Metrics/AbcSize - uri = req.header.request_uri - url = "#{uri.scheme}://#{uri.host}" - request_method = req.header.request_method - - attributes = { - 'http.method' => request_method, - 'http.scheme' => uri.scheme, - 'http.target' => uri.path, - 'http.url' => url, - 'net.peer.name' => uri.host, - 'net.peer.port' => uri.port - }.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes) - - tracer.in_span("HTTP #{request_method}", attributes: attributes, kind: :client) do |span| - OpenTelemetry.propagation.inject(req.header) - super.tap do - response = conn.pop - annotate_span_with_response!(span, response) - conn.push response - end - end - end - - def annotate_span_with_response!(span, response) - return unless response&.status_code - - status_code = response.status_code.to_i - - span.set_attribute('http.status_code', status_code) - span.status = OpenTelemetry::Trace::Status.error unless (100..399).include?(status_code.to_i) - end - - def tracer - HttpClient::Instrumentation.instance.tracer - end - end - end - end - end -end diff --git a/instrumentation/http_client/lib/opentelemetry/instrumentation/http_client/patches/session.rb b/instrumentation/http_client/lib/opentelemetry/instrumentation/http_client/patches/session.rb deleted file mode 100644 index 7604dff4c4..0000000000 --- a/instrumentation/http_client/lib/opentelemetry/instrumentation/http_client/patches/session.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module HttpClient - module Patches - # Module to prepend to HTTPClient::Session for instrumentation - module Session - def connect - site = @proxy || @dest - url = site.addr - - attributes = { 'http.url' => url }.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes) - tracer.in_span('HTTP CONNECT', attributes: attributes) do - super - end - end - - private - - def tracer - HttpClient::Instrumentation.instance.tracer - end - end - end - end - end -end diff --git a/instrumentation/http_client/lib/opentelemetry/instrumentation/http_client/version.rb b/instrumentation/http_client/lib/opentelemetry/instrumentation/http_client/version.rb deleted file mode 100644 index bc0c14630f..0000000000 --- a/instrumentation/http_client/lib/opentelemetry/instrumentation/http_client/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module HttpClient - VERSION = '0.20.0' - end - end -end diff --git a/instrumentation/http_client/opentelemetry-instrumentation-http_client.gemspec b/instrumentation/http_client/opentelemetry-instrumentation-http_client.gemspec deleted file mode 100644 index 7651428c15..0000000000 --- a/instrumentation/http_client/opentelemetry-instrumentation-http_client.gemspec +++ /dev/null @@ -1,51 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/http_client/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-http_client' - spec.version = OpenTelemetry::Instrumentation::HttpClient::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'HttpClient instrumentation for the OpenTelemetry framework' - spec.description = 'HttpClient instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-common', '~> 0.19.3' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.21.0' - - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'httpclient' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'rake', '~> 12.3.3' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'webmock', '~> 3.7.6' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-http_client/v#{OpenTelemetry::Instrumentation::HttpClient::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/master/instrumentation/http_client' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-http_client/v#{OpenTelemetry::Instrumentation::HttpClient::VERSION}" - end -end diff --git a/instrumentation/http_client/test/.rubocop.yml b/instrumentation/http_client/test/.rubocop.yml deleted file mode 100644 index dd94258585..0000000000 --- a/instrumentation/http_client/test/.rubocop.yml +++ /dev/null @@ -1,4 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false diff --git a/instrumentation/http_client/test/instrumentation/http_client/instrumentation_test.rb b/instrumentation/http_client/test/instrumentation/http_client/instrumentation_test.rb deleted file mode 100644 index 424f078e43..0000000000 --- a/instrumentation/http_client/test/instrumentation/http_client/instrumentation_test.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../lib/opentelemetry/instrumentation/http_client' - -describe OpenTelemetry::Instrumentation::HttpClient do - let(:instrumentation) { OpenTelemetry::Instrumentation::HttpClient::Instrumentation.instance } - - it 'has #name' do - _(instrumentation.name).must_equal 'OpenTelemetry::Instrumentation::HttpClient' - end - - it 'has #version' do - _(instrumentation.version).wont_be_nil - _(instrumentation.version).wont_be_empty - end - - describe '#install' do - it 'accepts argument' do - instrumentation.install({}) - end - end -end diff --git a/instrumentation/http_client/test/instrumentation/http_client/patches/client_test.rb b/instrumentation/http_client/test/instrumentation/http_client/patches/client_test.rb deleted file mode 100644 index d71d2555c5..0000000000 --- a/instrumentation/http_client/test/instrumentation/http_client/patches/client_test.rb +++ /dev/null @@ -1,127 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../lib/opentelemetry/instrumentation/http_client' -require_relative '../../../../lib/opentelemetry/instrumentation/http_client/patches/client' - -describe OpenTelemetry::Instrumentation::HttpClient::Patches::Client do - let(:instrumentation) { OpenTelemetry::Instrumentation::HttpClient::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:span) { exporter.finished_spans.first } - - before do - exporter.reset - @orig_propagation = OpenTelemetry.propagation - propagator = OpenTelemetry::Trace::Propagation::TraceContext.text_map_propagator - OpenTelemetry.propagation = propagator - instrumentation.install({}) - stub_request(:get, 'http://example.com/success').to_return(status: 200) - stub_request(:post, 'http://example.com/failure').to_return(status: 500) - stub_request(:get, 'https://example.com/timeout').to_timeout - end - - after do - # Force re-install of instrumentation - instrumentation.instance_variable_set(:@installed, false) - - OpenTelemetry.propagation = @orig_propagation - end - - describe '#do_request' do - it 'traces a simple request' do - http = HTTPClient.new - http.receive_timeout = 1 - http.get('http://example.com/success') - - _(exporter.finished_spans.size).must_equal(1) - _(span.name).must_equal 'HTTP GET' - _(span.attributes['http.method']).must_equal 'GET' - _(span.attributes['http.scheme']).must_equal 'http' - _(span.attributes['http.status_code']).must_equal 200 - _(span.attributes['http.target']).must_equal '/success' - _(span.attributes['net.peer.name']).must_equal 'example.com' - _(span.attributes['net.peer.port']).must_equal 80 - assert_requested( - :get, - 'http://example.com/success', - headers: { 'Traceparent' => "00-#{span.hex_trace_id}-#{span.hex_span_id}-01" } - ) - end - - it 'after request with failure code' do - http = HTTPClient.new - http.receive_timeout = 1 - http.post('http://example.com/failure') - - _(exporter.finished_spans.size).must_equal 1 - _(span.name).must_equal 'HTTP POST' - _(span.attributes['http.method']).must_equal 'POST' - _(span.attributes['http.scheme']).must_equal 'http' - _(span.attributes['http.status_code']).must_equal 500 - _(span.attributes['http.target']).must_equal '/failure' - _(span.attributes['net.peer.name']).must_equal 'example.com' - _(span.attributes['net.peer.port']).must_equal 80 - assert_requested( - :post, - 'http://example.com/failure', - headers: { 'Traceparent' => "00-#{span.hex_trace_id}-#{span.hex_span_id}-01" } - ) - end - - it 'after request timeout' do - expect do - http = HTTPClient.new - http.receive_timeout = 1 - http.get('https://example.com/timeout') - end.must_raise HTTPClient::TimeoutError - - _(exporter.finished_spans.size).must_equal 1 - _(span.name).must_equal 'HTTP GET' - _(span.attributes['http.method']).must_equal 'GET' - _(span.attributes['http.scheme']).must_equal 'https' - _(span.attributes['http.status_code']).must_be_nil - _(span.attributes['http.target']).must_equal '/timeout' - _(span.attributes['net.peer.name']).must_equal 'example.com' - _(span.attributes['net.peer.port']).must_equal 443 - _(span.status.code).must_equal( - OpenTelemetry::Trace::Status::ERROR - ) - _(span.status.description).must_equal( - 'Unhandled exception of type: HTTPClient::TimeoutError' - ) - assert_requested( - :get, - 'https://example.com/timeout', - headers: { 'Traceparent' => "00-#{span.hex_trace_id}-#{span.hex_span_id}-01" } - ) - end - - it 'merges http client attributes' do - OpenTelemetry::Common::HTTP::ClientContext.with_attributes('peer.service' => 'foo') do - http = HTTPClient.new - http.receive_timeout = 1 - http.get('http://example.com/success') - end - - _(exporter.finished_spans.size).must_equal 1 - _(span.name).must_equal 'HTTP GET' - _(span.attributes['http.method']).must_equal 'GET' - _(span.attributes['http.scheme']).must_equal 'http' - _(span.attributes['http.status_code']).must_equal 200 - _(span.attributes['http.target']).must_equal '/success' - _(span.attributes['net.peer.name']).must_equal 'example.com' - _(span.attributes['net.peer.port']).must_equal 80 - _(span.attributes['peer.service']).must_equal 'foo' - assert_requested( - :get, - 'http://example.com/success', - headers: { 'Traceparent' => "00-#{span.hex_trace_id}-#{span.hex_span_id}-01" } - ) - end - end -end diff --git a/instrumentation/http_client/test/instrumentation/http_client/patches/session_test.rb b/instrumentation/http_client/test/instrumentation/http_client/patches/session_test.rb deleted file mode 100644 index d38bd7a721..0000000000 --- a/instrumentation/http_client/test/instrumentation/http_client/patches/session_test.rb +++ /dev/null @@ -1,46 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../lib/opentelemetry/instrumentation/http_client' -require_relative '../../../../lib/opentelemetry/instrumentation/http_client/patches/session' - -describe OpenTelemetry::Instrumentation::HttpClient::Patches::Session do - let(:instrumentation) { OpenTelemetry::Instrumentation::HttpClient::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:span) { exporter.finished_spans.first } - - before do - exporter.reset - instrumentation.install({}) - end - - # Force re-install of instrumentation - after { instrumentation.instance_variable_set(:@installed, false) } - - describe '#connect' do - it 'emits span on connect' do - WebMock.allow_net_connect! - TCPServer.open('localhost', 0) do |server| - Thread.start { server.accept } - port = server.addr[1] - - assert_raises(HTTPClient::ReceiveTimeoutError) do - http = HTTPClient.new - http.receive_timeout = 0.01 - http.get("http://username:password@localhost:#{port}/example") - end - end - - _(exporter.finished_spans.size).must_equal(2) - _(span.name).must_equal 'HTTP CONNECT' - _(span.attributes['http.url']).must_match(%r{http://localhost:}) - ensure - WebMock.disable_net_connect! - end - end -end diff --git a/instrumentation/http_client/test/test_helper.rb b/instrumentation/http_client/test/test_helper.rb deleted file mode 100644 index 498831283c..0000000000 --- a/instrumentation/http_client/test/test_helper.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 -require 'httpclient' - -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' - -require 'pry' -require 'minitest/autorun' -require 'webmock/minitest' - -# global opentelemetry-sdk setup: -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry::SDK.configure do |c| - c.add_span_processor span_processor -end diff --git a/instrumentation/koala/.rubocop.yml b/instrumentation/koala/.rubocop.yml deleted file mode 100644 index 9b31a5e0a8..0000000000 --- a/instrumentation/koala/.rubocop.yml +++ /dev/null @@ -1,5 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-koala.rb" diff --git a/instrumentation/koala/.yardopts b/instrumentation/koala/.yardopts deleted file mode 100644 index ed23143455..0000000000 --- a/instrumentation/koala/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Koala Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/koala/Appraisals b/instrumentation/koala/Appraisals deleted file mode 100644 index edbf0003b3..0000000000 --- a/instrumentation/koala/Appraisals +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 -appraise 'koala-3' do - gem 'koala', '~> 3.0.0' - gem 'faraday', '< 2.0' -end diff --git a/instrumentation/koala/CHANGELOG.md b/instrumentation/koala/CHANGELOG.md deleted file mode 100644 index 4560262fce..0000000000 --- a/instrumentation/koala/CHANGELOG.md +++ /dev/null @@ -1,30 +0,0 @@ -# Release History: opentelemetry-instrumentation-koala - -### v0.19.0 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Broken test file requirements - -### v0.18.5 / 2022-05-05 - -* (No significant changes) - -### v0.18.4 / 2021-12-02 - -* (No significant changes) - -### v0.18.3 / 2021-09-29 - -* (No significant changes) - -### v0.18.2 / 2021-08-12 - -* DOCS: Update docs to rely more on environment variable configuration - -### v0.18.1 / 2021-06-23 - -* (No significant changes) - -### v0.18.0 / 2021-05-21 - -* Initial release. diff --git a/instrumentation/koala/Gemfile b/instrumentation/koala/Gemfile deleted file mode 100644 index 5b7d54b645..0000000000 --- a/instrumentation/koala/Gemfile +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :test do - gem 'opentelemetry-instrumentation-base', path: '../base' - gem 'pry-byebug' -end diff --git a/instrumentation/koala/LICENSE b/instrumentation/koala/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/koala/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/koala/README.md b/instrumentation/koala/README.md deleted file mode 100644 index 08c37c4828..0000000000 --- a/instrumentation/koala/README.md +++ /dev/null @@ -1,54 +0,0 @@ -# OpenTelemetry Koala Instrumentation - -The Koala instrumentation is a community-maintained instrumentation for the [Koala][koala-home] Facebook API library. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-koala -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-koala` in your `Gemfile`. - -## Usage - -To use the instrumentation, call `use` with the name of the instrumentation: - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Net::HTTP' - c.use 'OpenTelemetry::Instrumentation::Koala' -end -``` - -Alternatively, you can also call `use_all` to install all the available instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` - -## Examples - -Example usage can be seen in the `./example/trace_demonstration.rb` file [here](https://github.com/open-telemetry/opentelemetry-ruby/blob/master/instrumentation/koala/example/trace_demonstration.rb) - -## How can I get involved? - -The `opentelemetry-instrumentation-koala` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -The `opentelemetry-instrumentation-koala` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information. - -[koala-home]: https://github.com/arsduo/koala -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/master/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/instrumentation/koala/Rakefile b/instrumentation/koala/Rakefile deleted file mode 100644 index 1a64ba842e..0000000000 --- a/instrumentation/koala/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/koala/example/Gemfile b/instrumentation/koala/example/Gemfile deleted file mode 100644 index b11a453ad3..0000000000 --- a/instrumentation/koala/example/Gemfile +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -source 'https://rubygems.org' - -gem 'opentelemetry-api' -gem 'opentelemetry-common' -gem 'opentelemetry-instrumentation-koala' -gem 'opentelemetry-sdk' diff --git a/instrumentation/koala/example/trace_demonstration.rb b/instrumentation/koala/example/trace_demonstration.rb deleted file mode 100644 index 9dd42481aa..0000000000 --- a/instrumentation/koala/example/trace_demonstration.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -require 'rubygems' -require 'bundler/setup' -require 'koala' - -Bundler.require - -ENV['OTEL_TRACES_EXPORTER'] = 'console' -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Net::HTTP' - c.use 'OpenTelemetry::Instrumentation::Koala' -end - -graph = Koala::Facebook::API.new('token') -graph.get_object('me') diff --git a/instrumentation/koala/lib/opentelemetry-instrumentation-koala.rb b/instrumentation/koala/lib/opentelemetry-instrumentation-koala.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/koala/lib/opentelemetry-instrumentation-koala.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/koala/lib/opentelemetry/instrumentation.rb b/instrumentation/koala/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index f26e5c570b..0000000000 --- a/instrumentation/koala/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/koala' diff --git a/instrumentation/koala/lib/opentelemetry/instrumentation/koala.rb b/instrumentation/koala/lib/opentelemetry/instrumentation/koala.rb deleted file mode 100644 index ef86db1288..0000000000 --- a/instrumentation/koala/lib/opentelemetry/instrumentation/koala.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the Koala gem - module Koala - end - end -end - -require_relative './koala/instrumentation' -require_relative './koala/version' diff --git a/instrumentation/koala/lib/opentelemetry/instrumentation/koala/instrumentation.rb b/instrumentation/koala/lib/opentelemetry/instrumentation/koala/instrumentation.rb deleted file mode 100644 index e11d725017..0000000000 --- a/instrumentation/koala/lib/opentelemetry/instrumentation/koala/instrumentation.rb +++ /dev/null @@ -1,35 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' - -module OpenTelemetry - module Instrumentation - module Koala - # The Instrumentation class contains logic to detect and install the Koala instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - install do |_config| - require_dependencies - patch - end - - present do - !defined?(::Koala).nil? - end - - private - - def require_dependencies - require_relative 'patches/instrumentation' - end - - def patch - ::Koala::Facebook::API.prepend(Patches::Api) - end - end - end - end -end diff --git a/instrumentation/koala/lib/opentelemetry/instrumentation/koala/patches/instrumentation.rb b/instrumentation/koala/lib/opentelemetry/instrumentation/koala/patches/instrumentation.rb deleted file mode 100644 index 2fc08f45b0..0000000000 --- a/instrumentation/koala/lib/opentelemetry/instrumentation/koala/patches/instrumentation.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Koala - module Patches - # Module to prepend to Koala::Facebook::API for instrumentation - module Api - def graph_call(path, args = {}, verb = 'get', options = {}, &post_processing) - OpenTelemetry::Common::HTTP::ClientContext.with_attributes('peer.service' => 'facebook', 'koala.verb' => verb, 'koala.path' => path) do - super - end - end - end - end - end - end -end diff --git a/instrumentation/koala/lib/opentelemetry/instrumentation/koala/version.rb b/instrumentation/koala/lib/opentelemetry/instrumentation/koala/version.rb deleted file mode 100644 index 47842762c2..0000000000 --- a/instrumentation/koala/lib/opentelemetry/instrumentation/koala/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Koala - VERSION = '0.19.0' - end - end -end diff --git a/instrumentation/koala/opentelemetry-instrumentation-koala.gemspec b/instrumentation/koala/opentelemetry-instrumentation-koala.gemspec deleted file mode 100644 index 9195ca1801..0000000000 --- a/instrumentation/koala/opentelemetry-instrumentation-koala.gemspec +++ /dev/null @@ -1,52 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/koala/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-koala' - spec.version = OpenTelemetry::Instrumentation::Koala::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'Koala instrumentation for the OpenTelemetry framework' - spec.description = 'Koala instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-common', '~> 0.19.3' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.21.0' - - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'koala', '~> 3.0.0' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'rake', '~> 12.3.3' - spec.add_development_dependency 'rspec-mocks' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'webmock', '~> 3.7.6' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-koala/v#{OpenTelemetry::Instrumentation::Koala::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/master/instrumentation/koala' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-koala/v#{OpenTelemetry::Instrumentation::Koala::VERSION}" - end -end diff --git a/instrumentation/koala/test/instrumentation/koala/instrumentation_test.rb b/instrumentation/koala/test/instrumentation/koala/instrumentation_test.rb deleted file mode 100644 index 4352244ec4..0000000000 --- a/instrumentation/koala/test/instrumentation/koala/instrumentation_test.rb +++ /dev/null @@ -1,52 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' -require 'pry' - -require_relative '../../../../net_http/lib/opentelemetry/instrumentation/net/http' - -describe OpenTelemetry::Instrumentation::Koala do # rubocop:disable Metrics/BlockLength - let(:instrumentation) { OpenTelemetry::Instrumentation::Koala::Instrumentation.instance } - let(:http_instrumentation) { OpenTelemetry::Instrumentation::Net::HTTP::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:span) { exporter.finished_spans.first } - - it 'has #name' do - _(instrumentation.name).must_equal 'OpenTelemetry::Instrumentation::Koala' - end - - it 'has #version' do - _(instrumentation.version).wont_be_nil - _(instrumentation.version).wont_be_empty - end - - describe '#install' do - it 'accepts argument' do - instrumentation.install({}) - end - end - - describe 'install' do - before do - exporter.reset - http_instrumentation.install({}) - instrumentation.install({}) - end - - it 'when koala call made' do - stub_request(:get, 'https://graph.facebook.com/me?access_token=fake_token') - .to_return(status: 200, body: '{"id":"2531656920449469","name":"First Last"}', headers: {}) - - @graph = Koala::Facebook::API.new('fake_token') - @graph.get_object('me') - _(exporter.finished_spans.size).must_equal 1 - span = exporter.finished_spans.first - _(span.attributes['koala.verb']).must_equal 'get' - _(span.attributes['koala.path']).must_equal 'me' - end - end -end diff --git a/instrumentation/koala/test/test_helper.rb b/instrumentation/koala/test/test_helper.rb deleted file mode 100644 index e94339c8ea..0000000000 --- a/instrumentation/koala/test/test_helper.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'koala' - -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' - -require 'minitest/autorun' -require 'rspec/mocks/minitest_integration' -require 'webmock/minitest' - -require_relative '../lib/opentelemetry-instrumentation-koala' - -# global opentelemetry-sdk setup: -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry::SDK.configure do |c| - c.add_span_processor span_processor -end diff --git a/instrumentation/lmdb/.rubocop.yml b/instrumentation/lmdb/.rubocop.yml deleted file mode 100644 index f658963d11..0000000000 --- a/instrumentation/lmdb/.rubocop.yml +++ /dev/null @@ -1,5 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-lmdb.rb" diff --git a/instrumentation/lmdb/.yardopts b/instrumentation/lmdb/.yardopts deleted file mode 100644 index 7bf44ba360..0000000000 --- a/instrumentation/lmdb/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry LMDB Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/lmdb/Appraisals b/instrumentation/lmdb/Appraisals deleted file mode 100644 index 95a83b041b..0000000000 --- a/instrumentation/lmdb/Appraisals +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -appraise 'lmdb-0.5' do - gem 'lmdb', '~> 0.5.0' -end - -appraise 'lmdb-0.4' do - gem 'lmdb', '~> 0.4.0' -end diff --git a/instrumentation/lmdb/CHANGELOG.md b/instrumentation/lmdb/CHANGELOG.md deleted file mode 100644 index 2741a38a50..0000000000 --- a/instrumentation/lmdb/CHANGELOG.md +++ /dev/null @@ -1,39 +0,0 @@ -# Release History: opentelemetry-instrumentation-lmdb - -### v0.21.0 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Broken test file requirements - -### v0.20.0 / 2022-05-02 - -* ADDED: Validate Using Enums - -### v0.19.2 / 2021-12-02 - -* (No significant changes) - -### v0.19.1 / 2021-09-29 - -* (No significant changes) - -### v0.19.0 / 2021-08-12 - -* ADDED: Configure db.statement toggle -* DOCS: Update docs to rely more on environment variable configuration - -### v0.18.1 / 2021-06-23 - -* (No significant changes) - -### v0.18.0 / 2021-05-21 - -* ADDED: Updated API depedency for 1.0.0.rc1 - -### v0.17.0 / 2021-04-22 - -* (No significant changes) - -### v0.16.0 / 2021-03-17 - -* Initial release. diff --git a/instrumentation/lmdb/Gemfile b/instrumentation/lmdb/Gemfile deleted file mode 100644 index 5b7d54b645..0000000000 --- a/instrumentation/lmdb/Gemfile +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :test do - gem 'opentelemetry-instrumentation-base', path: '../base' - gem 'pry-byebug' -end diff --git a/instrumentation/lmdb/LICENSE b/instrumentation/lmdb/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/lmdb/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/lmdb/README.md b/instrumentation/lmdb/README.md deleted file mode 100644 index cd6ef0a4fa..0000000000 --- a/instrumentation/lmdb/README.md +++ /dev/null @@ -1,49 +0,0 @@ -# OpenTelemetry LMDB Instrumentation - -The LMDB instrumentation is a community-maintained instrumentation for the [LMDB][lmdb-home] gem. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-lmdb -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-lmdb` in your `Gemfile`. - -## Usage - -To use the instrumentation, call `use` with the name of the instrumentation: - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::LMDB' -end -``` - -Alternatively, you can also call `use_all` to install all the available instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` - -## How can I get involved? - -The `opentelemetry-instrumentation-lmdb` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -The `opentelemetry-instrumentation-lmdb` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information. - -[lmdb-home]: https://github.com/minad/lmdb -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/instrumentation/lmdb/Rakefile b/instrumentation/lmdb/Rakefile deleted file mode 100644 index 1a64ba842e..0000000000 --- a/instrumentation/lmdb/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/lmdb/lib/opentelemetry-instrumentation-lmdb.rb b/instrumentation/lmdb/lib/opentelemetry-instrumentation-lmdb.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/lmdb/lib/opentelemetry-instrumentation-lmdb.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/lmdb/lib/opentelemetry/instrumentation.rb b/instrumentation/lmdb/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index 12fd3514ff..0000000000 --- a/instrumentation/lmdb/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/lmdb' diff --git a/instrumentation/lmdb/lib/opentelemetry/instrumentation/lmdb.rb b/instrumentation/lmdb/lib/opentelemetry/instrumentation/lmdb.rb deleted file mode 100644 index 437e7f6ecb..0000000000 --- a/instrumentation/lmdb/lib/opentelemetry/instrumentation/lmdb.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the Lmdb gem - module LMDB - end - end -end - -require_relative './lmdb/instrumentation' -require_relative './lmdb/version' diff --git a/instrumentation/lmdb/lib/opentelemetry/instrumentation/lmdb/instrumentation.rb b/instrumentation/lmdb/lib/opentelemetry/instrumentation/lmdb/instrumentation.rb deleted file mode 100644 index 2ab389c039..0000000000 --- a/instrumentation/lmdb/lib/opentelemetry/instrumentation/lmdb/instrumentation.rb +++ /dev/null @@ -1,40 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' - -module OpenTelemetry - module Instrumentation - module LMDB - # The Instrumentation class contains logic to detect and install the LMDB instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - install do |_config| - require_dependencies - patch - end - - present do - defined?(::LMDB) - end - - option :peer_service, default: nil, validate: :string - option :db_statement, default: :include, validate: %I[omit include] - - private - - def patch - ::LMDB::Environment.prepend(Patches::Environment) - ::LMDB::Database.prepend(Patches::Database) - end - - def require_dependencies - require_relative 'patches/database' - require_relative 'patches/environment' - end - end - end - end -end diff --git a/instrumentation/lmdb/lib/opentelemetry/instrumentation/lmdb/patches/database.rb b/instrumentation/lmdb/lib/opentelemetry/instrumentation/lmdb/patches/database.rb deleted file mode 100644 index 71d3a1844c..0000000000 --- a/instrumentation/lmdb/lib/opentelemetry/instrumentation/lmdb/patches/database.rb +++ /dev/null @@ -1,78 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' - -module OpenTelemetry - module Instrumentation - module LMDB - module Patches - # Module to prepend to LMDB::Database for instrumentation - module Database - STATEMENT_MAX_LENGTH = 500 - - def get(key) - attributes = { 'db.system' => 'lmdb' } - attributes['db.statement'] = formatted_statement('GET', "GET #{key}") if config[:db_statement] == :include - attributes['peer.service'] = config[:peer_service] if config[:peer_service] - - tracer.in_span("GET #{key}", attributes: attributes, kind: :client) do - super - end - end - - def delete(key, value = nil) - attributes = { 'db.system' => 'lmdb' } - attributes['db.statement'] = formatted_statement('DELETE', "DELETE #{key} #{value}".strip) if config[:db_statement] == :include - attributes['peer.service'] = config[:peer_service] if config[:peer_service] - - tracer.in_span("DELETE #{key}", attributes: attributes, kind: :client) do - super - end - end - - def put(key, value) - attributes = { 'db.system' => 'lmdb' } - attributes['db.statement'] = formatted_statement('PUT', "PUT #{key} #{value}") if config[:db_statement] == :include - attributes['peer.service'] = config[:peer_service] if config[:peer_service] - - tracer.in_span("PUT #{key}", attributes: attributes, kind: :client) do - super - end - end - - def clear - attributes = { 'db.system' => 'lmdb' } - attributes['db.statement'] = 'CLEAR' if config[:db_statement] == :include - attributes['peer.service'] = config[:peer_service] if config[:peer_service] - - tracer.in_span('CLEAR', attributes: attributes, kind: :client) do - super - end - end - - private - - def formatted_statement(operation, statement) - statement = OpenTelemetry::Common::Utilities.truncate(statement, STATEMENT_MAX_LENGTH) - OpenTelemetry::Common::Utilities.utf8_encode(statement) - rescue StandardError => e - OpenTelemetry.logger.debug("non formattable LMDB statement #{statement}: #{e}") - "#{operation} BLOB (OMITTED)" - end - - def config - LMDB::Instrumentation.instance.config - end - - def tracer - LMDB::Instrumentation.instance.tracer - end - end - end - end - end -end diff --git a/instrumentation/lmdb/lib/opentelemetry/instrumentation/lmdb/patches/environment.rb b/instrumentation/lmdb/lib/opentelemetry/instrumentation/lmdb/patches/environment.rb deleted file mode 100644 index a3171249ca..0000000000 --- a/instrumentation/lmdb/lib/opentelemetry/instrumentation/lmdb/patches/environment.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' - -module OpenTelemetry - module Instrumentation - module LMDB - module Patches - # Module to prepend to LMDB::Environment for instrumentation - module Environment - def transaction(*args) - attributes = { 'db.system' => 'lmdb' } - attributes['peer.service'] = config[:peer_service] if config[:peer_service] - - tracer.in_span('TRANSACTION', attributes: attributes) do - super - end - end - - private - - def config - LMDB::Instrumentation.instance.config - end - - def tracer - LMDB::Instrumentation.instance.tracer - end - end - end - end - end -end diff --git a/instrumentation/lmdb/lib/opentelemetry/instrumentation/lmdb/version.rb b/instrumentation/lmdb/lib/opentelemetry/instrumentation/lmdb/version.rb deleted file mode 100644 index 29805591dc..0000000000 --- a/instrumentation/lmdb/lib/opentelemetry/instrumentation/lmdb/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module LMDB - VERSION = '0.21.0' - end - end -end diff --git a/instrumentation/lmdb/opentelemetry-instrumentation-lmdb.gemspec b/instrumentation/lmdb/opentelemetry-instrumentation-lmdb.gemspec deleted file mode 100644 index c79f167462..0000000000 --- a/instrumentation/lmdb/opentelemetry-instrumentation-lmdb.gemspec +++ /dev/null @@ -1,50 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/lmdb/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-lmdb' - spec.version = OpenTelemetry::Instrumentation::LMDB::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'LMDB instrumentation for the OpenTelemetry framework' - spec.description = 'LMDB instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.21.0' - - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'lmdb' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'rake', '~> 12.3.3' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'webmock', '~> 3.7.6' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-lmdb/v#{OpenTelemetry::Instrumentation::LMDB::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/lmdb' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-lmdb/v#{OpenTelemetry::Instrumentation::LMDB::VERSION}" - end -end diff --git a/instrumentation/lmdb/test/.rubocop.yml b/instrumentation/lmdb/test/.rubocop.yml deleted file mode 100644 index dd94258585..0000000000 --- a/instrumentation/lmdb/test/.rubocop.yml +++ /dev/null @@ -1,4 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false diff --git a/instrumentation/lmdb/test/instrumentation/lmdb/instrumentation_test.rb b/instrumentation/lmdb/test/instrumentation/lmdb/instrumentation_test.rb deleted file mode 100644 index 8f0ecc56af..0000000000 --- a/instrumentation/lmdb/test/instrumentation/lmdb/instrumentation_test.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../lib/opentelemetry/instrumentation/lmdb' - -describe OpenTelemetry::Instrumentation::LMDB do - let(:instrumentation) { OpenTelemetry::Instrumentation::LMDB::Instrumentation.instance } - - it 'has #name' do - _(instrumentation.name).must_equal 'OpenTelemetry::Instrumentation::LMDB' - end - - it 'has #version' do - _(instrumentation.version).wont_be_nil - _(instrumentation.version).wont_be_empty - end - - describe '#install' do - after { instrumentation.instance_variable_set(:@installed, false) } - - it 'accepts argument' do - _(instrumentation.install({})).must_equal(true) - end - end -end diff --git a/instrumentation/lmdb/test/instrumentation/lmdb/patches/database_test.rb b/instrumentation/lmdb/test/instrumentation/lmdb/patches/database_test.rb deleted file mode 100644 index 2ed57e6a12..0000000000 --- a/instrumentation/lmdb/test/instrumentation/lmdb/patches/database_test.rb +++ /dev/null @@ -1,158 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../lib/opentelemetry/instrumentation/lmdb' -require_relative '../../../../lib/opentelemetry/instrumentation/lmdb/patches/database' - -describe OpenTelemetry::Instrumentation::LMDB::Patches::Database do - let(:instrumentation) { OpenTelemetry::Instrumentation::LMDB::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:span) { exporter.finished_spans.first } - let(:last_span) { exporter.finished_spans.last } - let(:config) { {} } - let(:db_path) { File.join(File.dirname(__FILE__), '..', 'tmp', 'test') } - let(:lmdb) { LMDB.new(db_path) } - - before do - exporter.reset - instrumentation.install(config) - FileUtils.rm_rf(db_path) - FileUtils.mkdir_p(db_path) - end - - after do - FileUtils.rm_rf(db_path) - lmdb.close - instrumentation.instance_variable_set(:@installed, false) - end - - describe '#clear' do - it 'traces' do - lmdb.database.clear - _(span.name).must_equal('CLEAR') - _(span.kind).must_equal(:client) - _(span.attributes['db.system']).must_equal('lmdb') - _(span.attributes['db.statement']).must_equal('CLEAR') - end - - it 'omits db.statement attribute' do - instrumentation.instance_variable_set(:@installed, false) - instrumentation.install(db_statement: :omit) - - lmdb.database.clear - - _(span.kind).must_equal(:client) - _(span.attributes['db.system']).must_equal('lmdb') - _(last_span.attributes).wont_include('db.statement') - end - end - - describe '#put' do - it 'traces' do - lmdb.database['foo'] = 'bar' - _(span.name).must_equal('PUT foo') - _(span.kind).must_equal(:client) - _(span.attributes['db.system']).must_equal('lmdb') - _(span.attributes['db.statement']).must_equal('PUT foo bar') - end - - it 'truncates long statements' do - lmdb.database['foo'] = 'bar' * 200 - _(span.name).must_equal('PUT foo') - _(span.kind).must_equal(:client) - _(span.attributes['db.system']).must_equal('lmdb') - _(span.attributes['db.statement'].size).must_equal(500) - end - - describe 'when peer_service config is set' do - let(:config) { { peer_service: 'otel:lmdb' } } - - it 'adds peer.service attribute' do - lmdb.database['foo'] = 'bar' - _(span.name).must_equal('PUT foo') - _(span.kind).must_equal(:client) - _(span.attributes['db.system']).must_equal('lmdb') - _(span.attributes['db.statement']).must_equal('PUT foo bar') - _(span.attributes['peer.service']).must_equal('otel:lmdb') - end - end - - it 'omits db.statement attribute' do - instrumentation.instance_variable_set(:@installed, false) - instrumentation.install(db_statement: :omit) - - lmdb.database['foo'] = 'bar' - lmdb.database['foo'] - - _(span.name).must_equal('PUT foo') - _(span.kind).must_equal(:client) - _(span.attributes['db.system']).must_equal('lmdb') - _(last_span.attributes).wont_include('db.statement') - end - end - - describe '#get' do - it 'traces' do - lmdb.database['foo'] = 'bar' - lmdb.database['foo'] - - _(last_span.name).must_equal('GET foo') - _(last_span.kind).must_equal(:client) - _(last_span.attributes['db.system']).must_equal('lmdb') - _(last_span.attributes['db.statement']).must_equal('GET foo') - end - - it 'omits db.statement attribute' do - instrumentation.instance_variable_set(:@installed, false) - instrumentation.install(db_statement: :omit) - - lmdb.database['foo'] = 'bar' - lmdb.database['foo'] - - _(last_span.name).must_equal('GET foo') - _(last_span.kind).must_equal(:client) - _(last_span.attributes['db.system']).must_equal('lmdb') - _(last_span.attributes).wont_include('db.statement') - end - end - - describe '#delete' do - it 'traces' do - lmdb.database['foo'] = 'bar' - lmdb.database.delete('foo') - - _(last_span.name).must_equal('DELETE foo') - _(last_span.kind).must_equal(:client) - _(last_span.attributes['db.system']).must_equal('lmdb') - _(last_span.attributes['db.statement']).must_equal('DELETE foo') - end - - it 'traces with value supplied' do - lmdb.database['foo'] = 'bar' - lmdb.database.delete('foo', 'bar') - - _(last_span.name).must_equal('DELETE foo') - _(last_span.kind).must_equal(:client) - _(last_span.attributes['db.system']).must_equal('lmdb') - _(last_span.attributes['db.statement']).must_equal('DELETE foo bar') - end - - it 'omits db.statement attribute' do - instrumentation.instance_variable_set(:@installed, false) - instrumentation.install(db_statement: :omit) - - lmdb.database['foo'] = 'bar' - lmdb.database.delete('foo') - - _(last_span.name).must_equal('DELETE foo') - _(last_span.kind).must_equal(:client) - _(last_span.attributes['db.system']).must_equal('lmdb') - _(last_span.attributes).wont_include('db.statement') - end - end -end diff --git a/instrumentation/lmdb/test/instrumentation/lmdb/patches/environment_test.rb b/instrumentation/lmdb/test/instrumentation/lmdb/patches/environment_test.rb deleted file mode 100644 index d9bd1cb51b..0000000000 --- a/instrumentation/lmdb/test/instrumentation/lmdb/patches/environment_test.rb +++ /dev/null @@ -1,48 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../lib/opentelemetry/instrumentation/lmdb' -require_relative '../../../../lib/opentelemetry/instrumentation/lmdb/patches/environment' - -describe OpenTelemetry::Instrumentation::LMDB::Patches::Environment do - let(:instrumentation) { OpenTelemetry::Instrumentation::LMDB::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:span) { exporter.finished_spans.first } - let(:last_span) { exporter.finished_spans.last } - - let(:db_path) { File.join(File.dirname(__FILE__), '..', 'tmp', 'test') } - let(:lmdb) { LMDB.new(db_path) } - - before do - exporter.reset - instrumentation.install({}) - FileUtils.rm_rf(db_path) - FileUtils.mkdir_p(db_path) - end - - after do - FileUtils.rm_rf(db_path) - lmdb.close - instrumentation.instance_variable_set(:@installed, false) - end - - describe '#transaction' do - it 'traces' do - lmdb.transaction do - lmdb.database['foo'] = 'bar' - end - - _(span.name).must_equal('PUT foo') - _(span.attributes['db.system']).must_equal 'lmdb' - _(span.attributes['db.statement']).must_equal 'PUT foo bar' - - _(last_span.name).must_equal('TRANSACTION') - _(last_span.attributes['db.system']).must_equal 'lmdb' - end - end -end diff --git a/instrumentation/lmdb/test/test_helper.rb b/instrumentation/lmdb/test/test_helper.rb deleted file mode 100644 index 7b6c80cb81..0000000000 --- a/instrumentation/lmdb/test/test_helper.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 -require 'lmdb' - -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' - -require 'pry' -require 'minitest/autorun' -require 'webmock/minitest' - -# global opentelemetry-sdk setup: -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry::SDK.configure do |c| - c.add_span_processor span_processor -end diff --git a/instrumentation/mongo/.rubocop.yml b/instrumentation/mongo/.rubocop.yml deleted file mode 100644 index 324ff41e67..0000000000 --- a/instrumentation/mongo/.rubocop.yml +++ /dev/null @@ -1,5 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-mongo.rb" diff --git a/instrumentation/mongo/.yardopts b/instrumentation/mongo/.yardopts deleted file mode 100644 index 894ed1e755..0000000000 --- a/instrumentation/mongo/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Mongo Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/mongo/Appraisals b/instrumentation/mongo/Appraisals deleted file mode 100644 index 63b14c31eb..0000000000 --- a/instrumentation/mongo/Appraisals +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -appraise 'mongo-2.13' do - gem 'mongo', '~> 2.13.0' -end diff --git a/instrumentation/mongo/CHANGELOG.md b/instrumentation/mongo/CHANGELOG.md deleted file mode 100644 index cf253314ed..0000000000 --- a/instrumentation/mongo/CHANGELOG.md +++ /dev/null @@ -1,76 +0,0 @@ -# Release History: opentelemetry-instrumentation-mongo - -### v0.20.0 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Broken test file requirements - -### v0.19.0 / 2022-05-02 - -* ADDED: Validate Using Enums -* FIXED: RubyGems Fallback - -### v0.18.4 / 2021-12-02 - -* (No significant changes) - -### v0.18.3 / 2021-09-29 - -* (No significant changes) - -### v0.18.2 / 2021-08-12 - -* FIXED: Flakey mongo test - -### v0.18.1 / 2021-06-23 - -* (No significant changes) - -### v0.18.0 / 2021-05-21 - -* BREAKING CHANGE: Replace Time.now with Process.clock_gettime - -* ADDED: Updated API depedency for 1.0.0.rc1 -* FIXED: Replace Time.now with Process.clock_gettime -* FIXED: Mongodb test asserting error message - -### v0.17.0 / 2021-04-22 - -* ADDED: Mongo instrumentation accepts peer service config attribute. -* FIXED: Fix Mongo instrumentation example. -* FIXED: Refactor propagators to add #fields - -### v0.16.0 / 2021-03-17 - -* FIXED: Example scripts now reference local common lib -* DOCS: Replace Gitter with GitHub Discussions - -### v0.15.0 / 2021-02-18 - -* (No significant changes) - -### v0.14.0 / 2021-02-03 - -* BREAKING CHANGE: Replace getter and setter callables and remove rack specific propagators - -* ADDED: Replace getter and setter callables and remove rack specific propagators - -### v0.13.0 / 2021-01-29 - -* FIXED: Mongo Instrumenter: Do not send nil attributes - -### v0.12.0 / 2020-12-24 - -* (No significant changes) - -### v0.11.0 / 2020-12-11 - -* FIXED: Copyright comments to not reference year - -### v0.10.0 / 2020-12-03 - -* (No significant changes) - -### v0.9.0 / 2020-11-03 - -* Initial release of Mongo instrumenter (ported from Datadog) diff --git a/instrumentation/mongo/Gemfile b/instrumentation/mongo/Gemfile deleted file mode 100644 index eed60fe904..0000000000 --- a/instrumentation/mongo/Gemfile +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -gem 'opentelemetry-api', path: '../../api' -gem 'opentelemetry-instrumentation-base', path: '../base' - -group :test do - gem 'opentelemetry-common', path: '../../common' - gem 'opentelemetry-sdk', path: '../../sdk' - gem 'opentelemetry-semantic_conventions', path: '../../semantic_conventions' - gem 'opentelemetry-test-helpers', path: '../../test_helpers' -end diff --git a/instrumentation/mongo/LICENSE b/instrumentation/mongo/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/mongo/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/mongo/README.md b/instrumentation/mongo/README.md deleted file mode 100644 index 2b65ce9981..0000000000 --- a/instrumentation/mongo/README.md +++ /dev/null @@ -1,64 +0,0 @@ -# OpenTelemetry Mongo Instrumentation - -The OpenTelemetry Mongo Ruby gem is a community maintained instrumentation for [Mongo][mongo-home]. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-mongo -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-mongo` in your `Gemfile`. - -## Usage - -To install the instrumentation, call `use` with the name of the instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Mongo' -end -``` - -Alternatively, you can also call `use_all` to install all the available instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` - -## Example - -To run the example: - -1. Start MongoDB using docker-compose - * `docker-compose up mongo` -2. In a separate terminal window, `cd` to the examples directory and install gems - * `cd example` - * `bundle install` -3. Run the sample client script - * `ruby mongo.rb` - -This will run a few MongoDB commands, printing OpenTelemetry traces to the console as it goes. - -## How can I get involved? - -The `opentelemetry-instrumentation-mongo` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -Apache 2.0 license. See [LICENSE][license-github] for more information. - -[mongo-home]: https://github.com/mongodb/mongo-ruby-driver -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions - diff --git a/instrumentation/mongo/Rakefile b/instrumentation/mongo/Rakefile deleted file mode 100644 index 4b0e9b5a8e..0000000000 --- a/instrumentation/mongo/Rakefile +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] - t.warning = false -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/mongo/example/Gemfile b/instrumentation/mongo/example/Gemfile deleted file mode 100644 index 5c0cf49687..0000000000 --- a/instrumentation/mongo/example/Gemfile +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -source 'https://rubygems.org' - -gem 'mongo' -gem 'opentelemetry-api' -gem 'opentelemetry-instrumentation-mongo' -gem 'opentelemetry-sdk' diff --git a/instrumentation/mongo/example/mongo.rb b/instrumentation/mongo/example/mongo.rb deleted file mode 100755 index 33dc5bb1bd..0000000000 --- a/instrumentation/mongo/example/mongo.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'rubygems' -require 'bundler/setup' - -Bundler.require - -# Export traces to console by default -ENV['OTEL_TRACES_EXPORTER'] ||= 'console' - -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Mongo' -end - -client = Mongo::Client.new(['127.0.0.1:27017'], database: 'otel_test') - -client['people'].insert_one(name: 'Steve', hobbies: ['hiking']) - -client['people'].find(name: 'Steve').first diff --git a/instrumentation/mongo/lib/opentelemetry-instrumentation-mongo.rb b/instrumentation/mongo/lib/opentelemetry-instrumentation-mongo.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/mongo/lib/opentelemetry-instrumentation-mongo.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/mongo/lib/opentelemetry/instrumentation.rb b/instrumentation/mongo/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index e3d6b54caa..0000000000 --- a/instrumentation/mongo/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # "Instrumentation" are specified by - # https://github.com/open-telemetry/opentelemetry-specification/blob/784635d01d8690c8f5fcd1f55bdbc8a13cf2f4f2/specification/glossary.md#instrumentation-library - # - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/mongo' diff --git a/instrumentation/mongo/lib/opentelemetry/instrumentation/mongo.rb b/instrumentation/mongo/lib/opentelemetry/instrumentation/mongo.rb deleted file mode 100644 index 1b51b55a16..0000000000 --- a/instrumentation/mongo/lib/opentelemetry/instrumentation/mongo.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the Mongo gem - module Mongo - end - end -end - -require_relative './mongo/instrumentation' -require_relative './mongo/version' diff --git a/instrumentation/mongo/lib/opentelemetry/instrumentation/mongo/command_serializer.rb b/instrumentation/mongo/lib/opentelemetry/instrumentation/mongo/command_serializer.rb deleted file mode 100644 index 0990bed602..0000000000 --- a/instrumentation/mongo/lib/opentelemetry/instrumentation/mongo/command_serializer.rb +++ /dev/null @@ -1,103 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Mongo - # Serializes a Mongo command object to be added to the trace - class CommandSerializer - MASK_VALUE = '?' - ELLIPSES = '...' - - attr_reader :command, :command_name, :collection, :payload - - def initialize(command) - @command = command - @command_name, @collection = command.first - @collection = MASK_VALUE unless @collection.is_a?(String) || @collection.is_a?(Integer) - @payload = {} - end - - def serialize - build_payload - payload.to_json.freeze unless payload.empty? - end - - private - - def build_payload - build_command - build_updates - build_deletes - build_pipeline - end - - def build_command # rubocop:disable Metrics/AbcSize - add_val(payload, command, 'key') - add_map(payload, command, 'query') - add_map(payload, command, 'filter') - add_val(payload, command, 'sort') - add_val(payload, command, 'new') - add_map(payload, command, 'update') if command_name == 'findAndModify' - add_val(payload, command, 'remove') - end - - def build_updates - updates = command['updates'] - return unless updates - - update = updates[0] - update_payload = {} - add_map(update_payload, update, 'q') - add_map(update_payload, update, 'u') - add_val(update_payload, update, 'multi') - add_val(update_payload, update, 'upsert') - payload['updates'] = [update_payload] - payload['updates'] << ELLIPSES if updates.length > 1 - end - - def build_deletes - deletes = command['deletes'] - return unless deletes - - delete = deletes[0] - delete_payload = {} - add_map(delete_payload, delete, 'q') - add_map(delete_payload, delete, 'limit') - payload['deletes'] = [delete_payload] - payload['deletes'] << ELLIPSES if deletes.length > 1 - end - - def build_pipeline - pipeline = command['pipeline'] - return unless pipeline - - payload['pipeline'] = pipeline.map(&method(:mask)) - end - - def add_val(payload, command, key) - return unless command.key?(key) - - value = command[key] - payload[key] = value - end - - def add_map(payload, command, key) - value = command[key] - return unless value&.is_a?(Hash) && !value.empty? - - payload[key] = mask(value) - end - - def mask(hash) - hash.each_with_object({}) do |(k, v), h| - h[k] = v.is_a?(Hash) ? mask(v) : MASK_VALUE - end - end - end - end - end -end diff --git a/instrumentation/mongo/lib/opentelemetry/instrumentation/mongo/instrumentation.rb b/instrumentation/mongo/lib/opentelemetry/instrumentation/mongo/instrumentation.rb deleted file mode 100644 index e0627ad6c1..0000000000 --- a/instrumentation/mongo/lib/opentelemetry/instrumentation/mongo/instrumentation.rb +++ /dev/null @@ -1,47 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Mongo - # Instrumentation class that detects and installs the Mongo instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - MINIMUM_VERSION = Gem::Version.new('2.5.0') - - install do |_config| - require_dependencies - register_subscriber - end - - present do - !defined?(::Mongo::Monitoring::Global).nil? - end - - compatible do - gem_version >= MINIMUM_VERSION - end - - option :peer_service, default: nil, validate: :string - option :db_statement, default: :include, validate: %I[omit include] - - private - - def gem_version - Gem::Version.new(::Mongo::VERSION) - end - - def require_dependencies - require_relative 'subscriber' - end - - def register_subscriber - # Subscribe to all COMMAND queries with our subscriber class - ::Mongo::Monitoring::Global.subscribe(::Mongo::Monitoring::COMMAND, Subscriber.new) - end - end - end - end -end diff --git a/instrumentation/mongo/lib/opentelemetry/instrumentation/mongo/subscriber.rb b/instrumentation/mongo/lib/opentelemetry/instrumentation/mongo/subscriber.rb deleted file mode 100644 index f01de2e773..0000000000 --- a/instrumentation/mongo/lib/opentelemetry/instrumentation/mongo/subscriber.rb +++ /dev/null @@ -1,105 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative 'command_serializer' - -module OpenTelemetry - module Instrumentation - module Mongo - # Event handler class for Mongo Ruby driver - class Subscriber - THREAD_KEY = :__opentelemetry_mongo_spans__ - - def started(event) # rubocop:disable Metrics/AbcSize - # start a trace and store it in the current thread; using the `operation_id` - # is safe since it's a unique id used to link events together. Also only one - # thread is involved in this execution so thread-local storage should be safe. Reference: - # https://github.com/mongodb/mongo-ruby-driver/blob/master/lib/mongo/monitoring.rb#L70 - # https://github.com/mongodb/mongo-ruby-driver/blob/master/lib/mongo/monitoring/publishable.rb#L38-L56 - - collection = get_collection(event.command) - - attributes = { - 'db.system' => 'mongodb', - 'db.name' => event.database_name, - 'db.operation' => event.command_name, - 'net.peer.name' => event.address.host, - 'net.peer.port' => event.address.port - } - - config = Mongo::Instrumentation.instance.config - attributes['peer.service'] = config[:peer_service] if config[:peer_service] - # attributes['db.statement'] = CommandSerializer.new(event.command).serialize - attributes['db.statement'] = CommandSerializer.new(event.command).serialize if config[:db_statement] == :include - attributes['db.mongodb.collection'] = collection if collection - attributes.compact! - - span = tracer.start_span(span_name(collection, event.command_name), attributes: attributes, kind: :client) - set_span(event, span) - end - - def failed(event) - finish_event('failed', event) do |span| - if event.is_a?(::Mongo::Monitoring::Event::CommandFailed) - span.add_event('exception', - attributes: { - 'exception.type' => 'CommandFailed', - 'exception.message' => event.message - }) - end - end - end - - def succeeded(event) - finish_event('succeeded', event) - end - - private - - def finish_event(name, event) - span = get_span(event) - return unless span - - yield span if block_given? - rescue StandardError => e - OpenTelemetry.logger.debug("error when handling MongoDB '#{name}' event: #{e}") - ensure - # finish span to prevent leak and remove it from thread storage - span&.finish - clear_span(event) - end - - def span_name(collection, command_name) - return command_name unless collection - - "#{collection}.#{command_name}" - end - - def get_collection(command) - collection = command.values.first - collection if collection.is_a?(String) - end - - def get_span(event) - Thread.current[THREAD_KEY]&.[](event.request_id) - end - - def set_span(event, span) - Thread.current[THREAD_KEY] ||= {} - Thread.current[THREAD_KEY][event.request_id] = span - end - - def clear_span(event) - Thread.current[THREAD_KEY]&.delete(event.request_id) - end - - def tracer - Mongo::Instrumentation.instance.tracer - end - end - end - end -end diff --git a/instrumentation/mongo/lib/opentelemetry/instrumentation/mongo/version.rb b/instrumentation/mongo/lib/opentelemetry/instrumentation/mongo/version.rb deleted file mode 100644 index 57ca02b204..0000000000 --- a/instrumentation/mongo/lib/opentelemetry/instrumentation/mongo/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Mongo - VERSION = '0.20.0' - end - end -end diff --git a/instrumentation/mongo/opentelemetry-instrumentation-mongo.gemspec b/instrumentation/mongo/opentelemetry-instrumentation-mongo.gemspec deleted file mode 100644 index 354fc7e640..0000000000 --- a/instrumentation/mongo/opentelemetry-instrumentation-mongo.gemspec +++ /dev/null @@ -1,51 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/mongo/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-mongo' - spec.version = OpenTelemetry::Instrumentation::Mongo::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'Mongo instrumentation for the OpenTelemetry framework' - spec.description = 'Mongo instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.21.0' - - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'mongo', '~> 2.5' - spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' - spec.add_development_dependency 'pry' - spec.add_development_dependency 'pry-byebug' unless RUBY_ENGINE == 'jruby' - spec.add_development_dependency 'rspec-mocks' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'webmock', '~> 3.7.6' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-mongo/v#{OpenTelemetry::Instrumentation::Mongo::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/mongo' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-mongo/v#{OpenTelemetry::Instrumentation::Mongo::VERSION}" - end -end diff --git a/instrumentation/mongo/test/.rubocop.yml b/instrumentation/mongo/test/.rubocop.yml deleted file mode 100644 index e97eda560f..0000000000 --- a/instrumentation/mongo/test/.rubocop.yml +++ /dev/null @@ -1,6 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false -Style/MultilineIfModifier: - Enabled: false diff --git a/instrumentation/mongo/test/opentelemetry/instrumentation/mongo/subscriber_test.rb b/instrumentation/mongo/test/opentelemetry/instrumentation/mongo/subscriber_test.rb deleted file mode 100644 index 0b4b7b47fc..0000000000 --- a/instrumentation/mongo/test/opentelemetry/instrumentation/mongo/subscriber_test.rb +++ /dev/null @@ -1,384 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative '../../../test_helper' - -# require Instrumentation so .install method is found: -require_relative '../../../../lib/opentelemetry/instrumentation/mongo/subscriber' - -describe OpenTelemetry::Instrumentation::Mongo::Subscriber do - let(:instrumentation) { OpenTelemetry::Instrumentation::Mongo::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:spans) { exporter.finished_spans } - let(:span) { exporter.finished_spans.first } - let(:client) { TestHelper.client } - let(:collection) { :artists } - let(:config) { {} } - - before do - # Clear previous instrumentation subscribers between test runs - Mongo::Monitoring::Global.subscribers['Command'] = [] - instrumentation.install(config) - exporter.reset - - TestHelper.setup_mongo - - # this is currently a noop but this will future proof the test - @orig_propagation = OpenTelemetry.propagation - propagator = OpenTelemetry::Trace::Propagation::TraceContext.text_map_propagator - OpenTelemetry.propagation = propagator - end - - after do - instrumentation.instance_variable_set(:@installed, false) - OpenTelemetry.propagation = @orig_propagation - TestHelper.teardown_mongo - end - - module MongoTraceTest - it 'has basic properties' do - _(spans.size).must_equal 1 - _(span.attributes['db.system']).must_equal 'mongodb' - _(span.attributes['db.name']).must_equal TestHelper.database - _(span.attributes['net.peer.name']).must_equal TestHelper.host - _(span.attributes['net.peer.port']).must_equal TestHelper.port - end - end - - describe '#insert_one operation' do - before { client[collection].insert_one(params) } - - describe 'for a basic document' do - let(:params) { { name: 'FKA Twigs' } } - - include MongoTraceTest - - it 'has operation-specific properties' do - _(span.name).must_equal 'artists.insert' - _(span.attributes['db.operation']).must_equal 'insert' - _(span.attributes['db.mongodb.collection']).must_equal 'artists' - refute(span.attributes.key?('db.statement')) - end - end - - describe 'for a document with an array' do - let(:params) { { name: 'Steve', hobbies: ['hiking', 'tennis', 'fly fishing'] } } - let(:collection) { :people } - - include MongoTraceTest - - it 'has operation-specific properties' do - _(span.name).must_equal 'people.insert' - _(span.attributes['db.operation']).must_equal 'insert' - _(span.attributes['db.mongodb.collection']).must_equal 'people' - refute(span.attributes.key?('db.statement')) - end - end - end - - describe 'when peer service has been set in config' do - let(:params) { { name: 'FKA Twigs' } } - let(:config) { { peer_service: 'example:mongo' } } - - include MongoTraceTest - - before do - client[collection].insert_one(params) - end - - it 'includes it in the span attributes' do - _(span.attributes['peer.service']).must_equal 'example:mongo' - end - end - - describe '#insert_many operation' do - before { client[collection].insert_many(params) } - - describe 'for documents with arrays' do - let(:params) do - [ - { name: 'Steve', hobbies: ['hiking', 'tennis', 'fly fishing'] }, - { name: 'Sally', hobbies: ['skiing', 'stamp collecting'] } - ] - end - - let(:collection) { :people } - - include MongoTraceTest - - it 'has operation-specific properties' do - _(span.name).must_equal 'people.insert' - _(span.attributes['db.operation']).must_equal 'insert' - _(span.attributes['db.mongodb.collection']).must_equal 'people' - refute(span.attributes.key?('db.statement')) - end - end - end - - describe '#find_all operation' do - let(:collection) { :people } - - before do - # insert a document - client[collection].insert_one(name: 'Steve', hobbies: ['hiking', 'tennis', 'fly fishing']) - exporter.reset - - # do #find_all operation - client[collection].find.each do |document| - # => yields a BSON::Document. - end - end - - include MongoTraceTest - - it 'has operation-specific properties' do - _(span.name).must_equal 'people.find' - _(span.attributes['db.operation']).must_equal 'find' - _(span.attributes['db.mongodb.collection']).must_equal 'people' - refute(span.attributes.key?('db.statement')) - end - end - - describe '#find operation' do - let(:collection) { :people } - - before do - # insert a document - client[collection].insert_one(name: 'Steve', hobbies: ['hiking']) - exporter.reset - - # do #find operation - result = client[collection].find(name: 'Steve').first[:hobbies] - _(result).must_equal ['hiking'] - end - - include MongoTraceTest - - it 'has operation-specific properties' do - _(span.name).must_equal 'people.find' - _(span.attributes['db.operation']).must_equal 'find' - _(span.attributes['db.mongodb.collection']).must_equal 'people' - _(span.attributes['db.statement']).must_equal '{"filter":{"name":"?"}}' - end - end - - describe '#update_one operation' do - let(:collection) { :people } - - before do - # insert a document - client[collection].insert_one(name: 'Sally', hobbies: ['skiing', 'stamp collecting']) - exporter.reset - - # do #update_one operation - client[collection].update_one({ name: 'Sally' }, '$set' => { 'phone_number' => '555-555-5555' }) - end - - include MongoTraceTest - - it 'has operation-specific properties' do - _(span.name).must_equal 'people.update' - _(span.attributes['db.operation']).must_equal 'update' - _(span.attributes['db.mongodb.collection']).must_equal 'people' - _(span.attributes['db.statement']).must_equal '{"updates":[{"q":{"name":"?"},"u":{"$set":{"phone_number":"?"}}}]}' - end - - it 'correctly performs operation' do - _(client[collection].find(name: 'Sally').first[:phone_number]).must_equal '555-555-5555' - end - end - - describe '#update_many operation' do - let(:collection) { :people } - let(:documents) do - [ - { name: 'Steve', hobbies: ['hiking', 'tennis', 'fly fishing'] }, - { name: 'Sally', hobbies: ['skiing', 'stamp collecting'] } - ] - end - - before do - # insert documents - client[collection].insert_many(documents) - exporter.reset - - # do #update_many operation - client[collection].update_many({}, '$set' => { 'phone_number' => '555-555-5555' }) - end - - include MongoTraceTest - - it 'has operation-specific properties' do - _(span.name).must_equal 'people.update' - _(span.attributes['db.operation']).must_equal 'update' - _(span.attributes['db.mongodb.collection']).must_equal 'people' - _(span.attributes['db.statement']).must_equal '{"updates":[{"u":{"$set":{"phone_number":"?"}},"multi":true}]}' - end - - it 'correctly performs operation' do - documents.each do |d| - _(client[collection].find(name: d[:name]).first[:phone_number]).must_equal '555-555-5555' - end - end - end - - describe '#delete_one operation' do - let(:collection) { :people } - - before do - # insert a document - client[collection].insert_one(name: 'Sally', hobbies: ['skiing', 'stamp collecting']) - exporter.reset - - # do #delete_one operation - client[collection].delete_one(name: 'Sally') - end - - include MongoTraceTest - - it 'has operation-specific properties' do - _(span.name).must_equal 'people.delete' - _(span.attributes['db.operation']).must_equal 'delete' - _(span.attributes['db.mongodb.collection']).must_equal 'people' - _(span.attributes['db.statement']).must_equal '{"deletes":[{"q":{"name":"?"}}]}' - end - - it 'correctly performs operation' do - _(client[collection].find(name: 'Sally').count).must_equal 0 - end - end - - describe '#delete_many operation' do - let(:collection) { :people } - let(:documents) do - [ - { name: 'Steve', hobbies: ['hiking', 'tennis', 'fly fishing'] }, - { name: 'Sally', hobbies: ['skiing', 'stamp collecting'] } - ] - end - - before do - # insert documents - client[collection].insert_many(documents) - exporter.reset - - # do #delete_many operation - client[collection].delete_many(name: /$S*/) - end - - include MongoTraceTest - - it 'has operation-specific properties' do - _(span.name).must_equal 'people.delete' - _(span.attributes['db.operation']).must_equal 'delete' - _(span.attributes['db.mongodb.collection']).must_equal 'people' - _(span.attributes['db.statement']).must_equal '{"deletes":[{"q":{"name":"?"}}]}' - end - - it 'correctly performs operation' do - documents.each do |d| - _(client[collection].find(name: d[:name]).count).must_equal 0 - end - end - end - - describe '#drop operation' do - let(:collection) { 1 } # because drop operation doesn't have a collection - - before { client.database.drop } - - include MongoTraceTest - - it 'has operation-specific properties' do - _(span.name).must_equal 'dropDatabase' - _(span.attributes['db.operation']).must_equal 'dropDatabase' - refute(span.attributes.key?('db.mongodb.collection')) - refute(span.attributes.key?('db.statement')) - end - end - - describe 'db_statement option' do - let(:collection) { :people } - let(:config) { { db_statement: :omit } } - - before do - # insert a document - client[collection].insert_one(name: 'Steve', hobbies: ['hiking']) - exporter.reset - - # do #find operation - result = client[collection].find(name: 'Steve').first[:hobbies] - _(result).must_equal ['hiking'] - end - - it 'omits db.statement attribute' do - _(span.name).must_equal 'people.find' - _(span.attributes['db.operation']).must_equal 'find' - _(span.attributes['db.mongodb.collection']).must_equal 'people' - _(span.attributes).wont_include 'db.statement' - end - end - - describe 'a failed query' do - before { client[:artists].drop } - - include MongoTraceTest - - it 'has operation-specific properties' do - _(span.name).must_equal 'artists.drop' - _(span.attributes['db.operation']).must_equal 'drop' - _(span.attributes['db.mongodb.collection']).must_equal 'artists' - refute(span.attributes.key?('db.statement')) - _(span.events.size).must_equal 1 - _(span.events[0].name).must_equal 'exception' - _(span.events[0].timestamp).must_be_kind_of Integer - _(span.events[0].attributes['exception.type']).must_equal 'CommandFailed' - _(span.events[0].attributes['exception.message']).must_equal 'ns not found (26)' - end - - describe 'that triggers #failed before #started' do - let(:subscriber) { OpenTelemetry::Instrumentation::Mongo::Subscriber.new } - let(:failed_event) { subscriber.failed(event) } - let(:event) { instance_double(Mongo::Monitoring::Event::CommandFailed, request_id: double('request_id')) } - - it 'does not raise error even when thread is cleared' do - Thread.current[:__opentelemetry_mongo_spans__] = nil - failed_event - end - end - end - - describe 'with LDAP/SASL authentication' do - let(:client) { Mongo::Client.new(["#{TestHelper.host}:#{TestHelper.port}"], client_options) } - let(:client_options) do - { - database: TestHelper.database, - auth_mech: :plain, - user: 'plain_user', - password: 'plain_pass' - } - end - - describe 'which fails' do - before do - client[collection].insert_one(name: 'Steve', hobbies: ['hiking']) - rescue Mongo::Auth::Unauthorized - nil - end - - it 'produces spans for command and authentication' do - _(spans.size).must_equal 1 - _(span.name).must_equal 'saslStart' - _(span.attributes['db.operation']).must_equal 'saslStart' - _(span.events.size).must_equal 1 - _(span.events[0].name).must_equal 'exception' - _(span.events[0].timestamp).must_be_kind_of Integer - _(span.events[0].attributes['exception.type']).must_equal 'CommandFailed' - _(span.events[0].attributes['exception.message']).must_match(/mechanism.+PLAIN./) - end - end - end -end unless ENV['OMIT_SERVICES'] diff --git a/instrumentation/mongo/test/opentelemetry/instrumentation/mongo_test.rb b/instrumentation/mongo/test/opentelemetry/instrumentation/mongo_test.rb deleted file mode 100644 index 2fdf4a32be..0000000000 --- a/instrumentation/mongo/test/opentelemetry/instrumentation/mongo_test.rb +++ /dev/null @@ -1,78 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 -require_relative '../../test_helper' - -describe OpenTelemetry::Instrumentation::Mongo do - let(:instrumentation) { OpenTelemetry::Instrumentation::Mongo::Instrumentation.instance } - let(:exporter) { EXPORTER } - - before do - # Clear previous instrumentation subscribers between test runs - Mongo::Monitoring::Global.subscribers['Command'] = [] if defined?(::Mongo::Monitoring::Global) - instrumentation.install - exporter.reset - end - - after do - instrumentation.instance_variable_set(:@installed, false) - end - - describe 'present' do - it 'when mongo gem installed' do - _(instrumentation.present?).must_equal true - end - - it 'when mongo gem not installed' do - hide_const('Mongo') - _(instrumentation.present?).must_equal false - end - end - - describe 'compatible' do - it 'when older gem version installed' do - stub_const('::Mongo::VERSION', '2.4.3') - _(instrumentation.compatible?).must_equal false - end - - it 'when future gem version installed' do - _(instrumentation.compatible?).must_equal true - end - end - - describe 'install' do - it 'installs the subscriber' do - klass = OpenTelemetry::Instrumentation::Mongo::Subscriber - subscribers = Mongo::Monitoring::Global.subscribers['Command'] - - _(subscribers.size).must_equal 1 - _(subscribers.first).must_be_kind_of klass - end - end - - describe 'tracing' do - before do - TestHelper.setup_mongo - end - - after do - TestHelper.teardown_mongo - end - - it 'before job' do - _(exporter.finished_spans.size).must_equal 0 - end - - it 'after job' do - client = TestHelper.client - - client['people'].insert_one(name: 'Steve', hobbies: ['hiking']) - _(exporter.finished_spans.size).must_equal 1 - - client['people'].find(name: 'Steve').first - _(exporter.finished_spans.size).must_equal 2 - end - end unless ENV['OMIT_SERVICES'] -end diff --git a/instrumentation/mongo/test/test_helper.rb b/instrumentation/mongo/test/test_helper.rb deleted file mode 100644 index e5b1adad94..0000000000 --- a/instrumentation/mongo/test/test_helper.rb +++ /dev/null @@ -1,58 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'pry' -require 'mongo' - -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' - -require 'minitest/autorun' -require 'rspec/mocks/minitest_integration' -require 'webmock/minitest' - -require_relative '../lib/opentelemetry-instrumentation-mongo' - -# global opentelemetry-sdk setup: -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry::SDK.configure do |c| - c.add_span_processor span_processor -end - -class Module - include Minitest::Spec::DSL -end - -module TestHelper - extend self - - def setup_mongo - Mongo::Logger.logger.level = ::Logger::WARN - client - end - - def teardown_mongo - client.database.drop - end - - def client - @client ||= Mongo::Client.new(["#{host}:#{port}"], database: database) - end - - def database - 'otel_test' - end - - def host - ENV.fetch('TEST_MONGODB_HOST', '127.0.0.1') - end - - def port - ENV.fetch('TEST_MONGODB_PORT', 27_017).to_i - end -end diff --git a/instrumentation/mysql2/.rubocop.yml b/instrumentation/mysql2/.rubocop.yml deleted file mode 100644 index 6ff74c04ed..0000000000 --- a/instrumentation/mysql2/.rubocop.yml +++ /dev/null @@ -1,5 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-mysql2.rb" diff --git a/instrumentation/mysql2/.yardopts b/instrumentation/mysql2/.yardopts deleted file mode 100644 index 02a9acb21f..0000000000 --- a/instrumentation/mysql2/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Mysql2 Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/mysql2/Appraisals b/instrumentation/mysql2/Appraisals deleted file mode 100644 index 71b5ab2255..0000000000 --- a/instrumentation/mysql2/Appraisals +++ /dev/null @@ -1,5 +0,0 @@ -# frozen_string_literal: true - -appraise 'mysql2-0.4.0' do - gem 'mysql2' -end diff --git a/instrumentation/mysql2/CHANGELOG.md b/instrumentation/mysql2/CHANGELOG.md deleted file mode 100644 index 1965967f74..0000000000 --- a/instrumentation/mysql2/CHANGELOG.md +++ /dev/null @@ -1,94 +0,0 @@ -# Release History: opentelemetry-instrumentation-mysql2 - -### v0.21.0 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Broken test file requirements - -### v0.20.1 / 2022-05-03 - -* ADDED: `with_attributes` method for context propagation - -### v0.20.0 / 2021-12-01 - -* ADDED: Add default options config helper + env var config option support - -### v0.19.1 / 2021-09-29 - -* (No significant changes) - -### v0.19.0 / 2021-08-12 - -* BREAKING CHANGE: Add option for db.statement - -* ADDED: Add option for db.statement -* DOCS: Update docs to rely more on environment variable configuration -* DOCS: Move to using new db_statement - -### v0.18.1 / 2021-06-23 - -* (No significant changes) - -### v0.18.0 / 2021-05-21 - -* ADDED: Updated API depedency for 1.0.0.rc1 -* Fix: Nil value for db.name attribute #744 - -### v0.17.0 / 2021-04-22 - -* (No significant changes) - -### v0.16.0 / 2021-03-17 - -* FIXED: Update DB semantic conventions -* FIXED: Example scripts now reference local common lib -* ADDED: Configurable obfuscation of sql in mysql2 instrumentation to avoid logging sensitive data - -### v0.15.0 / 2021-02-18 - -* ADDED: Add instrumentation config validation - -### v0.14.0 / 2021-02-03 - -* (No significant changes) - -### v0.13.0 / 2021-01-29 - -* (No significant changes) - -### v0.12.0 / 2020-12-24 - -* (No significant changes) - -### v0.11.0 / 2020-12-11 - -* ADDED: Add peer service config to mysql -* FIXED: Copyright comments to not reference year - -### v0.10.1 / 2020-12-09 - -* FIXED: Semantic conventions db.type -> db.system - -### v0.10.0 / 2020-12-03 - -* (No significant changes) - -### v0.9.0 / 2020-11-27 - -* BREAKING CHANGE: Add timeout for force_flush and shutdown - -* ADDED: Add timeout for force_flush and shutdown - -### v0.8.0 / 2020-10-27 - -* BREAKING CHANGE: Remove 'canonical' from status codes - -* FIXED: Remove 'canonical' from status codes - -### v0.7.0 / 2020-10-07 - -* DOCS: Standardize toplevel docs structure and readme - -### v0.6.0 / 2020-09-10 - -* (No significant changes) diff --git a/instrumentation/mysql2/Gemfile b/instrumentation/mysql2/Gemfile deleted file mode 100644 index b2f83af8da..0000000000 --- a/instrumentation/mysql2/Gemfile +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :test, :development do - gem 'opentelemetry-instrumentation-base', path: '../base' -end diff --git a/instrumentation/mysql2/LICENSE b/instrumentation/mysql2/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/mysql2/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/mysql2/README.md b/instrumentation/mysql2/README.md deleted file mode 100644 index 8ae6b6f4c7..0000000000 --- a/instrumentation/mysql2/README.md +++ /dev/null @@ -1,76 +0,0 @@ -# OpenTelemetry Mysql2 Instrumentation - -The OpenTelemetry Mysql2 Ruby gem is a community maintained instrumentation for [Mysql2][mysql2-home]. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-mysql2 -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-mysql2` in your `Gemfile`. - -## Usage - -To use the instrumentation, call `use` with the name of the instrumentation: - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Mysql2' -end -``` - -Alternatively, you can also call `use_all` to install all the available instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` - -The `mysql2` instrumentation allows the user to supply additional attributes via the `with_attributes` method. This makes it possible to supply additional attributes on mysql2 spans. Attributes supplied in `with_attributes` supersede those automatically generated within `mysql2`'s automatic instrumentation. If you supply a `db.statement` attribute in `with_attributes`, this library's `:db_statement` configuration will not be applied. - -```ruby -require 'opentelemetry/instrumentation/mysql2' - -client = Mysql2::Client.new(:host => "localhost", :username => "root") -OpenTelemetry::Instrumentation::Mysql2.with_attributes('pizzatoppings' => 'mushrooms') do - client.query("SELECT 1") -end -``` - -### Configuration options - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Mysql2', { - # The obfuscation of SQL in the db.statement attribute is disabled by default. - # To enable, set db_statement to :obfuscate. - db_statement: :obfuscate, - } -end -``` - -## Examples - -An example of usage can be seen in [`example/mysql2.rb`](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/instrumentation/mysql2/example/mysql2.rb). - -## How can I get involved? - -The `opentelemetry-instrumentation-mysql2` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us on our [gitter channel][ruby-gitter] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -The `opentelemetry-instrumentation-mysql2` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information. - -[mysql2-home]: https://github.com/brianmario/mysql2 -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[ruby-gitter]: https://gitter.im/open-telemetry/opentelemetry-ruby diff --git a/instrumentation/mysql2/Rakefile b/instrumentation/mysql2/Rakefile deleted file mode 100644 index 1a64ba842e..0000000000 --- a/instrumentation/mysql2/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/mysql2/example/Gemfile b/instrumentation/mysql2/example/Gemfile deleted file mode 100644 index 7960d8db8c..0000000000 --- a/instrumentation/mysql2/example/Gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -source 'https://rubygems.org' - -gem 'mysql2' -gem 'opentelemetry-api' -gem 'opentelemetry-common' -gem 'opentelemetry-instrumentation-mysql2' -gem 'opentelemetry-sdk' diff --git a/instrumentation/mysql2/example/mysql2.rb b/instrumentation/mysql2/example/mysql2.rb deleted file mode 100644 index 437cec6dc4..0000000000 --- a/instrumentation/mysql2/example/mysql2.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -require 'rubygems' -require 'bundler/setup' - -Bundler.require - -ENV['OTEL_TRACES_EXPORTER'] = 'console' -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Mysql2' -end - -client = Mysql2::Client.new( - host: ENV.fetch('TEST_MYSQL_HOST') { '127.0.0.1' }, - port: ENV.fetch('TEST_MYSQL_PORT') { '3306' }, - database: ENV.fetch('TEST_MYSQL_DB') { 'mysql' }, - username: ENV.fetch('TEST_MYSQL_USER') { 'root' }, - password: ENV.fetch('TEST_MYSQL_PASSWORD') { 'root' } -) - -client.query("SELECT * FROM users WHERE group='x'") diff --git a/instrumentation/mysql2/lib/opentelemetry-instrumentation-mysql2.rb b/instrumentation/mysql2/lib/opentelemetry-instrumentation-mysql2.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/mysql2/lib/opentelemetry-instrumentation-mysql2.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/mysql2/lib/opentelemetry/instrumentation.rb b/instrumentation/mysql2/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index da7fc93b1e..0000000000 --- a/instrumentation/mysql2/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # "Instrumentation" are specified by - # https://github.com/open-telemetry/opentelemetry-specification/blob/784635d01d8690c8f5fcd1f55bdbc8a13cf2f4f2/specification/glossary.md#instrumentation-library - # - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/mysql2' diff --git a/instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2.rb b/instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2.rb deleted file mode 100644 index 0df3f94c6f..0000000000 --- a/instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2.rb +++ /dev/null @@ -1,58 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the Mysql2 gem - module Mysql2 - extend self - - CURRENT_ATTRIBUTES_KEY = Context.create_key('mysql-attributes-hash') - - private_constant :CURRENT_ATTRIBUTES_KEY - - # Returns the attributes hash representing the Mysql2 context found - # in the optional context or the current context if none is provided. - # - # @param [optional Context] context The context to lookup the current - # attributes hash. Defaults to Context.current - def attributes(context = nil) - context ||= Context.current - context.value(CURRENT_ATTRIBUTES_KEY) || {} - end - - # Returns a context containing the merged attributes hash, derived from the - # optional parent context, or the current context if one was not provided. - # - # @param [optional Context] context The context to use as the parent for - # the returned context - def context_with_attributes(attributes_hash, parent_context: Context.current) - attributes_hash = attributes(parent_context).merge(attributes_hash) - parent_context.set_value(CURRENT_ATTRIBUTES_KEY, attributes_hash) - end - - # Activates/deactivates the merged attributes hash within the current Context, - # which makes the "current attributes hash" available implicitly. - # - # On exit, the attributes hash that was active before calling this method - # will be reactivated. - # - # @param [Span] span the span to activate - # @yield [Hash, Context] yields attributes hash and a context containing the - # attributes hash to the block. - def with_attributes(attributes_hash) - attributes_hash = attributes.merge(attributes_hash) - Context.with_value(CURRENT_ATTRIBUTES_KEY, attributes_hash) { |c, h| yield h, c } - end - end - end -end - -require_relative './mysql2/instrumentation' -require_relative './mysql2/version' diff --git a/instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2/instrumentation.rb b/instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2/instrumentation.rb deleted file mode 100644 index e8d28a5168..0000000000 --- a/instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2/instrumentation.rb +++ /dev/null @@ -1,46 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Mysql2 - # The Instrumentation class contains logic to detect and install the Mysql2 - # instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - install do |config| - if config[:enable_sql_obfuscation] - config[:db_statement] = :obfuscate - OpenTelemetry.logger.warn( - 'Instrumentation mysql2 configuration option enable_sql_obfuscation has been deprecated,' \ - 'use db_statement option instead' - ) - end - - require_dependencies - patch_client - end - - present do - defined?(::Mysql2) - end - - option :peer_service, default: nil, validate: :string - option :enable_sql_obfuscation, default: false, validate: :boolean - option :db_statement, default: :include, validate: %I[omit include obfuscate] - - private - - def require_dependencies - require_relative 'patches/client' - end - - def patch_client - ::Mysql2::Client.prepend(Patches::Client) - end - end - end - end -end diff --git a/instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2/patches/client.rb b/instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2/patches/client.rb deleted file mode 100644 index 37a0beb569..0000000000 --- a/instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2/patches/client.rb +++ /dev/null @@ -1,150 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Mysql2 - module Patches - # Module to prepend to Mysql2::Client for instrumentation - module Client - QUERY_NAMES = [ - 'set names', - 'select', - 'insert', - 'update', - 'delete', - 'begin', - 'commit', - 'rollback', - 'savepoint', - 'release savepoint', - 'explain', - 'drop database', - 'drop table', - 'create database', - 'create table' - ].freeze - - QUERY_NAME_RE = Regexp.new("^(#{QUERY_NAMES.join('|')})", Regexp::IGNORECASE) - - COMPONENTS_REGEX_MAP = { - single_quotes: /'(?:[^']|'')*?(?:\\'.*|'(?!'))/, - double_quotes: /"(?:[^"]|"")*?(?:\\".*|"(?!"))/, - numeric_literals: /-?\b(?:[0-9]+\.)?[0-9]+([eE][+-]?[0-9]+)?\b/, - boolean_literals: /\b(?:true|false|null)\b/i, - hexadecimal_literals: /0x[0-9a-fA-F]+/, - comments: /(?:#|--).*?(?=\r|\n|$)/i, - multi_line_comments: %r{\/\*(?:[^\/]|\/[^*])*?(?:\*\/|\/\*.*)} - }.freeze - - MYSQL_COMPONENTS = %i[ - single_quotes - double_quotes - numeric_literals - boolean_literals - hexadecimal_literals - comments - multi_line_comments - ].freeze - - def query(sql, options = {}) - attributes = client_attributes - case config[:db_statement] - when :include - attributes['db.statement'] = sql - when :obfuscate - attributes['db.statement'] = obfuscate_sql(sql) - end - tracer.in_span( - database_span_name(sql), - attributes: attributes.merge!(OpenTelemetry::Instrumentation::Mysql2.attributes), - kind: :client - ) do - super(sql, options) - end - end - - private - - def obfuscate_sql(sql) - if sql.size > 2000 - 'SQL query too large to remove sensitive data ...' - else - obfuscated = sql.gsub(generated_mysql_regex, '?') - obfuscated = 'Failed to obfuscate SQL query - quote characters remained after obfuscation' if detect_unmatched_pairs(obfuscated) - obfuscated - end - end - - def generated_mysql_regex - @generated_mysql_regex ||= Regexp.union(MYSQL_COMPONENTS.map { |component| COMPONENTS_REGEX_MAP[component] }) - end - - def detect_unmatched_pairs(obfuscated) - # We use this to check whether the query contains any quote characters - # after obfuscation. If so, that's a good indication that the original - # query was malformed, and so our obfuscation can't reliably find - # literals. In such a case, we'll replace the entire query with a - # placeholder. - %r{'|"|\/\*|\*\/}.match(obfuscated) - end - - def database_span_name(sql) - # Setting span name to the SQL query without obfuscation would - # result in PII + cardinality issues. - # First attempt to infer the statement type then fallback to - # current Otel approach {database.component_name}.{database_instance_name} - # https://github.com/open-telemetry/opentelemetry-python/blob/39fa078312e6f41c403aa8cad1868264011f7546/ext/opentelemetry-ext-dbapi/tests/test_dbapi_integration.py#L53 - # This creates span names like mysql.default, mysql.replica, postgresql.staging etc. - - statement_type = extract_statement_type(sql) - - return statement_type unless statement_type.nil? - - # fallback - database_name ? "mysql.#{database_name}" : 'mysql' - end - - def database_name - # https://github.com/brianmario/mysql2/blob/ca08712c6c8ea672df658bb25b931fea22555f27/lib/mysql2/client.rb#L78 - (query_options[:database] || query_options[:dbname] || query_options[:db])&.to_s - end - - def client_attributes - # The client specific attributes can be found via the query_options instance variable - # exposed on the mysql2 Client - # https://github.com/brianmario/mysql2/blob/ca08712c6c8ea672df658bb25b931fea22555f27/lib/mysql2/client.rb#L25-L26 - host = (query_options[:host] || query_options[:hostname]).to_s - port = query_options[:port].to_s - - attributes = { - 'db.system' => 'mysql', - 'net.peer.name' => host, - 'net.peer.port' => port - } - attributes['db.name'] = database_name if database_name - attributes['peer.service'] = config[:peer_service] if config[:peer_service] - attributes - end - - def tracer - Mysql2::Instrumentation.instance.tracer - end - - def config - Mysql2::Instrumentation.instance.config - end - - def extract_statement_type(sql) - QUERY_NAME_RE.match(sql) { |match| match[1].downcase } unless sql.nil? - rescue StandardError => e - OpenTelemetry.logger.debug("Error extracting sql statement type: #{e.message}") - end - end - end - end - end -end diff --git a/instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2/version.rb b/instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2/version.rb deleted file mode 100644 index f0dc9c0ae1..0000000000 --- a/instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Mysql2 - VERSION = '0.21.0' - end - end -end diff --git a/instrumentation/mysql2/opentelemetry-instrumentation-mysql2.gemspec b/instrumentation/mysql2/opentelemetry-instrumentation-mysql2.gemspec deleted file mode 100644 index 374e480ae7..0000000000 --- a/instrumentation/mysql2/opentelemetry-instrumentation-mysql2.gemspec +++ /dev/null @@ -1,50 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/mysql2/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-mysql2' - spec.version = OpenTelemetry::Instrumentation::Mysql2::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'Mysql2 instrumentation for the OpenTelemetry framework' - spec.description = 'Mysql2 instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.21.0' - - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'mysql2', '>= 0.4.0' - spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'pry' - spec.add_development_dependency 'pry-byebug' unless RUBY_ENGINE == 'jruby' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-mysql2/v#{OpenTelemetry::Instrumentation::Mysql2::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/mysql2' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-mysql2/v#{OpenTelemetry::Instrumentation::Mysql2::VERSION}" - end -end diff --git a/instrumentation/mysql2/test/.rubocop.yml b/instrumentation/mysql2/test/.rubocop.yml deleted file mode 100644 index e97eda560f..0000000000 --- a/instrumentation/mysql2/test/.rubocop.yml +++ /dev/null @@ -1,6 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false -Style/MultilineIfModifier: - Enabled: false diff --git a/instrumentation/mysql2/test/opentelemetry/instrumentation/mysql2/instrumentation_test.rb b/instrumentation/mysql2/test/opentelemetry/instrumentation/mysql2/instrumentation_test.rb deleted file mode 100644 index 697cd04928..0000000000 --- a/instrumentation/mysql2/test/opentelemetry/instrumentation/mysql2/instrumentation_test.rb +++ /dev/null @@ -1,301 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' -require 'mysql2' - -require_relative '../../../../lib/opentelemetry/instrumentation/mysql2' -require_relative '../../../../lib/opentelemetry/instrumentation/mysql2/patches/client' - -# This test suite requires a running mysql container and dedicated test container -# To run tests: -# 1. Build the opentelemetry/opentelemetry-ruby image -# - docker-compose build -# 2. Bundle install -# - docker-compose run ex-instrumentation-mysql2-test bundle install -# 3. Run test suite -# - docker-compose run ex-instrumentation-mysql2-test bundle exec rake test -describe OpenTelemetry::Instrumentation::Mysql2::Instrumentation do - let(:instrumentation) { OpenTelemetry::Instrumentation::Mysql2::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:span) { exporter.finished_spans.first } - let(:config) { {} } - - before do - exporter.reset - end - - after do - # Force re-install of instrumentation - instrumentation.instance_variable_set(:@installed, false) - end - - describe 'tracing' do - let(:client) do - ::Mysql2::Client.new( - host: host, - port: port, - database: database, - username: username, - password: password - ) - end - - let(:host) { ENV.fetch('TEST_MYSQL_HOST') { '127.0.0.1' } } - let(:port) { ENV.fetch('TEST_MYSQL_PORT') { '3306' } } - let(:database) { ENV.fetch('TEST_MYSQL_DB') { 'mysql' } } - let(:username) { ENV.fetch('TEST_MYSQL_USER') { 'root' } } - let(:password) { ENV.fetch('TEST_MYSQL_PASSWORD') { 'root' } } - - before do - instrumentation.install(config) - end - - it 'before request' do - _(exporter.finished_spans.size).must_equal 0 - end - - it 'accepts peer service name from config' do - instrumentation.instance_variable_set(:@installed, false) - instrumentation.install(peer_service: 'readonly:mysql') - client.query('SELECT 1') - - _(span.attributes['peer.service']).must_equal 'readonly:mysql' - end - - describe '.attributes' do - let(:attributes) { { 'db.statement' => 'foobar' } } - - it 'returns an empty hash by default' do - _(OpenTelemetry::Instrumentation::Mysql2.attributes).must_equal({}) - end - - it 'returns the current attributes hash' do - OpenTelemetry::Instrumentation::Mysql2.with_attributes(attributes) do - _(OpenTelemetry::Instrumentation::Mysql2.attributes).must_equal(attributes) - end - end - - it 'sets span attributes according to with_attributes hash' do - OpenTelemetry::Instrumentation::Mysql2.with_attributes(attributes) do - client.query('SELECT 1') - end - - _(span.attributes['db.statement']).must_equal 'foobar' - end - end - - it 'after requests' do - client.query('SELECT 1') - - _(span.name).must_equal 'select' - _(span.attributes['db.system']).must_equal 'mysql' - _(span.attributes['db.name']).must_equal 'mysql' - _(span.attributes['db.statement']).must_equal 'SELECT 1' - _(span.attributes['net.peer.name']).must_equal host.to_s - _(span.attributes['net.peer.port']).must_equal port.to_s - end - - it 'after error' do - expect do - client.query('SELECT INVALID') - end.must_raise Mysql2::Error - - _(span.name).must_equal 'select' - _(span.attributes['db.system']).must_equal 'mysql' - _(span.attributes['db.name']).must_equal 'mysql' - _(span.attributes['db.statement']).must_equal 'SELECT INVALID' - _(span.attributes['net.peer.name']).must_equal host.to_s - _(span.attributes['net.peer.port']).must_equal port.to_s - - _(span.status.code).must_equal( - OpenTelemetry::Trace::Status::ERROR - ) - _(span.events.first.name).must_equal 'exception' - _(span.events.first.attributes['exception.type']).must_equal 'Mysql2::Error' - assert(!span.events.first.attributes['exception.message'].nil?) - assert(!span.events.first.attributes['exception.stacktrace'].nil?) - end - - it 'extracts statement type that begins the query' do - base_sql = 'SELECT 1' - explain = 'EXPLAIN' - explain_sql = "#{explain} #{base_sql}" - client.query(explain_sql) - - _(span.name).must_equal 'explain' - _(span.attributes['db.system']).must_equal 'mysql' - _(span.attributes['db.name']).must_equal 'mysql' - _(span.attributes['db.statement']).must_equal explain_sql - _(span.attributes['net.peer.name']).must_equal host.to_s - _(span.attributes['net.peer.port']).must_equal port.to_s - end - - it 'uses component.name and instance.name as span.name fallbacks with invalid sql' do - expect do - client.query('DESELECT 1') - end.must_raise Mysql2::Error - - _(span.name).must_equal 'mysql.mysql' - _(span.attributes['db.system']).must_equal 'mysql' - _(span.attributes['db.name']).must_equal 'mysql' - _(span.attributes['db.statement']).must_equal 'DESELECT 1' - _(span.attributes['net.peer.name']).must_equal host.to_s - _(span.attributes['net.peer.port']).must_equal port.to_s - - _(span.status.code).must_equal( - OpenTelemetry::Trace::Status::ERROR - ) - _(span.events.first.name).must_equal 'exception' - _(span.events.first.attributes['exception.type']).must_equal 'Mysql2::Error' - assert(!span.events.first.attributes['exception.message'].nil?) - assert(!span.events.first.attributes['exception.stacktrace'].nil?) - end - - describe 'when db_statement set as obfuscate' do - let(:config) { { db_statement: :obfuscate } } - - it 'obfuscates SQL parameters in db.statement' do - sql = "SELECT * from users where users.id = 1 and users.email = 'test@test.com'" - obfuscated_sql = 'SELECT * from users where users.id = ? and users.email = ?' - expect do - client.query(sql) - end.must_raise Mysql2::Error - - _(span.attributes['db.system']).must_equal 'mysql' - _(span.attributes['db.name']).must_equal 'mysql' - _(span.name).must_equal 'select' - _(span.attributes['db.statement']).must_equal obfuscated_sql - _(span.attributes['net.peer.name']).must_equal host.to_s - _(span.attributes['net.peer.port']).must_equal port.to_s - end - end - - describe 'when db_statement set as omit' do - let(:config) { { db_statement: :omit } } - - it 'omits db.statement attribute' do - sql = "SELECT * from users where users.id = 1 and users.email = 'test@test.com'" - expect do - client.query(sql) - end.must_raise Mysql2::Error - - _(span.attributes['db.system']).must_equal 'mysql' - _(span.attributes['db.name']).must_equal 'mysql' - _(span.name).must_equal 'select' - _(span.attributes).wont_include('db.statement') - _(span.attributes['net.peer.name']).must_equal host.to_s - _(span.attributes['net.peer.port']).must_equal port.to_s - end - end - - describe 'when enable_sql_obfuscation is enabled' do - let(:config) { { enable_sql_obfuscation: true } } - - it 'is compatible with legacy enable_sql_obfuscation option' do - sql = "SELECT * from users where users.id = 1 and users.email = 'test@test.com'" - obfuscated_sql = 'SELECT * from users where users.id = ? and users.email = ?' - expect do - client.query(sql) - end.must_raise Mysql2::Error - - _(span.attributes['db.system']).must_equal 'mysql' - _(span.attributes['db.name']).must_equal 'mysql' - _(span.name).must_equal 'select' - _(span.attributes['db.statement']).must_equal obfuscated_sql - _(span.attributes['net.peer.name']).must_equal host.to_s - _(span.attributes['net.peer.port']).must_equal port.to_s - end - end - - describe 'when enable_sql_obfuscation is enabled with db_statement set' do - let(:config) { { enable_sql_obfuscation: true, db_statement: :omit } } - - it 'respects enable_sql_obfuscation when enabled' do - sql = "SELECT * from users where users.id = 1 and users.email = 'test@test.com'" - obfuscated_sql = 'SELECT * from users where users.id = ? and users.email = ?' - expect do - client.query(sql) - end.must_raise Mysql2::Error - - _(span.attributes['db.system']).must_equal 'mysql' - _(span.attributes['db.name']).must_equal 'mysql' - _(span.name).must_equal 'select' - _(span.attributes['db.statement']).must_equal obfuscated_sql - _(span.attributes['net.peer.name']).must_equal host.to_s - _(span.attributes['net.peer.port']).must_equal port.to_s - end - end - - describe 'when db_statement is configured via environment variable' do - describe 'when db_statement set as omit' do - it 'omits db.statement attribute' do - OpenTelemetry::TestHelpers.with_env('OTEL_RUBY_INSTRUMENTATION_MYSQL2_CONFIG_OPTS' => 'db_statement=omit;') do - instrumentation.instance_variable_set(:@installed, false) - instrumentation.install - sql = "SELECT * from users where users.id = 1 and users.email = 'test@test.com'" - expect do - client.query(sql) - end.must_raise Mysql2::Error - - _(span.attributes['db.system']).must_equal 'mysql' - _(span.attributes['db.name']).must_equal 'mysql' - _(span.name).must_equal 'select' - _(span.attributes).wont_include('db.statement') - _(span.attributes['net.peer.name']).must_equal host.to_s - _(span.attributes['net.peer.port']).must_equal port.to_s - end - end - end - - describe 'when db_statement set as obfuscate' do - it 'obfuscates SQL parameters in db.statement' do - OpenTelemetry::TestHelpers.with_env('OTEL_RUBY_INSTRUMENTATION_MYSQL2_CONFIG_OPTS' => 'db_statement=obfuscate;') do - instrumentation.instance_variable_set(:@installed, false) - instrumentation.install - - sql = "SELECT * from users where users.id = 1 and users.email = 'test@test.com'" - obfuscated_sql = 'SELECT * from users where users.id = ? and users.email = ?' - expect do - client.query(sql) - end.must_raise Mysql2::Error - - _(span.attributes['db.system']).must_equal 'mysql' - _(span.attributes['db.name']).must_equal 'mysql' - _(span.name).must_equal 'select' - _(span.attributes['db.statement']).must_equal obfuscated_sql - _(span.attributes['net.peer.name']).must_equal host.to_s - _(span.attributes['net.peer.port']).must_equal port.to_s - end - end - end - - describe 'when db_statement is set differently than local config' do - let(:config) { { db_statement: :omit } } - - it 'overrides local config and obfuscates SQL parameters in db.statement' do - OpenTelemetry::TestHelpers.with_env('OTEL_RUBY_INSTRUMENTATION_MYSQL2_CONFIG_OPTS' => 'db_statement=obfuscate') do - instrumentation.instance_variable_set(:@installed, false) - instrumentation.install - - sql = "SELECT * from users where users.id = 1 and users.email = 'test@test.com'" - obfuscated_sql = 'SELECT * from users where users.id = ? and users.email = ?' - expect do - client.query(sql) - end.must_raise Mysql2::Error - - _(span.attributes['db.system']).must_equal 'mysql' - _(span.attributes['db.name']).must_equal 'mysql' - _(span.name).must_equal 'select' - _(span.attributes['db.statement']).must_equal obfuscated_sql - _(span.attributes['net.peer.name']).must_equal host.to_s - _(span.attributes['net.peer.port']).must_equal port.to_s - end - end - end - end - end unless ENV['OMIT_SERVICES'] -end diff --git a/instrumentation/mysql2/test/test_helper.rb b/instrumentation/mysql2/test/test_helper.rb deleted file mode 100644 index 2da15108c4..0000000000 --- a/instrumentation/mysql2/test/test_helper.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'mysql2' -require 'opentelemetry-test-helpers' -require 'opentelemetry/sdk' -require 'minitest/autorun' -require 'pry' - -# global opentelemetry-sdk setup: -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry::SDK.configure do |c| - c.add_span_processor span_processor -end diff --git a/instrumentation/net_http/.rubocop.yml b/instrumentation/net_http/.rubocop.yml deleted file mode 100644 index 8c449d6680..0000000000 --- a/instrumentation/net_http/.rubocop.yml +++ /dev/null @@ -1,5 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-net_http.rb" diff --git a/instrumentation/net_http/.yardopts b/instrumentation/net_http/.yardopts deleted file mode 100644 index d73e77966e..0000000000 --- a/instrumentation/net_http/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Net::HTTP Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/net_http/CHANGELOG.md b/instrumentation/net_http/CHANGELOG.md deleted file mode 100644 index e3d6f3c1c5..0000000000 --- a/instrumentation/net_http/CHANGELOG.md +++ /dev/null @@ -1,91 +0,0 @@ -# Release History: opentelemetry-instrumentation-net_http - -### v0.20.0 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Broken test file requirements - -### v0.19.5 / 2022-05-05 - -* (No significant changes) - -### v0.19.4 / 2022-02-02 - -* FIXED: Clientcontext attrs overwrite in net::http -* FIXED: Excessive hash creation on context attr merging - -### v0.19.3 / 2021-12-01 - -* FIXED: Change net attribute names to match the semantic conventions spec for http - -### v0.19.2 / 2021-09-29 - -* (No significant changes) - -### v0.19.1 / 2021-08-12 - -* DOCS: Update docs to rely more on environment variable configuration - -### v0.19.0 / 2021-06-23 - -* BREAKING CHANGE: Total order constraint on span.status= - -* FIXED: Total order constraint on span.status= - -### v0.18.0 / 2021-05-21 - -* ADDED: Updated API depedency for 1.0.0.rc1 - -### v0.17.0 / 2021-04-22 - -* FIXED: Refactor propagators to add #fields - -### v0.16.0 / 2021-03-17 - -* FIXED: Example scripts now reference local common lib -* DOCS: Replace Gitter with GitHub Discussions - -### v0.15.0 / 2021-02-18 - -* ADDED: Add Net::HTTP#connect tracing - -### v0.14.0 / 2021-02-03 - -* BREAKING CHANGE: Replace getter and setter callables and remove rack specific propagators - -* ADDED: Replace getter and setter callables and remove rack specific propagators - -### v0.13.0 / 2021-01-29 - -* (No significant changes) - -### v0.12.0 / 2020-12-24 - -* (No significant changes) - -### v0.11.0 / 2020-12-11 - -* FIXED: Copyright comments to not reference year - -### v0.10.0 / 2020-12-03 - -* (No significant changes) - -### v0.9.0 / 2020-11-27 - -* ADDED: Add common helpers - -### v0.8.0 / 2020-10-27 - -* BREAKING CHANGE: Remove 'canonical' from status codes - -* FIXED: Remove 'canonical' from status codes - -### v0.7.0 / 2020-10-07 - -* DOCS: Added documentation for net_http gem in instrumentation -* DOCS: Standardize toplevel docs structure and readme - -### v0.6.0 / 2020-09-10 - -* (No significant changes) diff --git a/instrumentation/net_http/Gemfile b/instrumentation/net_http/Gemfile deleted file mode 100644 index 2baf57ac47..0000000000 --- a/instrumentation/net_http/Gemfile +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :test do - gem 'opentelemetry-instrumentation-base', path: '../base' -end diff --git a/instrumentation/net_http/LICENSE b/instrumentation/net_http/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/net_http/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/net_http/README.md b/instrumentation/net_http/README.md deleted file mode 100644 index 37176284a3..0000000000 --- a/instrumentation/net_http/README.md +++ /dev/null @@ -1,53 +0,0 @@ -# OpenTelemetry Net::HTTP Instrumentation - -The OpenTelemetry Net::HTTP Ruby gem is a community maintained instrumentation for [Net::HTTP][net-http-home]. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-net_http -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-net_http` in your `Gemfile`. - -## Usage - -To install the instrumentation, call `use` with the name of the instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Net::HTTP' -end -``` - -Alternatively, you can also call `use_all` to install all the available instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` - -## Example - -An example of usage can be seen in [`example/net_http.rb`](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/instrumentation/net_http/example/net_http.rb). - -## How can I get involved? - -The `opentelemetry-instrumentation-net_http` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -Apache 2.0 license. See [LICENSE][license-github] for more information. - -[net-http-home]: https://docs.ruby-lang.org/en/2.0.0/Net/HTTP.html -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/instrumentation/net_http/Rakefile b/instrumentation/net_http/Rakefile deleted file mode 100644 index 1a64ba842e..0000000000 --- a/instrumentation/net_http/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/net_http/example/Gemfile b/instrumentation/net_http/example/Gemfile deleted file mode 100644 index 890ec3664a..0000000000 --- a/instrumentation/net_http/example/Gemfile +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -source 'https://rubygems.org' - -gem 'opentelemetry-api' -gem 'opentelemetry-common' -gem 'opentelemetry-instrumentation-net_http' -gem 'opentelemetry-sdk' diff --git a/instrumentation/net_http/example/net_http.rb b/instrumentation/net_http/example/net_http.rb deleted file mode 100644 index 106b607ab4..0000000000 --- a/instrumentation/net_http/example/net_http.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -require 'rubygems' -require 'bundler/setup' -require 'net/http' - -Bundler.require - -ENV['OTEL_TRACES_EXPORTER'] = 'console' -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Net::HTTP' -end - -Net::HTTP.get(URI('http://example.com')) diff --git a/instrumentation/net_http/lib/opentelemetry-instrumentation-net_http.rb b/instrumentation/net_http/lib/opentelemetry-instrumentation-net_http.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/net_http/lib/opentelemetry-instrumentation-net_http.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/net_http/lib/opentelemetry/instrumentation.rb b/instrumentation/net_http/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index 97340f005b..0000000000 --- a/instrumentation/net_http/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # "Instrumentation" are specified by - # https://github.com/open-telemetry/opentelemetry-specification/blob/784635d01d8690c8f5fcd1f55bdbc8a13cf2f4f2/specification/glossary.md#instrumentation-library - # - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/net/http' diff --git a/instrumentation/net_http/lib/opentelemetry/instrumentation/net/http.rb b/instrumentation/net_http/lib/opentelemetry/instrumentation/net/http.rb deleted file mode 100644 index dc64428357..0000000000 --- a/instrumentation/net_http/lib/opentelemetry/instrumentation/net/http.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry/common' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - module Net - # Contains the OpenTelemetry instrumentation for the Net::HTTP gem - module HTTP - end - end - end -end - -require_relative './http/instrumentation' -require_relative './http/version' diff --git a/instrumentation/net_http/lib/opentelemetry/instrumentation/net/http/instrumentation.rb b/instrumentation/net_http/lib/opentelemetry/instrumentation/net/http/instrumentation.rb deleted file mode 100644 index 0653734581..0000000000 --- a/instrumentation/net_http/lib/opentelemetry/instrumentation/net/http/instrumentation.rb +++ /dev/null @@ -1,36 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Net - module HTTP - # The Instrumentation class contains logic to detect and install the Net::HTTP - # instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - install do |_config| - require_dependencies - patch - end - - present do - defined?(::Net::HTTP) - end - - private - - def require_dependencies - require_relative 'patches/instrumentation' - end - - def patch - ::Net::HTTP.prepend(Patches::Instrumentation) - end - end - end - end - end -end diff --git a/instrumentation/net_http/lib/opentelemetry/instrumentation/net/http/patches/instrumentation.rb b/instrumentation/net_http/lib/opentelemetry/instrumentation/net/http/patches/instrumentation.rb deleted file mode 100644 index 173344195a..0000000000 --- a/instrumentation/net_http/lib/opentelemetry/instrumentation/net/http/patches/instrumentation.rb +++ /dev/null @@ -1,80 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Net - module HTTP - module Patches - # Module to prepend to Net::HTTP for instrumentation - module Instrumentation - HTTP_METHODS_TO_SPAN_NAMES = Hash.new { |h, k| h[k] = "HTTP #{k}" } - USE_SSL_TO_SCHEME = { false => 'http', true => 'https' }.freeze - - def request(req, body = nil, &block) - # Do not trace recursive call for starting the connection - return super(req, body, &block) unless started? - - attributes = { - OpenTelemetry::SemanticConventions::Trace::HTTP_METHOD => req.method, - OpenTelemetry::SemanticConventions::Trace::HTTP_SCHEME => USE_SSL_TO_SCHEME[use_ssl?], - OpenTelemetry::SemanticConventions::Trace::HTTP_TARGET => req.path, - OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME => @address, - OpenTelemetry::SemanticConventions::Trace::NET_PEER_PORT => @port - }.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes) - - tracer.in_span( - HTTP_METHODS_TO_SPAN_NAMES[req.method], - attributes: attributes, - kind: :client - ) do |span| - OpenTelemetry.propagation.inject(req) - - super(req, body, &block).tap do |response| - annotate_span_with_response!(span, response) - end - end - end - - private - - def connect - if proxy? - conn_address = proxy_address - conn_port = proxy_port - else - conn_address = address - conn_port = port - end - - attributes = { - OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME => conn_address, - OpenTelemetry::SemanticConventions::Trace::NET_PEER_PORT => conn_port - }.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes) - - tracer.in_span('HTTP CONNECT', attributes: attributes) do - super - end - end - - def annotate_span_with_response!(span, response) - return unless response&.code - - status_code = response.code.to_i - - span.set_attribute(OpenTelemetry::SemanticConventions::Trace::HTTP_STATUS_CODE, status_code) - span.status = OpenTelemetry::Trace::Status.error unless (100..399).include?(status_code.to_i) - end - - def tracer - Net::HTTP::Instrumentation.instance.tracer - end - end - end - end - end - end -end diff --git a/instrumentation/net_http/lib/opentelemetry/instrumentation/net/http/version.rb b/instrumentation/net_http/lib/opentelemetry/instrumentation/net/http/version.rb deleted file mode 100644 index 15a420da27..0000000000 --- a/instrumentation/net_http/lib/opentelemetry/instrumentation/net/http/version.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Net - module HTTP - VERSION = '0.20.0' - end - end - end -end diff --git a/instrumentation/net_http/opentelemetry-instrumentation-net_http.gemspec b/instrumentation/net_http/opentelemetry-instrumentation-net_http.gemspec deleted file mode 100644 index 5b6792717a..0000000000 --- a/instrumentation/net_http/opentelemetry-instrumentation-net_http.gemspec +++ /dev/null @@ -1,49 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/net/http/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-net_http' - spec.version = OpenTelemetry::Instrumentation::Net::HTTP::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'Net::HTTP instrumentation for the OpenTelemetry framework' - spec.description = 'Net::HTTP instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-common', '~> 0.19.3' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.21.0' - - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'rake', '~> 13.0.1' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'webmock', '~> 3.11.0' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-net_http/v#{OpenTelemetry::Instrumentation::Net::HTTP::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/net_http' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-net_http/v#{OpenTelemetry::Instrumentation::Net::HTTP::VERSION}" - end -end diff --git a/instrumentation/net_http/test/.rubocop.yml b/instrumentation/net_http/test/.rubocop.yml deleted file mode 100644 index dd94258585..0000000000 --- a/instrumentation/net_http/test/.rubocop.yml +++ /dev/null @@ -1,4 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false diff --git a/instrumentation/net_http/test/opentelemetry/instrumentation/net/http/instrumentation_test.rb b/instrumentation/net_http/test/opentelemetry/instrumentation/net/http/instrumentation_test.rb deleted file mode 100644 index 09b0d5b78c..0000000000 --- a/instrumentation/net_http/test/opentelemetry/instrumentation/net/http/instrumentation_test.rb +++ /dev/null @@ -1,167 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../../lib/opentelemetry/instrumentation/net/http' -require_relative '../../../../../lib/opentelemetry/instrumentation/net/http/patches/instrumentation' - -describe OpenTelemetry::Instrumentation::Net::HTTP::Instrumentation do - let(:instrumentation) { OpenTelemetry::Instrumentation::Net::HTTP::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:span) { exporter.finished_spans.first } - - before do - exporter.reset - stub_request(:get, 'http://example.com/success').to_return(status: 200) - stub_request(:post, 'http://example.com/failure').to_return(status: 500) - stub_request(:get, 'https://example.com/timeout').to_timeout - - # this is currently a noop but this will future proof the test - @orig_propagation = OpenTelemetry.propagation - propagator = OpenTelemetry::Trace::Propagation::TraceContext.text_map_propagator - OpenTelemetry.propagation = propagator - instrumentation.install - end - - after do - # Force re-install of instrumentation - instrumentation.instance_variable_set(:@installed, false) - - OpenTelemetry.propagation = @orig_propagation - end - - describe '#request' do - it 'before request' do - _(exporter.finished_spans.size).must_equal 0 - end - - it 'after request with success code' do - ::Net::HTTP.get('example.com', '/success') - - _(exporter.finished_spans.size).must_equal 1 - _(span.name).must_equal 'HTTP GET' - _(span.attributes['http.method']).must_equal 'GET' - _(span.attributes['http.scheme']).must_equal 'http' - _(span.attributes['http.status_code']).must_equal 200 - _(span.attributes['http.target']).must_equal '/success' - _(span.attributes['net.peer.name']).must_equal 'example.com' - _(span.attributes['net.peer.port']).must_equal 80 - assert_requested( - :get, - 'http://example.com/success', - headers: { 'Traceparent' => "00-#{span.hex_trace_id}-#{span.hex_span_id}-01" } - ) - end - - it 'after request with failure code' do - ::Net::HTTP.post(URI('http://example.com/failure'), 'q' => 'ruby') - - _(exporter.finished_spans.size).must_equal 1 - _(span.name).must_equal 'HTTP POST' - _(span.attributes['http.method']).must_equal 'POST' - _(span.attributes['http.scheme']).must_equal 'http' - _(span.attributes['http.status_code']).must_equal 500 - _(span.attributes['http.target']).must_equal '/failure' - _(span.attributes['net.peer.name']).must_equal 'example.com' - _(span.attributes['net.peer.port']).must_equal 80 - assert_requested( - :post, - 'http://example.com/failure', - headers: { 'Traceparent' => "00-#{span.hex_trace_id}-#{span.hex_span_id}-01" } - ) - end - - it 'after request timeout' do - expect do - ::Net::HTTP.get(URI('https://example.com/timeout')) - end.must_raise Net::OpenTimeout - - _(exporter.finished_spans.size).must_equal 1 - _(span.name).must_equal 'HTTP GET' - _(span.attributes['http.method']).must_equal 'GET' - _(span.attributes['http.scheme']).must_equal 'https' - _(span.attributes['http.status_code']).must_be_nil - _(span.attributes['http.target']).must_equal '/timeout' - _(span.attributes['net.peer.name']).must_equal 'example.com' - _(span.attributes['net.peer.port']).must_equal 443 - _(span.status.code).must_equal( - OpenTelemetry::Trace::Status::ERROR - ) - _(span.status.description).must_equal( - 'Unhandled exception of type: Net::OpenTimeout' - ) - assert_requested( - :get, - 'https://example.com/timeout', - headers: { 'Traceparent' => "00-#{span.hex_trace_id}-#{span.hex_span_id}-01" } - ) - end - - it 'merges http client attributes' do - OpenTelemetry::Common::HTTP::ClientContext.with_attributes('peer.service' => 'foo', 'http.target' => 'REDACTED') do - ::Net::HTTP.get('example.com', '/success') - end - - _(exporter.finished_spans.size).must_equal 1 - _(span.name).must_equal 'HTTP GET' - _(span.attributes['http.method']).must_equal 'GET' - _(span.attributes['http.scheme']).must_equal 'http' - _(span.attributes['http.status_code']).must_equal 200 - _(span.attributes['http.target']).must_equal 'REDACTED' - _(span.attributes['net.peer.name']).must_equal 'example.com' - _(span.attributes['net.peer.port']).must_equal 80 - _(span.attributes['peer.service']).must_equal 'foo' - assert_requested( - :get, - 'http://example.com/success', - headers: { 'Traceparent' => "00-#{span.hex_trace_id}-#{span.hex_span_id}-01" } - ) - end - end - - describe '#connect' do - it 'emits span on connect' do - WebMock.allow_net_connect! - TCPServer.open('localhost', 0) do |server| - Thread.start { server.accept } - port = server.addr[1] - - uri = URI.parse("http://localhost:#{port}/example") - http = Net::HTTP.new(uri.host, uri.port) - http.read_timeout = 0 - _(-> { http.request(Net::HTTP::Get.new(uri.request_uri)) }).must_raise(Net::ReadTimeout) - end - - _(exporter.finished_spans.size).must_equal(2) - _(span.name).must_equal 'HTTP CONNECT' - _(span.attributes['net.peer.name']).must_equal('localhost') - _(span.attributes['net.peer.port']).wont_be_nil - ensure - WebMock.disable_net_connect! - end - - it 'captures errors' do - WebMock.allow_net_connect! - - uri = URI.parse('http://localhost:99999/example') - http = Net::HTTP.new(uri.host, uri.port) - _(-> { http.request(Net::HTTP::Get.new(uri.request_uri)) }).must_raise - - _(exporter.finished_spans.size).must_equal(1) - _(span.name).must_equal 'HTTP CONNECT' - _(span.attributes['net.peer.name']).must_equal('localhost') - _(span.attributes['net.peer.port']).must_equal(99_999) - - span_event = span.events.first - _(span_event.name).must_equal 'exception' - _(span_event.attributes['exception.type']).wont_be_nil - _(span_event.attributes['exception.message']).must_match(/Failed to open TCP connection to localhost:99999/) - ensure - WebMock.disable_net_connect! - end - end -end diff --git a/instrumentation/net_http/test/test_helper.rb b/instrumentation/net_http/test/test_helper.rb deleted file mode 100644 index d9c9f7eac7..0000000000 --- a/instrumentation/net_http/test/test_helper.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'net/http' - -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' - -require 'minitest/autorun' -require 'webmock/minitest' - -# global opentelemetry-sdk setup: -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry::SDK.configure do |c| - c.add_span_processor span_processor -end diff --git a/instrumentation/pg/.rubocop.yml b/instrumentation/pg/.rubocop.yml deleted file mode 100644 index 385b49e491..0000000000 --- a/instrumentation/pg/.rubocop.yml +++ /dev/null @@ -1,5 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-pg.rb" diff --git a/instrumentation/pg/.yardopts b/instrumentation/pg/.yardopts deleted file mode 100644 index c7fa210f1c..0000000000 --- a/instrumentation/pg/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry PG Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/pg/Appraisals b/instrumentation/pg/Appraisals deleted file mode 100644 index b97184733c..0000000000 --- a/instrumentation/pg/Appraisals +++ /dev/null @@ -1,5 +0,0 @@ -# frozen_string_literal: true - -appraise 'pg-1.2.3' do - gem 'pg' -end diff --git a/instrumentation/pg/CHANGELOG.md b/instrumentation/pg/CHANGELOG.md deleted file mode 100644 index 1caf9bc73e..0000000000 --- a/instrumentation/pg/CHANGELOG.md +++ /dev/null @@ -1,39 +0,0 @@ -# Release History: opentelemetry-instrumentation-pg - -### v0.21.0 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Broken test file requirements - -### v0.20.0 / 2022-05-02 - -* ADDED: Validate Using Enums -* FIXED: Update pg instrumentation to handle non primitive argument -* FIXED: RubyGems Fallback - -### v0.19.2 / 2021-12-02 - -* (No significant changes) - -### v0.19.1 / 2021-09-29 - -* (No significant changes) - -### v0.19.0 / 2021-08-12 - -* ADDED: Add db_statement toggle for postgres -* DOCS: Update docs to rely more on environment variable configuration - -### v0.18.1 / 2021-06-23 - -* (No significant changes) - -### v0.18.0 / 2021-05-21 - -* ADDED: Updated API depedency for 1.0.0.rc1 -* ADDED: Add option to postgres instrumentation to disable db.statement - -### v0.17.1 / 2021-04-23 - -* Initial release. -* ADDED: Initial postgresql instrumentation diff --git a/instrumentation/pg/Gemfile b/instrumentation/pg/Gemfile deleted file mode 100644 index 2baf57ac47..0000000000 --- a/instrumentation/pg/Gemfile +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :test do - gem 'opentelemetry-instrumentation-base', path: '../base' -end diff --git a/instrumentation/pg/LICENSE b/instrumentation/pg/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/pg/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/pg/README.md b/instrumentation/pg/README.md deleted file mode 100644 index d8c726ec3b..0000000000 --- a/instrumentation/pg/README.md +++ /dev/null @@ -1,70 +0,0 @@ -# OpenTelemetry PG Instrumentation - -The OpenTelemetry PG Ruby gem is a community maintained instrumentation for [PG][pg-home]. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-pg -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-pg` in your `Gemfile`. - -## Usage - -To use the instrumentation, call `use` with the name of the instrumentation: - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::PG' -end -``` - -Alternatively, you can also call `use_all` to install all the available instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` - -### Configuration options - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::PG', { - # You may optionally set a value for 'peer.service', which - # will be included on all spans from this instrumentation: - peer_service: 'postgres:readonly', - - # By default, this instrumentation includes the executed SQL as the `db.statement` - # semantic attribute. Optionally, you may disable the inclusion of this attribute entirely by - # setting this option to :omit or sanitize the attribute by setting to :obfuscate - db_statement: :include, - } -end -``` - -## Examples - -An example of usage can be seen in [`example/pg.rb`](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/instrumentation/pg/example/pg.rb). - -## How can I get involved? - -The `opentelemetry-instrumentation-pg` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us on our [gitter channel][ruby-gitter] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -The `opentelemetry-instrumentation-pg` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information. - -[pg-home]: https://github.com/ged/ruby-pg -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[ruby-gitter]: https://gitter.im/open-telemetry/opentelemetry-ruby diff --git a/instrumentation/pg/Rakefile b/instrumentation/pg/Rakefile deleted file mode 100644 index 1a64ba842e..0000000000 --- a/instrumentation/pg/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/pg/example/Gemfile b/instrumentation/pg/example/Gemfile deleted file mode 100644 index 27d6219c75..0000000000 --- a/instrumentation/pg/example/Gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -source 'https://rubygems.org' - -gem 'opentelemetry-api' -gem 'opentelemetry-common' -gem 'opentelemetry-instrumentation-pg' -gem 'opentelemetry-sdk' -gem 'pg' diff --git a/instrumentation/pg/example/pg.rb b/instrumentation/pg/example/pg.rb deleted file mode 100644 index 893d9f9618..0000000000 --- a/instrumentation/pg/example/pg.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -require 'rubygems' -require 'bundler/setup' - -Bundler.require - -ENV['OTEL_TRACES_EXPORTER'] = 'console' -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::PG', enable_sql_obfuscation: true -end - -conn = PG::Connection.open( - host: ENV.fetch('TEST_POSTGRES_HOST') { '127.0.0.1' }, - port: ENV.fetch('TEST_POSTGRES_PORT') { '5432' }, - user: ENV.fetch('TEST_POSTGRES_USER') { 'postgres' }, - dbname: ENV.fetch('TEST_POSTGRES_DB') { 'postgres' }, - password: ENV.fetch('TEST_POSTGRES_PASSWORD') { 'postgres' } -) - -# Spans will be printed to your terminal when this statement executes: -conn.exec('SELECT 1 AS a, 2 AS b, NULL AS c').each_row { |r| puts r.inspect } - -# You can use parameterized queries like so: -# conn.exec_params('SELECT $1 AS a, $2 AS b, $3 AS c', [1, 2, nil]).each_row { |r| puts r.inspect } - -# And, you can prepare statements and execute them like this: -# conn.prepare('foo', 'SELECT $1 AS a, $2 AS b, $3 AS c') -# conn.exec_prepared('foo', [1, 2, nil]) diff --git a/instrumentation/pg/lib/opentelemetry-instrumentation-pg.rb b/instrumentation/pg/lib/opentelemetry-instrumentation-pg.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/pg/lib/opentelemetry-instrumentation-pg.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/pg/lib/opentelemetry/instrumentation.rb b/instrumentation/pg/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index ffac053fb8..0000000000 --- a/instrumentation/pg/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # "Instrumentation" are specified by - # https://github.com/open-telemetry/opentelemetry-specification/blob/784635d01d8690c8f5fcd1f55bdbc8a13cf2f4f2/specification/glossary.md#instrumentation-library - # - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/pg' diff --git a/instrumentation/pg/lib/opentelemetry/instrumentation/pg.rb b/instrumentation/pg/lib/opentelemetry/instrumentation/pg.rb deleted file mode 100644 index 592e025a6d..0000000000 --- a/instrumentation/pg/lib/opentelemetry/instrumentation/pg.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the Pg gem - module PG - end - end -end - -require_relative './pg/instrumentation' -require_relative './pg/version' diff --git a/instrumentation/pg/lib/opentelemetry/instrumentation/pg/constants.rb b/instrumentation/pg/lib/opentelemetry/instrumentation/pg/constants.rb deleted file mode 100644 index e69ee9a460..0000000000 --- a/instrumentation/pg/lib/opentelemetry/instrumentation/pg/constants.rb +++ /dev/null @@ -1,124 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module PG - module Constants - # A list of SQL commands, from: https://www.postgresql.org/docs/current/sql-commands.html - # Commands are truncated to their first word, and all duplicates - # are removed, This favors brevity and low-cardinality over descriptiveness. - SQL_COMMANDS = %w[ - ABORT - ALTER - ANALYZE - BEGIN - CALL - CHECKPOINT - CLOSE - CLUSTER - COMMENT - COMMIT - COPY - CREATE - DEALLOCATE - DECLARE - DELETE - DISCARD - DO - DROP - END - EXECUTE - EXPLAIN - FETCH - GRANT - IMPORT - INSERT - LISTEN - LOAD - LOCK - MOVE - NOTIFY - PREPARE - PREPARE - REASSIGN - REFRESH - REINDEX - RELEASE - RESET - REVOKE - ROLLBACK - SAVEPOINT - SECURITY - SELECT - SELECT - SET - SHOW - START - TRUNCATE - UNLISTEN - UPDATE - VACUUM - VALUES - ].freeze - - # From: https://github.com/newrelic/newrelic-ruby-agent/blob/9787095d4b5b2d8fcaf2fdbd964ed07c731a8b6b/lib/new_relic/agent/database/obfuscation_helpers.rb#L9-L34 - COMPONENTS_REGEX_MAP = { - single_quotes: /'(?:[^']|'')*?(?:\\'.*|'(?!'))/, - dollar_quotes: /(\$(?!\d)[^$]*?\$).*?(?:\1|$)/, - uuids: /\{?(?:[0-9a-fA-F]\-*){32}\}?/, - numeric_literals: /-?\b(?:[0-9]+\.)?[0-9]+([eE][+-]?[0-9]+)?\b/, - boolean_literals: /\b(?:true|false|null)\b/i, - comments: /(?:#|--).*?(?=\r|\n|$)/i, - multi_line_comments: %r{\/\*(?:[^\/]|\/[^*])*?(?:\*\/|\/\*.*)} - }.freeze - - POSTGRES_COMPONENTS = %i[ - single_quotes - dollar_quotes - uuids - numeric_literals - boolean_literals - comments - multi_line_comments - ].freeze - - UNMATCHED_PAIRS_REGEX = %r{'|\/\*|\*\/|\$(?!\?)}.freeze - - # These are all alike in that they will have a SQL statement as the first parameter. - # That statement may possibly be parameterized, but we can still use it - the - # obfuscation code will just transform $1 -> $? in that case (which is fine enough). - EXEC_ISH_METHODS = %i[ - exec - query - sync_exec - async_exec - exec_params - async_exec_params - sync_exec_params - ].freeze - - # The following methods all take a statement name as the first - # parameter, and a SQL statement as the second - and possibly - # further parameters after that. We can trace them all alike. - PREPARE_ISH_METHODS = %i[ - prepare - async_prepare - sync_prepare - ].freeze - - # The following methods take a prepared statement name as their first - # parameter - everything after that is either potentially quite sensitive - # (an array of bind params) or not useful to us. We trace them all alike. - EXEC_PREPARED_ISH_METHODS = %i[ - exec_prepared - async_exec_prepared - sync_exec_prepared - ].freeze - end - end - end -end diff --git a/instrumentation/pg/lib/opentelemetry/instrumentation/pg/instrumentation.rb b/instrumentation/pg/lib/opentelemetry/instrumentation/pg/instrumentation.rb deleted file mode 100644 index 528a3b3602..0000000000 --- a/instrumentation/pg/lib/opentelemetry/instrumentation/pg/instrumentation.rb +++ /dev/null @@ -1,64 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module PG - # The Instrumentation class contains logic to detect and install the Pg instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - MINIMUM_VERSION = Gem::Version.new('1.1.0') - - install do |config| - if config[:enable_sql_obfuscation] - config[:db_statement] = :obfuscate - OpenTelemetry.logger.warn( - 'Instrumentation pg configuration option enable_sql_obfuscation has been deprecated,' \ - 'use db_statement option instead' - ) - end - - unless config[:enable_statement_attribute] - config[:db_statement] = :omit - OpenTelemetry.logger.warn( - 'Instrumentation pg configuration option enable_statement_attribute has been deprecated,' \ - 'use db_statement option instead' - ) - end - - require_dependencies - patch_client - end - - present do - defined?(::PG) - end - - compatible do - gem_version > Gem::Version.new(MINIMUM_VERSION) - end - - option :peer_service, default: nil, validate: :string - option :enable_sql_obfuscation, default: false, validate: :boolean - option :enable_statement_attribute, default: true, validate: :boolean - option :db_statement, default: :include, validate: %I[omit include obfuscate] - - private - - def gem_version - Gem::Version.new(::PG::VERSION) - end - - def require_dependencies - require_relative 'patches/connection' - end - - def patch_client - ::PG::Connection.prepend(Patches::Connection) - end - end - end - end -end diff --git a/instrumentation/pg/lib/opentelemetry/instrumentation/pg/lru_cache.rb b/instrumentation/pg/lib/opentelemetry/instrumentation/pg/lru_cache.rb deleted file mode 100644 index c04e650528..0000000000 --- a/instrumentation/pg/lib/opentelemetry/instrumentation/pg/lru_cache.rb +++ /dev/null @@ -1,44 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module PG - # A simple LRU cache for the postgres instrumentation. - class LruCache - # Rather than take a dependency on another gem, we implement a very, very basic - # LRU cache here. We can take advantage of the fact that Ruby hashes are ordered - # to always keep the recently-accessed keys at the top. - def initialize(size) - raise ArgumentError, 'Invalid size' if size < 1 - - @limit = size - @store = {} - end - - def [](key) - # We need to check for the key explicitly, because `nil` is a valid hash value. - return unless @store.key?(key) - - # Since the cache contains the item, we delete and re-insert into the hash. - # This guarantees that hash keys are ordered by access recency. - value = @store.delete(key) - @store[key] = value - - value - end - - def []=(key, value) - # We remove the value if it's already present, so that the hash keys remain ordered - # by access recency. - @store.delete(key) - @store[key] = value - @store.shift if @store.length > @limit - end - end - end - end -end diff --git a/instrumentation/pg/lib/opentelemetry/instrumentation/pg/patches/connection.rb b/instrumentation/pg/lib/opentelemetry/instrumentation/pg/patches/connection.rb deleted file mode 100644 index ffe9fe4616..0000000000 --- a/instrumentation/pg/lib/opentelemetry/instrumentation/pg/patches/connection.rb +++ /dev/null @@ -1,156 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative '../constants' -require_relative '../lru_cache' - -module OpenTelemetry - module Instrumentation - module PG - module Patches - # Module to prepend to PG::Connection for instrumentation - module Connection - PG::Constants::EXEC_ISH_METHODS.each do |method| - define_method method do |*args| - span_name, attrs = span_attrs(:query, *args) - tracer.in_span(span_name, attributes: attrs, kind: :client) do - super(*args) - end - end - end - - PG::Constants::PREPARE_ISH_METHODS.each do |method| - define_method method do |*args| - span_name, attrs = span_attrs(:prepare, *args) - tracer.in_span(span_name, attributes: attrs, kind: :client) do - super(*args) - end - end - end - - PG::Constants::EXEC_PREPARED_ISH_METHODS.each do |method| - define_method method do |*args| - span_name, attrs = span_attrs(:execute, *args) - tracer.in_span(span_name, attributes: attrs, kind: :client) do - super(*args) - end - end - end - - private - - def tracer - PG::Instrumentation.instance.tracer - end - - def config - PG::Instrumentation.instance.config - end - - def lru_cache - # When SQL is being sanitized, we know that this cache will - # never be more than 50 entries * 2000 characters (so, presumably - # 100k bytes - or 97k). When not sanitizing SQL, then this cache - # could grow much larger - but the small cache size should otherwise - # help contain memory growth. The intended use here is to cache - # prepared SQL statements, so that we can attach a reasonable - # `db.sql.statement` value to spans when those prepared statements - # are executed later on. - @lru_cache ||= LruCache.new(50) - end - - # Rubocop is complaining about 19.31/18 for Metrics/AbcSize. - # But, getting that metric in line would force us over the - # module size limit! We can't win here unless we want to start - # abstracting things into a million pieces. - def span_attrs(kind, *args) # rubocop:disable Metrics/AbcSize - if kind == :query - operation = extract_operation(args[0]) - sql = obfuscate_sql(args[0]).to_s - else - statement_name = args[0] - - if kind == :prepare - sql = obfuscate_sql(args[1]).to_s - lru_cache[statement_name] = sql - operation = 'PREPARE' - else - sql = lru_cache[statement_name] - operation = 'EXECUTE' - end - end - - attrs = { 'db.operation' => validated_operation(operation), 'db.postgresql.prepared_statement_name' => statement_name } - attrs['db.statement'] = sql unless config[:db_statement] == :omit - attrs.reject! { |_, v| v.nil? } - - [span_name(operation), client_attributes.merge(attrs)] - end - - def extract_operation(sql) - # From: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/9244a08a8d014afe26b82b91cf86e407c2599d73/plugins/node/opentelemetry-instrumentation-pg/src/utils.ts#L35 - sql.to_s.split[0].to_s.upcase - end - - def span_name(operation) - [validated_operation(operation), database_name].compact.join(' ') - end - - def validated_operation(operation) - operation if PG::Constants::SQL_COMMANDS.include?(operation) - end - - def obfuscate_sql(sql) - return sql unless config[:db_statement] == :obfuscate - - # Borrowed from opentelemetry-instrumentation-mysql2 - return 'SQL query too large to remove sensitive data ...' if sql.size > 2000 - - # From: - # https://github.com/newrelic/newrelic-ruby-agent/blob/9787095d4b5b2d8fcaf2fdbd964ed07c731a8b6b/lib/new_relic/agent/database/obfuscator.rb - # https://github.com/newrelic/newrelic-ruby-agent/blob/9787095d4b5b2d8fcaf2fdbd964ed07c731a8b6b/lib/new_relic/agent/database/obfuscation_helpers.rb - obfuscated = sql.gsub(generated_postgres_regex, '?') - obfuscated = 'Failed to obfuscate SQL query - quote characters remained after obfuscation' if PG::Constants::UNMATCHED_PAIRS_REGEX.match(obfuscated) - - obfuscated - end - - def generated_postgres_regex - @generated_postgres_regex ||= Regexp.union(PG::Constants::POSTGRES_COMPONENTS.map { |component| PG::Constants::COMPONENTS_REGEX_MAP[component] }) - end - - def database_name - conninfo_hash[:dbname]&.to_s - end - - def client_attributes - attributes = { - 'db.system' => 'postgresql', - 'db.user' => conninfo_hash[:user]&.to_s, - 'db.name' => database_name, - 'net.peer.name' => conninfo_hash[:host]&.to_s - } - attributes['peer.service'] = config[:peer_service] if config[:peer_service] - - attributes.merge(transport_attrs).reject { |_, v| v.nil? } - end - - def transport_attrs - if conninfo_hash[:host]&.start_with?('/') - { 'net.transport' => 'Unix' } - else - { - 'net.transport' => 'IP.TCP', - 'net.peer.ip' => conninfo_hash[:hostaddr]&.to_s, - 'net.peer.port' => conninfo_hash[:port]&.to_s - } - end - end - end - end - end - end -end diff --git a/instrumentation/pg/lib/opentelemetry/instrumentation/pg/version.rb b/instrumentation/pg/lib/opentelemetry/instrumentation/pg/version.rb deleted file mode 100644 index 3d6197fe14..0000000000 --- a/instrumentation/pg/lib/opentelemetry/instrumentation/pg/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module PG - VERSION = '0.21.0' - end - end -end diff --git a/instrumentation/pg/opentelemetry-instrumentation-pg.gemspec b/instrumentation/pg/opentelemetry-instrumentation-pg.gemspec deleted file mode 100644 index af52ced623..0000000000 --- a/instrumentation/pg/opentelemetry-instrumentation-pg.gemspec +++ /dev/null @@ -1,51 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/pg/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-pg' - spec.version = OpenTelemetry::Instrumentation::PG::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'PG (PostgreSQL) instrumentation for the OpenTelemetry framework' - spec.description = 'PG (PostgreSQL) instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.21.0' - - spec.add_development_dependency 'activerecord' - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'pg', '>= 1.1.0' - spec.add_development_dependency 'pry' - spec.add_development_dependency 'pry-byebug' unless RUBY_ENGINE == 'jruby' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-pg/v#{OpenTelemetry::Instrumentation::PG::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/pg' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-pg/v#{OpenTelemetry::Instrumentation::PG::VERSION}" - end -end diff --git a/instrumentation/pg/test/.rubocop.yml b/instrumentation/pg/test/.rubocop.yml deleted file mode 100644 index e97eda560f..0000000000 --- a/instrumentation/pg/test/.rubocop.yml +++ /dev/null @@ -1,6 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false -Style/MultilineIfModifier: - Enabled: false diff --git a/instrumentation/pg/test/opentelemetry/instrumentation/pg/instrumentation_test.rb b/instrumentation/pg/test/opentelemetry/instrumentation/pg/instrumentation_test.rb deleted file mode 100644 index 840631b446..0000000000 --- a/instrumentation/pg/test/opentelemetry/instrumentation/pg/instrumentation_test.rb +++ /dev/null @@ -1,278 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' -require 'active_record' -require 'pg' - -require_relative '../../../../lib/opentelemetry/instrumentation/pg' -require_relative '../../../../lib/opentelemetry/instrumentation/pg/patches/connection' - -# This test suite requires a running postgres container and dedicated test container -# To run tests: -# 1. Build the opentelemetry/opentelemetry-ruby image -# - docker-compose build -# 2. Bundle install -# - docker-compose run ex-instrumentation-pg-test bundle install -# 3. Run test suite -# - docker-compose run ex-instrumentation-pg-test bundle exec rake test -describe OpenTelemetry::Instrumentation::PG::Instrumentation do - let(:instrumentation) { OpenTelemetry::Instrumentation::PG::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:span) { exporter.finished_spans.first } - let(:last_span) { exporter.finished_spans.last } - let(:config) { {} } - - before do - exporter.reset - end - - after do - # Force re-install of instrumentation - instrumentation.instance_variable_set(:@installed, false) - end - - describe 'tracing' do - let(:client) do - ::PG::Connection.open( - host: host, - port: port, - user: user, - dbname: dbname, - password: password - ) - end - - let(:host) { ENV.fetch('TEST_POSTGRES_HOST') { '127.0.0.1' } } - let(:port) { ENV.fetch('TEST_POSTGRES_PORT') { '5432' } } - let(:user) { ENV.fetch('TEST_POSTGRES_USER') { 'postgres' } } - let(:dbname) { ENV.fetch('TEST_POSTGRES_DB') { 'postgres' } } - let(:password) { ENV.fetch('TEST_POSTGRES_PASSWORD') { 'postgres' } } - - before do - instrumentation.install(config) - end - - it 'before request' do - _(exporter.finished_spans.size).must_equal 0 - end - - it 'accepts peer service name from config' do - instrumentation.instance_variable_set(:@installed, false) - instrumentation.install(peer_service: 'readonly:postgres') - client.query('SELECT 1') - - _(span.attributes['peer.service']).must_equal 'readonly:postgres' - end - - %i[exec query sync_exec async_exec].each do |method| - it "after request (with method: #{method})" do - client.send(method, 'SELECT 1') - - _(span.name).must_equal 'SELECT postgres' - _(span.attributes['db.system']).must_equal 'postgresql' - _(span.attributes['db.name']).must_equal 'postgres' - _(span.attributes['db.statement']).must_equal 'SELECT 1' - _(span.attributes['db.operation']).must_equal 'SELECT' - _(span.attributes['net.peer.name']).must_equal host.to_s - _(span.attributes['net.peer.port']).must_equal port.to_s - end - end - - %i[exec_params async_exec_params sync_exec_params].each do |method| - it "after request (with method: #{method}) " do - client.send(method, 'SELECT $1 AS a', [1]) - - _(span.name).must_equal 'SELECT postgres' - _(span.attributes['db.system']).must_equal 'postgresql' - _(span.attributes['db.name']).must_equal 'postgres' - _(span.attributes['db.statement']).must_equal 'SELECT $1 AS a' - _(span.attributes['db.operation']).must_equal 'SELECT' - _(span.attributes['net.peer.name']).must_equal host.to_s - _(span.attributes['net.peer.port']).must_equal port.to_s - end - end - - %i[prepare async_prepare sync_prepare].each do |method| - it "after preparing a statement (with method: #{method})" do - client.send(method, 'foo', 'SELECT $1 AS a') - - _(span.name).must_equal 'PREPARE postgres' - _(span.attributes['db.system']).must_equal 'postgresql' - _(span.attributes['db.name']).must_equal 'postgres' - _(span.attributes['db.statement']).must_equal 'SELECT $1 AS a' - _(span.attributes['db.operation']).must_equal 'PREPARE' - _(span.attributes['db.postgresql.prepared_statement_name']).must_equal 'foo' - _(span.attributes['net.peer.name']).must_equal host.to_s - _(span.attributes['net.peer.port']).must_equal port.to_s - end - end - - %i[exec_prepared async_exec_prepared sync_exec_prepared].each do |method| - it "after executing prepared statement (with method: #{method})" do - client.prepare('foo', 'SELECT $1 AS a') - client.send(method, 'foo', [1]) - - _(last_span.name).must_equal 'EXECUTE postgres' - _(last_span.attributes['db.system']).must_equal 'postgresql' - _(last_span.attributes['db.name']).must_equal 'postgres' - _(last_span.attributes['db.operation']).must_equal 'EXECUTE' - _(last_span.attributes['db.statement']).must_equal 'SELECT $1 AS a' - _(last_span.attributes['db.postgresql.prepared_statement_name']).must_equal 'foo' - _(last_span.attributes['net.peer.name']).must_equal host.to_s - _(last_span.attributes['net.peer.port']).must_equal port.to_s - end - end - - %i[exec query sync_exec async_exec].each do |method| - it "after request using Arel (with method: #{method})" do - client.send(method, Arel.sql('SELECT 1')) - - _(span.name).must_equal 'SELECT postgres' - _(span.attributes['db.system']).must_equal 'postgresql' - _(span.attributes['db.name']).must_equal 'postgres' - _(span.attributes['db.statement']).must_equal 'SELECT 1' - _(span.attributes['db.operation']).must_equal 'SELECT' - _(span.attributes['net.peer.name']).must_equal host.to_s - _(span.attributes['net.peer.port']).must_equal port.to_s - end - end - - it 'only caches 50 prepared statement names' do - 51.times { |i| client.prepare("foo#{i}", "SELECT $1 AS foo#{i}") } - client.exec_prepared('foo0', [1]) - - _(last_span.name).must_equal 'EXECUTE postgres' - _(last_span.attributes['db.system']).must_equal 'postgresql' - _(last_span.attributes['db.name']).must_equal 'postgres' - _(last_span.attributes['db.operation']).must_equal 'EXECUTE' - # We should have evicted the statement from the cache - _(last_span.attributes['db.statement']).must_be_nil - _(last_span.attributes['db.postgresql.prepared_statement_name']).must_equal 'foo0' - _(last_span.attributes['net.peer.name']).must_equal host.to_s - _(last_span.attributes['net.peer.port']).must_equal port.to_s - end - - it 'after error' do - expect do - client.exec('SELECT INVALID') - end.must_raise PG::UndefinedColumn - - _(span.name).must_equal 'SELECT postgres' - _(span.attributes['db.system']).must_equal 'postgresql' - _(span.attributes['db.name']).must_equal 'postgres' - _(span.attributes['db.statement']).must_equal 'SELECT INVALID' - _(span.attributes['db.operation']).must_equal 'SELECT' - _(span.attributes['net.peer.name']).must_equal host.to_s - _(span.attributes['net.peer.port']).must_equal port.to_s - - _(span.status.code).must_equal( - OpenTelemetry::Trace::Status::ERROR - ) - _(span.events.first.name).must_equal 'exception' - _(span.events.first.attributes['exception.type']).must_equal 'PG::UndefinedColumn' - assert(!span.events.first.attributes['exception.message'].nil?) - assert(!span.events.first.attributes['exception.stacktrace'].nil?) - end - - it 'extracts statement type that begins the query' do - base_sql = 'SELECT 1' - explain = 'EXPLAIN' - explain_sql = "#{explain} #{base_sql}" - client.exec(explain_sql) - - _(span.name).must_equal 'EXPLAIN postgres' - _(span.attributes['db.system']).must_equal 'postgresql' - _(span.attributes['db.name']).must_equal 'postgres' - _(span.attributes['db.statement']).must_equal explain_sql - _(span.attributes['db.operation']).must_equal 'EXPLAIN' - _(span.attributes['net.peer.name']).must_equal host.to_s - _(span.attributes['net.peer.port']).must_equal port.to_s - end - - it 'uses database name as span.name fallback with invalid sql' do - expect do - client.exec('DESELECT 1') - end.must_raise PG::SyntaxError - - _(span.name).must_equal 'postgres' - _(span.attributes['db.system']).must_equal 'postgresql' - _(span.attributes['db.name']).must_equal 'postgres' - _(span.attributes['db.statement']).must_equal 'DESELECT 1' - _(span.attributes['db.operation']).must_be_nil - _(span.attributes['net.peer.name']).must_equal host.to_s - _(span.attributes['net.peer.port']).must_equal port.to_s - - _(span.status.code).must_equal( - OpenTelemetry::Trace::Status::ERROR - ) - _(span.events.first.name).must_equal 'exception' - _(span.events.first.attributes['exception.type']).must_equal 'PG::SyntaxError' - assert(!span.events.first.attributes['exception.message'].nil?) - assert(!span.events.first.attributes['exception.stacktrace'].nil?) - end - - describe 'when db_statement is obfuscate' do - let(:config) { { db_statement: :obfuscate } } - - it 'obfuscates SQL parameters in db.statement' do - sql = "SELECT * from users where users.id = 1 and users.email = 'test@test.com'" - obfuscated_sql = 'SELECT * from users where users.id = ? and users.email = ?' - expect do - client.exec(sql) - end.must_raise PG::UndefinedTable - - _(span.attributes['db.system']).must_equal 'postgresql' - _(span.attributes['db.name']).must_equal 'postgres' - _(span.name).must_equal 'SELECT postgres' - _(span.attributes['db.statement']).must_equal obfuscated_sql - _(span.attributes['db.operation']).must_equal 'SELECT' - _(span.attributes['net.peer.name']).must_equal host.to_s - _(span.attributes['net.peer.port']).must_equal port.to_s - end - end - - describe 'when db_statement is omit' do - let(:config) { { db_statement: :omit } } - - it 'does not include SQL statement as db.statement attribute' do - sql = "SELECT * from users where users.id = 1 and users.email = 'test@test.com'" - expect do - client.exec(sql) - end.must_raise PG::UndefinedTable - - _(span.attributes['db.system']).must_equal 'postgresql' - _(span.attributes['db.name']).must_equal 'postgres' - _(span.name).must_equal 'SELECT postgres' - _(span.attributes['db.operation']).must_equal 'SELECT' - _(span.attributes['net.peer.name']).must_equal host.to_s - _(span.attributes['net.peer.port']).must_equal port.to_s - - _(span.attributes['db.statement']).must_be_nil - end - end - - describe 'when enable_statement_attribute is false' do - let(:config) { { enable_statement_attribute: false } } - - it 'does not include SQL statement as db.statement attribute' do - sql = "SELECT * from users where users.id = 1 and users.email = 'test@test.com'" - expect do - client.exec(sql) - end.must_raise PG::UndefinedTable - - _(span.attributes['db.system']).must_equal 'postgresql' - _(span.attributes['db.name']).must_equal 'postgres' - _(span.name).must_equal 'SELECT postgres' - _(span.attributes['db.operation']).must_equal 'SELECT' - _(span.attributes['net.peer.name']).must_equal host.to_s - _(span.attributes['net.peer.port']).must_equal port.to_s - - _(span.attributes['db.statement']).must_be_nil - end - end - end unless ENV['OMIT_SERVICES'] -end diff --git a/instrumentation/pg/test/opentelemetry/instrumentation/pg/lru_cache_test.rb b/instrumentation/pg/test/opentelemetry/instrumentation/pg/lru_cache_test.rb deleted file mode 100644 index 397047cce2..0000000000 --- a/instrumentation/pg/test/opentelemetry/instrumentation/pg/lru_cache_test.rb +++ /dev/null @@ -1,60 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' -require_relative '../../../../lib/opentelemetry/instrumentation/pg/lru_cache' - -describe OpenTelemetry::Instrumentation::PG::LruCache do - let(:cache) { OpenTelemetry::Instrumentation::PG::LruCache.new(10) } - - it 'can set and retrieve a value' do - cache['foo'] = 'bar' - _(cache['foo']).must_equal('bar') - end - - it 'does not evict keys which were recently read' do - 10.times { |i| cache[i] = i } - - cache[0] # this should cause the '0' key to be the most recently-used - cache[10] = 10 # As the 11th item, this should cause a cache eviction - - # Because 0 was recently active, it should still be in the cache. - # 1 should have been the oldest item and should not be present. - _(cache[0]).must_equal(0) - _(cache[10]).must_equal(10) - _(cache[1]).must_be_nil - end - - it 'does not evict keys which were recently set' do - 10.times { |i| cache[i] = i } - cache[0] = 0 # this should cause the '0' key to be the most recently-used - cache[10] = 10 # As the 11th item, this should cause a cache eviction - - # Because 0 was recently active, it should still be in the cache. - # 1 should have been the oldest item and should not be present. - _(cache[0]).must_equal(0) - _(cache[10]).must_equal(10) - _(cache[1]).must_be_nil - end - - it 'returns nil if the key is not present' do - _(cache[:nope]).must_be_nil - end - - it 'has a fixed size limit' do - cache = OpenTelemetry::Instrumentation::PG::LruCache.new(1) - 2.times { |i| cache[i] = i } - - _(cache[0]).must_be_nil - _(cache[1]).must_equal(1) - end - - it 'disallows invalid size limits' do - expect do - OpenTelemetry::Instrumentation::PG::LruCache.new(0) - end.must_raise ArgumentError - end -end diff --git a/instrumentation/pg/test/test_helper.rb b/instrumentation/pg/test/test_helper.rb deleted file mode 100644 index 565da741f5..0000000000 --- a/instrumentation/pg/test/test_helper.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'active_record' -require 'pg' - -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' - -require 'minitest/autorun' - -require 'pry' - -# global opentelemetry-sdk setup: -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry::SDK.configure do |c| - c.add_span_processor span_processor -end diff --git a/instrumentation/que/.gitignore b/instrumentation/que/.gitignore deleted file mode 100644 index 19e018075d..0000000000 --- a/instrumentation/que/.gitignore +++ /dev/null @@ -1 +0,0 @@ -db/ diff --git a/instrumentation/que/.rubocop.yml b/instrumentation/que/.rubocop.yml deleted file mode 100644 index b28284bcee..0000000000 --- a/instrumentation/que/.rubocop.yml +++ /dev/null @@ -1,5 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-que.rb" diff --git a/instrumentation/que/.yardopts b/instrumentation/que/.yardopts deleted file mode 100644 index a81afb8877..0000000000 --- a/instrumentation/que/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Que Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/que/Appraisals b/instrumentation/que/Appraisals deleted file mode 100644 index ff13c57329..0000000000 --- a/instrumentation/que/Appraisals +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -appraise 'que-1.0' do - gem 'que', '1.0.0.beta4' -end diff --git a/instrumentation/que/CHANGELOG.md b/instrumentation/que/CHANGELOG.md deleted file mode 100644 index c896c62d23..0000000000 --- a/instrumentation/que/CHANGELOG.md +++ /dev/null @@ -1,23 +0,0 @@ -# Release History: opentelemetry-instrumentation-que - -### v0.4.0 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Broken test file requirements - -### v0.3.0 / 2022-05-02 - -* ADDED: Validate Using Enums -* FIXED: RubyGems Fallback - -### v0.2.0 / 2021-12-01 - -* ADDED: Instrument Que poller - -### v0.1.1 / 2021-09-29 - -* (No significant changes) - -### v0.1.0 / 2021-09-15 - -* Initial release. diff --git a/instrumentation/que/Gemfile b/instrumentation/que/Gemfile deleted file mode 100644 index e92e24be6d..0000000000 --- a/instrumentation/que/Gemfile +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :test do - gem 'opentelemetry-instrumentation-base', path: '../base' - gem 'opentelemetry-instrumentation-pg', path: '../../instrumentation/pg' -end diff --git a/instrumentation/que/LICENSE b/instrumentation/que/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/que/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/que/README.md b/instrumentation/que/README.md deleted file mode 100644 index 796e49eca5..0000000000 --- a/instrumentation/que/README.md +++ /dev/null @@ -1,78 +0,0 @@ -# Que Instrumentation - -The Que instrumentation is a community-maintained instrumentation for the [Que][que-home]. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-que -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-que` to your `Gemfile`. - -## Usage - -To install the instrumentation, add the gem to your Gemfile: - -```ruby -gem 'opentelemetry-instrumentation-que' -``` - -Then call `use` with the name of the instrumentation: - -```ruby -require 'rubygems' -require 'bundler/setup' - -Bundler.require - -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Que' -end -``` - -Alternatively, you can also call `use_all` to install all the available instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` - -By default tracing information is propagated using Que Job tags. This can be disabled using: - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Que', propagation_style: :none -end -``` - -If you wish the job will be executed in the same logicial trace as a direct -child of the span that enqueued the job then set propagation_style to `child`. By -default the jobs are just linked together. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Que', propagation_style: :child -end -``` - -## How can I get involved? - -The `opentelemetry-instrumentation-que` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -The `opentelemetry-instrumentation-que` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information. - -[que-home]: https://github.com/que-rb/que -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/instrumentation/que/Rakefile b/instrumentation/que/Rakefile deleted file mode 100644 index 1a64ba842e..0000000000 --- a/instrumentation/que/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/que/example/Gemfile b/instrumentation/que/example/Gemfile deleted file mode 100644 index 7d987006ef..0000000000 --- a/instrumentation/que/example/Gemfile +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gem 'activerecord', '~> 6.0' -gem 'opentelemetry-api' -gem 'opentelemetry-common' -gem 'opentelemetry-instrumentation-que' -gem 'opentelemetry-sdk' -gem 'pg', '~> 1.1' -gem 'que', '~> 1.0.0.beta4' diff --git a/instrumentation/que/example/example.rb b/instrumentation/que/example/example.rb deleted file mode 100755 index 94bed13baf..0000000000 --- a/instrumentation/que/example/example.rb +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env ruby - -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'rubygems' -require 'bundler/setup' - -require 'active_record' -ActiveRecord::Base.establish_connection( - adapter: 'postgresql', - host: ENV.fetch('TEST_POSTGRES_HOST', '127.0.0.1'), - port: ENV.fetch('TEST_POSTGRES_PORT', '5432'), - user: ENV.fetch('TEST_POSTGRES_USER', 'postgres'), - database: ENV.fetch('TEST_POSTGRES_DB', 'postgres'), - password: ENV.fetch('TEST_POSTGRES_PASSWORD', 'postgres') -) - -require 'que' -Que.connection = ActiveRecord -Que.migrate!(version: 4) - -# Job for testing -class TestJob < Que::Job - def run - puts 'Executing TestJob' - end -end - -ENV['OTEL_TRACES_EXPORTER'] = 'console' -require 'opentelemetry-instrumentation-que' -require 'opentelemetry/sdk' -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Que' -end - -puts 'Enqueing a new job' -TestJob.enqueue - -# Start Que worker (based on bin/que) -locker = Que::Locker.new({}) - -# Process jobs for 5 seconds and then stop the worker -sleep 5 -locker.stop! diff --git a/instrumentation/que/example/run.sh b/instrumentation/que/example/run.sh deleted file mode 100755 index c32fb41688..0000000000 --- a/instrumentation/que/example/run.sh +++ /dev/null @@ -1,4 +0,0 @@ -#! /bin/bash - -# Start the server, wait a bit, and provide a command line to run the client -./example.rb & (sleep 5; /bin/bash) diff --git a/instrumentation/que/lib/opentelemetry-instrumentation-que.rb b/instrumentation/que/lib/opentelemetry-instrumentation-que.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/que/lib/opentelemetry-instrumentation-que.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/que/lib/opentelemetry/instrumentation.rb b/instrumentation/que/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index 5becfe89d0..0000000000 --- a/instrumentation/que/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # "Instrumentation" are specified by - # https://github.com/open-telemetry/opentelemetry-specification/blob/784635d01d8690c8f5fcd1f55bdbc8a13cf2f4f2/specification/glossary.md#instrumentation-library - # - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/que' diff --git a/instrumentation/que/lib/opentelemetry/instrumentation/que.rb b/instrumentation/que/lib/opentelemetry/instrumentation/que.rb deleted file mode 100644 index e5cce426b6..0000000000 --- a/instrumentation/que/lib/opentelemetry/instrumentation/que.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the Que gem - module Que - end - end -end - -require_relative './que/instrumentation' -require_relative './que/version' diff --git a/instrumentation/que/lib/opentelemetry/instrumentation/que/instrumentation.rb b/instrumentation/que/lib/opentelemetry/instrumentation/que/instrumentation.rb deleted file mode 100644 index daafa1f20d..0000000000 --- a/instrumentation/que/lib/opentelemetry/instrumentation/que/instrumentation.rb +++ /dev/null @@ -1,71 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Que - # The Instrumentation class contains logic to detect and install the Que - # instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - MINIMUM_VERSION = Gem::Version.new('1.0.0.beta4') - - install do |_| - require_dependencies - patch - - ::Que.job_middleware.push(Middlewares::ServerMiddleware) - end - - present do - defined?(::Que) - end - - compatible do - gem_version >= MINIMUM_VERSION - end - - ## Supported configuration keys for the install config hash: - # - # propagation_style: controls how the job's execution is traced and related - # to the trace where the job was enqueued. Can be one of: - # - # - :link (default) - the job will be executed in a separate trace. - # The initial span of the execution trace will be linked to the span - # that enqueued the job, via a Span Link. - # - :child - the job will be executed in the same logical trace, as a - # direct child of the span that enqueued the job. - # - :none - the job's execution will not be explicitly linked to the - # span that enqueued the job. - # trace_poller: controls whether Que Poller is traced or not. - # - # Note that in all cases, we will store Que's Job ID as the - # `messaging.message_id` attribute, so out-of-band correlation may - # still be possible depending on your backend system. - # - option :propagation_style, default: :link, validate: %i[link child none] - option :trace_poller, default: false, validate: :boolean - - private - - def require_dependencies - require_relative 'tag_setter' - require_relative 'middlewares/server_middleware' - require_relative 'patches/que_job' - require_relative 'patches/poller' - end - - def gem_version - Gem::Version.new(::Que::VERSION) - end - - def patch - ::Que::Job.prepend(Patches::QueJob) - ::Que::Poller.prepend(Patches::Poller) - end - end - end - end -end diff --git a/instrumentation/que/lib/opentelemetry/instrumentation/que/middlewares/server_middleware.rb b/instrumentation/que/lib/opentelemetry/instrumentation/que/middlewares/server_middleware.rb deleted file mode 100644 index 23cafe5cb0..0000000000 --- a/instrumentation/que/lib/opentelemetry/instrumentation/que/middlewares/server_middleware.rb +++ /dev/null @@ -1,95 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Que - module Middlewares - # Server middleware to trace Que jobs - class ServerMiddleware - def self.call(job, &block) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength - job_class = job_class(job) - span_name = "#{job_class} process" - attributes = attributes_before_job_completion(job, job_class) - - extracted_context = extract_context_from_tags(job.que_attrs[:data][:tags] || []) - - OpenTelemetry::Context.with_current(extracted_context) do - if otel_config[:propagation_style] == :child - tracer.in_span(span_name, attributes: attributes, kind: :consumer) do |span| - block.call - enhance_span_after_job_completion(span, job) - end - else - span_links = otel_config[:propagation_style] == :link ? prepare_span_links(extracted_context) : [] - - root_span = tracer.start_root_span(span_name, attributes: attributes, links: span_links, kind: :consumer) - OpenTelemetry::Trace.with_span(root_span) do |span| - block.call - enhance_span_after_job_completion(span, job) - ensure - root_span.finish - end - end - end - - # return value is not important - nil - end - - def self.tracer - OpenTelemetry::Instrumentation::Que::Instrumentation.instance.tracer - end - - def self.otel_config - Que::Instrumentation.instance.config - end - - def self.attributes_before_job_completion(job, job_class) - attributes = { - 'messaging.system' => 'que', - 'messaging.destination' => job.que_attrs[:queue] || 'default', - 'messaging.destination_kind' => 'queue', - 'messaging.operation' => 'process', - 'messaging.que.job_class' => job_class, - 'messaging.que.priority' => job.que_attrs[:priority] || 100 - } - attributes['messaging.message_id'] = job.que_attrs[:id] if job.que_attrs[:id] - attributes - end - - def self.enhance_span_after_job_completion(span, job) - span.set_attribute('messaging.que.attempts', job.que_attrs[:error_count]) - - error = job.que_error - return unless error - - span.record_exception(error) - span.status = OpenTelemetry::Trace::Status.error("Unhandled exception of type: #{error.class}") - end - - # tags is an array looking something like ["tag1", "traceparent:..."] - def self.extract_context_from_tags(tags) - # Convert tags into Hash (ignoring elements that cannot be converted) - tags_hash = Hash[ - tags.map { |value| value.split(':', 2) }.select { |value| value.size == 2 } - ] - OpenTelemetry.propagation.extract(tags_hash) - end - - def self.job_class(job) - job.que_attrs[:job_class] || job.class.name - end - - def self.prepare_span_links(extracted_context) - span_context = OpenTelemetry::Trace.current_span(extracted_context).context - span_context.valid? ? [OpenTelemetry::Trace::Link.new(span_context)] : [] - end - end - end - end - end -end diff --git a/instrumentation/que/lib/opentelemetry/instrumentation/que/patches/poller.rb b/instrumentation/que/lib/opentelemetry/instrumentation/que/patches/poller.rb deleted file mode 100644 index c2786e2e2a..0000000000 --- a/instrumentation/que/lib/opentelemetry/instrumentation/que/patches/poller.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Que - module Patches - # Instrumentation for the Que::Poller module - module Poller - def poll(*args, **kwargs) - # Avoid tracing when should_poll? returns true. This is also used - # in Poller#poll to decide if the actual poll should be executed or - # not. Without this we would generate a lot of unnecessary spans. - return unless should_poll? - - if Que::Instrumentation.instance.config[:trace_poller] - Que::Instrumentation.instance.tracer.in_span('Que::Poller#poll') { super(*args, **kwargs) } - else - OpenTelemetry::Common::Utilities.untraced { super(*args, **kwargs) } - end - end - end - end - end - end -end diff --git a/instrumentation/que/lib/opentelemetry/instrumentation/que/patches/que_job.rb b/instrumentation/que/lib/opentelemetry/instrumentation/que/patches/que_job.rb deleted file mode 100644 index eb97723a6b..0000000000 --- a/instrumentation/que/lib/opentelemetry/instrumentation/que/patches/que_job.rb +++ /dev/null @@ -1,71 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Que - module Patches - # Module to prepend to Que::Job for instrumentation - module QueJob - def self.prepended(base) - class << base - prepend ClassMethods - end - end - - # Module to prepend to Que singleton class - module ClassMethods - def enqueue(*args, tags: nil, **arg_opts) - tracer = Que::Instrumentation.instance.tracer - otel_config = Que::Instrumentation.instance.config - - tracer.in_span('send', kind: :producer) do |span| - # Que doesn't have a good place to store metadata. There are - # basically two options: the job payload and the job tags. - # - # Using the job payload is very brittle. We'd have to modify - # existing Hash arguments or add a new argument when there are - # no arguments we can modify. If the server side is not using - # this instrumentation yet (e.g. old jobs before the - # instrumentation was added or when instrumentation is being - # added to client side first) then the server can error out due - # to unexpected payload. - # - # The second option (which we are using here) is to use tags. - # They also are not meant for tracing information but they are - # much safer to use than modifying the payload. - if otel_config[:propagation_style] != :none - tags ||= [] - OpenTelemetry.propagation.inject(tags, setter: TagSetter) - end - - job = super(*args, tags: tags, **arg_opts) - - span.name = "#{job.que_attrs[:job_class]} send" - span.add_attributes(QueJob.job_attributes(job)) - - job - end - end - end - - def self.job_attributes(job) - attributes = { - 'messaging.system' => 'que', - 'messaging.destination_kind' => 'queue', - 'messaging.operation' => 'send', - 'messaging.destination' => job.que_attrs[:queue] || 'default', - 'messaging.que.job_class' => job.que_attrs[:job_class], - 'messaging.que.priority' => job.que_attrs[:priority] || 100 - } - attributes['messaging.message_id'] = job.que_attrs[:id] if job.que_attrs[:id] - attributes - end - end - end - end - end -end diff --git a/instrumentation/que/lib/opentelemetry/instrumentation/que/tag_setter.rb b/instrumentation/que/lib/opentelemetry/instrumentation/que/tag_setter.rb deleted file mode 100644 index 55d636448b..0000000000 --- a/instrumentation/que/lib/opentelemetry/instrumentation/que/tag_setter.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Que - # The TagSetter class provides methods for writing tracing information to - # Que tags. - # - # @example - # OpenTelemetry.propagation.inject(tags, setter: TagSetter) - class TagSetter - def self.set(carrier, key, value) - carrier << "#{key}:#{value}" - end - end - end - end -end diff --git a/instrumentation/que/lib/opentelemetry/instrumentation/que/version.rb b/instrumentation/que/lib/opentelemetry/instrumentation/que/version.rb deleted file mode 100644 index 4879517dfc..0000000000 --- a/instrumentation/que/lib/opentelemetry/instrumentation/que/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Que - VERSION = '0.4.0' - end - end -end diff --git a/instrumentation/que/opentelemetry-instrumentation-que.gemspec b/instrumentation/que/opentelemetry-instrumentation-que.gemspec deleted file mode 100644 index d1d05e3131..0000000000 --- a/instrumentation/que/opentelemetry-instrumentation-que.gemspec +++ /dev/null @@ -1,52 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/que/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-que' - spec.version = OpenTelemetry::Instrumentation::Que::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'Que instrumentation for the OpenTelemetry framework' - spec.description = 'Que instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.21.0' - - spec.add_development_dependency 'activerecord', '~> 6.0' - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-instrumentation-pg', '~> 0.20' - spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'pg', '~> 1.1' - spec.add_development_dependency 'que', '~> 1.0.0.beta4' - spec.add_development_dependency 'rake', '~> 13.0' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-que/v#{OpenTelemetry::Instrumentation::Que::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/que' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-que/v#{OpenTelemetry::Instrumentation::Que::VERSION}" - end -end diff --git a/instrumentation/que/test/.rubocop.yml b/instrumentation/que/test/.rubocop.yml deleted file mode 100644 index e97eda560f..0000000000 --- a/instrumentation/que/test/.rubocop.yml +++ /dev/null @@ -1,6 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false -Style/MultilineIfModifier: - Enabled: false diff --git a/instrumentation/que/test/opentelemetry/instrumentation/que_test.rb b/instrumentation/que/test/opentelemetry/instrumentation/que_test.rb deleted file mode 100644 index d1838fe6e0..0000000000 --- a/instrumentation/que/test/opentelemetry/instrumentation/que_test.rb +++ /dev/null @@ -1,291 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' -require 'opentelemetry-instrumentation-pg' - -describe OpenTelemetry::Instrumentation::Que do - let(:instrumentation) { OpenTelemetry::Instrumentation::Que::Instrumentation.instance } - let(:pg_instrumentation) { OpenTelemetry::Instrumentation::PG::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:config) { { propagation_style: :link } } - - before do - prepare_que - pg_instrumentation.install - instrumentation.install - instrumentation.instance_variable_set(:@config, config) - exporter.reset - end - - describe 'enqueuing a job' do - it 'creates a span' do - TestJobAsync.enqueue - - _(finished_spans.size).must_equal(1) - - span = finished_spans.last - _(span.kind).must_equal(:producer) - end - - it 'names the created span' do - TestJobAsync.enqueue - - span = finished_spans.last - _(span.name).must_equal('TestJobAsync send') - end - - it 'records attributes' do - TestJobAsync.enqueue - - attributes = finished_spans.last.attributes - _(attributes['messaging.system']).must_equal('que') - _(attributes['messaging.destination']).must_equal('default') - _(attributes['messaging.destination_kind']).must_equal('queue') - _(attributes['messaging.operation']).must_equal('send') - _(attributes['messaging.message_id']).must_be_instance_of(Integer) - _(attributes['messaging.que.job_class']).must_equal('TestJobAsync') - _(attributes['messaging.que.priority']).must_equal(100) - end - end - - describe 'processing a job' do - before do - job = TestJobAsync.enqueue - exporter.reset - Que.run_job_middleware(job) { job.tap(&:_run) } - end - - it 'creates a span' do - _(finished_spans.size).must_equal(1) - - span = finished_spans.last - _(span.kind).must_equal(:consumer) - end - - it 'names the created span' do - span = finished_spans.last - _(span.name).must_equal('TestJobAsync process') - end - - it 'records attributes' do - attributes = finished_spans.last.attributes - _(attributes['messaging.system']).must_equal('que') - _(attributes['messaging.destination']).must_equal('default') - _(attributes['messaging.destination_kind']).must_equal('queue') - _(attributes['messaging.operation']).must_equal('process') - _(attributes['messaging.message_id']).must_be_instance_of(Integer) - _(attributes['messaging.que.job_class']).must_equal('TestJobAsync') - _(attributes['messaging.que.priority']).must_equal(100) - _(attributes['messaging.que.attempts']).must_equal(0) - end - end - - describe 'processing a job that fails' do - before do - job = JobThatFails.enqueue - exporter.reset - Que.run_job_middleware(job) { job.tap(&:_run) } - end - - it 'marks the span as failed' do - span = finished_spans.last - _(span.status.ok?).must_equal(false) - end - end - - # Sync job is usually used for testing. It bypasses the whole job storage - # part and executes the job immediately. We'll still create a span for - # creating a job and one for processing the job. - describe 'enqueuing a sync job' do - it 'creates two spans' do - TestJobSync.enqueue - - _(finished_spans.size).must_equal(2) - - span1 = finished_spans.last - _(span1.kind).must_equal(:producer) - - span2 = finished_spans.first - _(span2.kind).must_equal(:consumer) - end - - it 'names the created span' do - TestJobSync.enqueue - - span1 = finished_spans.last - _(span1.name).must_equal('TestJobSync send') - - span2 = finished_spans.first - _(span2.name).must_equal('TestJobSync process') - end - - it 'records attributes' do - TestJobSync.enqueue - - attributes = finished_spans.first.attributes - _(attributes['messaging.system']).must_equal('que') - _(attributes['messaging.destination']).must_equal('default') - _(attributes['messaging.destination_kind']).must_equal('queue') - _(attributes['messaging.operation']).must_equal('process') - _(attributes['messaging.que.job_class']).must_equal('TestJobSync') - _(attributes['messaging.que.priority']).must_equal(100) - end - end - - describe 'span propagation' do - describe 'when propagation_style is set to link' do - it 'stores tracing information in the last parameter' do - job_class = Class.new(Que::Job) do - def self.run(first, second); end - end - first = 'first-argument' - second = 'second-argument' - job_class.enqueue(first, second, job_class: 'LastHashParameter') - - model = last_record_in_database - _(model.data['tags'].size).must_equal(1) - _(model.data['tags'][0]).must_match(/traceparent:/) - end - - it 'keeps original tags' do - job_class = Class.new(Que::Job) do - def self.run(first, second); end - end - first = 'first-argument' - second = 'second-argument' - job_class.enqueue(first, second, job_class: 'LastHashParameterWithTags', tags: ['high-priority']) - - model = last_record_in_database - _(model.data['tags'].size).must_equal(2) - _(model.data['tags'][0]).must_equal('high-priority') - _(model.data['tags'][1]).must_match(/traceparent:/) - end - - it 'links spans together' do - job = TestJobAsync.enqueue - Que.run_job_middleware(job) { job.tap(&:_run) } - - _(finished_spans.size).must_equal(2) - - send_span = finished_spans.first - process_span = finished_spans.last - - _(send_span.trace_id).wont_equal(process_span.trace_id) - - _(process_span.total_recorded_links).must_equal(1) - _(process_span.links[0].span_context.trace_id).must_equal(send_span.trace_id) - _(process_span.links[0].span_context.span_id).must_equal(send_span.span_id) - end - end - - describe 'when propagation_style is set to child' do - let(:config) { { propagation_style: :child } } - - it 'links spans together using parent/child relationship' do - job = TestJobAsync.enqueue - Que.run_job_middleware(job) { job.tap(&:_run) } - - _(finished_spans.size).must_equal(2) - - send_span = finished_spans.first - process_span = finished_spans.last - - _(send_span.trace_id).must_equal(process_span.trace_id) - _(process_span.parent_span_id).must_equal(send_span.span_id) - _(process_span.total_recorded_links).must_equal(0) - end - end - - describe 'when propagation_style is set to none' do - let(:config) { { propagation_style: :none } } - - it 'does not store tracing information' do - job_class = Class.new(Que::Job) do - def self.run(first, second); end - end - first = 'first-argument' - second = 'second-argument' - job_class.enqueue(first, second, job_class: 'PropagationStyleSetToNone') - - model = last_record_in_database - _(model.data['tags']).must_be_nil - end - - it 'does not link spans together' do - job = TestJobAsync.enqueue - Que.run_job_middleware(job) { job.tap(&:_run) } - - _(finished_spans.size).must_equal(2) - - send_span = finished_spans.first - process_span = finished_spans.last - - _(send_span.trace_id).wont_equal(process_span.trace_id) - _(send_span.total_recorded_links).must_equal(0) - _(process_span.total_recorded_links).must_equal(0) - end - end - end - - describe 'que poller' do - describe 'when trace_poller is enabled' do - let(:config) { { trace_poller: true } } - - it 'traces calls to Que::Poller#poll' do - spans = run_one_locker_cycle - spans = spans.sort_by(&:name) - - root_span = spans.detect { |span| span.name == 'Que::Poller#poll' } - _(root_span.parent_span_id).must_equal(OpenTelemetry::Trace::INVALID_SPAN_ID) - - other_spans = spans - [root_span] - _(other_spans.count.positive?).must_equal(true) - - other_spans.each do |other_span| - _(other_span.parent_span_id).must_equal(root_span.span_id) - end - end - end - - describe 'when trace_poller is disabled' do - let(:config) { { trace_poller: false } } - - it 'does not create any spans' do - spans = run_one_locker_cycle - _(spans).must_equal([]) - end - end - end - - def finished_spans(include_pg: false) - if include_pg - exporter.finished_spans - else - exporter.finished_spans.reject { |span| span.name =~ /#{database_name}/ } - end - end - - def last_record_in_database - require 'que/active_record/model' - Que::ActiveRecord::Model.last - end - - def run_one_locker_cycle - poll_interval = 0.1 # in seconds - locker = Que::Locker.new(poll_interval: poll_interval, wait_period: 0.001) - - # Clear all the startup spans - sleep 0.05 - exporter.reset - - sleep poll_interval - finished_spans = finished_spans(include_pg: true) - locker.stop! - - finished_spans - end -end unless ENV['OMIT_SERVICES'] diff --git a/instrumentation/que/test/test_helper.rb b/instrumentation/que/test/test_helper.rb deleted file mode 100644 index 6ebef4f7cb..0000000000 --- a/instrumentation/que/test/test_helper.rb +++ /dev/null @@ -1,57 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' - -require 'minitest/autorun' - -require_relative '../lib/opentelemetry-instrumentation-que' - -# global opentelemetry-sdk setup: -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -require 'que' - -class TestJobSync < Que::Job - self.run_synchronously = true -end - -class TestJobAsync < Que::Job -end - -class JobThatFails < Que::Job - def run - raise 'oh no' - end -end - -OpenTelemetry::SDK.configure do |c| - c.add_span_processor span_processor -end - -def prepare_que - require 'active_record' - ActiveRecord::Base.establish_connection( - adapter: 'postgresql', - host: ENV.fetch('TEST_POSTGRES_HOST', '127.0.0.1'), - port: ENV.fetch('TEST_POSTGRES_PORT', '5432'), - user: ENV.fetch('TEST_POSTGRES_USER', 'postgres'), - database: database_name, - password: ENV.fetch('TEST_POSTGRES_PASSWORD', 'postgres') - ) - - Que.connection = ActiveRecord - Que.migrate!(version: 4) - - # Make sure the que_jobs table is empty before running tests. - ActiveRecord::Base.connection.execute('TRUNCATE que_jobs') -end - -def database_name - ENV.fetch('TEST_POSTGRES_DB', 'postgres') -end diff --git a/instrumentation/rack/.rubocop.yml b/instrumentation/rack/.rubocop.yml deleted file mode 100644 index 146324b9c2..0000000000 --- a/instrumentation/rack/.rubocop.yml +++ /dev/null @@ -1,5 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-rack.rb" diff --git a/instrumentation/rack/.yardopts b/instrumentation/rack/.yardopts deleted file mode 100644 index 8161402211..0000000000 --- a/instrumentation/rack/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Rack Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/rack/Appraisals b/instrumentation/rack/Appraisals deleted file mode 100644 index e39f83a89b..0000000000 --- a/instrumentation/rack/Appraisals +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -appraise 'rack-2.1' do - gem 'rack', '~> 2.1.2' -end - -appraise 'rack-2.0' do - gem 'rack', '2.0.8' -end diff --git a/instrumentation/rack/CHANGELOG.md b/instrumentation/rack/CHANGELOG.md deleted file mode 100644 index 7695d8ac63..0000000000 --- a/instrumentation/rack/CHANGELOG.md +++ /dev/null @@ -1,119 +0,0 @@ -# Release History: opentelemetry-instrumentation-rack - -### v0.21.0 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Broken test file requirements - -### v0.20.2 / 2022-05-02 - -* FIXED: Update server instrumentation to not reflect 400 status as error - -### v0.20.1 / 2021-12-01 - -* FIXED: [Instruentation Rack] Log content type http header -* FIXED: Use monotonic clock where possible -* FIXED: Rack to stop using api env getter - -### v0.20.0 / 2021-10-06 - -* FIXED: Prevent high cardinality rack span name as a default [#973](https://github.com/open-telemetry/opentelemetry-ruby/pull/973) - -The default was to set the span name as the path of the request, we have -corrected this as it was not adhering to the spec requirement using low -cardinality span names. You can restore the previous behaviour of high -cardinality span names by passing in a url quantization function that -forwards the uri path. More details on this is available in the readme. - -### v0.19.3 / 2021-09-29 - -* (No significant changes) - -### v0.19.2 / 2021-08-18 - -* FIXED: Rack middleware assuming script_name presence - -### v0.19.1 / 2021-08-12 - -* DOCS: Update docs to rely more on environment variable configuration - -### v0.19.0 / 2021-06-23 - -* BREAKING CHANGE: Total order constraint on span.status= - -* ADDED: Add Tracer.non_recording_span to API -* FIXED: Total order constraint on span.status= - -### v0.18.0 / 2021-05-21 - -* ADDED: Updated API depedency for 1.0.0.rc1 -* FIXED: Removed http.status_text attribute #750 - -### v0.17.0 / 2021-04-22 - -* (No significant changes) - -### v0.16.0 / 2021-03-17 - -* BREAKING CHANGE: Pass env to url quantization rack config to allow more flexibility - -* ADDED: Pass env to url quantization rack config to allow more flexibility -* ADDED: Add rack instrumentation config option to accept callable to filter requests to trace -* FIXED: Example scripts now reference local common lib -* DOCS: Replace Gitter with GitHub Discussions - -### v0.15.0 / 2021-02-18 - -* ADDED: Add instrumentation config validation - -### v0.14.0 / 2021-02-03 - -* BREAKING CHANGE: Replace getter and setter callables and remove rack specific propagators - -* ADDED: Replace getter and setter callables and remove rack specific propagators -* ADDED: Add untraced endpoints config to rack middleware - -### v0.13.0 / 2021-01-29 - -* FIXED: Only include user agent when present - -### v0.12.0 / 2020-12-24 - -* (No significant changes) - -### v0.11.0 / 2020-12-11 - -* FIXED: Copyright comments to not reference year - -### v0.10.1 / 2020-12-09 - -* FIXED: Rack current_span - -### v0.10.0 / 2020-12-03 - -* (No significant changes) - -### v0.9.0 / 2020-11-27 - -* BREAKING CHANGE: Add timeout for force_flush and shutdown - -* ADDED: Instrument rails -* ADDED: Add timeout for force_flush and shutdown - -### v0.8.0 / 2020-10-27 - -* BREAKING CHANGE: Move context/span methods to Trace module -* BREAKING CHANGE: Remove 'canonical' from status codes - -* FIXED: Move context/span methods to Trace module -* FIXED: Remove 'canonical' from status codes - -### v0.7.0 / 2020-10-07 - -* FIXED: Remove superfluous file from Rack gem -* DOCS: Added README for Rack Instrumentation -* DOCS: Standardize toplevel docs structure and readme - -### v0.6.0 / 2020-09-10 - -* (No significant changes) diff --git a/instrumentation/rack/Gemfile b/instrumentation/rack/Gemfile deleted file mode 100644 index 5b7d54b645..0000000000 --- a/instrumentation/rack/Gemfile +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :test do - gem 'opentelemetry-instrumentation-base', path: '../base' - gem 'pry-byebug' -end diff --git a/instrumentation/rack/LICENSE b/instrumentation/rack/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/rack/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/rack/README.md b/instrumentation/rack/README.md deleted file mode 100644 index f32c55cf43..0000000000 --- a/instrumentation/rack/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# OpenTelemetry Rack Instrumentation - -The Rack instrumentation is a community-maintained instrumentation for the [Rack][rack-home] web server interface. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-rack -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-rack` in your `Gemfile`. - -## Usage - -To use the instrumentation, call `use` with the name of the instrumentation: - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Rack' -end -``` - -Alternatively, you can also call `use_all` to install all the available instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` -## Controlling span name cardinality - -By default we will set the rack span name to match the format "HTTP #{method}" (ie. HTTP GET). There are different ways to control span names with this instrumentation. - -### Enriching rack spans - -We surface a hook to easily retrieve the rack span within the context of a request so that you can add information to or rename your server span. - -This is how the rails controller instrumentation is able to rename the span names to match the controller and action that process the request. See https://github.com/open-telemetry/opentelemetry-ruby/blob/f6fb025bef69f839078748f56516ce38c7d51eb8/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/patches/action_controller/metal.rb#L15-L16 for an example. - -### High cardinality example - -You can pass in an url quantization lambda that simply uses the URL path, the result is you will end up with high cardinality span names, however this may be acceptable in your deployment and is easy configurable using the following example. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Rack', { url_quantization: ->(path, _env) { path.to_s } } -end -``` - -## Examples - -Example usage can be seen in the `./example/trace_demonstration.rb` file [here](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/instrumentation/rack/example/trace_demonstration.rb) - -## How can I get involved? - -The `opentelemetry-instrumentation-rack` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -The `opentelemetry-instrumentation-rack` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information. - -[rack-home]: https://github.com/rack/rack -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/instrumentation/rack/Rakefile b/instrumentation/rack/Rakefile deleted file mode 100644 index 1a64ba842e..0000000000 --- a/instrumentation/rack/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/rack/example/Gemfile b/instrumentation/rack/example/Gemfile deleted file mode 100644 index 9aacccbda2..0000000000 --- a/instrumentation/rack/example/Gemfile +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -source 'https://rubygems.org' - -gem 'opentelemetry-api' -gem 'opentelemetry-common' -gem 'opentelemetry-instrumentation-rack' -gem 'opentelemetry-sdk' -gem 'rack' -gem 'rack-test' diff --git a/instrumentation/rack/example/trace_demonstration.rb b/instrumentation/rack/example/trace_demonstration.rb deleted file mode 100644 index e6253f57cf..0000000000 --- a/instrumentation/rack/example/trace_demonstration.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'rubygems' -require 'bundler/setup' - -Bundler.require - -ENV['OTEL_TRACES_EXPORTER'] = 'console' -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Rack' -end - -# setup fake rack application: -builder = Rack::Builder.app do - # integration should be automatic in web frameworks (like rails), - # but for a plain Rack application, enable it in your config.ru, e.g., - use OpenTelemetry::Instrumentation::Rack::Middlewares::TracerMiddleware - - app = ->(_env) { [200, { 'Content-Type' => 'text/plain' }, ['All responses are OK']] } - run app -end - -# demonstrate tracing (span output to console): -puts Rack::MockRequest.new(builder).get('/') diff --git a/instrumentation/rack/example/trace_demonstration2.rb b/instrumentation/rack/example/trace_demonstration2.rb deleted file mode 100644 index c6ac649e9e..0000000000 --- a/instrumentation/rack/example/trace_demonstration2.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'rubygems' -require 'bundler/setup' - -Bundler.require - -# setup fake rack application: -builder = Rack::Builder.new -app = ->(_env) { [200, { 'Content-Type' => 'text/plain' }, ['All responses are OK']] } -builder.run app - -# demonstrate integration using 'retain_middlware_names' and 'application': -ENV['OTEL_TRACES_EXPORTER'] = 'console' -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Rack', - retain_middleware_names: true, - application: builder, - record_frontend_span: true -end - -# integrate instrumentation explicitly: -builder.use OpenTelemetry::Instrumentation::Rack::Middlewares::TracerMiddleware - -# demonstrate tracing (span output to console): -puts Rack::MockRequest.new(builder).get('/') diff --git a/instrumentation/rack/lib/opentelemetry-instrumentation-rack.rb b/instrumentation/rack/lib/opentelemetry-instrumentation-rack.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/rack/lib/opentelemetry-instrumentation-rack.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/rack/lib/opentelemetry/instrumentation.rb b/instrumentation/rack/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index 55a43ab07a..0000000000 --- a/instrumentation/rack/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/rack' diff --git a/instrumentation/rack/lib/opentelemetry/instrumentation/rack.rb b/instrumentation/rack/lib/opentelemetry/instrumentation/rack.rb deleted file mode 100644 index 0274c89752..0000000000 --- a/instrumentation/rack/lib/opentelemetry/instrumentation/rack.rb +++ /dev/null @@ -1,53 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the Rack gem - module Rack - extend self - - CURRENT_SPAN_KEY = Context.create_key('current-span') - - private_constant :CURRENT_SPAN_KEY - - # Returns the current span from the current or provided context - # - # @param [optional Context] context The context to lookup the current - # {Span} from. Defaults to Context.current - def current_span(context = nil) - context ||= Context.current - context.value(CURRENT_SPAN_KEY) || OpenTelemetry::Trace::Span::INVALID - end - - # Returns a context containing the span, derived from the optional parent - # context, or the current context if one was not provided. - # - # @param [optional Context] context The context to use as the parent for - # the returned context - def context_with_span(span, parent_context: Context.current) - parent_context.set_value(CURRENT_SPAN_KEY, span) - end - - # Activates/deactivates the Span within the current Context, which makes the "current span" - # available implicitly. - # - # On exit, the Span that was active before calling this method will be reactivated. - # - # @param [Span] span the span to activate - # @yield [span, context] yields span and a context containing the span to the block. - def with_span(span) - Context.with_value(CURRENT_SPAN_KEY, span) { |c, s| yield s, c } - end - end - end -end - -require_relative './rack/instrumentation' -require_relative './rack/version' diff --git a/instrumentation/rack/lib/opentelemetry/instrumentation/rack/instrumentation.rb b/instrumentation/rack/lib/opentelemetry/instrumentation/rack/instrumentation.rb deleted file mode 100644 index d2277c22a9..0000000000 --- a/instrumentation/rack/lib/opentelemetry/instrumentation/rack/instrumentation.rb +++ /dev/null @@ -1,66 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' - -module OpenTelemetry - module Instrumentation - module Rack - # The Instrumentation class contains logic to detect and install the Rack - # instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - install do |config| - require_dependencies - - retain_middleware_names if config[:retain_middleware_names] - end - - present do - defined?(::Rack) - end - - option :allowed_request_headers, default: [], validate: :array - option :allowed_response_headers, default: [], validate: :array - option :application, default: nil, validate: :callable - option :record_frontend_span, default: false, validate: :boolean - option :retain_middleware_names, default: false, validate: :boolean - option :untraced_endpoints, default: [], validate: :array - option :url_quantization, default: nil, validate: :callable - option :untraced_requests, default: nil, validate: :callable - - private - - def require_dependencies - require_relative 'middlewares/tracer_middleware' - end - - MissingApplicationError = Class.new(StandardError) - - # intercept all middleware-compatible calls, retain class name - def retain_middleware_names - next_middleware = config[:application] - raise MissingApplicationError unless next_middleware - - while next_middleware - if next_middleware.respond_to?(:call) - next_middleware.singleton_class.class_eval do - alias_method :__call, :call - - def call(env) - env['RESPONSE_MIDDLEWARE'] = self.class.to_s - __call(env) - end - end - end - - next_middleware = next_middleware.instance_variable_defined?('@app') && - next_middleware.instance_variable_get('@app') - end - end - end - end - end -end diff --git a/instrumentation/rack/lib/opentelemetry/instrumentation/rack/middlewares/tracer_middleware.rb b/instrumentation/rack/lib/opentelemetry/instrumentation/rack/middlewares/tracer_middleware.rb deleted file mode 100644 index 68d5b5d53a..0000000000 --- a/instrumentation/rack/lib/opentelemetry/instrumentation/rack/middlewares/tracer_middleware.rb +++ /dev/null @@ -1,202 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry/trace/status' - -require_relative '../util/queue_time' - -module OpenTelemetry - module Instrumentation - module Rack - module Middlewares - # TracerMiddleware propagates context and instruments Rack requests - # by way of its middleware system - class TracerMiddleware # rubocop:disable Metrics/ClassLength - class << self - def allowed_rack_request_headers - @allowed_rack_request_headers ||= Array(config[:allowed_request_headers]).each_with_object({}) do |header, memo| - key = header.to_s.upcase.gsub(/[-\s]/, '_') - case key - when 'CONTENT_TYPE', 'CONTENT_LENGTH' - memo[key] = build_attribute_name('http.request.headers.', header) - else - memo["HTTP_#{key}"] = build_attribute_name('http.request.headers.', header) - end - end - end - - def allowed_response_headers - @allowed_response_headers ||= Array(config[:allowed_response_headers]).each_with_object({}) do |header, memo| - memo[header] = build_attribute_name('http.response.headers.', header) - memo[header.to_s.upcase] = build_attribute_name('http.response.headers.', header) - end - end - - def build_attribute_name(prefix, suffix) - prefix + suffix.to_s.downcase.gsub(/[-\s]/, '_') - end - - def config - Rack::Instrumentation.instance.config - end - - private - - def clear_cached_config - @allowed_rack_request_headers = nil - @allowed_response_headers = nil - end - end - - EMPTY_HASH = {}.freeze - - def initialize(app) - @app = app - @untraced_endpoints = config[:untraced_endpoints] - end - - def call(env) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength - if untraced_request?(env) - OpenTelemetry::Common::Utilities.untraced do - return @app.call(env) - end - end - - original_env = env.dup - extracted_context = OpenTelemetry.propagation.extract( - env, - getter: OpenTelemetry::Common::Propagation.rack_env_getter - ) - frontend_context = create_frontend_span(env, extracted_context) - - # restore extracted context in this process: - OpenTelemetry::Context.with_current(frontend_context || extracted_context) do - request_span_name = create_request_span_name(env['REQUEST_URI'] || original_env['PATH_INFO'], env) - request_span_kind = frontend_context.nil? ? :server : :internal - tracer.in_span(request_span_name, - attributes: request_span_attributes(env: env), - kind: request_span_kind) do |request_span| - OpenTelemetry::Instrumentation::Rack.with_span(request_span) do - @app.call(env).tap do |status, headers, response| - set_attributes_after_request(request_span, status, headers, response) - end - end - end - end - ensure - finish_span(frontend_context) - end - - private - - def untraced_request?(env) - return true if @untraced_endpoints.include?(env['PATH_INFO']) - return true if config[:untraced_requests]&.call(env) - - false - end - - # return Context with the frontend span as the current span - def create_frontend_span(env, extracted_context) - request_start_time = OpenTelemetry::Instrumentation::Rack::Util::QueueTime.get_request_start(env) - - return unless config[:record_frontend_span] && !request_start_time.nil? - - span = tracer.start_span('http_server.proxy', - with_parent: extracted_context, - start_timestamp: request_start_time, - kind: :server) - - OpenTelemetry::Trace.context_with_span(span, parent_context: extracted_context) - end - - def finish_span(context) - OpenTelemetry::Trace.current_span(context).finish if context - end - - def tracer - OpenTelemetry::Instrumentation::Rack::Instrumentation.instance.tracer - end - - def request_span_attributes(env:) - attributes = { - 'http.method' => env['REQUEST_METHOD'], - 'http.host' => env['HTTP_HOST'] || 'unknown', - 'http.scheme' => env['rack.url_scheme'], - 'http.target' => env['QUERY_STRING'].empty? ? env['PATH_INFO'] : "#{env['PATH_INFO']}?#{env['QUERY_STRING']}" - } - - attributes['http.user_agent'] = env['HTTP_USER_AGENT'] if env['HTTP_USER_AGENT'] - attributes.merge!(allowed_request_headers(env)) - end - - # https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/data-http.md#name - # - # recommendation: span.name(s) should be low-cardinality (e.g., - # strip off query param value, keep param name) - # - # see http://github.com/open-telemetry/opentelemetry-specification/pull/416/files - def create_request_span_name(request_uri_or_path_info, env) - # NOTE: dd-trace-rb has implemented 'quantization' (which lowers url cardinality) - # see Datadog::Quantization::HTTP.url - - if (implementation = config[:url_quantization]) - implementation.call(request_uri_or_path_info, env) - else - "HTTP #{env['REQUEST_METHOD']}" - end - end - - def set_attributes_after_request(span, status, headers, _response) - span.status = OpenTelemetry::Trace::Status.error unless (100..499).include?(status.to_i) - span.set_attribute('http.status_code', status) - - # NOTE: if data is available, it would be good to do this: - # set_attribute('http.route', ... - # e.g., "/users/:userID? - - allowed_response_headers(headers).each { |k, v| span.set_attribute(k, v) } - end - - def allowed_request_headers(env) - return EMPTY_HASH if self.class.allowed_rack_request_headers.empty? - - {}.tap do |result| - self.class.allowed_rack_request_headers.each do |key, value| - result[value] = env[key] if env.key?(key) - end - end - end - - def allowed_response_headers(headers) - return EMPTY_HASH if headers.nil? - return EMPTY_HASH if self.class.allowed_response_headers.empty? - - {}.tap do |result| - self.class.allowed_response_headers.each do |key, value| - if headers.key?(key) - result[value] = headers[key] - else - # do case-insensitive match: - headers.each do |k, v| - if k.upcase == key - result[value] = v - break - end - end - end - end - end - end - - def config - Rack::Instrumentation.instance.config - end - end - end - end - end -end diff --git a/instrumentation/rack/lib/opentelemetry/instrumentation/rack/util/queue_time.rb b/instrumentation/rack/lib/opentelemetry/instrumentation/rack/util/queue_time.rb deleted file mode 100644 index 29176ee793..0000000000 --- a/instrumentation/rack/lib/opentelemetry/instrumentation/rack/util/queue_time.rb +++ /dev/null @@ -1,48 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Rack - module Util - # QueueTime simply... - module QueueTime - REQUEST_START = 'HTTP_X_REQUEST_START' - QUEUE_START = 'HTTP_X_QUEUE_START' - MINIMUM_ACCEPTABLE_TIME_VALUE = 1_000_000_000 - - module_function - - def get_request_start(env, now = nil) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity - header = env[REQUEST_START] || env[QUEUE_START] - return unless header - - # nginx header is seconds in the format "t=1512379167.574" - # apache header is microseconds in the format "t=1570633834463123" - # heroku header is milliseconds in the format "1570634024294" - time_string = header.to_s.delete('^0-9') - return if time_string.nil? - - # Return nil if the time is clearly invalid - time_value = "#{time_string[0, 10]}.#{time_string[10, 6]}".to_f - return if time_value.zero? || time_value < MINIMUM_ACCEPTABLE_TIME_VALUE - - # return the request_start only if it's lesser than - # current time, to avoid significant clock skew - request_start = Time.at(time_value) - now ||= Time.now.utc - request_start.utc > now ? nil : request_start - rescue StandardError => e - # in case of an Exception we don't create a - # `request.queuing` span - OpenTelemetry.logger.debug("[rack] unable to parse request queue headers: #{e}") - nil - end - end - end - end - end -end diff --git a/instrumentation/rack/lib/opentelemetry/instrumentation/rack/version.rb b/instrumentation/rack/lib/opentelemetry/instrumentation/rack/version.rb deleted file mode 100644 index d7de0c4dd7..0000000000 --- a/instrumentation/rack/lib/opentelemetry/instrumentation/rack/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Rack - VERSION = '0.21.0' - end - end -end diff --git a/instrumentation/rack/opentelemetry-instrumentation-rack.gemspec b/instrumentation/rack/opentelemetry-instrumentation-rack.gemspec deleted file mode 100644 index 10bd92fa7b..0000000000 --- a/instrumentation/rack/opentelemetry-instrumentation-rack.gemspec +++ /dev/null @@ -1,52 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/rack/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-rack' - spec.version = OpenTelemetry::Instrumentation::Rack::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'Rack instrumentation for the OpenTelemetry framework' - spec.description = 'Rack instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-common', '~> 0.19.3' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.21.0' - - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'rack', '~> 2.0.8' - spec.add_development_dependency 'rack-test', '~> 1.1.0' - spec.add_development_dependency 'rake', '~> 12.3.3' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'webmock', '~> 3.7.6' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-rack/v#{OpenTelemetry::Instrumentation::Rack::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/rack' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-rack/v#{OpenTelemetry::Instrumentation::Rack::VERSION}" - end -end diff --git a/instrumentation/rack/test/.rubocop.yml b/instrumentation/rack/test/.rubocop.yml deleted file mode 100644 index dd94258585..0000000000 --- a/instrumentation/rack/test/.rubocop.yml +++ /dev/null @@ -1,4 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false diff --git a/instrumentation/rack/test/opentelemetry/instrumentation/rack/instrumentation_test.rb b/instrumentation/rack/test/opentelemetry/instrumentation/rack/instrumentation_test.rb deleted file mode 100644 index e7d9c170a3..0000000000 --- a/instrumentation/rack/test/opentelemetry/instrumentation/rack/instrumentation_test.rb +++ /dev/null @@ -1,74 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -describe OpenTelemetry::Instrumentation::Rack::Instrumentation do - let(:instrumentation_class) { OpenTelemetry::Instrumentation::Rack::Instrumentation } - let(:instrumentation) { instrumentation_class.instance } - let(:config) { {} } - - after do - # simulate a fresh install: - instrumentation.instance_variable_set('@installed', false) - instrumentation.install({}) - end - - describe 'config[:retain_middleware_names]' do - let(:config) { Hash(retain_middleware_names: true) } - - describe 'without config[:application]' do - it 'raises error' do - # allow for re-installation with new config: - instrumentation.instance_variable_set('@installed', false) - - assert_raises instrumentation_class::MissingApplicationError do - instrumentation.install(config) - end - end - end - - describe 'default' do - class MyAppClass - attr_reader :env - - def use(*); end - - def call(env) - @env = env - [200, { 'Content-Type' => 'text/plain' }, ['OK']] - end - end - - let(:app) { MyAppClass.new } - - describe 'without config' do - it 'does not set RESPONSE_MIDDLEWARE' do - app.call({}) - - _(app.env['RESPONSE_MIDDLEWARE']).must_be_nil - end - end - - describe 'with config[:application]' do - let(:config) do - { retain_middleware_names: true, - application: app } - end - - it 'retains RESPONSE_MIDDLEWARE after .call' do - # allow for re-installation with new config: - instrumentation.instance_variable_set('@installed', false) - - instrumentation.install(config) - app.call({}) - - _(app.env['RESPONSE_MIDDLEWARE']).must_equal 'MyAppClass' - end - end - end - end -end diff --git a/instrumentation/rack/test/opentelemetry/instrumentation/rack/middlewares/tracer_middleware_test.rb b/instrumentation/rack/test/opentelemetry/instrumentation/rack/middlewares/tracer_middleware_test.rb deleted file mode 100644 index b640fc7a39..0000000000 --- a/instrumentation/rack/test/opentelemetry/instrumentation/rack/middlewares/tracer_middleware_test.rb +++ /dev/null @@ -1,328 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -# require Instrumentation so .install method is found: -require_relative '../../../../../lib/opentelemetry/instrumentation/rack' -require_relative '../../../../../lib/opentelemetry/instrumentation/rack/instrumentation' -require_relative '../../../../../lib/opentelemetry/instrumentation/rack/middlewares/tracer_middleware' - -describe OpenTelemetry::Instrumentation::Rack::Middlewares::TracerMiddleware do - let(:instrumentation_module) { OpenTelemetry::Instrumentation::Rack } - let(:instrumentation_class) { instrumentation_module::Instrumentation } - let(:instrumentation) { instrumentation_class.instance } - - let(:described_class) { OpenTelemetry::Instrumentation::Rack::Middlewares::TracerMiddleware } - - let(:app) { ->(_env) { [200, { 'Content-Type' => 'text/plain' }, ['OK']] } } - let(:middleware) { described_class.new(app) } - let(:rack_builder) { Rack::Builder.new } - - let(:exporter) { EXPORTER } - let(:finished_spans) { exporter.finished_spans } - let(:first_span) { exporter.finished_spans.first } - - let(:default_config) { {} } - let(:config) { default_config } - let(:env) { {} } - let(:uri) { '/' } - - before do - # clear captured spans: - exporter.reset - - # simulate a fresh install: - instrumentation.instance_variable_set('@installed', false) - instrumentation.install(config) - - # clear out cached config: - described_class.send(:clear_cached_config) - - # integrate tracer middleware: - rack_builder.run app - rack_builder.use described_class - end - - after do - # installation is 'global', so it should be reset: - instrumentation.instance_variable_set('@installed', false) - instrumentation.install(default_config) - end - - describe '#call' do - before do - Rack::MockRequest.new(rack_builder).get(uri, env) - end - - it 'records attributes' do - _(first_span.attributes['http.method']).must_equal 'GET' - _(first_span.attributes['http.status_code']).must_equal 200 - _(first_span.attributes['http.target']).must_equal '/' - _(first_span.attributes['http.url']).must_be_nil - _(first_span.name).must_equal 'HTTP GET' - _(first_span.kind).must_equal :server - end - - it 'does not explicitly set status OK' do - _(first_span.status.code).must_equal OpenTelemetry::Trace::Status::UNSET - end - - it 'has no parent' do - _(first_span.parent_span_id).must_equal OpenTelemetry::Trace::INVALID_SPAN_ID - end - - describe 'when a query is passed in' do - let(:uri) { '/endpoint?query=true' } - - it 'records the query path' do - _(first_span.attributes['http.target']).must_equal '/endpoint?query=true' - _(first_span.name).must_equal 'HTTP GET' - end - end - - describe 'config[:untraced_endpoints]' do - describe 'when an array is passed in' do - let(:config) { { untraced_endpoints: ['/ping'] } } - - it 'does not trace paths listed in the array' do - Rack::MockRequest.new(rack_builder).get('/ping', env) - - ping_span = finished_spans.find { |s| s.attributes['http.target'] == '/ping' } - _(ping_span).must_be_nil - - root_span = finished_spans.find { |s| s.attributes['http.target'] == '/' } - _(root_span).wont_be_nil - end - end - - describe 'when a string is passed in' do - let(:config) { { untraced_endpoints: '/ping' } } - - it 'traces everything' do - Rack::MockRequest.new(rack_builder).get('/ping', env) - - ping_span = finished_spans.find { |s| s.attributes['http.target'] == '/ping' } - _(ping_span).wont_be_nil - - root_span = finished_spans.find { |s| s.attributes['http.target'] == '/' } - _(root_span).wont_be_nil - end - end - - describe 'when nil is passed in' do - let(:config) { { untraced_endpoints: nil } } - - it 'traces everything' do - Rack::MockRequest.new(rack_builder).get('/ping', env) - - ping_span = finished_spans.find { |s| s.attributes['http.target'] == '/ping' } - _(ping_span).wont_be_nil - - root_span = finished_spans.find { |s| s.attributes['http.target'] == '/' } - _(root_span).wont_be_nil - end - end - end - - describe 'config[:untraced_requests]' do - describe 'when a callable is passed in' do - let(:untraced_callable) do - ->(env) { env['PATH_INFO'] =~ %r{^\/assets} } - end - let(:config) { default_config.merge(untraced_requests: untraced_callable) } - - it 'does not trace requests in which the callable returns true' do - Rack::MockRequest.new(rack_builder).get('/assets', env) - - ping_span = finished_spans.find { |s| s.attributes['http.target'] == '/assets' } - _(ping_span).must_be_nil - - root_span = finished_spans.find { |s| s.attributes['http.target'] == '/' } - _(root_span).wont_be_nil - end - end - - describe 'when nil is passed in' do - let(:config) { { untraced_requests: nil } } - - it 'traces everything' do - Rack::MockRequest.new(rack_builder).get('/assets', env) - - ping_span = finished_spans.find { |s| s.attributes['http.target'] == '/assets' } - _(ping_span).wont_be_nil - - root_span = finished_spans.find { |s| s.attributes['http.target'] == '/' } - _(root_span).wont_be_nil - end - end - end - - describe 'config[:allowed_request_headers]' do - let(:env) do - Hash( - 'CONTENT_LENGTH' => '123', - 'CONTENT_TYPE' => 'application/json', - 'HTTP_FOO_BAR' => 'http foo bar value' - ) - end - - it 'defaults to nil' do - _(first_span.attributes['http.request.headers.foo_bar']).must_be_nil - end - - describe 'when configured' do - let(:config) { default_config.merge(allowed_request_headers: ['foo_BAR']) } - - it 'returns attribute' do - _(first_span.attributes['http.request.headers.foo_bar']).must_equal 'http foo bar value' - end - end - - describe 'when content-type' do - let(:config) { default_config.merge(allowed_request_headers: ['CONTENT_TYPE']) } - - it 'returns attribute' do - _(first_span.attributes['http.request.headers.content_type']).must_equal 'application/json' - end - end - - describe 'when content-length' do - let(:config) { default_config.merge(allowed_request_headers: ['CONTENT_LENGTH']) } - - it 'returns attribute' do - _(first_span.attributes['http.request.headers.content_length']).must_equal '123' - end - end - end - - describe 'config[:allowed_response_headers]' do - let(:app) do - ->(_env) { [200, { 'Foo-Bar' => 'foo bar response header' }, ['OK']] } - end - - it 'defaults to nil' do - _(first_span.attributes['http.response.headers.foo_bar']).must_be_nil - end - - describe 'when configured' do - let(:config) { default_config.merge(allowed_response_headers: ['Foo-Bar']) } - - it 'returns attribute' do - _(first_span.attributes['http.response.headers.foo_bar']).must_equal 'foo bar response header' - end - - describe 'case-sensitively' do - let(:config) { default_config.merge(allowed_response_headers: ['fOO-bAR']) } - - it 'returns attribute' do - _(first_span.attributes['http.response.headers.foo_bar']).must_equal 'foo bar response header' - end - end - end - end - - describe 'config[:record_frontend_span]' do - let(:request_span) { exporter.finished_spans.first } - - describe 'default' do - it 'does not record span' do - _(exporter.finished_spans.size).must_equal 1 - end - - it 'does not parent the request_span' do - _(request_span.parent_span_id).must_equal OpenTelemetry::Trace::INVALID_SPAN_ID - end - end - - describe 'when recordable' do - let(:config) { default_config.merge(record_frontend_span: true) } - let(:env) { Hash('HTTP_X_REQUEST_START' => Time.now.to_i) } - let(:frontend_span) { exporter.finished_spans[1] } - let(:request_span) { exporter.finished_spans[0] } - - it 'records span' do - _(exporter.finished_spans.size).must_equal 2 - _(frontend_span.name).must_equal 'http_server.proxy' - _(frontend_span.attributes['service']).must_be_nil - end - - it 'changes request_span kind' do - _(request_span.kind).must_equal :internal - end - - it 'frontend_span parents request_span' do - _(request_span.parent_span_id).must_equal frontend_span.span_id - end - end - end - - describe '#called with 400 level http status code' do - let(:app) do - ->(_env) { [404, { 'Foo-Bar' => 'foo bar response header' }, ['Not Found']] } - end - - it 'leaves status code unset' do - _(first_span.attributes['http.status_code']).must_equal 404 - _(first_span.kind).must_equal :server - _(first_span.status.code).must_equal OpenTelemetry::Trace::Status::UNSET - end - end - end - - describe 'config[:quantization]' do - before do - Rack::MockRequest.new(rack_builder).get('/really_long_url', env) - end - - describe 'without quantization' do - it 'span.name defaults to low cardinality name HTTP method' do - _(first_span.name).must_equal 'HTTP GET' - _(first_span.attributes['http.target']).must_equal '/really_long_url' - end - end - - describe 'with simple quantization' do - let(:quantization_example) do - ->(url, _env) { url.to_s } - end - - let(:config) { default_config.merge(url_quantization: quantization_example) } - - it 'sets the span.name to the full path' do - _(first_span.name).must_equal '/really_long_url' - _(first_span.attributes['http.target']).must_equal '/really_long_url' - end - end - - describe 'with quantization' do - let(:quantization_example) do - # demonstrate simple shortening of URL: - ->(url, _env) { url.to_s[0..5] } - end - let(:config) { default_config.merge(url_quantization: quantization_example) } - - it 'mutates url according to url_quantization' do - _(first_span.name).must_equal '/reall' - end - end - end - - describe '#call with error' do - SimulatedError = Class.new(StandardError) - - let(:app) do - ->(_env) { raise SimulatedError } - end - - it 'records error in span and then re-raises' do - assert_raises SimulatedError do - Rack::MockRequest.new(rack_builder).get('/', env) - end - _(first_span.status.code).must_equal OpenTelemetry::Trace::Status::ERROR - end - end -end diff --git a/instrumentation/rack/test/opentelemetry/instrumentation/rack/util/queue_time_test.rb b/instrumentation/rack/test/opentelemetry/instrumentation/rack/util/queue_time_test.rb deleted file mode 100644 index 5d95050c34..0000000000 --- a/instrumentation/rack/test/opentelemetry/instrumentation/rack/util/queue_time_test.rb +++ /dev/null @@ -1,90 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require 'rack' -require_relative '../../../../../lib/opentelemetry/instrumentation/rack/util/queue_time' - -describe OpenTelemetry::Instrumentation::Rack::Util::QueueTime do - let(:described_class) { OpenTelemetry::Instrumentation::Rack::Util::QueueTime } - - describe '#get_request_start' do - let(:request_start) { described_class.get_request_start(env) } - - describe 'given a Rack env with' do - describe 'milliseconds' do - describe 'REQUEST_START' do - let(:env) { { described_class::REQUEST_START => "t=#{expected}" } } - let(:expected) { 1_512_379_167.574 } - it { expect(request_start.to_f).must_equal(expected) } - - describe 'but does not start with t=' do - let(:env) { { described_class::REQUEST_START => expected } } - it { expect(request_start.to_f).must_equal(expected) } - end - - describe 'without decimal places' do - let(:env) { { described_class::REQUEST_START => expected } } - let(:expected) { 1_512_379_167_574 } - it { expect(request_start.to_f).must_equal(1_512_379_167.574) } - end - - describe 'but a malformed expected' do - let(:expected) { 'foobar' } - it { _(request_start).must_be_nil } - end - - describe 'before the start of the acceptable time range' do - let(:expected) { 999_999_999.000 } - it { _(request_start).must_be_nil } - end - end - - describe 'QUEUE_START' do - let(:env) { { described_class::QUEUE_START => "t=#{expected}" } } - let(:expected) { 1_512_379_167.574 } - it { expect(request_start.to_f).must_equal(expected) } - end - end - - describe 'microseconds' do - describe 'REQUEST_START' do - let(:env) { { described_class::REQUEST_START => "t=#{expected}" } } - let(:expected) { 1_570_633_834.463123 } - it { expect(request_start.to_f).must_equal(expected) } - - describe 'but does not start with t=' do - let(:env) { { described_class::REQUEST_START => expected } } - it { expect(request_start.to_f).must_equal(expected) } - end - - describe 'without decimal places' do - let(:env) { { described_class::REQUEST_START => expected } } - let(:expected) { 1_570_633_834_463_123 } - it { expect(request_start.to_f).must_equal(1_570_633_834.463123) } - end - - describe 'but a malformed expected' do - let(:expected) { 'foobar' } - it { _(request_start).must_be_nil } - end - end - - describe 'QUEUE_START' do - let(:env) { { described_class::QUEUE_START => "t=#{expected}" } } - let(:expected) { 1_570_633_834.463123 } - it { expect(request_start.to_f).must_equal(expected) } - end - end - - describe 'nothing' do - let(:env) { {} } - it { _(request_start).must_be_nil } - end - end - end -end diff --git a/instrumentation/rack/test/opentelemetry/instrumentation/rack_test.rb b/instrumentation/rack/test/opentelemetry/instrumentation/rack_test.rb deleted file mode 100644 index 5eccd35aa4..0000000000 --- a/instrumentation/rack/test/opentelemetry/instrumentation/rack_test.rb +++ /dev/null @@ -1,55 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -describe OpenTelemetry::Instrumentation::Rack do - let(:instrumentation) { OpenTelemetry::Instrumentation::Rack::Instrumentation.instance } - let(:new_span) { OpenTelemetry::Trace.non_recording_span(OpenTelemetry::Trace::SpanContext.new) } - - it 'has #name' do - _(instrumentation.name).must_equal 'OpenTelemetry::Instrumentation::Rack' - end - - it 'has #version' do - _(instrumentation.version).wont_be_nil - _(instrumentation.version).wont_be_empty - end - - describe '#install' do - it 'accepts argument' do - instrumentation.install({}) - end - end - - describe '#current_span' do - it 'returns Span::INVALID when there is none set' do - _(OpenTelemetry::Instrumentation::Rack.current_span).must_equal(OpenTelemetry::Trace::Span::INVALID) - end - - it 'returns the span when set' do - test_span = new_span - context = OpenTelemetry::Instrumentation::Rack.context_with_span(test_span) - _(OpenTelemetry::Instrumentation::Rack.current_span(context)).must_equal(test_span) - end - end - - describe '#with_span' do - it 'respects context nesting' do - test_span = new_span - test_span2 = new_span - OpenTelemetry::Instrumentation::Rack.with_span(test_span) do - _(OpenTelemetry::Instrumentation::Rack.current_span).must_equal(test_span) - - OpenTelemetry::Instrumentation::Rack.with_span(test_span2) do - _(OpenTelemetry::Instrumentation::Rack.current_span).must_equal(test_span2) - end - - _(OpenTelemetry::Instrumentation::Rack.current_span).must_equal(test_span) - end - end - end -end diff --git a/instrumentation/rack/test/test_helper.rb b/instrumentation/rack/test/test_helper.rb deleted file mode 100644 index 3609d8e091..0000000000 --- a/instrumentation/rack/test/test_helper.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'rack' - -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' - -require 'pry' -require 'minitest/autorun' -require 'webmock/minitest' - -require_relative '../lib/opentelemetry-instrumentation-rack' - -# global opentelemetry-sdk setup: -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry::SDK.configure do |c| - c.add_span_processor span_processor -end diff --git a/instrumentation/rails/.rubocop.yml b/instrumentation/rails/.rubocop.yml deleted file mode 100644 index 27f6effb3f..0000000000 --- a/instrumentation/rails/.rubocop.yml +++ /dev/null @@ -1,15 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -AllCops: - Exclude: - - test/railtie/dummy/**/* - - gemfiles/*.gemfilqe - -Metrics/BlockLength: - Enabled: false -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-rails.rb" -Style/ClassAndModuleChildren: - Exclude: - - test/railtie/**/* diff --git a/instrumentation/rails/.yardopts b/instrumentation/rails/.yardopts deleted file mode 100644 index a27dc5d13f..0000000000 --- a/instrumentation/rails/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Rails Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/rails/Appraisals b/instrumentation/rails/Appraisals deleted file mode 100644 index fca584fad1..0000000000 --- a/instrumentation/rails/Appraisals +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# Rails 5.2 is incompatible with Ruby 3. -if RUBY_VERSION < '3' - appraise 'rails-5.2' do - gem 'rails', '~> 5.2.0' - end -end - -if Gem::Requirement.new('>= 2.7.0', '< 3.1').satisfied_by?(Gem::Version.new(RUBY_VERSION)) - appraise 'rails-6.0' do - gem 'rails', '~> 6.0.0' - end - - appraise 'rails-6.1' do - gem 'rails', '~> 6.1.0' - end - - appraise 'rails-7.0' do - gem 'rails', '~> 7.0.0' - end -end - -if Gem::Requirement.new('>= 3.1').satisfied_by?(Gem::Version.new(RUBY_VERSION)) - appraise 'rails-7.0.ruby.3.1' do - gem 'rails', '~> 7.0.1' - end -end diff --git a/instrumentation/rails/CHANGELOG.md b/instrumentation/rails/CHANGELOG.md deleted file mode 100644 index b178c501ce..0000000000 --- a/instrumentation/rails/CHANGELOG.md +++ /dev/null @@ -1,91 +0,0 @@ -# Release History: opentelemetry-instrumentation-rails - -### v0.22.0 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Broken test file requirements - -### v0.21.0 / 2022-05-02 - -* ADDED: OTel Railtie -* FIXED: RubyGems Fallback - -### v0.20.0 / 2021-12-01 - -* ADDED: Move activesupport notification subsciber out of action_view gem -* FIXED: Instrumentation of Rails 7 - -### v0.19.4 / 2021-10-06 - -* (No significant changes) - -### v0.19.3 / 2021-09-29 - -* (No significant changes) - -### v0.19.2 / 2021-09-29 - -* (No significant changes) - -### v0.19.1 / 2021-09-09 - -* (No significant changes) - -### v0.19.0 / 2021-08-12 - -* ADDED: Instrument active record -* ADDED: Add ActionView instrumentation via ActiveSupport::Notifications -* FIXED: Rails instrumentation to not explicitly install sub gems -* DOCS: Update docs to rely more on environment variable configuration - -* This release adds support for Active Record and Action View. -* The `enable_recognize_route` configuration option has been moved to the ActionPack gem. -* See readme for details on how to configure the sub instrumentation gems. - -### v0.18.1 / 2021-06-23 - -* FIXED: Updated rack middleware position to zero - -### v0.18.0 / 2021-05-21 - -* ADDED: Updated API depedency for 1.0.0.rc1 - -### v0.17.0 / 2021-04-22 - -* ADDED: Added http.route in rails instrumentation to match the spec -* FIXED: Rails example by not using `rails` from git -* FIXED: Updated rack middleware position to zero - -### v0.16.0 / 2021-03-17 - -* FIXED: Example scripts now reference local common lib -* DOCS: Replace Gitter with GitHub Discussions - -### v0.15.0 / 2021-02-18 - -* (No significant changes) - -### v0.14.0 / 2021-02-03 - -* (No significant changes) - -### v0.13.0 / 2021-01-29 - -* (No significant changes) - -### v0.12.0 / 2020-12-24 - -* (No significant changes) - -### v0.11.0 / 2020-12-11 - -* FIXED: Rails tests -* FIXED: Copyright comments to not reference year - -### v0.10.0 / 2020-12-03 - -* FIXED: Otel-instrumentation-all not installing all - -### v0.9.0 / 2020-11-27 - -* Initial release. diff --git a/instrumentation/rails/Gemfile b/instrumentation/rails/Gemfile deleted file mode 100644 index 9309137321..0000000000 --- a/instrumentation/rails/Gemfile +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :test, :development do - gem 'opentelemetry-instrumentation-action_pack', path: '../../instrumentation/action_pack' - gem 'opentelemetry-instrumentation-action_view', path: '../../instrumentation/action_view' - gem 'opentelemetry-instrumentation-active_record', path: '../../instrumentation/active_record' - gem 'opentelemetry-instrumentation-active_support', path: '../../instrumentation/active_support' - gem 'opentelemetry-instrumentation-base', path: '../base' - gem 'opentelemetry-instrumentation-rack', path: '../../instrumentation/rack' - gem 'pry-byebug' -end diff --git a/instrumentation/rails/LICENSE b/instrumentation/rails/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/rails/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/rails/README.md b/instrumentation/rails/README.md deleted file mode 100644 index 41278c6b14..0000000000 --- a/instrumentation/rails/README.md +++ /dev/null @@ -1,56 +0,0 @@ -# OpenTelemetry Rails Instrumentation - -The Rails instrumentation is a community-maintained instrumentation for the [Ruby on Rails][rails-home] web-application framework. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-rails -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-rails` in your `Gemfile`. - -## Usage - -To use the Rails instrumentation, call `use_all` so it installs all the instrumentation gems. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` - -### Configuration options - -The Rails instrumentation attempts to mirror the structure of the Ruby on Rails. It is a collection of instrumentation gems for components of Rails such as Action View, Active Record, Action Pack, etc... - -You may want to include all of the Rails instrumentation but disable a single instrumentation gem that it includes. Here is an example of how you can disable Active Record when using this instrumentation gem. -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all({ 'OpenTelemetry::Instrumentation::ActiveRecord' => { enabled: false } }) -end -``` - -## Examples - -Example usage can be seen in the `./example/trace_demonstration.rb` file [here](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/instrumentation/rails/example/trace_request_demonstration.ru) - -## How can I get involved? - -The `opentelemetry-instrumentation-rails` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -The `opentelemetry-instrumentation-rails` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information. - -[rails-home]: https://github.com/rails/rails -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/instrumentation/rails/Rakefile b/instrumentation/rails/Rakefile deleted file mode 100644 index 14260497c3..0000000000 --- a/instrumentation/rails/Rakefile +++ /dev/null @@ -1,39 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -namespace :test do - Rake::TestTask.new :instrumentation do |t| - t.libs << 'lib' - t.libs << 'test/instrumentation' - t.test_files = FileList['test/instrumentation/**/*_test.rb'] - end - - Rake::TestTask.new :railtie do |t| - t.libs << 'lib' - t.libs << 'test/railtie' - t.test_files = FileList['test/railtie/**/*_test.rb'] - end -end - -desc 'Run all tests' -task test: %i[test:instrumentation test:railtie] - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/rails/example/trace_request_demonstration.ru b/instrumentation/rails/example/trace_request_demonstration.ru deleted file mode 100644 index 1a6f2b16d8..0000000000 --- a/instrumentation/rails/example/trace_request_demonstration.ru +++ /dev/null @@ -1,44 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/inline' - -gemfile(true) do - source 'https://rubygems.org' - - gem 'rails' - gem 'opentelemetry-sdk' - gem 'opentelemetry-instrumentation-rails' -end - -require 'action_controller/railtie' - -# TraceRequestApp is a minimal Rails application inspired by the Rails -# bug report template for action controller. -# https://github.com/rails/rails/blob/v6.0.0/guides/bug_report_templates/action_controller_gem.rb -# The configuration is compatible with Rails 6.0 -class TraceRequestApp < Rails::Application - config.root = __dir__ - config.hosts << 'example.org' - secrets.secret_key_base = 'secret_key_base' - config.eager_load = false - config.logger = Logger.new($stdout) - Rails.logger = config.logger -end - -ENV['OTEL_TRACES_EXPORTER'] = 'console' -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Rails' -end - -Rails.application.initialize! - -run Rails.application - -# To run this example run the `rackup` command with this file -# Example: rackup trace_request_demonstration.ru -# Navigate to http://localhost:9292/ -# Spans for the requests will appear in the console diff --git a/instrumentation/rails/lib/opentelemetry-instrumentation-rails.rb b/instrumentation/rails/lib/opentelemetry-instrumentation-rails.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/rails/lib/opentelemetry-instrumentation-rails.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/rails/lib/opentelemetry/instrumentation.rb b/instrumentation/rails/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index d3ec33d604..0000000000 --- a/instrumentation/rails/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/rails' diff --git a/instrumentation/rails/lib/opentelemetry/instrumentation/rails.rb b/instrumentation/rails/lib/opentelemetry/instrumentation/rails.rb deleted file mode 100644 index 59de2fbe4b..0000000000 --- a/instrumentation/rails/lib/opentelemetry/instrumentation/rails.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the Rails gem - module Rails - end - end -end - -require 'opentelemetry-instrumentation-action_pack' -require 'opentelemetry-instrumentation-active_support' -require 'opentelemetry-instrumentation-action_view' -require 'opentelemetry-instrumentation-active_record' -require_relative './rails/instrumentation' -require_relative './rails/version' diff --git a/instrumentation/rails/lib/opentelemetry/instrumentation/rails/instrumentation.rb b/instrumentation/rails/lib/opentelemetry/instrumentation/rails/instrumentation.rb deleted file mode 100644 index c738e6cb4c..0000000000 --- a/instrumentation/rails/lib/opentelemetry/instrumentation/rails/instrumentation.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' - -module OpenTelemetry - module Instrumentation - module Rails - # The Instrumentation class contains logic to detect and install the Rails - # instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - MINIMUM_VERSION = Gem::Version.new('5.2.0') - - # This gem requires the instrumentantion gems for the different - # components of Rails, as a result it does not have any explicit - # work to do in the install step. - install { true } - present { defined?(::Rails) } - compatible { gem_version >= MINIMUM_VERSION } - - private - - def gem_version - ::ActionPack.version - end - end - end - end -end diff --git a/instrumentation/rails/lib/opentelemetry/instrumentation/rails/railtie.rb b/instrumentation/rails/lib/opentelemetry/instrumentation/rails/railtie.rb deleted file mode 100644 index 2420ddd7d1..0000000000 --- a/instrumentation/rails/lib/opentelemetry/instrumentation/rails/railtie.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 -module OpenTelemetry - module Instrumentation - module Rails - # Railtie automatically configure the OpentTelemetry SDK - # - # This railtie will set defaults for the following environment variables: - # `OTEL_SERVICE_NAME` - if unset, will default to the Rails application name - # `OTEL_RESOURCE_ATTRIBUTES` - if unset, will set the deployment environment to the current Rails environment - # - # This will also set the `OpenTelemetry.logger` to the Rails logger. - class Railtie < ::Rails::Railtie - railtie_name :opentelemetry - initializer 'opentelemetry.configure' do |app| - # See https://api.rubyonrails.org/classes/Rails/Generators/NamedBase.html#method-i-application_name - ENV['OTEL_SERVICE_NAME'] ||= app.class.name.split('::').first.underscore - - ::OpenTelemetry::SDK.configure do |c| - c.logger = ::Rails.logger - c.use_all - end - end - end - end - end -end diff --git a/instrumentation/rails/lib/opentelemetry/instrumentation/rails/version.rb b/instrumentation/rails/lib/opentelemetry/instrumentation/rails/version.rb deleted file mode 100644 index b19b5daa7a..0000000000 --- a/instrumentation/rails/lib/opentelemetry/instrumentation/rails/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Rails - VERSION = '0.22.0' - end - end -end diff --git a/instrumentation/rails/opentelemetry-instrumentation-rails.gemspec b/instrumentation/rails/opentelemetry-instrumentation-rails.gemspec deleted file mode 100644 index c130fbea66..0000000000 --- a/instrumentation/rails/opentelemetry-instrumentation-rails.gemspec +++ /dev/null @@ -1,50 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/rails/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-rails' - spec.version = OpenTelemetry::Instrumentation::Rails::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'Rails instrumentation for the OpenTelemetry framework' - spec.description = 'Rails instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-instrumentation-action_pack', '~> 0.2.0' - spec.add_dependency 'opentelemetry-instrumentation-action_view', '~> 0.3.0' - spec.add_dependency 'opentelemetry-instrumentation-active_record', '~> 0.4.0' - spec.add_dependency 'opentelemetry-instrumentation-active_support', '~> 0.2.0' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.21.0' - - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'rack-test', '~> 1.1.0' - spec.add_development_dependency 'rails' - spec.add_development_dependency 'rake', '~> 12.3.3' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'webmock', '~> 3.7.6' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/rails' if spec.respond_to?(:metadata) -end diff --git a/instrumentation/rails/test/instrumentation/opentelemetry/instrumentation/rails/instrumentation_test.rb b/instrumentation/rails/test/instrumentation/opentelemetry/instrumentation/rails/instrumentation_test.rb deleted file mode 100644 index bae64a5b66..0000000000 --- a/instrumentation/rails/test/instrumentation/opentelemetry/instrumentation/rails/instrumentation_test.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -describe OpenTelemetry::Instrumentation::Rails::Instrumentation do - it 'adds the rack tracing middleware' do - _(DEFAULT_RAILS_APP.config.middleware).must_include OpenTelemetry::Instrumentation::Rack::Middlewares::TracerMiddleware - end -end diff --git a/instrumentation/rails/test/instrumentation/opentelemetry/instrumentation/rails/patches/action_controller/metal_test.rb b/instrumentation/rails/test/instrumentation/opentelemetry/instrumentation/rails/patches/action_controller/metal_test.rb deleted file mode 100644 index 944887841c..0000000000 --- a/instrumentation/rails/test/instrumentation/opentelemetry/instrumentation/rails/patches/action_controller/metal_test.rb +++ /dev/null @@ -1,44 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -describe OpenTelemetry::Instrumentation::Rails do - include Rack::Test::Methods - - let(:exporter) { EXPORTER } - let(:spans) { exporter.finished_spans } - let(:span) { exporter.finished_spans.last } - let(:rails_app) { DEFAULT_RAILS_APP } - - # Clear captured spans - before { exporter.reset } - - it 'sets the span name to ControllerName#action' do - get '/ok' - - _(last_response.body).must_equal 'actually ok' - _(last_response.ok?).must_equal true - _(span.name).must_equal 'ExampleController#ok' - _(span.kind).must_equal :server - _(span.status.ok?).must_equal true - - _(span.instrumentation_library.name).must_equal 'OpenTelemetry::Instrumentation::Rack' - _(span.instrumentation_library.version).must_equal OpenTelemetry::Instrumentation::Rack::VERSION - - _(span.attributes['http.method']).must_equal 'GET' - _(span.attributes['http.host']).must_equal 'example.org' - _(span.attributes['http.scheme']).must_equal 'http' - _(span.attributes['http.target']).must_equal '/ok' - _(span.attributes['http.status_code']).must_equal 200 - _(span.attributes['http.user_agent']).must_be_nil - _(span.attributes['http.route']).must_be_nil - end - - def app - rails_app - end -end diff --git a/instrumentation/rails/test/instrumentation/test_helper.rb b/instrumentation/rails/test/instrumentation/test_helper.rb deleted file mode 100644 index d35ac43750..0000000000 --- a/instrumentation/rails/test/instrumentation/test_helper.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'rails' - -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' - -require 'pry' -require 'minitest/autorun' -require 'rack/test' -require 'test_helpers/app_config.rb' - -require_relative '../../lib/opentelemetry/instrumentation' - -# Global opentelemetry-sdk setup -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry::SDK.configure do |c| - c.logger = ::Logger.new(File::NULL) - c.use_all - c.add_span_processor span_processor -end - -# Create a globally available Rails app, this should be used in test unless -# specifically testing behaviour with different initialization configs. -DEFAULT_RAILS_APP = AppConfig.initialize_app -::Rails.application = DEFAULT_RAILS_APP diff --git a/instrumentation/rails/test/instrumentation/test_helpers/app_config.rb b/instrumentation/rails/test/instrumentation/test_helpers/app_config.rb deleted file mode 100644 index b88ec6089e..0000000000 --- a/instrumentation/rails/test/instrumentation/test_helpers/app_config.rb +++ /dev/null @@ -1,94 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -class Application < Rails::Application; end -require 'action_controller/railtie' -require_relative 'middlewares' -require_relative 'controllers' -require_relative 'routes' - -module AppConfig - extend self - - def initialize_app(use_exceptions_app: false, remove_rack_tracer_middleware: false) - new_app = Application.new - new_app.config.secret_key_base = 'secret_key_base' - - # Ensure we don't see this Rails warning when testing - new_app.config.eager_load = false - - # Prevent tests from creating log/*.log - new_app.config.logger = Logger.new(File::NULL) - - case Rails.version - when /^6\.0/ - apply_rails_6_0_configs(new_app) - when /^6\.1/ - apply_rails_6_1_configs(new_app) - when /^7\./ - apply_rails_7_configs(new_app) - end - - remove_rack_middleware(new_app) if remove_rack_tracer_middleware - add_exceptions_app(new_app) if use_exceptions_app - add_middlewares(new_app) - - new_app.initialize! - - draw_routes(new_app) - - new_app - end - - private - - def remove_rack_middleware(application) - application.middleware.delete( - OpenTelemetry::Instrumentation::Rack::Middlewares::TracerMiddleware - ) - end - - def add_exceptions_app(application) - application.config.exceptions_app = lambda do |env| - ExceptionsController.action(:show).call(env) - end - end - - def add_middlewares(application) - application.middleware.insert_after( - ActionDispatch::DebugExceptions, - ExceptionRaisingMiddleware - ) - - application.middleware.insert_after( - ActionDispatch::DebugExceptions, - RedirectMiddleware - ) - end - - def apply_rails_6_0_configs(application) - # Required in Rails 6 - application.config.hosts << 'example.org' - # Creates a lot of deprecation warnings on subsequent app initializations if not explicitly set. - application.config.action_view.finalize_compiled_template_methods = ActionView::Railtie::NULL_OPTION - end - - def apply_rails_6_1_configs(application) - # Required in Rails 6 - application.config.hosts << 'example.org' - end - - def apply_rails_7_configs(application) - # Required in Rails 7 - application.config.hosts << 'example.org' - - # Unfreeze values which may have been frozen on previous initializations. - ActiveSupport::Dependencies.autoload_paths = - ActiveSupport::Dependencies.autoload_paths.dup - ActiveSupport::Dependencies.autoload_once_paths = - ActiveSupport::Dependencies.autoload_once_paths.dup - end -end diff --git a/instrumentation/rails/test/instrumentation/test_helpers/controllers.rb b/instrumentation/rails/test/instrumentation/test_helpers/controllers.rb deleted file mode 100644 index 1f58e148f2..0000000000 --- a/instrumentation/rails/test/instrumentation/test_helpers/controllers.rb +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative 'controllers/example_controller' -require_relative 'controllers/exceptions_controller' diff --git a/instrumentation/rails/test/instrumentation/test_helpers/controllers/example_controller.rb b/instrumentation/rails/test/instrumentation/test_helpers/controllers/example_controller.rb deleted file mode 100644 index 9bb5546555..0000000000 --- a/instrumentation/rails/test/instrumentation/test_helpers/controllers/example_controller.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -class ExampleController < ActionController::Base - include ::Rails.application.routes.url_helpers - - def ok - render plain: 'actually ok' - end - - def internal_server_error - raise :internal_server_error - end -end diff --git a/instrumentation/rails/test/instrumentation/test_helpers/controllers/exceptions_controller.rb b/instrumentation/rails/test/instrumentation/test_helpers/controllers/exceptions_controller.rb deleted file mode 100644 index 546698389c..0000000000 --- a/instrumentation/rails/test/instrumentation/test_helpers/controllers/exceptions_controller.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -class ExceptionsController < ActionController::Base - def show - render plain: 'oops', status: :internal_server_error - end -end diff --git a/instrumentation/rails/test/instrumentation/test_helpers/middlewares.rb b/instrumentation/rails/test/instrumentation/test_helpers/middlewares.rb deleted file mode 100644 index 2e09386fe6..0000000000 --- a/instrumentation/rails/test/instrumentation/test_helpers/middlewares.rb +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative 'middlewares/exception_raising_middleware' -require_relative 'middlewares/redirect_middleware' diff --git a/instrumentation/rails/test/instrumentation/test_helpers/middlewares/exception_raising_middleware.rb b/instrumentation/rails/test/instrumentation/test_helpers/middlewares/exception_raising_middleware.rb deleted file mode 100644 index 257cb69544..0000000000 --- a/instrumentation/rails/test/instrumentation/test_helpers/middlewares/exception_raising_middleware.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -class ExceptionRaisingMiddleware - def initialize(app, _options = {}) - @app = app - end - - def call(env) - raise 'a little hell' if should_raise?(env) - - @app.call(env) - end - - private - - def should_raise?(env) - env['PATH_INFO'] == '/exception' || env['QUERY_STRING'].include?('raise_in_middleware') - end -end diff --git a/instrumentation/rails/test/instrumentation/test_helpers/middlewares/redirect_middleware.rb b/instrumentation/rails/test/instrumentation/test_helpers/middlewares/redirect_middleware.rb deleted file mode 100644 index c531fe3dda..0000000000 --- a/instrumentation/rails/test/instrumentation/test_helpers/middlewares/redirect_middleware.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -class RedirectMiddleware - def initialize(app, _options = {}) - @app = app - end - - def call(env) - return [307, {}, 'Temporary Redirect'] if should_redirect?(env) - - @app.call(env) - end - - private - - def should_redirect?(env) - env['PATH_INFO'] == '/redirection' || env['QUERY_STRING'].include?('redirect_in_middleware') - end -end diff --git a/instrumentation/rails/test/instrumentation/test_helpers/routes.rb b/instrumentation/rails/test/instrumentation/test_helpers/routes.rb deleted file mode 100644 index 88f0565f21..0000000000 --- a/instrumentation/rails/test/instrumentation/test_helpers/routes.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -def draw_routes(rails_app) - rails_app.routes.draw do - get '/ok', to: 'example#ok' - get '/internal_server_error', to: 'example#internal_server_error' - end -end diff --git a/instrumentation/rails/test/railtie/dummy/Rakefile b/instrumentation/rails/test/railtie/dummy/Rakefile deleted file mode 100644 index 9a5ea7383a..0000000000 --- a/instrumentation/rails/test/railtie/dummy/Rakefile +++ /dev/null @@ -1,6 +0,0 @@ -# Add your own tasks in files placed in lib/tasks ending in .rake, -# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. - -require_relative "config/application" - -Rails.application.load_tasks diff --git a/instrumentation/rails/test/railtie/dummy/app/controllers/application_controller.rb b/instrumentation/rails/test/railtie/dummy/app/controllers/application_controller.rb deleted file mode 100644 index 4ac8823b09..0000000000 --- a/instrumentation/rails/test/railtie/dummy/app/controllers/application_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class ApplicationController < ActionController::API -end diff --git a/instrumentation/rails/test/railtie/dummy/app/controllers/concerns/.keep b/instrumentation/rails/test/railtie/dummy/app/controllers/concerns/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/instrumentation/rails/test/railtie/dummy/bin/rails b/instrumentation/rails/test/railtie/dummy/bin/rails deleted file mode 100755 index efc0377492..0000000000 --- a/instrumentation/rails/test/railtie/dummy/bin/rails +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env ruby -APP_PATH = File.expand_path("../config/application", __dir__) -require_relative "../config/boot" -require "rails/commands" diff --git a/instrumentation/rails/test/railtie/dummy/bin/rake b/instrumentation/rails/test/railtie/dummy/bin/rake deleted file mode 100755 index 4fbf10b960..0000000000 --- a/instrumentation/rails/test/railtie/dummy/bin/rake +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env ruby -require_relative "../config/boot" -require "rake" -Rake.application.run diff --git a/instrumentation/rails/test/railtie/dummy/bin/setup b/instrumentation/rails/test/railtie/dummy/bin/setup deleted file mode 100755 index ec47b79b3b..0000000000 --- a/instrumentation/rails/test/railtie/dummy/bin/setup +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env ruby -require "fileutils" - -# path to your application root. -APP_ROOT = File.expand_path("..", __dir__) - -def system!(*args) - system(*args) || abort("\n== Command #{args} failed ==") -end - -FileUtils.chdir APP_ROOT do - # This script is a way to set up or update your development environment automatically. - # This script is idempotent, so that you can run it at any time and get an expectable outcome. - # Add necessary setup steps to this file. - - puts "== Installing dependencies ==" - system! "gem install bundler --conservative" - system("bundle check") || system!("bundle install") - - # puts "\n== Copying sample files ==" - # unless File.exist?("config/database.yml") - # FileUtils.cp "config/database.yml.sample", "config/database.yml" - # end - - puts "\n== Preparing database ==" - system! "bin/rails db:prepare" - - puts "\n== Removing old logs and tempfiles ==" - system! "bin/rails log:clear tmp:clear" - - puts "\n== Restarting application server ==" - system! "bin/rails restart" -end diff --git a/instrumentation/rails/test/railtie/dummy/config.ru b/instrumentation/rails/test/railtie/dummy/config.ru deleted file mode 100644 index 4a3c09a688..0000000000 --- a/instrumentation/rails/test/railtie/dummy/config.ru +++ /dev/null @@ -1,6 +0,0 @@ -# This file is used by Rack-based servers to start the application. - -require_relative "config/environment" - -run Rails.application -Rails.application.load_server diff --git a/instrumentation/rails/test/railtie/dummy/config/application.rb b/instrumentation/rails/test/railtie/dummy/config/application.rb deleted file mode 100644 index 1768b94892..0000000000 --- a/instrumentation/rails/test/railtie/dummy/config/application.rb +++ /dev/null @@ -1,37 +0,0 @@ -require_relative "boot" - -require "rails" -# Pick the frameworks you want: -require "active_model/railtie" -require "active_job/railtie" -# require "active_record/railtie" -# require "active_storage/engine" -require "action_controller/railtie" -# require "action_mailer/railtie" -# require "action_mailbox/engine" -# require "action_text/engine" -require "action_view/railtie" -# require "action_cable/engine" -# require "sprockets/railtie" -require "rails/test_unit/railtie" - -# Require the gems listed in Gemfile, including any gems -# you've limited to :test, :development, or :production. -Bundler.require(*Rails.groups) -require "opentelemetry/instrumentation/rails/railtie" - -module Dummy - class Application < Rails::Application - config.load_defaults Rails::VERSION::STRING.to_f - - # Configuration for the application, engines, and railties goes here. - # - # These settings can be overridden in specific environments using the files - # in config/environments, which are processed later. - # - # config.time_zone = "Central Time (US & Canada)" - # config.eager_load_paths << Rails.root.join("extras") - config.logger = ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(File::NULL)) - config.api_only = true - end -end diff --git a/instrumentation/rails/test/railtie/dummy/config/boot.rb b/instrumentation/rails/test/railtie/dummy/config/boot.rb deleted file mode 100644 index 116591a4ed..0000000000 --- a/instrumentation/rails/test/railtie/dummy/config/boot.rb +++ /dev/null @@ -1,5 +0,0 @@ -# Set up gems listed in the Gemfile. -ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__) - -require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"]) -$LOAD_PATH.unshift File.expand_path("../../../lib", __dir__) diff --git a/instrumentation/rails/test/railtie/dummy/config/environment.rb b/instrumentation/rails/test/railtie/dummy/config/environment.rb deleted file mode 100644 index cac5315775..0000000000 --- a/instrumentation/rails/test/railtie/dummy/config/environment.rb +++ /dev/null @@ -1,5 +0,0 @@ -# Load the Rails application. -require_relative "application" - -# Initialize the Rails application. -Rails.application.initialize! diff --git a/instrumentation/rails/test/railtie/dummy/config/environments/development.rb b/instrumentation/rails/test/railtie/dummy/config/environments/development.rb deleted file mode 100644 index 8d1635ee6f..0000000000 --- a/instrumentation/rails/test/railtie/dummy/config/environments/development.rb +++ /dev/null @@ -1,68 +0,0 @@ -require "active_support/core_ext/integer/time" - -Rails.application.configure do - # Settings specified here will take precedence over those in config/application.rb. - - # In the development environment your application's code is reloaded any time - # it changes. This slows down response time but is perfect for development - # since you don't have to restart the web server when you make code changes. - config.cache_classes = false - - # Do not eager load code on boot. - config.eager_load = false - - # Show full error reports. - config.consider_all_requests_local = true - - # Enable server timing - config.server_timing = true - - # Enable/disable caching. By default caching is disabled. - # Run rails dev:cache to toggle caching. - if Rails.root.join("tmp/caching-dev.txt").exist? - config.action_controller.perform_caching = true - config.action_controller.enable_fragment_cache_logging = true - - config.cache_store = :memory_store - config.public_file_server.headers = { - "Cache-Control" => "public, max-age=#{2.days.to_i}" - } - else - config.action_controller.perform_caching = false - - config.cache_store = :null_store - end - - # Store uploaded files on the local file system (see config/storage.yml for options). - config.active_storage.service = :local - - # Don't care if the mailer can't send. - config.action_mailer.raise_delivery_errors = false - - config.action_mailer.perform_caching = false - - # Print deprecation notices to the Rails logger. - config.active_support.deprecation = :log - - # Raise exceptions for disallowed deprecations. - config.active_support.disallowed_deprecation = :raise - - # Tell Active Support which deprecation messages to disallow. - config.active_support.disallowed_deprecation_warnings = [] - - # Raise an error on page load if there are pending migrations. - config.active_record.migration_error = :page_load - - # Highlight code that triggered database queries in logs. - config.active_record.verbose_query_logs = true - - - # Raises error for missing translations. - # config.i18n.raise_on_missing_translations = true - - # Annotate rendered view with file names. - # config.action_view.annotate_rendered_view_with_filenames = true - - # Uncomment if you wish to allow Action Cable access from any origin. - # config.action_cable.disable_request_forgery_protection = true -end diff --git a/instrumentation/rails/test/railtie/dummy/config/environments/production.rb b/instrumentation/rails/test/railtie/dummy/config/environments/production.rb deleted file mode 100644 index b60aa07e40..0000000000 --- a/instrumentation/rails/test/railtie/dummy/config/environments/production.rb +++ /dev/null @@ -1,87 +0,0 @@ -require "active_support/core_ext/integer/time" - -Rails.application.configure do - # Settings specified here will take precedence over those in config/application.rb. - - # Code is not reloaded between requests. - config.cache_classes = true - - # Eager load code on boot. This eager loads most of Rails and - # your application in memory, allowing both threaded web servers - # and those relying on copy on write to perform better. - # Rake tasks automatically ignore this option for performance. - config.eager_load = true - - # Full error reports are disabled and caching is turned on. - config.consider_all_requests_local = false - config.action_controller.perform_caching = true - - # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] - # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). - # config.require_master_key = true - - # Disable serving static files from the `/public` folder by default since - # Apache or NGINX already handles this. - config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? - - # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.asset_host = "http://assets.example.com" - - # Specifies the header that your server uses for sending files. - # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache - # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX - - # Store uploaded files on the local file system (see config/storage.yml for options). - config.active_storage.service = :local - - # Mount Action Cable outside main process or domain. - # config.action_cable.mount_path = nil - # config.action_cable.url = "wss://example.com/cable" - # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ] - - # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. - # config.force_ssl = true - - # Include generic and useful information about system operation, but avoid logging too much - # information to avoid inadvertent exposure of personally identifiable information (PII). - config.log_level = :info - - # Prepend all log lines with the following tags. - config.log_tags = [ :request_id ] - - # Use a different cache store in production. - # config.cache_store = :mem_cache_store - - # Use a real queuing backend for Active Job (and separate queues per environment). - # config.active_job.queue_adapter = :resque - # config.active_job.queue_name_prefix = "dummy_production" - - config.action_mailer.perform_caching = false - - # Ignore bad email addresses and do not raise email delivery errors. - # Set this to true and configure the email server for immediate delivery to raise delivery errors. - # config.action_mailer.raise_delivery_errors = false - - # Enable locale fallbacks for I18n (makes lookups for any locale fall back to - # the I18n.default_locale when a translation cannot be found). - config.i18n.fallbacks = true - - # Don't log any deprecations. - config.active_support.report_deprecations = false - - # Use default logging formatter so that PID and timestamp are not suppressed. - config.log_formatter = ::Logger::Formatter.new - - # Use a different logger for distributed setups. - # require "syslog/logger" - # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name") - - # if ENV["RAILS_LOG_TO_STDOUT"].present? - # logger = ActiveSupport::Logger.new(STDOUT) - # logger.formatter = config.log_formatter - # config.logger = ActiveSupport::TaggedLogging.new(logger) - # end - - # Do not dump schema after migrations. - config.active_record.dump_schema_after_migration = false -end diff --git a/instrumentation/rails/test/railtie/dummy/config/environments/test.rb b/instrumentation/rails/test/railtie/dummy/config/environments/test.rb deleted file mode 100644 index 6bebc8a548..0000000000 --- a/instrumentation/rails/test/railtie/dummy/config/environments/test.rb +++ /dev/null @@ -1,60 +0,0 @@ -require "active_support/core_ext/integer/time" - -# The test environment is used exclusively to run your application's -# test suite. You never need to work with it otherwise. Remember that -# your test database is "scratch space" for the test suite and is wiped -# and recreated between test runs. Don't rely on the data there! - -Rails.application.configure do - # Settings specified here will take precedence over those in config/application.rb. - - # Turn false under Spring and add config.action_view.cache_template_loading = true. - config.cache_classes = true - - # Eager loading loads your whole application. When running a single test locally, - # this probably isn't necessary. It's a good idea to do in a continuous integration - # system, or in some way before deploying your code. - config.eager_load = true - - # Configure public file server for tests with Cache-Control for performance. - config.public_file_server.enabled = true - config.public_file_server.headers = { - "Cache-Control" => "public, max-age=#{1.hour.to_i}" - } - - # Show full error reports and disable caching. - config.consider_all_requests_local = true - config.action_controller.perform_caching = false - config.cache_store = :null_store - - # Raise exceptions instead of rendering exception templates. - config.action_dispatch.show_exceptions = false - - # Disable request forgery protection in test environment. - config.action_controller.allow_forgery_protection = false - - # Store uploaded files on the local file system in a temporary directory. - # config.active_storage.service = :test - - # config.action_mailer.perform_caching = false - - # Tell Action Mailer not to deliver emails to the real world. - # The :test delivery method accumulates sent emails in the - # ActionMailer::Base.deliveries array. - # config.action_mailer.delivery_method = :test - - # Print deprecation notices to the stderr. - config.active_support.deprecation = :stderr - - # Raise exceptions for disallowed deprecations. - config.active_support.disallowed_deprecation = :raise - - # Tell Active Support which deprecation messages to disallow. - config.active_support.disallowed_deprecation_warnings = [] - - # Raises error for missing translations. - # config.i18n.raise_on_missing_translations = true - - # Annotate rendered view with file names. - # config.action_view.annotate_rendered_view_with_filenames = true -end diff --git a/instrumentation/rails/test/railtie/dummy/config/initializers/content_security_policy.rb b/instrumentation/rails/test/railtie/dummy/config/initializers/content_security_policy.rb deleted file mode 100644 index 3621f97f8e..0000000000 --- a/instrumentation/rails/test/railtie/dummy/config/initializers/content_security_policy.rb +++ /dev/null @@ -1,26 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Define an application-wide content security policy -# For further information see the following documentation -# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy - -# Rails.application.configure do -# config.content_security_policy do |policy| -# policy.default_src :self, :https -# policy.font_src :self, :https, :data -# policy.img_src :self, :https, :data -# policy.object_src :none -# policy.script_src :self, :https -# policy.style_src :self, :https -# # Specify URI for violation reports -# # policy.report_uri "/csp-violation-report-endpoint" -# end -# -# # Generate session nonces for permitted importmap and inline scripts -# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } -# config.content_security_policy_nonce_directives = %w(script-src) -# -# # Report CSP violations to a specified URI. See: -# # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only -# # config.content_security_policy_report_only = true -# end diff --git a/instrumentation/rails/test/railtie/dummy/config/initializers/filter_parameter_logging.rb b/instrumentation/rails/test/railtie/dummy/config/initializers/filter_parameter_logging.rb deleted file mode 100644 index 4b34a03668..0000000000 --- a/instrumentation/rails/test/railtie/dummy/config/initializers/filter_parameter_logging.rb +++ /dev/null @@ -1,6 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Configure sensitive parameters which will be filtered from the log file. -Rails.application.config.filter_parameters += [ - :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn -] diff --git a/instrumentation/rails/test/railtie/dummy/config/initializers/inflections.rb b/instrumentation/rails/test/railtie/dummy/config/initializers/inflections.rb deleted file mode 100644 index 3860f659ea..0000000000 --- a/instrumentation/rails/test/railtie/dummy/config/initializers/inflections.rb +++ /dev/null @@ -1,16 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Add new inflection rules using the following format. Inflections -# are locale specific, and you may define rules for as many different -# locales as you wish. All of these examples are active by default: -# ActiveSupport::Inflector.inflections(:en) do |inflect| -# inflect.plural /^(ox)$/i, "\\1en" -# inflect.singular /^(ox)en/i, "\\1" -# inflect.irregular "person", "people" -# inflect.uncountable %w( fish sheep ) -# end - -# These inflection rules are supported but not enabled by default: -# ActiveSupport::Inflector.inflections(:en) do |inflect| -# inflect.acronym "RESTful" -# end diff --git a/instrumentation/rails/test/railtie/dummy/config/initializers/permissions_policy.rb b/instrumentation/rails/test/railtie/dummy/config/initializers/permissions_policy.rb deleted file mode 100644 index 00f64d71b0..0000000000 --- a/instrumentation/rails/test/railtie/dummy/config/initializers/permissions_policy.rb +++ /dev/null @@ -1,11 +0,0 @@ -# Define an application-wide HTTP permissions policy. For further -# information see https://developers.google.com/web/updates/2018/06/feature-policy -# -# Rails.application.config.permissions_policy do |f| -# f.camera :none -# f.gyroscope :none -# f.microphone :none -# f.usb :none -# f.fullscreen :self -# f.payment :self, "https://secure.example.com" -# end diff --git a/instrumentation/rails/test/railtie/dummy/config/locales/en.yml b/instrumentation/rails/test/railtie/dummy/config/locales/en.yml deleted file mode 100644 index 8ca56fc74f..0000000000 --- a/instrumentation/rails/test/railtie/dummy/config/locales/en.yml +++ /dev/null @@ -1,33 +0,0 @@ -# Files in the config/locales directory are used for internationalization -# and are automatically loaded by Rails. If you want to use locales other -# than English, add the necessary files in this directory. -# -# To use the locales, use `I18n.t`: -# -# I18n.t "hello" -# -# In views, this is aliased to just `t`: -# -# <%= t("hello") %> -# -# To use a different locale, set it with `I18n.locale`: -# -# I18n.locale = :es -# -# This would use the information in config/locales/es.yml. -# -# The following keys must be escaped otherwise they will not be retrieved by -# the default I18n backend: -# -# true, false, on, off, yes, no -# -# Instead, surround them with single quotes. -# -# en: -# "true": "foo" -# -# To learn more, please read the Rails Internationalization guide -# available at https://guides.rubyonrails.org/i18n.html. - -en: - hello: "Hello world" diff --git a/instrumentation/rails/test/railtie/dummy/config/puma.rb b/instrumentation/rails/test/railtie/dummy/config/puma.rb deleted file mode 100644 index daaf036999..0000000000 --- a/instrumentation/rails/test/railtie/dummy/config/puma.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Puma can serve each request in a thread from an internal thread pool. -# The `threads` method setting takes two numbers: a minimum and maximum. -# Any libraries that use thread pools should be configured to match -# the maximum value specified for Puma. Default is set to 5 threads for minimum -# and maximum; this matches the default thread size of Active Record. -# -max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } -min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } -threads min_threads_count, max_threads_count - -# Specifies the `worker_timeout` threshold that Puma will use to wait before -# terminating a worker in development environments. -# -worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" - -# Specifies the `port` that Puma will listen on to receive requests; default is 3000. -# -port ENV.fetch("PORT") { 3000 } - -# Specifies the `environment` that Puma will run in. -# -environment ENV.fetch("RAILS_ENV") { "development" } - -# Specifies the `pidfile` that Puma will use. -pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } - -# Specifies the number of `workers` to boot in clustered mode. -# Workers are forked web server processes. If using threads and workers together -# the concurrency of the application would be max `threads` * `workers`. -# Workers do not work on JRuby or Windows (both of which do not support -# processes). -# -# workers ENV.fetch("WEB_CONCURRENCY") { 2 } - -# Use the `preload_app!` method when specifying a `workers` number. -# This directive tells Puma to first boot the application and load code -# before forking the application. This takes advantage of Copy On Write -# process behavior so workers use less memory. -# -# preload_app! - -# Allow puma to be restarted by `bin/rails restart` command. -plugin :tmp_restart diff --git a/instrumentation/rails/test/railtie/dummy/config/routes.rb b/instrumentation/rails/test/railtie/dummy/config/routes.rb deleted file mode 100644 index 262ffd5472..0000000000 --- a/instrumentation/rails/test/railtie/dummy/config/routes.rb +++ /dev/null @@ -1,6 +0,0 @@ -Rails.application.routes.draw do - # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html - - # Defines the root path route ("/") - # root "articles#index" -end diff --git a/instrumentation/rails/test/railtie/dummy/tmp/development_secret.txt b/instrumentation/rails/test/railtie/dummy/tmp/development_secret.txt deleted file mode 100644 index 5be479ebd7..0000000000 --- a/instrumentation/rails/test/railtie/dummy/tmp/development_secret.txt +++ /dev/null @@ -1 +0,0 @@ -c9b8cb0c770beb85f0a8f3f0b0fb292ba85898cdf16193bb6ce27c8249f5c48669734b958fc7b847de4100b929febf9ee51ca1bd3a4ae0e36f047287d4e87370 \ No newline at end of file diff --git a/instrumentation/rails/test/railtie/opentelemetry/instrumentation/rails/railtie_test.rb b/instrumentation/rails/test/railtie/opentelemetry/instrumentation/rails/railtie_test.rb deleted file mode 100644 index 1e35cf636e..0000000000 --- a/instrumentation/rails/test/railtie/opentelemetry/instrumentation/rails/railtie_test.rb +++ /dev/null @@ -1,47 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 -require 'test_helper' - -class OpenTelemetry::Instrumentation::Rails::RailtieTest < ActiveSupport::TestCase - include OpenTelemetry::SemanticConventions - - setup do - OpenTelemetry::Instrumentation.registry.instance_variable_get('@instrumentation').each do |i| - i.instance_variable_set('@instance', nil) - end - OpenTelemetry::SDK::Resources::Resource.instance_variable_set('@default', nil) - OpenTelemetry.tracer_provider = OpenTelemetry::Internal::ProxyTracerProvider.new - end - - test 'configures a default instance of the SDK' do - OpenTelemetry::TestHelpers.with_env('OTEL_SERVICE_NAME' => nil) do - run_initializer - assert_instance_of(OpenTelemetry::SDK::Trace::TracerProvider, OpenTelemetry.tracer_provider) - assert_same(Rails.logger, OpenTelemetry.logger.instance_variable_get('@logger')) - end - end - - test 'uses standard OTel environment variables for SDK configuration' do - OpenTelemetry::TestHelpers.with_env('OTEL_SERVICE_NAME' => 'test_service_name') do - run_initializer - - actual_attributes = find_resource_attributes(Resource::SERVICE_NAME) - - expected_attributes = { Resource::SERVICE_NAME => 'test_service_name' } - assert_equal(expected_attributes, actual_attributes) - end - end - - private - - def run_initializer - Rails.application.initializers.find { |i| i.name == 'opentelemetry.configure' }.run(Rails.application) - end - - def find_resource_attributes(*keys) - OpenTelemetry.tracer_provider.resource.attribute_enumerator.to_h.slice(*keys) - end -end diff --git a/instrumentation/rails/test/railtie/test_helper.rb b/instrumentation/rails/test/railtie/test_helper.rb deleted file mode 100644 index 4fe9c926d0..0000000000 --- a/instrumentation/rails/test/railtie/test_helper.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# Configure Rails Environment -ENV['RACK_ENV'] = 'test' -ENV['RAILS_ENV'] = 'test' - -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' -require_relative '../../test/railtie/dummy/config/environment' -require 'rails/test_help' - -require 'simplecov' -SimpleCov.start diff --git a/instrumentation/rdkafka/.rubocop.yml b/instrumentation/rdkafka/.rubocop.yml deleted file mode 100644 index ffe8aa4d64..0000000000 --- a/instrumentation/rdkafka/.rubocop.yml +++ /dev/null @@ -1,5 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-rdkafka.rb" diff --git a/instrumentation/rdkafka/.yardopts b/instrumentation/rdkafka/.yardopts deleted file mode 100644 index 0d08bf6396..0000000000 --- a/instrumentation/rdkafka/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Rdkafka Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/rdkafka/Appraisals b/instrumentation/rdkafka/Appraisals deleted file mode 100644 index 2550a5eb3d..0000000000 --- a/instrumentation/rdkafka/Appraisals +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# 0.10.0 is the current version at the time of instrumentation creation -appraise 'rdkafka-0.10.0' do - gem 'rdkafka', '0.10.0' -end diff --git a/instrumentation/rdkafka/CHANGELOG.md b/instrumentation/rdkafka/CHANGELOG.md deleted file mode 100644 index 92ce306a26..0000000000 --- a/instrumentation/rdkafka/CHANGELOG.md +++ /dev/null @@ -1,10 +0,0 @@ -# Release History: opentelemetry-instrumentation-rdkafka - -### v0.2.0 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Broken test file requirements - -### v0.1.0 / 2022-05-02 - -* Initial release. diff --git a/instrumentation/rdkafka/Gemfile b/instrumentation/rdkafka/Gemfile deleted file mode 100644 index 2baf57ac47..0000000000 --- a/instrumentation/rdkafka/Gemfile +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :test do - gem 'opentelemetry-instrumentation-base', path: '../base' -end diff --git a/instrumentation/rdkafka/LICENSE b/instrumentation/rdkafka/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/rdkafka/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/rdkafka/README.md b/instrumentation/rdkafka/README.md deleted file mode 100644 index 916583e9e7..0000000000 --- a/instrumentation/rdkafka/README.md +++ /dev/null @@ -1,52 +0,0 @@ -# OpenTelemetry Rdkafka Instrumentation - -The Rdkafka instrumentation is a community-maintained instrumentation for [Rdkafka](https://github.com/appsignal/rdkafka-ruby), a client library for Apache Kafka. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-rdkafka -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-rdkafka` in your `Gemfile`. - -## Usage - -To use the instrumentation, call `use` with the name of the instrumentation: - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Rdkafka' -end -``` - -Alternatively, you can also call `use_all` to install all the available instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` - -## Examples - -Example usage can be seen in the `./example/rdkafka_trace_demonstration.rb` file [here](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/instrumentation/rdkafka/example/trace_demonstration.rb) - -## How can I get involved? - -The `opentelemetry-instrumentation-rdkafka` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -The `opentelemetry-instrumentation-rdkafka` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information. - -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/instrumentation/rdkafka/Rakefile b/instrumentation/rdkafka/Rakefile deleted file mode 100644 index 4b0e9b5a8e..0000000000 --- a/instrumentation/rdkafka/Rakefile +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] - t.warning = false -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/rdkafka/example/rdkafka_trace_demonstration.rb b/instrumentation/rdkafka/example/rdkafka_trace_demonstration.rb deleted file mode 100644 index 00342435e6..0000000000 --- a/instrumentation/rdkafka/example/rdkafka_trace_demonstration.rb +++ /dev/null @@ -1,63 +0,0 @@ -# frozen_string_literal: true - -require 'bundler/inline' -require 'securerandom' - -gemfile(true) do - source 'https://rubygems.org' - - gem 'opentelemetry-api' - gem 'opentelemetry-instrumentation-base' - gem 'opentelemetry-instrumentation-rdkafka' - gem 'opentelemetry-sdk' - gem 'rdkafka', '0.10.0' -end - -require 'opentelemetry-api' -require 'opentelemetry-sdk' -require 'opentelemetry-instrumentation-rdkafka' -require 'rdkafka' - -ENV['OTEL_TRACES_EXPORTER'] ||= 'console' - -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Rdkafka' -end - -host = ENV.fetch('TEST_KAFKA_HOST') { '127.0.0.1' } -port = ENV.fetch('TEST_KAFKA_PORT') { 9092 } -server = "#{host}:#{port}" - -rand_hash = SecureRandom.hex(10) - -producer_config = { "bootstrap.servers": server } -producer = Rdkafka::Config.new(producer_config).producer -delivery_handles = [] - -5.times do |i| - puts "Producing message #{i}" - delivery_handles << producer.produce( - topic: "ruby-test-topic-#{rand_hash}", - payload: "Payload #{i}", - key: "Key #{i}" - ) -end - -delivery_handles.each(&:wait) - -consumer_config = { - "bootstrap.servers": server, - "group.id": 'ruby-test', - "auto.offset.reset": 'smallest' -} -consumer = Rdkafka::Config.new(consumer_config).consumer -consumer.subscribe("ruby-test-topic-#{rand_hash}") - -received_message_count = 0 - -consumer.each do |message| - puts "Message received: #{message}" - received_message_count += 1 - - break if received_message_count == 5 -end diff --git a/instrumentation/rdkafka/lib/opentelemetry-instrumentation-rdkafka.rb b/instrumentation/rdkafka/lib/opentelemetry-instrumentation-rdkafka.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/rdkafka/lib/opentelemetry-instrumentation-rdkafka.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/rdkafka/lib/opentelemetry/instrumentation.rb b/instrumentation/rdkafka/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index ff601cf59e..0000000000 --- a/instrumentation/rdkafka/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/rdkafka' diff --git a/instrumentation/rdkafka/lib/opentelemetry/instrumentation/rdkafka.rb b/instrumentation/rdkafka/lib/opentelemetry/instrumentation/rdkafka.rb deleted file mode 100644 index 07e0c5e976..0000000000 --- a/instrumentation/rdkafka/lib/opentelemetry/instrumentation/rdkafka.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the Rdkafka gem - module Rdkafka - end - end -end - -require_relative './rdkafka/instrumentation' -require_relative './rdkafka/version' diff --git a/instrumentation/rdkafka/lib/opentelemetry/instrumentation/rdkafka/instrumentation.rb b/instrumentation/rdkafka/lib/opentelemetry/instrumentation/rdkafka/instrumentation.rb deleted file mode 100644 index 34c0ac27c0..0000000000 --- a/instrumentation/rdkafka/lib/opentelemetry/instrumentation/rdkafka/instrumentation.rb +++ /dev/null @@ -1,41 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Rdkafka - # The Instrumentation class contains logic to detect and install the Rdkafka instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - MINIMUM_VERSION = Gem::Version.new('0.10.0') - - compatible do - Gem.loaded_specs['rdkafka'].version >= MINIMUM_VERSION - end - - install do |_config| - require_patches - patch - end - - present do - defined?(::Rdkafka) - end - - private - - def require_patches - require_relative 'patches/producer' - require_relative 'patches/consumer' - end - - def patch - ::Rdkafka::Producer.prepend(Patches::Producer) - ::Rdkafka::Consumer.prepend(Patches::Consumer) - end - end - end - end -end diff --git a/instrumentation/rdkafka/lib/opentelemetry/instrumentation/rdkafka/patches/consumer.rb b/instrumentation/rdkafka/lib/opentelemetry/instrumentation/rdkafka/patches/consumer.rb deleted file mode 100644 index 1f29eb9de9..0000000000 --- a/instrumentation/rdkafka/lib/opentelemetry/instrumentation/rdkafka/patches/consumer.rb +++ /dev/null @@ -1,69 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Rdkafka - module Patches - # The Consumer module contains the instrumentation patch for the Consumer class - module Consumer - def each - super do |message| - attributes = { - 'messaging.system' => 'kafka', - 'messaging.destination' => message.topic, - 'messaging.destination_kind' => 'topic', - 'messaging.kafka.partition' => message.partition, - 'messaging.kafka.offset' => message.offset - } - - attributes['messaging.kafka.message_key'] = message.key if message.key - parent_context = OpenTelemetry.propagation.extract(message.headers, getter: OpenTelemetry::Common::Propagation.symbol_key_getter) - span_context = OpenTelemetry::Trace.current_span(parent_context).context - links = [OpenTelemetry::Trace::Link.new(span_context)] if span_context.valid? - - OpenTelemetry::Context.with_current(parent_context) do - tracer.in_span("#{message.topic} process", links: links, attributes: attributes, kind: :consumer) do - yield message - end - end - end - end - - def each_batch(max_items: 100, bytes_threshold: Float::INFINITY, timeout_ms: 250, yield_on_error: false, &block) - super do |messages, error| - if messages.empty? - yield messages, error - else - attributes = { - 'messaging.system' => 'kafka', - 'messaging.destination_kind' => 'topic', - 'messaging.kafka.message_count' => messages.size - } - - links = messages.map do |message| - span_context = OpenTelemetry::Trace.current_span(OpenTelemetry.propagation.extract(message.headers, getter: OpenTelemetry::Common::Propagation.symbol_key_getter)).context - OpenTelemetry::Trace::Link.new(span_context) if span_context.valid? - end - links.compact! - - tracer.in_span('batch process', attributes: attributes, links: links, kind: :consumer) do - yield messages, error - end - end - end - end - - private - - def tracer - Rdkafka::Instrumentation.instance.tracer - end - end - end - end - end -end diff --git a/instrumentation/rdkafka/lib/opentelemetry/instrumentation/rdkafka/patches/producer.rb b/instrumentation/rdkafka/lib/opentelemetry/instrumentation/rdkafka/patches/producer.rb deleted file mode 100644 index 7b234b70e9..0000000000 --- a/instrumentation/rdkafka/lib/opentelemetry/instrumentation/rdkafka/patches/producer.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Rdkafka - module Patches - # The Producer module contains the instrumentation patch the Producer#produce method - module Producer - def produce(topic:, payload: nil, key: nil, partition: nil, partition_key: nil, timestamp: nil, headers: nil) - attributes = { - 'messaging.system' => 'kafka', - 'messaging.destination' => topic, - 'messaging.destination_kind' => 'topic' - } - - headers ||= {} - - tracer.in_span("#{topic} send", attributes: attributes, kind: :producer) do - OpenTelemetry.propagation.inject(headers) - super - end - end - - private - - def tracer - Rdkafka::Instrumentation.instance.tracer - end - end - end - end - end -end diff --git a/instrumentation/rdkafka/lib/opentelemetry/instrumentation/rdkafka/version.rb b/instrumentation/rdkafka/lib/opentelemetry/instrumentation/rdkafka/version.rb deleted file mode 100644 index 7c01406df2..0000000000 --- a/instrumentation/rdkafka/lib/opentelemetry/instrumentation/rdkafka/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Rdkafka - VERSION = '0.2.0' - end - end -end diff --git a/instrumentation/rdkafka/opentelemetry-instrumentation-rdkafka.gemspec b/instrumentation/rdkafka/opentelemetry-instrumentation-rdkafka.gemspec deleted file mode 100644 index 8eb472c1d0..0000000000 --- a/instrumentation/rdkafka/opentelemetry-instrumentation-rdkafka.gemspec +++ /dev/null @@ -1,52 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/rdkafka/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-rdkafka' - spec.version = OpenTelemetry::Instrumentation::Rdkafka::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'Rdkafka instrumentation for the OpenTelemetry framework' - spec.description = 'Rdkafka instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0.0' - spec.add_dependency 'opentelemetry-common', '~> 0.19.3' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.21.0' - - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-sdk' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'pry-byebug' unless RUBY_ENGINE == 'jruby' - spec.add_development_dependency 'rake', '~> 12.3.3' - spec.add_development_dependency 'rdkafka' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'webmock', '~> 3.7.6' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-rdkafka/v#{OpenTelemetry::Instrumentation::Rdkafka::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/rdkafka' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-rdkafka/v#{OpenTelemetry::Instrumentation::Rdkafka::VERSION}" - end -end diff --git a/instrumentation/rdkafka/test/.rubocop.yml b/instrumentation/rdkafka/test/.rubocop.yml deleted file mode 100644 index dd94258585..0000000000 --- a/instrumentation/rdkafka/test/.rubocop.yml +++ /dev/null @@ -1,4 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false diff --git a/instrumentation/rdkafka/test/opentelemetry/instrumentation/rdkafka/instrumentation_test.rb b/instrumentation/rdkafka/test/opentelemetry/instrumentation/rdkafka/instrumentation_test.rb deleted file mode 100644 index 9344b459d0..0000000000 --- a/instrumentation/rdkafka/test/opentelemetry/instrumentation/rdkafka/instrumentation_test.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../lib/opentelemetry/instrumentation/rdkafka' - -describe OpenTelemetry::Instrumentation::Rdkafka do - let(:instrumentation) { OpenTelemetry::Instrumentation::Rdkafka::Instrumentation.instance } - - it 'has #name' do - _(instrumentation.name).must_equal 'OpenTelemetry::Instrumentation::Rdkafka' - end - - it 'has #version' do - _(instrumentation.version).wont_be_nil - _(instrumentation.version).wont_be_empty - end - - describe '#install' do - it 'accepts argument' do - _(instrumentation.install({})).must_equal(true) - instrumentation.instance_variable_set(:@installed, false) - end - end -end diff --git a/instrumentation/rdkafka/test/opentelemetry/instrumentation/rdkafka/patches/consumer_test.rb b/instrumentation/rdkafka/test/opentelemetry/instrumentation/rdkafka/patches/consumer_test.rb deleted file mode 100644 index 11b499bd14..0000000000 --- a/instrumentation/rdkafka/test/opentelemetry/instrumentation/rdkafka/patches/consumer_test.rb +++ /dev/null @@ -1,179 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' -require 'securerandom' -require 'pry' - -require_relative '../../../../../lib/opentelemetry/instrumentation/rdkafka' -require_relative '../../../../../lib/opentelemetry/instrumentation/rdkafka/patches/consumer' - -unless ENV['OMIT_SERVICES'] - describe OpenTelemetry::Instrumentation::Rdkafka::Patches::Consumer do - let(:instrumentation) { OpenTelemetry::Instrumentation::Rdkafka::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:spans) { exporter.finished_spans } - - let(:host) { ENV.fetch('TEST_KAFKA_HOST') { '127.0.0.1' } } - let(:port) { (ENV.fetch('TEST_KAFKA_PORT') { 29_092 }) } - - before do - # Clear spans - exporter.reset - - instrumentation.install - end - - after do - # Force re-install of instrumentation - instrumentation.instance_variable_set(:@installed, false) - end - - describe '#each' do - it 'traces each call' do - rand_hash = SecureRandom.hex(10) - topic_name = "consumer-patch-trace-#{rand_hash}" - config = { "bootstrap.servers": "#{host}:#{port}" } - - producer = Rdkafka::Config.new(config).producer - delivery_handles = [] - - delivery_handles << producer.produce( - topic: topic_name, - payload: 'never gonna', - key: 'Key 1' - ) - - delivery_handles << producer.produce( - topic: topic_name, - payload: 'give you up', - key: 'Key 2' - ) - - delivery_handles.each(&:wait) - - producer.close - - consumer_config = config.merge( - "group.id": 'me', - "auto.offset.reset": 'smallest' # https://stackoverflow.com/a/51081649 - ) - consumer = Rdkafka::Config.new(config.merge(consumer_config)).consumer - consumer.subscribe(topic_name) - - counter = 0 - begin - consumer.each do |_msg| - counter += 1 - raise 'oops' if counter >= 2 - end - rescue StandardError # rubocop:disable Lint/HandleExceptions - end - - process_spans = spans.select { |s| s.name == "#{topic_name} process" } - - # First pair for send and process spans - first_process_span = process_spans[0] - _(first_process_span.name).must_equal("#{topic_name} process") - _(first_process_span.kind).must_equal(:consumer) - _(first_process_span.attributes['messaging.destination']).must_equal(topic_name) - _(first_process_span.attributes['messaging.kafka.partition']).wont_be_nil - - first_process_span_link = first_process_span.links[0] - linked_span_context = first_process_span_link.span_context - - linked_send_span = spans.find { |s| s.span_id == linked_span_context.span_id } - _(linked_send_span.name).must_equal("#{topic_name} send") - _(linked_send_span.trace_id).must_equal(first_process_span.trace_id) - _(linked_send_span.trace_id).must_equal(linked_span_context.trace_id) - - # Second pair of send and process spans - second_process_span = process_spans[1] - _(second_process_span.name).must_equal("#{topic_name} process") - _(second_process_span.kind).must_equal(:consumer) - - second_process_span_link = second_process_span.links[0] - linked_span_context = second_process_span_link.span_context - - linked_send_span = spans.find { |s| s.span_id == linked_span_context.span_id } - _(linked_send_span.name).must_equal("#{topic_name} send") - _(linked_send_span.trace_id).must_equal(second_process_span.trace_id) - _(linked_send_span.trace_id).must_equal(linked_span_context.trace_id) - - event = second_process_span.events.first - _(event.name).must_equal('exception') - _(event.attributes['exception.type']).must_equal('RuntimeError') - _(event.attributes['exception.message']).must_equal('oops') - - _(spans.size).must_equal(4) - - consumer.close - end - end - - describe '#each_batch' do - it 'traces each_batch call' do - rand_hash = SecureRandom.hex(10) - topic_name = "consumer-patch-batch-trace-#{rand_hash}" - config = { "bootstrap.servers": "#{host}:#{port}" } - - producer = Rdkafka::Config.new(config).producer - delivery_handles = [] - - delivery_handles << producer.produce( - topic: topic_name, - payload: 'wow', - key: 'Key 1' - ) - - delivery_handles << producer.produce( - topic: topic_name, - payload: 'super', - key: 'Key 2' - ) - - delivery_handles.each(&:wait) - - producer.close - - consumer_config = config.merge( - "group.id": 'me', - "auto.offset.reset": 'smallest' # https://stackoverflow.com/a/51081649 - ) - consumer = Rdkafka::Config.new(config.merge(consumer_config)).consumer - consumer.subscribe(topic_name) - - begin - consumer.each_batch(max_items: 2) do |messages| - raise 'oops' unless messages.empty? - end - rescue StandardError # rubocop:disable Lint/HandleExceptions - end - - span = spans.find { |s| s.name == 'batch process' } - _(span.kind).must_equal(:consumer) - _(span.attributes['messaging.kafka.message_count']).must_equal(2) - - event = span.events.first - _(event.name).must_equal('exception') - _(event.attributes['exception.type']).must_equal('RuntimeError') - _(event.attributes['exception.message']).must_equal('oops') - - first_link = span.links[0] - linked_span_context = first_link.span_context - _(linked_span_context.trace_id).must_equal(spans[0].trace_id) - _(linked_span_context.span_id).must_equal(spans[0].span_id) - - second_link = span.links[1] - linked_span_context = second_link.span_context - _(linked_span_context.trace_id).must_equal(spans[1].trace_id) - _(linked_span_context.span_id).must_equal(spans[1].span_id) - - _(spans.size).must_equal(3) - end - end - end -end diff --git a/instrumentation/rdkafka/test/opentelemetry/instrumentation/rdkafka/patches/producer_test.rb b/instrumentation/rdkafka/test/opentelemetry/instrumentation/rdkafka/patches/producer_test.rb deleted file mode 100644 index f4bad8a984..0000000000 --- a/instrumentation/rdkafka/test/opentelemetry/instrumentation/rdkafka/patches/producer_test.rb +++ /dev/null @@ -1,61 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../../lib/opentelemetry/instrumentation/rdkafka' -require_relative '../../../../../lib/opentelemetry/instrumentation/rdkafka/patches/producer' - -unless ENV['OMIT_SERVICES'] - describe OpenTelemetry::Instrumentation::Rdkafka::Patches::Producer do - let(:instrumentation) { OpenTelemetry::Instrumentation::Rdkafka::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:spans) { exporter.finished_spans } - - let(:host) { ENV.fetch('TEST_KAFKA_HOST') { '127.0.0.1' } } - let(:port) { (ENV.fetch('TEST_KAFKA_PORT') { 29_092 }) } - - before do - # Clear spans - exporter.reset - - instrumentation.install - end - - after do - # Force re-install of instrumentation - instrumentation.instance_variable_set(:@installed, false) - end - - describe 'tracing' do - it 'traces sync produce calls' do - topic_name = 'producer-patch-trace' - config = { "bootstrap.servers": "#{host}:#{port}" } - - producer = Rdkafka::Config.new(config).producer - delivery_handles = [] - - message_name = "msg#{Time.now}" - - delivery_handles << producer.produce( - topic: topic_name, - payload: "Payload #{message_name}", - key: "Key #{message_name}" - ) - - delivery_handles.each(&:wait) - - _(spans.first.name).must_equal("#{topic_name} send") - _(spans.first.kind).must_equal(:producer) - - _(spans.first.attributes['messaging.system']).must_equal('kafka') - _(spans.first.attributes['messaging.destination']).must_equal(topic_name) - - producer.close - end - end - end -end diff --git a/instrumentation/rdkafka/test/test_helper.rb b/instrumentation/rdkafka/test/test_helper.rb deleted file mode 100644 index cc20540eaf..0000000000 --- a/instrumentation/rdkafka/test/test_helper.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' - -require 'minitest/autorun' -require 'webmock/minitest' - -require 'rdkafka' - -# global opentelemetry-sdk setup: -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry::SDK.configure do |c| - c.add_span_processor span_processor -end diff --git a/instrumentation/redis/.rubocop.yml b/instrumentation/redis/.rubocop.yml deleted file mode 100644 index 16fbd0ed50..0000000000 --- a/instrumentation/redis/.rubocop.yml +++ /dev/null @@ -1,5 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-redis.rb" diff --git a/instrumentation/redis/.yardopts b/instrumentation/redis/.yardopts deleted file mode 100644 index 381e276e40..0000000000 --- a/instrumentation/redis/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Redis Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/redis/Appraisals b/instrumentation/redis/Appraisals deleted file mode 100644 index 0f8374dc8f..0000000000 --- a/instrumentation/redis/Appraisals +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -appraise 'redis-4.6' do - gem 'redis', '~> 4.1.0' -end - -appraise 'redis-4.5' do - gem 'redis', '~> 4.1.0' -end - -appraise 'redis-4.4' do - gem 'redis', '~> 4.1.0' -end - -appraise 'redis-4.3' do - gem 'redis', '~> 4.1.0' -end - -appraise 'redis-4.2' do - gem 'redis', '~> 4.1.0' -end - -appraise 'redis-4.1' do - gem 'redis', '~> 4.1.0' -end - -appraise 'redis-4.0' do - gem 'redis', '~> 4.0.0' -end diff --git a/instrumentation/redis/CHANGELOG.md b/instrumentation/redis/CHANGELOG.md deleted file mode 100644 index 8e6b6a4261..0000000000 --- a/instrumentation/redis/CHANGELOG.md +++ /dev/null @@ -1,113 +0,0 @@ -# Release History: opentelemetry-instrumentation-redis - -### v0.23.0 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Broken test file requirements - -### v0.22.1 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Broken test file requirements - -### v0.22.0 / 2022-05-02 - -* ADDED: Validate Using Enums -* FIXED: Add appraisals for redis 4.2-4.6 - -### v0.21.3 / 2022-02-02 - -* FIXED: Prevent redis instrumentation from mutating the command - -### v0.21.2 / 2021-12-01 - -* (No significant changes) - -### v0.21.1 / 2021-09-29 - -* (No significant changes) - -### v0.21.0 / 2021-08-12 - -* ADDED: Add toggle for redis db.statement attribute - -### v0.20.0 / 2021-06-23 - -* BREAKING CHANGE: Total order constraint on span.status= - -* FIXED: Total order constraint on span.status= - -### v0.19.0 / 2021-05-28 - -* ADDED: Configuration option to enable or disable redis root spans [#777](https://github.com/open-telemetry/opentelemetry-ruby/pull/777) - -### v0.18.0 / 2021-05-21 - -* ADDED: Updated API depedency for 1.0.0.rc1 -refactor: redis attribute utils [#760](https://github.com/open-telemetry/opentelemetry-ruby/pull/760) -refactor: simplify redis attribute assignment [#758](https://github.com/open-telemetry/opentelemetry-ruby/pull/758) -test: split redis instrumentation test [#754](https://github.com/open-telemetry/opentelemetry-ruby/pull/754) -* ADDED: Option to obfuscate redis arguments -* FIXED: Instrument Redis more thoroughly by patching Client#process. - -### v0.17.0 / 2021-04-22 - -* (No significant changes) - -### v0.16.0 / 2021-03-17 - -* FIXED: Update DB semantic conventions -* FIXED: Example scripts now reference local common lib -* DOCS: Replace Gitter with GitHub Discussions - -### v0.15.0 / 2021-02-18 - -* ADDED: Add instrumentation config validation - -### v0.14.0 / 2021-02-03 - -* (No significant changes) - -### v0.13.0 / 2021-01-29 - -* (No significant changes) - -### v0.12.0 / 2020-12-24 - -* (No significant changes) - -### v0.11.0 / 2020-12-11 - -* ADDED: Accept config for redis peer service attribute -* ADDED: Move utf8 encoding to common utils -* FIXED: Copyright comments to not reference year - -### v0.10.1 / 2020-12-09 - -* FIXED: Semantic conventions db.type -> db.system - -### v0.10.0 / 2020-12-03 - -* (No significant changes) - -### v0.9.0 / 2020-11-27 - -* BREAKING CHANGE: Add timeout for force_flush and shutdown - -* ADDED: Redis attribute propagation -* ADDED: Add timeout for force_flush and shutdown - -### v0.8.0 / 2020-10-27 - -* BREAKING CHANGE: Remove 'canonical' from status codes - -* FIXED: Remove 'canonical' from status codes - -### v0.7.0 / 2020-10-07 - -* DOCS: Added redis documentation -* DOCS: Standardize toplevel docs structure and readme - -### v0.6.0 / 2020-09-10 - -* (No significant changes) diff --git a/instrumentation/redis/Gemfile b/instrumentation/redis/Gemfile deleted file mode 100644 index 2baf57ac47..0000000000 --- a/instrumentation/redis/Gemfile +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :test do - gem 'opentelemetry-instrumentation-base', path: '../base' -end diff --git a/instrumentation/redis/LICENSE b/instrumentation/redis/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/redis/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/redis/README.md b/instrumentation/redis/README.md deleted file mode 100644 index 1610156269..0000000000 --- a/instrumentation/redis/README.md +++ /dev/null @@ -1,83 +0,0 @@ -# OpenTelemetry Redis Instrumentation - -The OpenTelemetry Redis Ruby gem is a community maintained instrumentation for [Redis][redis-home]. This is an in-memory data store that is used as a database, cache, and message broker. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-redis -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-redis` in your `Gemfile`. - -## Usage - -To install the instrumentation, call `use` with the name of the instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Redis' -end -``` - -Alternatively, you can also call `use_all` to install all the available instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` - -The Redis instrumentation allows the user to supply additional attributes via context propagation. This may be used to propagate attributes from instrumentation for things like Resque and Sidekiq, for example, to attach to the Redis client spans. - -```ruby -require 'opentelemetry/instrumentation/redis' - -redis = ::Redis.new -OpenTelemetry::Instrumentation::Redis.with_attributes('peer.service' => 'cache') do - redis.set('K', 'x') -end -``` - -### Configuration options - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Redis', { - # The obfuscation of arguments in the db.statement attribute is enabled by default. - # To include the full query, set db_statement to :include. - # To obfuscate, set db_statement to :obfuscate. - # To omit the attribute, set db_statement to :omit. - db_statement: :include, - } -end -``` - -## Example - -An example of usage can be seen in [`example/redis.rb`](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/instrumentation/redis/example/redis.rb). - -## Development - -You'll need Redis installed locally to run the test suite. Once you've -installed it, it will start and stop automatically when you run `rake`. - -## How can I get involved? - -The `opentelemetry-instrumentation-redis` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -Apache 2.0 license. See [LICENSE][license-github] for more information. - -[redis-home]: https://redis.io -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/instrumentation/redis/Rakefile b/instrumentation/redis/Rakefile deleted file mode 100644 index 626fca193e..0000000000 --- a/instrumentation/redis/Rakefile +++ /dev/null @@ -1,35 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -task :start_redis do - @redis_pid = fork { exec 'redis-server test/redis.conf' } -end - -Rake::TestTask.new test: :start_redis do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] - at_exit do - Process.kill('USR1', @redis_pid) if @redis_pid - end -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/redis/example/Gemfile b/instrumentation/redis/example/Gemfile deleted file mode 100644 index 7ebee0a8df..0000000000 --- a/instrumentation/redis/example/Gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -source 'https://rubygems.org' - -gem 'opentelemetry-api' -gem 'opentelemetry-common' -gem 'opentelemetry-instrumentation-redis' -gem 'opentelemetry-sdk' -gem 'redis' diff --git a/instrumentation/redis/example/redis.rb b/instrumentation/redis/example/redis.rb deleted file mode 100644 index 0cf0d0d577..0000000000 --- a/instrumentation/redis/example/redis.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -require 'rubygems' -require 'bundler/setup' - -Bundler.require - -# Export traces to console by default -ENV['OTEL_TRACES_EXPORTER'] ||= 'console' - -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Redis' -end - -port = ENV['TEST_REDIS_PORT'] || '16379' -password = ENV['REDIS_PASSWORD'] || 'passw0rd' -redis = Redis.new(port: port, password: password) -redis.set('mykey', 'hello world') diff --git a/instrumentation/redis/lib/opentelemetry-instrumentation-redis.rb b/instrumentation/redis/lib/opentelemetry-instrumentation-redis.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/redis/lib/opentelemetry-instrumentation-redis.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/redis/lib/opentelemetry/instrumentation.rb b/instrumentation/redis/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index 72d237e7c0..0000000000 --- a/instrumentation/redis/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # "Instrumentation" are specified by - # https://github.com/open-telemetry/opentelemetry-specification/blob/784635d01d8690c8f5fcd1f55bdbc8a13cf2f4f2/specification/glossary.md#instrumentation-library - # - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/redis' diff --git a/instrumentation/redis/lib/opentelemetry/instrumentation/redis.rb b/instrumentation/redis/lib/opentelemetry/instrumentation/redis.rb deleted file mode 100644 index 2cac4e4602..0000000000 --- a/instrumentation/redis/lib/opentelemetry/instrumentation/redis.rb +++ /dev/null @@ -1,59 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry/common' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the Redis gem - module Redis - extend self - - CURRENT_ATTRIBUTES_HASH = Context.create_key('redis-attributes-hash') - - private_constant :CURRENT_ATTRIBUTES_HASH - - # Returns the attributes hash representing the Redis client context found - # in the optional context or the current context if none is provided. - # - # @param [optional Context] context The context to lookup the current - # attributes hash. Defaults to Context.current - def attributes(context = nil) - context ||= Context.current - context.value(CURRENT_ATTRIBUTES_HASH) || {} - end - - # Returns a context containing the merged attributes hash, derived from the - # optional parent context, or the current context if one was not provided. - # - # @param [optional Context] context The context to use as the parent for - # the returned context - def context_with_attributes(attributes_hash, parent_context: Context.current) - attributes_hash = attributes(parent_context).merge(attributes_hash) - parent_context.set_value(CURRENT_ATTRIBUTES_HASH, attributes_hash) - end - - # Activates/deactivates the merged attributes hash within the current Context, - # which makes the "current attributes hash" available implicitly. - # - # On exit, the attributes hash that was active before calling this method - # will be reactivated. - # - # @param [Span] span the span to activate - # @yield [Hash, Context] yields attributes hash and a context containing the - # attributes hash to the block. - def with_attributes(attributes_hash) - attributes_hash = attributes.merge(attributes_hash) - Context.with_value(CURRENT_ATTRIBUTES_HASH, attributes_hash) { |c, h| yield h, c } - end - end - end -end - -require_relative './redis/instrumentation' -require_relative './redis/version' diff --git a/instrumentation/redis/lib/opentelemetry/instrumentation/redis/instrumentation.rb b/instrumentation/redis/lib/opentelemetry/instrumentation/redis/instrumentation.rb deleted file mode 100644 index 1416a0ec6e..0000000000 --- a/instrumentation/redis/lib/opentelemetry/instrumentation/redis/instrumentation.rb +++ /dev/null @@ -1,38 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Redis - # The Instrumentation class contains logic to detect and install the Redis - # instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - install do |_config| - require_dependencies - patch_client - end - - present do - defined?(::Redis) - end - - option :peer_service, default: nil, validate: :string - option :trace_root_spans, default: true, validate: :boolean - option :db_statement, default: :obfuscate, validate: %I[omit include obfuscate] - - private - - def require_dependencies - require_relative 'patches/client' - end - - def patch_client - ::Redis::Client.prepend(Patches::Client) - end - end - end - end -end diff --git a/instrumentation/redis/lib/opentelemetry/instrumentation/redis/patches/client.rb b/instrumentation/redis/lib/opentelemetry/instrumentation/redis/patches/client.rb deleted file mode 100644 index fd2f793b24..0000000000 --- a/instrumentation/redis/lib/opentelemetry/instrumentation/redis/patches/client.rb +++ /dev/null @@ -1,95 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Redis - module Patches - # Module to prepend to Redis::Client for instrumentation - module Client - MAX_STATEMENT_LENGTH = 500 - private_constant :MAX_STATEMENT_LENGTH - - def process(commands) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity - return super unless config[:trace_root_spans] || OpenTelemetry::Trace.current_span.context.valid? - - host = options[:host] - port = options[:port] - - attributes = { - 'db.system' => 'redis', - 'net.peer.name' => host, - 'net.peer.port' => port - } - - attributes['db.redis.database_index'] = options[:db] unless options[:db].zero? - attributes['peer.service'] = config[:peer_service] if config[:peer_service] - attributes.merge!(OpenTelemetry::Instrumentation::Redis.attributes) - - unless config[:db_statement] == :omit - parsed_commands = parse_commands(commands) - parsed_commands = OpenTelemetry::Common::Utilities.truncate(parsed_commands, MAX_STATEMENT_LENGTH) - parsed_commands = OpenTelemetry::Common::Utilities.utf8_encode(parsed_commands, binary: true) - attributes['db.statement'] = parsed_commands - end - - span_name = if commands.length == 1 - commands[0][0].to_s.upcase - else - 'PIPELINED' - end - - tracer.in_span(span_name, attributes: attributes, kind: :client) do |s| - super(commands).tap do |reply| - if reply.is_a?(::Redis::CommandError) - s.record_exception(reply) - s.status = Trace::Status.error(reply.message) - end - end - end - end - - private - - # Examples of commands received for parsing - # Redis#queue [[[:set, "v1", "0"]], [[:incr, "v1"]], [[:get, "v1"]]] - # Redis#pipeline: [[:set, "v1", "0"], [:incr, "v1"], [:get, "v1"]] - # Redis#hmset [[:hmset, "hash", "f1", 1234567890.0987654]] - # Redis#set [[:set, "K", "x"]] - def parse_commands(commands) # rubocop:disable Metrics/AbcSize - commands.map do |command| - # We are checking for the use of Redis#queue command, if we detect the - # extra level of array nesting we return the first element so it - # can be parsed. - command = command[0] if command.is_a?(Array) && command[0].is_a?(Array) - - # If we receive an authentication request command - # we want to short circuit parsing the commands - # and return the obfuscated command - return 'AUTH ?' if command[0] == :auth - - if config[:db_statement] == :obfuscate - command[0].to_s.upcase + ' ?' * (command.size - 1) - else - command_copy = command.dup - command_copy[0] = command_copy[0].to_s.upcase - command_copy.join(' ') - end - end.join("\n") - end - - def tracer - Redis::Instrumentation.instance.tracer - end - - def config - Redis::Instrumentation.instance.config - end - end - end - end - end -end diff --git a/instrumentation/redis/lib/opentelemetry/instrumentation/redis/version.rb b/instrumentation/redis/lib/opentelemetry/instrumentation/redis/version.rb deleted file mode 100644 index 15917a25d8..0000000000 --- a/instrumentation/redis/lib/opentelemetry/instrumentation/redis/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Redis - VERSION = '0.23.0' - end - end -end diff --git a/instrumentation/redis/opentelemetry-instrumentation-redis.gemspec b/instrumentation/redis/opentelemetry-instrumentation-redis.gemspec deleted file mode 100644 index c0f16d1796..0000000000 --- a/instrumentation/redis/opentelemetry-instrumentation-redis.gemspec +++ /dev/null @@ -1,49 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/redis/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-redis' - spec.version = OpenTelemetry::Instrumentation::Redis::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'Redis instrumentation for the OpenTelemetry framework' - spec.description = 'Redis instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-common', '~> 0.19.3' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.21.0' - - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'redis', '~> 4.1.0' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-redis/v#{OpenTelemetry::Instrumentation::Redis::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/redis' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-redis/v#{OpenTelemetry::Instrumentation::Redis::VERSION}" - end -end diff --git a/instrumentation/redis/test/.rubocop.yml b/instrumentation/redis/test/.rubocop.yml deleted file mode 100644 index e97eda560f..0000000000 --- a/instrumentation/redis/test/.rubocop.yml +++ /dev/null @@ -1,6 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false -Style/MultilineIfModifier: - Enabled: false diff --git a/instrumentation/redis/test/opentelemetry/instrumentation/redis/instrumentation_test.rb b/instrumentation/redis/test/opentelemetry/instrumentation/redis/instrumentation_test.rb deleted file mode 100644 index cf3261e2db..0000000000 --- a/instrumentation/redis/test/opentelemetry/instrumentation/redis/instrumentation_test.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../lib/opentelemetry/instrumentation/redis' -require_relative '../../../../lib/opentelemetry/instrumentation/redis/patches/client' - -describe OpenTelemetry::Instrumentation::Redis::Instrumentation do - let(:instrumentation) { OpenTelemetry::Instrumentation::Redis::Instrumentation.instance } - - it 'has #name' do - _(instrumentation.name).must_equal 'OpenTelemetry::Instrumentation::Redis' - end - - it 'has #version' do - _(instrumentation.version).wont_be_nil - _(instrumentation.version).wont_be_empty - end - - describe '#install' do - it 'accepts argument' do - _(instrumentation.install({})).must_equal(true) - instrumentation.instance_variable_set(:@installed, false) - end - end -end diff --git a/instrumentation/redis/test/opentelemetry/instrumentation/redis/patches/client_test.rb b/instrumentation/redis/test/opentelemetry/instrumentation/redis/patches/client_test.rb deleted file mode 100644 index 971065fe6b..0000000000 --- a/instrumentation/redis/test/opentelemetry/instrumentation/redis/patches/client_test.rb +++ /dev/null @@ -1,352 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../../lib/opentelemetry/instrumentation/redis' -require_relative '../../../../../lib/opentelemetry/instrumentation/redis/patches/client' - -describe OpenTelemetry::Instrumentation::Redis::Patches::Client do - let(:instrumentation) { OpenTelemetry::Instrumentation::Redis::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:password) { 'passw0rd' } - let(:redis_host) { ENV['TEST_REDIS_HOST'] } - let(:redis_port) { ENV['TEST_REDIS_PORT'].to_i } - let(:last_span) { exporter.finished_spans.last } - - # Instantiate the Redis client with the correct password. Note that this - # will generate one extra span on connect because the Redis client will - # send an AUTH command before doing anything else. - def redis_with_auth(redis_options = {}) - redis_options[:password] = password - redis_options[:host] = redis_host - redis_options[:port] = redis_port - redis = ::Redis.new(redis_options) - redis - end - - before do - # ensure obfuscation is off if it was previously set in a different test - config = { db_statement: :include } - instrumentation.install(config) - exporter.reset - end - - # Force re-install of instrumentation - after { instrumentation.instance_variable_set(:@installed, false) } - - describe '#process' do - it 'before request' do - _(exporter.finished_spans.size).must_equal 0 - end - - it 'accepts peer service name from config' do - instrumentation.instance_variable_set(:@installed, false) - instrumentation.install(peer_service: 'readonly:redis') - ::Redis.new(host: redis_host, port: redis_port).auth(password) - - _(last_span.attributes['peer.service']).must_equal 'readonly:redis' - end - - it 'context attributes take priority' do - instrumentation.instance_variable_set(:@installed, false) - instrumentation.install(peer_service: 'readonly:redis') - redis = redis_with_auth - - OpenTelemetry::Instrumentation::Redis.with_attributes('peer.service' => 'foo') do - redis.set('K', 'x') - end - - _(last_span.attributes['peer.service']).must_equal 'foo' - end - - it 'after authorization with Redis server' do - ::Redis.new(host: redis_host, port: redis_port).auth(password) - - _(last_span.name).must_equal 'AUTH' - _(last_span.attributes['db.system']).must_equal 'redis' - _(last_span.attributes['db.statement']).must_equal 'AUTH ?' - _(last_span.attributes['net.peer.name']).must_equal redis_host - _(last_span.attributes['net.peer.port']).must_equal redis_port - end - - it 'after requests' do - redis = redis_with_auth - _(redis.set('K', 'x')).must_equal 'OK' - _(redis.get('K')).must_equal 'x' - - _(exporter.finished_spans.size).must_equal 3 - - set_span = exporter.finished_spans[1] - _(set_span.name).must_equal 'SET' - _(set_span.attributes['db.system']).must_equal 'redis' - _(set_span.attributes['db.statement']).must_equal('SET K x') - _(set_span.attributes['net.peer.name']).must_equal redis_host - _(set_span.attributes['net.peer.port']).must_equal redis_port - - get_span = exporter.finished_spans.last - _(get_span.name).must_equal 'GET' - _(get_span.attributes['db.system']).must_equal 'redis' - _(get_span.attributes['db.statement']).must_equal 'GET K' - _(get_span.attributes['net.peer.name']).must_equal redis_host - _(get_span.attributes['net.peer.port']).must_equal redis_port - end - - it 'reflects db index' do - redis = redis_with_auth(db: 1) - redis.get('K') - - _(exporter.finished_spans.size).must_equal 3 - - select_span = exporter.finished_spans[1] - _(select_span.name).must_equal 'SELECT' - _(select_span.attributes['db.system']).must_equal 'redis' - _(select_span.attributes['db.statement']).must_equal('SELECT 1') - _(select_span.attributes['net.peer.name']).must_equal redis_host - _(select_span.attributes['net.peer.port']).must_equal redis_port - - get_span = exporter.finished_spans.last - _(get_span.name).must_equal 'GET' - _(get_span.attributes['db.system']).must_equal 'redis' - _(get_span.attributes['db.statement']).must_equal('GET K') - _(get_span.attributes['db.redis.database_index']).must_equal 1 - _(get_span.attributes['net.peer.name']).must_equal redis_host - _(get_span.attributes['net.peer.port']).must_equal redis_port - end - - it 'merges context attributes' do - redis = redis_with_auth - OpenTelemetry::Instrumentation::Redis.with_attributes('peer.service' => 'foo') do - redis.set('K', 'x') - end - - _(exporter.finished_spans.size).must_equal 2 - - set_span = exporter.finished_spans[1] - _(set_span.name).must_equal 'SET' - _(set_span.attributes['db.system']).must_equal 'redis' - _(set_span.attributes['db.statement']).must_equal('SET K x') - _(set_span.attributes['peer.service']).must_equal 'foo' - _(set_span.attributes['net.peer.name']).must_equal redis_host - _(set_span.attributes['net.peer.port']).must_equal redis_port - end - - it 'records exceptions' do - expect do - redis = redis_with_auth - redis.call 'THIS_IS_NOT_A_REDIS_FUNC', 'THIS_IS_NOT_A_VALID_ARG' - end.must_raise Redis::CommandError - - _(exporter.finished_spans.size).must_equal 2 - _(last_span.name).must_equal 'THIS_IS_NOT_A_REDIS_FUNC' - _(last_span.attributes['db.system']).must_equal 'redis' - _(last_span.attributes['db.statement']).must_equal( - 'THIS_IS_NOT_A_REDIS_FUNC THIS_IS_NOT_A_VALID_ARG' - ) - _(last_span.attributes['net.peer.name']).must_equal redis_host - _(last_span.attributes['net.peer.port']).must_equal redis_port - _(last_span.status.code).must_equal( - OpenTelemetry::Trace::Status::ERROR - ) - _(last_span.status.description).must_equal( - 'ERR unknown command `THIS_IS_NOT_A_REDIS_FUNC`, with args beginning with: `THIS_IS_NOT_A_VALID_ARG`,' - ) - end - - it 'records net.peer.name and net.peer.port attributes' do - expect do - ::Redis.new(host: 'example.com', port: 8321, timeout: 0.01).auth(password) - end.must_raise Redis::CannotConnectError - - _(last_span.name).must_equal 'AUTH' - _(last_span.attributes['db.system']).must_equal 'redis' - _(last_span.attributes['db.statement']).must_equal 'AUTH ?' - _(last_span.attributes['net.peer.name']).must_equal 'example.com' - _(last_span.attributes['net.peer.port']).must_equal 8321 - end - - it 'traces pipelined commands' do - redis = redis_with_auth - redis.pipelined do |r| - r.set('v1', '0') - r.incr('v1') - r.get('v1') - end - - _(exporter.finished_spans.size).must_equal 2 - _(last_span.name).must_equal 'PIPELINED' - _(last_span.attributes['db.system']).must_equal 'redis' - _(last_span.attributes['db.statement']).must_equal "SET v1 0\nINCR v1\nGET v1" - _(last_span.attributes['net.peer.name']).must_equal redis_host - _(last_span.attributes['net.peer.port']).must_equal redis_port - end - - it 'traces pipelined commands on commit' do - redis = redis_with_auth - redis.queue([:set, 'v1', '0']) - redis.queue([:incr, 'v1']) - redis.queue([:get, 'v1']) - redis.commit - - _(exporter.finished_spans.size).must_equal 2 - _(last_span.name).must_equal 'PIPELINED' - _(last_span.attributes['db.system']).must_equal 'redis' - _(last_span.attributes['db.statement']).must_equal "SET v1 0\nINCR v1\nGET v1" - _(last_span.attributes['net.peer.name']).must_equal redis_host - _(last_span.attributes['net.peer.port']).must_equal redis_port - end - - it 'records floats' do - redis = redis_with_auth - redis.hmset('hash', 'f1', 1_234_567_890.0987654321) - - _(last_span.name).must_equal 'HMSET' - _(last_span.attributes['db.statement']).must_equal 'HMSET hash f1 1234567890.0987654' - end - - it 'records nil' do - redis = redis_with_auth - redis.set('K', nil) - - _(last_span.name).must_equal 'SET' - _(last_span.attributes['db.statement']).must_equal 'SET K ' - end - - it 'records empty string' do - redis = redis_with_auth - redis.set('K', '') - - _(last_span.name).must_equal 'SET' - _(last_span.attributes['db.statement']).must_equal 'SET K ' - end - - it 'truncates long db.statements' do - redis = redis_with_auth - the_long_value = 'y' * 100 - redis.queue([:set, 'v1', the_long_value]) - redis.queue([:set, 'v1', the_long_value]) - redis.queue([:set, 'v1', the_long_value]) - redis.queue([:set, 'v1', the_long_value]) - redis.queue([:set, 'v1', the_long_value]) - redis.queue([:set, 'v1', the_long_value]) - redis.queue([:set, 'v1', the_long_value]) - redis.queue([:set, 'v1', the_long_value]) - redis.queue([:set, 'v1', the_long_value]) - redis.commit - - expected_db_statement = <<~HEREDOC.chomp - SET v1 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy - SET v1 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy - SET v1 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy - SET v1 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy - SET v1 yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy... - HEREDOC - - _(last_span.name).must_equal 'PIPELINED' - _(last_span.attributes['db.statement'].size).must_equal 500 - _(last_span.attributes['db.statement']).must_equal expected_db_statement - end - - it 'encodes invalid byte sequences for db.statement' do - redis = redis_with_auth - - # \255 is off-limits https://en.wikipedia.org/wiki/UTF-8#Codepage_layout - redis.set('K', "x\255") - - _(last_span.name).must_equal 'SET' - _(last_span.attributes['db.statement']).must_equal 'SET K x' - end - - describe 'when trace_root_spans is disabled' do - before do - instrumentation.instance_variable_set(:@installed, false) - instrumentation.install(trace_root_spans: false) - end - - it 'traces redis spans with a parent' do - redis = redis_with_auth - OpenTelemetry.tracer_provider.tracer('tester').in_span('a root!') do - redis.set('a', 'b') - end - - redis_span = exporter.finished_spans.find { |s| s.name == 'SET' } - _(redis_span.name).must_equal 'SET' - _(redis_span.attributes['db.statement']).must_equal 'SET ? ?' - end - - it 'does not trace redis spans without a parent' do - redis = redis_with_auth - redis.set('a', 'b') - - _(exporter.finished_spans.size).must_equal 0 - end - end - - describe 'when db_statement is :omit' do - before do - instrumentation.instance_variable_set(:@installed, false) - instrumentation.install(db_statement: :omit) - end - - it 'omits db.statement attribute' do - redis = redis_with_auth - _(redis.set('K', 'xyz')).must_equal 'OK' - _(redis.get('K')).must_equal 'xyz' - _(exporter.finished_spans.size).must_equal 3 - - set_span = exporter.finished_spans[0] - _(set_span.name).must_equal 'AUTH' - _(set_span.attributes['db.system']).must_equal 'redis' - _(set_span.attributes).wont_include('db.statement') - - set_span = exporter.finished_spans[1] - _(set_span.name).must_equal 'SET' - _(set_span.attributes['db.system']).must_equal 'redis' - _(set_span.attributes).wont_include('db.statement') - - set_span = exporter.finished_spans[2] - _(set_span.name).must_equal 'GET' - _(set_span.attributes['db.system']).must_equal 'redis' - _(set_span.attributes).wont_include('db.statement') - end - end - - describe 'when db_statement is :obfuscate' do - before do - instrumentation.instance_variable_set(:@installed, false) - instrumentation.install(db_statement: :obfuscate) - end - - it 'obfuscates arguments in db.statement' do - redis = redis_with_auth - _(redis.set('K', 'xyz')).must_equal 'OK' - _(redis.get('K')).must_equal 'xyz' - _(exporter.finished_spans.size).must_equal 3 - - set_span = exporter.finished_spans[0] - _(set_span.name).must_equal 'AUTH' - _(set_span.attributes['db.system']).must_equal 'redis' - _(set_span.attributes['db.statement']).must_equal( - 'AUTH ?' - ) - - set_span = exporter.finished_spans[1] - _(set_span.name).must_equal 'SET' - _(set_span.attributes['db.system']).must_equal 'redis' - _(set_span.attributes['db.statement']).must_equal( - 'SET ? ?' - ) - - set_span = exporter.finished_spans[2] - _(set_span.name).must_equal 'GET' - _(set_span.attributes['db.system']).must_equal 'redis' - _(set_span.attributes['db.statement']).must_equal( - 'GET ?' - ) - end - end - end -end unless ENV['OMIT_SERVICES'] diff --git a/instrumentation/redis/test/opentelemetry/instrumentation/redis_test.rb b/instrumentation/redis/test/opentelemetry/instrumentation/redis_test.rb deleted file mode 100644 index 58548b083e..0000000000 --- a/instrumentation/redis/test/opentelemetry/instrumentation/redis_test.rb +++ /dev/null @@ -1,101 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -describe OpenTelemetry::Instrumentation::Redis do - let(:redis) { OpenTelemetry::Instrumentation::Redis } - - describe '#attributes' do - let(:attributes) { { 'foo' => 'bar' } } - - it 'returns an empty hash by default' do - _(redis.attributes).must_equal({}) - end - - it 'returns the current attributes hash' do - redis.with_attributes(attributes) do - _(redis.attributes).must_equal(attributes) - end - end - - it 'returns the current attributes hash from the provided context' do - context = redis.context_with_attributes(attributes, parent_context: OpenTelemetry::Context.empty) - _(redis.attributes).wont_equal(attributes) - _(redis.attributes(context)).must_equal(attributes) - end - end - - describe '#with_attributes' do - it 'yields the passed in attributes' do - redis.with_attributes('foo' => 'bar') do |attributes| - _(attributes).must_equal('foo' => 'bar') - end - end - - it 'yields context containing attributes' do - redis.with_attributes('foo' => 'bar') do |attributes, context| - _(context).must_equal(OpenTelemetry::Context.current) - _(redis.attributes).must_equal(attributes) - end - end - - it 'should reactivate the attributes after the block' do - redis.with_attributes('foo' => 'bar') do - _(redis.attributes).must_equal('foo' => 'bar') - - redis.with_attributes('foo' => 'baz') do - _(redis.attributes).must_equal('foo' => 'baz') - end - - _(redis.attributes).must_equal('foo' => 'bar') - end - end - - it 'should merge attributes' do - redis.with_attributes( - 'a' => '1', - 'c' => '2' - ) do - _(redis.attributes).must_equal( - 'a' => '1', - 'c' => '2' - ) - - redis.with_attributes( - 'a' => '0', - 'b' => '1' - ) do - _(redis.attributes).must_equal( - 'a' => '0', - 'b' => '1', - 'c' => '2' - ) - end - - _(redis.attributes).must_equal( - 'a' => '1', - 'c' => '2' - ) - end - end - end - - describe '#context_with_attributes' do - it 'returns a context containing attributes' do - attrs = { 'foo' => 'bar' } - ctx = redis.context_with_attributes(attrs) - _(redis.attributes(ctx)).must_equal(attrs) - end - - it 'returns a context containing attributes' do - parent_ctx = OpenTelemetry::Context.empty.set_value('foo', 'bar') - ctx = redis.context_with_attributes({ 'bar' => 'baz' }, parent_context: parent_ctx) - _(redis.attributes(ctx)).must_equal('bar' => 'baz') - _(ctx.value('foo')).must_equal('bar') - end - end -end diff --git a/instrumentation/redis/test/redis.conf b/instrumentation/redis/test/redis.conf deleted file mode 100644 index 83f8fb5d67..0000000000 --- a/instrumentation/redis/test/redis.conf +++ /dev/null @@ -1,6 +0,0 @@ -bind 127.0.0.1 -requirepass passw0rd -databases 16 -appendonly no -save "" -port 16379 diff --git a/instrumentation/redis/test/test_helper.rb b/instrumentation/redis/test/test_helper.rb deleted file mode 100644 index b05a55ba7c..0000000000 --- a/instrumentation/redis/test/test_helper.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'redis' - -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' - -require 'minitest/autorun' - -ENV['TEST_REDIS_HOST'] ||= '127.0.0.1' -ENV['TEST_REDIS_PORT'] ||= '16379' - -# global opentelemetry-sdk setup: -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry::SDK.configure do |c| - c.add_span_processor span_processor -end diff --git a/instrumentation/resque/.rubocop.yml b/instrumentation/resque/.rubocop.yml deleted file mode 100644 index cb9316d9bb..0000000000 --- a/instrumentation/resque/.rubocop.yml +++ /dev/null @@ -1,5 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-resque.rb" diff --git a/instrumentation/resque/.yardopts b/instrumentation/resque/.yardopts deleted file mode 100644 index d72ec275da..0000000000 --- a/instrumentation/resque/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Resque Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/resque/Appraisals b/instrumentation/resque/Appraisals deleted file mode 100644 index 363843531e..0000000000 --- a/instrumentation/resque/Appraisals +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -appraise 'resque-2.0' do - gem 'resque', '~> 2.0.0' -end - -appraise 'resque-1.27' do - gem 'resque', '~> 1.27.0' - gem 'redis', '3.3.5' -end diff --git a/instrumentation/resque/CHANGELOG.md b/instrumentation/resque/CHANGELOG.md deleted file mode 100644 index fab3c88f1e..0000000000 --- a/instrumentation/resque/CHANGELOG.md +++ /dev/null @@ -1,26 +0,0 @@ -# Release History: opentelemetry-instrumentation-resque - -### v0.3.0 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Broken test file requirements - -### v0.2.0 / 2022-05-02 - -* ADDED: Validate Using Enums - -### v0.1.3 / 2021-12-02 - -* (No significant changes) - -### v0.1.2 / 2021-09-29 - -* (No significant changes) - -### v0.1.1 / 2021-08-12 - -* (No significant changes) - -### v0.1.0 / 2021-06-23 - -* Initial release. diff --git a/instrumentation/resque/Gemfile b/instrumentation/resque/Gemfile deleted file mode 100644 index a340f69a9b..0000000000 --- a/instrumentation/resque/Gemfile +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :test do - gem 'activejob' - gem 'opentelemetry-instrumentation-base', path: '../base' - gem 'pry-byebug' -end diff --git a/instrumentation/resque/LICENSE b/instrumentation/resque/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/resque/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/resque/README.md b/instrumentation/resque/README.md deleted file mode 100644 index 3d9d124fb3..0000000000 --- a/instrumentation/resque/README.md +++ /dev/null @@ -1,53 +0,0 @@ -# OpenTelemetry Resque Instrumentation - -The Resque instrumentation is a community-maintained instrumentation for the [Resque][resque-home] Ruby jobs system. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-resque -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-resque` in your `Gemfile`. - -## Usage - -To use the instrumentation, call `use` with the name of the instrumentation: - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Resque' -end -``` - -Alternatively, you can also call `use_all` to install all the available instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` - -## Examples - -Example usage can be seen in the `./example/trace_demonstration.rb` file [here](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/instrumentation/resque/example/trace_demonstration.rb) - -## How can I get involved? - -The `opentelemetry-instrumentation-resque` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -The `opentelemetry-instrumentation-resque` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information. - -[resque-home]: https://github.com/resque/resque -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/instrumentation/resque/Rakefile b/instrumentation/resque/Rakefile deleted file mode 100644 index 413184dd02..0000000000 --- a/instrumentation/resque/Rakefile +++ /dev/null @@ -1,35 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -task :start_redis do - @redis_pid = fork { exec 'redis-server test/redis.conf' } -end - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] - at_exit do - Process.kill('USR1', @redis_pid) if @redis_pid - end -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/resque/example/trace_demonstration.rb b/instrumentation/resque/example/trace_demonstration.rb deleted file mode 100644 index 1895a44250..0000000000 --- a/instrumentation/resque/example/trace_demonstration.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -require 'bundler/inline' - -gemfile(true) do - source 'https://rubygems.org' - gem 'opentelemetry-api' - gem 'opentelemetry-instrumentation-base' - gem 'opentelemetry-instrumentation-resque' - gem 'opentelemetry-sdk' - gem 'resque' -end - -require 'opentelemetry-api' -require 'opentelemetry-sdk' -require 'opentelemetry-instrumentation-resque' -require 'resque' - -# Export traces to console by default -ENV['OTEL_TRACES_EXPORTER'] ||= 'console' - -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Resque' -end - -# A basic Sidekiq job worker example -class SimpleJob - @queue = :demo - - def self.perform(*args) - puts "Workin'" - end -end - -Resque.enqueue(SimpleJob) - -Resque.reserve(:demo).perform diff --git a/instrumentation/resque/lib/opentelemetry-instrumentation-resque.rb b/instrumentation/resque/lib/opentelemetry-instrumentation-resque.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/resque/lib/opentelemetry-instrumentation-resque.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/resque/lib/opentelemetry/instrumentation.rb b/instrumentation/resque/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index be3432f278..0000000000 --- a/instrumentation/resque/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/resque' diff --git a/instrumentation/resque/lib/opentelemetry/instrumentation/resque.rb b/instrumentation/resque/lib/opentelemetry/instrumentation/resque.rb deleted file mode 100644 index fc54020adc..0000000000 --- a/instrumentation/resque/lib/opentelemetry/instrumentation/resque.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the Resque gem - module Resque - end - end -end - -require_relative './resque/instrumentation' -require_relative './resque/version' diff --git a/instrumentation/resque/lib/opentelemetry/instrumentation/resque/instrumentation.rb b/instrumentation/resque/lib/opentelemetry/instrumentation/resque/instrumentation.rb deleted file mode 100644 index 60684570af..0000000000 --- a/instrumentation/resque/lib/opentelemetry/instrumentation/resque/instrumentation.rb +++ /dev/null @@ -1,38 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Resque - # The Instrumentation class contains logic to detect and install the Resque instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - install do |_config| - require_dependencies - patch - end - - present do - defined?(::Resque) - end - - option :span_naming, default: :queue, validate: %I[job_class queue] - option :propagation_style, default: :link, validate: %i[link child none] - - private - - def patch - ::Resque.prepend(Patches::ResqueModule) - ::Resque::Job.prepend(Patches::ResqueJob) - end - - def require_dependencies - require_relative 'patches/resque_module' - require_relative 'patches/resque_job' - end - end - end - end -end diff --git a/instrumentation/resque/lib/opentelemetry/instrumentation/resque/patches/resque_job.rb b/instrumentation/resque/lib/opentelemetry/instrumentation/resque/patches/resque_job.rb deleted file mode 100644 index eab7569fee..0000000000 --- a/instrumentation/resque/lib/opentelemetry/instrumentation/resque/patches/resque_job.rb +++ /dev/null @@ -1,72 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Resque - module Patches - # Module to prepend to Resque::Job for instrumentation - module ResqueJob - def perform # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity - job_args = args || [] - - # Check if the job is being wrapped by ActiveJob - # before retrieving the job class name - job_class = if payload_class_name == 'ActiveJob::QueueAdapters::ResqueAdapter::JobWrapper' && job_args[0]&.is_a?(Hash) - job_args[0]['job_class'] - else - payload_class_name - end - - attributes = { - 'messaging.system' => 'resque', - 'messaging.destination' => queue.to_s, - 'messaging.destination_kind' => 'queue', - 'messaging.resque.job_class' => job_class - } - - span_name = case config[:span_naming] - when :job_class then "#{job_class} process" - else "#{queue} process" - end - - extracted_context = OpenTelemetry.propagation.extract(@payload) - - OpenTelemetry::Context.with_current(extracted_context) do - if config[:propagation_style] == :child - tracer.in_span(span_name, attributes: attributes, kind: :consumer) { super } - else - links = [] - span_context = OpenTelemetry::Trace.current_span(extracted_context).context - links << OpenTelemetry::Trace::Link.new(span_context) if config[:propagation_style] == :link && span_context.valid? - span = tracer.start_root_span(span_name, attributes: attributes, links: links, kind: :consumer) - OpenTelemetry::Trace.with_span(span) do - super - rescue Exception => e # rubocop:disable Lint/RescueException - span.record_exception(e) - span.status = OpenTelemetry::Trace::Status.error("Unhandled exception of type: #{e.class}") - raise e - ensure - span.finish - end - end - end - end - - private - - def tracer - Resque::Instrumentation.instance.tracer - end - - def config - Resque::Instrumentation.instance.config - end - end - end - end - end -end diff --git a/instrumentation/resque/lib/opentelemetry/instrumentation/resque/patches/resque_module.rb b/instrumentation/resque/lib/opentelemetry/instrumentation/resque/patches/resque_module.rb deleted file mode 100644 index d5884c5898..0000000000 --- a/instrumentation/resque/lib/opentelemetry/instrumentation/resque/patches/resque_module.rb +++ /dev/null @@ -1,60 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Resque - module Patches - # Module to prepend to Resque for instrumentation - module ResqueModule - def self.prepended(base) - class << base - prepend ClassMethods - end - end - - # Module to prepend to Resque singleton class - module ClassMethods - def push(queue, item) - # Check if the job is being wrapped by ActiveJob - # before retrieving the job class name - job_class = if item[:class] == 'ActiveJob::QueueAdapters::ResqueAdapter::JobWrapper' && item[:args][0]&.is_a?(Hash) - item[:args][0]['job_class'] - else - item[:class] - end - - attributes = { - 'messaging.system' => 'resque', - 'messaging.destination' => queue.to_s, - 'messaging.destination_kind' => 'queue', - 'messaging.resque.job_class' => job_class - } - - span_name = case config[:span_naming] - when :job_class then "#{job_class} send" - else "#{queue} send" - end - - tracer.in_span(span_name, attributes: attributes, kind: :producer) do - OpenTelemetry.propagation.inject(item) - super - end - end - - def tracer - Resque::Instrumentation.instance.tracer - end - - def config - Resque::Instrumentation.instance.config - end - end - end - end - end - end -end diff --git a/instrumentation/resque/lib/opentelemetry/instrumentation/resque/version.rb b/instrumentation/resque/lib/opentelemetry/instrumentation/resque/version.rb deleted file mode 100644 index 6a253e48a4..0000000000 --- a/instrumentation/resque/lib/opentelemetry/instrumentation/resque/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Resque - VERSION = '0.3.0' - end - end -end diff --git a/instrumentation/resque/opentelemetry-instrumentation-resque.gemspec b/instrumentation/resque/opentelemetry-instrumentation-resque.gemspec deleted file mode 100644 index e89b0ba2fd..0000000000 --- a/instrumentation/resque/opentelemetry-instrumentation-resque.gemspec +++ /dev/null @@ -1,50 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/resque/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-resque' - spec.version = OpenTelemetry::Instrumentation::Resque::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'Resque instrumentation for the OpenTelemetry framework' - spec.description = 'Resque instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.21.0' - - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'rake', '~> 12.3.3' - spec.add_development_dependency 'resque' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'webmock', '~> 3.7.6' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-resque/v#{OpenTelemetry::Instrumentation::Resque::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/resque' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-resque/v#{OpenTelemetry::Instrumentation::Resque::VERSION}" - end -end diff --git a/instrumentation/resque/test/.rubocop.yml b/instrumentation/resque/test/.rubocop.yml deleted file mode 100644 index e97eda560f..0000000000 --- a/instrumentation/resque/test/.rubocop.yml +++ /dev/null @@ -1,6 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false -Style/MultilineIfModifier: - Enabled: false diff --git a/instrumentation/resque/test/opentelemetry/instrumentation/resque/instrumentation_test.rb b/instrumentation/resque/test/opentelemetry/instrumentation/resque/instrumentation_test.rb deleted file mode 100644 index 4d7b6a218a..0000000000 --- a/instrumentation/resque/test/opentelemetry/instrumentation/resque/instrumentation_test.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../lib/opentelemetry/instrumentation/resque' - -describe OpenTelemetry::Instrumentation::Resque::Instrumentation do - let(:instrumentation) { OpenTelemetry::Instrumentation::Resque::Instrumentation.instance } - - it 'has #name' do - _(instrumentation.name).must_equal 'OpenTelemetry::Instrumentation::Resque' - end - - it 'has #version' do - _(instrumentation.version).wont_be_nil - _(instrumentation.version).wont_be_empty - end - - describe '#install' do - it 'accepts argument' do - _(instrumentation.install({})).must_equal(true) - instrumentation.instance_variable_set(:@installed, false) - end - end -end diff --git a/instrumentation/resque/test/opentelemetry/instrumentation/resque/patches/resque_job_test.rb b/instrumentation/resque/test/opentelemetry/instrumentation/resque/patches/resque_job_test.rb deleted file mode 100644 index fe2385955e..0000000000 --- a/instrumentation/resque/test/opentelemetry/instrumentation/resque/patches/resque_job_test.rb +++ /dev/null @@ -1,195 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../../lib/opentelemetry/instrumentation/resque' -require_relative '../../../../../lib/opentelemetry/instrumentation/resque/patches/resque_job' - -describe OpenTelemetry::Instrumentation::Resque::Patches::ResqueJob do - let(:instrumentation) { OpenTelemetry::Instrumentation::Resque::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:finished_spans) { exporter.finished_spans } - let(:job_span) { finished_spans.last } - let(:config) { {} } - - before do - instrumentation.install(config) - exporter.reset - end - - after { instrumentation.instance_variable_set(:@installed, false) } - - describe '#perform' do - it 'traces' do - ::Resque.enqueue(DummyJob) - work_off_jobs - - _(job_span.name).must_equal('super_urgent process') - _(job_span.attributes['messaging.system']).must_equal('resque') - _(job_span.attributes['messaging.resque.job_class']).must_equal('DummyJob') - _(job_span.attributes['messaging.destination']).must_equal('super_urgent') - _(job_span.attributes['messaging.destination_kind']).must_equal('queue') - end - - it 'traces when enqueued with Active Job' do - DummyJobWithActiveJob.perform_later(1, 2) - work_off_jobs - - _(job_span.name).must_equal('super_urgent process') - _(job_span.attributes['messaging.system']).must_equal('resque') - _(job_span.attributes['messaging.resque.job_class']).must_equal('DummyJobWithActiveJob') - _(job_span.attributes['messaging.destination']).must_equal('super_urgent') - _(job_span.attributes['messaging.destination_kind']).must_equal('queue') - end - - it 'defaults to using links to the enqueing span but does not continue the trace' do - ::Resque.enqueue(DummyJob) - work_off_jobs - - enqueuer_span = finished_spans.first - _(job_span.links.first.span_context.span_id).must_equal(enqueuer_span.span_id) - _(job_span.links.first.span_context.trace_id).must_equal(enqueuer_span.trace_id) - - _(job_span.parent_span_id).wont_equal(enqueuer_span.span_id) - _(job_span.trace_id).wont_equal(enqueuer_span.trace_id) - end - - describe 'when span_naming is job_class' do - let(:config) { { span_naming: :job_class } } - - it 'uses the job class name for the span name' do - ::Resque.enqueue(DummyJob) - work_off_jobs - - _(job_span.name).must_equal('DummyJob process') - end - - it 'uses the job class name when enqueued with Active Job' do - DummyJobWithActiveJob.perform_later(1, 2) - work_off_jobs - - _(job_span.name).must_equal('DummyJobWithActiveJob process') - end - end - - describe 'when propagation_style is link' do - let(:config) { { propagation_style: :link } } - - it 'continues the enqueuer trace to the job process' do - ::Resque.enqueue(DummyJob) - work_off_jobs - - enqueuer_span = finished_spans.first - _(job_span.links.first.span_context.span_id).must_equal(enqueuer_span.span_id) - _(job_span.links.first.span_context.trace_id).must_equal(enqueuer_span.trace_id) - - enqueuer_span = finished_spans.first - - _(job_span.parent_span_id).wont_equal(enqueuer_span.span_id) - _(job_span.trace_id).wont_equal(enqueuer_span.trace_id) - end - - it 'propagates baggage' do - ctx = OpenTelemetry::Baggage.set_value('testing_baggage', 'it_worked') - OpenTelemetry::Context.with_current(ctx) do - ::Resque.enqueue(BaggageTestingJob) - end - - work_off_jobs - - _(job_span.attributes['success']).must_equal(true) - end - - it 'records exceptions' do - ::Resque.enqueue(ExceptionTestingJob) - _(-> { work_off_jobs }).must_raise(RuntimeError) - - ev = job_span.events - _(ev[0].attributes['exception.type']).must_equal('RuntimeError') - _(ev[0].attributes['exception.message']).must_equal('a little hell') - _(ev[0].attributes['exception.stacktrace']).wont_be_nil - end - end - - describe 'when propagation_style is child' do - let(:config) { { propagation_style: :child } } - - it 'continues the enqueuer trace to the job process' do - ::Resque.enqueue(DummyJob) - work_off_jobs - - enqueuer_span = finished_spans.first - _(job_span.parent_span_id).must_equal(enqueuer_span.span_id) - _(job_span.trace_id).must_equal(enqueuer_span.trace_id) - end - - it 'propagates baggage' do - ctx = OpenTelemetry::Baggage.set_value('testing_baggage', 'it_worked') - OpenTelemetry::Context.with_current(ctx) do - ::Resque.enqueue(BaggageTestingJob) - end - - work_off_jobs - - _(job_span.attributes['success']).must_equal(true) - end - - it 'records exceptions' do - ::Resque.enqueue(ExceptionTestingJob) - _(-> { work_off_jobs }).must_raise(RuntimeError) - - ev = job_span.events - _(ev[0].attributes['exception.type']).must_equal('RuntimeError') - _(ev[0].attributes['exception.message']).must_equal('a little hell') - _(ev[0].attributes['exception.stacktrace']).wont_be_nil - end - end - - describe 'when propagation_style is none' do - let(:config) { { propagation_style: :none } } - - it 'continues the enqueuer trace to the job process' do - ::Resque.enqueue(DummyJob) - work_off_jobs - - enqueuer_span = finished_spans.first - - _(job_span.parent_span_id).wont_equal(enqueuer_span.span_id) - _(job_span.trace_id).wont_equal(enqueuer_span.trace_id) - end - - it 'propagates baggage' do - ctx = OpenTelemetry::Baggage.set_value('testing_baggage', 'it_worked') - OpenTelemetry::Context.with_current(ctx) do - ::Resque.enqueue(BaggageTestingJob) - end - - work_off_jobs - - _(job_span.attributes['success']).must_equal(true) - end - - it 'records exceptions' do - ::Resque.enqueue(ExceptionTestingJob) - _(-> { work_off_jobs }).must_raise(RuntimeError) - - ev = job_span.events - _(ev[0].attributes['exception.type']).must_equal('RuntimeError') - _(ev[0].attributes['exception.message']).must_equal('a little hell') - _(ev[0].attributes['exception.stacktrace']).wont_be_nil - end - end - end unless ENV['OMIT_SERVICES'] - - private - - def work_off_jobs - while (job = ::Resque.reserve(:super_urgent)) - job.perform - end - end -end diff --git a/instrumentation/resque/test/opentelemetry/instrumentation/resque/patches/resque_test.rb b/instrumentation/resque/test/opentelemetry/instrumentation/resque/patches/resque_test.rb deleted file mode 100644 index 12aa67ee30..0000000000 --- a/instrumentation/resque/test/opentelemetry/instrumentation/resque/patches/resque_test.rb +++ /dev/null @@ -1,60 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../../lib/opentelemetry/instrumentation/resque' -require_relative '../../../../../lib/opentelemetry/instrumentation/resque/patches/resque_module' - -describe OpenTelemetry::Instrumentation::Resque::Patches::ResqueModule do - let(:instrumentation) { OpenTelemetry::Instrumentation::Resque::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:enqueue_span) { exporter.finished_spans.first } - let(:config) { {} } - - before do - instrumentation.install(config) - exporter.reset - end - - after { instrumentation.instance_variable_set(:@installed, false) } - - describe '#enqueue' do - it 'traces' do - ::Resque.enqueue(DummyJob) - - _(enqueue_span.name).must_equal('super_urgent send') - _(enqueue_span.attributes['messaging.system']).must_equal('resque') - _(enqueue_span.attributes['messaging.resque.job_class']).must_equal('DummyJob') - _(enqueue_span.attributes['messaging.destination']).must_equal('super_urgent') - _(enqueue_span.attributes['messaging.destination_kind']).must_equal('queue') - end - - it 'traces when enqueued with Active Job' do - DummyJobWithActiveJob.perform_later(1, 2) - _(enqueue_span.name).must_equal('super_urgent send') - _(enqueue_span.attributes['messaging.system']).must_equal('resque') - _(enqueue_span.attributes['messaging.resque.job_class']).must_equal('DummyJobWithActiveJob') - _(enqueue_span.attributes['messaging.destination']).must_equal('super_urgent') - _(enqueue_span.attributes['messaging.destination_kind']).must_equal('queue') - end - - describe 'when span_naming is job_class' do - let(:config) { { span_naming: :job_class } } - - it 'uses the job class name for the span name' do - ::Resque.enqueue(DummyJob) - - _(enqueue_span.name).must_equal('DummyJob send') - end - - it 'uses the job class name when enqueued with Active Job' do - DummyJobWithActiveJob.perform_later(1, 2) - _(enqueue_span.name).must_equal('DummyJobWithActiveJob send') - end - end - end -end unless ENV['OMIT_SERVICES'] diff --git a/instrumentation/resque/test/redis.conf b/instrumentation/resque/test/redis.conf deleted file mode 100644 index 83f8fb5d67..0000000000 --- a/instrumentation/resque/test/redis.conf +++ /dev/null @@ -1,6 +0,0 @@ -bind 127.0.0.1 -requirepass passw0rd -databases 16 -appendonly no -save "" -port 16379 diff --git a/instrumentation/resque/test/test_helper.rb b/instrumentation/resque/test/test_helper.rb deleted file mode 100644 index ef221e1cc3..0000000000 --- a/instrumentation/resque/test/test_helper.rb +++ /dev/null @@ -1,59 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'resque' -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' - -require 'pry' -require 'minitest/autorun' -require 'webmock/minitest' -require 'active_job' - -# global opentelemetry-sdk setup: -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry::SDK.configure do |c| - c.add_span_processor span_processor -end - -ActiveJob::Base.logger = Logger.new('/dev/null') - -redis_options = {} -redis_options[:password] = ENV['TEST_REDIS_PASSWORD'] || 'passw0rd' -redis_options[:host] = ENV['TEST_REDIS_HOST'] || '127.0.0.1' -redis_options[:port] = ENV['TEST_REDIS_PORT'] || '16379' -Resque.redis = redis_options - -class DummyJob - @queue = :super_urgent - - def self.perform(*args); end -end - -class DummyJobWithActiveJob < ActiveJob::Base - self.queue_adapter = :resque - queue_as :super_urgent - - def perform(*args); end -end - -class BaggageTestingJob - @queue = :super_urgent - - def self.perform(*args) - OpenTelemetry::Trace.current_span['success'] = true if OpenTelemetry::Baggage.value('testing_baggage') == 'it_worked' - end -end - -class ExceptionTestingJob - @queue = :super_urgent - - def self.perform(*args) - raise 'a little hell' - end -end diff --git a/instrumentation/restclient/.rubocop.yml b/instrumentation/restclient/.rubocop.yml deleted file mode 100644 index 5c1795a8c8..0000000000 --- a/instrumentation/restclient/.rubocop.yml +++ /dev/null @@ -1,5 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-restclient.rb" diff --git a/instrumentation/restclient/.yardopts b/instrumentation/restclient/.yardopts deleted file mode 100644 index eace6145e6..0000000000 --- a/instrumentation/restclient/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry RestClient Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/restclient/Appraisals b/instrumentation/restclient/Appraisals deleted file mode 100644 index 5a7c3ae064..0000000000 --- a/instrumentation/restclient/Appraisals +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -appraise 'rest-client-2.1' do - gem 'rest-client', '~> 2.1.0' -end - -appraise 'rest-client-2.0' do - gem 'rest-client', '~> 2.0.0' -end diff --git a/instrumentation/restclient/CHANGELOG.md b/instrumentation/restclient/CHANGELOG.md deleted file mode 100644 index c9239b4933..0000000000 --- a/instrumentation/restclient/CHANGELOG.md +++ /dev/null @@ -1,90 +0,0 @@ -# Release History: opentelemetry-instrumentation-restclient - -### v0.20.0 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Broken test file requirements - -### v0.19.4 / 2022-05-02 - -* FIXED: Restclient invalid span attribute type Symbol - -### v0.19.3 / 2021-12-02 - -* (No significant changes) - -### v0.19.2 / 2021-09-29 - -* (No significant changes) - -### v0.19.1 / 2021-08-12 - -* DOCS: Update docs to rely more on environment variable configuration - -### v0.19.0 / 2021-06-23 - -* BREAKING CHANGE: Total order constraint on span.status= - -* FIXED: Total order constraint on span.status= - -### v0.18.0 / 2021-05-21 - -* ADDED: Updated API depedency for 1.0.0.rc1 -* FIXED: Removed http.status_text attribute #750 - -### v0.17.0 / 2021-04-22 - -* ADDED: RestClient instrumentation accepts peer service config attribute. -* FIXED: Refactor propagators to add #fields - -### v0.16.0 / 2021-03-17 - -* FIXED: Remove passwords from http.url -* FIXED: Example scripts now reference local common lib -* DOCS: Replace Gitter with GitHub Discussions - -### v0.15.0 / 2021-02-18 - -* (No significant changes) - -### v0.14.0 / 2021-02-03 - -* BREAKING CHANGE: Replace getter and setter callables and remove rack specific propagators - -* ADDED: Replace getter and setter callables and remove rack specific propagators - -### v0.13.0 / 2021-01-29 - -* (No significant changes) - -### v0.12.0 / 2020-12-24 - -* (No significant changes) - -### v0.11.0 / 2020-12-11 - -* FIXED: Copyright comments to not reference year - -### v0.10.0 / 2020-12-03 - -* (No significant changes) - -### v0.9.0 / 2020-11-27 - -* BREAKING CHANGE: Add timeout for force_flush and shutdown - -* ADDED: Add timeout for force_flush and shutdown - -### v0.8.0 / 2020-10-27 - -* BREAKING CHANGE: Move context/span methods to Trace module - -* FIXED: Move context/span methods to Trace module - -### v0.7.0 / 2020-10-07 - -* DOCS: Standardize toplevel docs structure and readme - -### v0.6.0 / 2020-09-10 - -* (No significant changes) diff --git a/instrumentation/restclient/Gemfile b/instrumentation/restclient/Gemfile deleted file mode 100644 index 2baf57ac47..0000000000 --- a/instrumentation/restclient/Gemfile +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :test do - gem 'opentelemetry-instrumentation-base', path: '../base' -end diff --git a/instrumentation/restclient/LICENSE b/instrumentation/restclient/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/restclient/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/restclient/README.md b/instrumentation/restclient/README.md deleted file mode 100644 index 8df4be8368..0000000000 --- a/instrumentation/restclient/README.md +++ /dev/null @@ -1,49 +0,0 @@ -# OpenTelemetry RestClient Instrumentation - -The OpenTelemetry RestClient gem is a community maintained instrumentation for the [RestClient][restclient-home] library. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-restclient -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-restclient` in your `Gemfile`. - -## Usage - -To install the instrumentation, call `use` with the name of the instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::RestClient' -end -``` - -Alternatively, you can also call `use_all` to install all the available instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` - -## How can I get involved? - -The `opentelemetry-instrumentation-restclient` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -Apache 2.0 license. See [LICENSE][license-github] for more information. - -[restclient-home]: https://github.com/rest-client/rest-client -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/instrumentation/restclient/Rakefile b/instrumentation/restclient/Rakefile deleted file mode 100644 index 1a64ba842e..0000000000 --- a/instrumentation/restclient/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/restclient/example/Gemfile b/instrumentation/restclient/example/Gemfile deleted file mode 100644 index 13f2eb460f..0000000000 --- a/instrumentation/restclient/example/Gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -source 'https://rubygems.org' - -gem 'opentelemetry-api' -gem 'opentelemetry-common' -gem 'opentelemetry-instrumentation-restclient' -gem 'opentelemetry-sdk' -gem 'rest-client' diff --git a/instrumentation/restclient/example/restclient.rb b/instrumentation/restclient/example/restclient.rb deleted file mode 100644 index 625add69c6..0000000000 --- a/instrumentation/restclient/example/restclient.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -require 'rubygems' -require 'bundler/setup' - -Bundler.require - -ENV['OTEL_TRACES_EXPORTER'] = 'console' -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::RestClient' -end - -RestClient.get('http://example.com') diff --git a/instrumentation/restclient/lib/opentelemetry-instrumentation-restclient.rb b/instrumentation/restclient/lib/opentelemetry-instrumentation-restclient.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/restclient/lib/opentelemetry-instrumentation-restclient.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/restclient/lib/opentelemetry/instrumentation.rb b/instrumentation/restclient/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index c4ae2a8aa4..0000000000 --- a/instrumentation/restclient/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # "Instrumentation" are specified by - # https://github.com/open-telemetry/opentelemetry-specification/blob/784635d01d8690c8f5fcd1f55bdbc8a13cf2f4f2/specification/glossary.md#instrumentation-library - # - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/restclient' diff --git a/instrumentation/restclient/lib/opentelemetry/instrumentation/restclient.rb b/instrumentation/restclient/lib/opentelemetry/instrumentation/restclient.rb deleted file mode 100644 index 6abb7fe9cc..0000000000 --- a/instrumentation/restclient/lib/opentelemetry/instrumentation/restclient.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the RestClient gem - module RestClient - end - end -end - -require_relative './restclient/instrumentation' -require_relative './restclient/version' diff --git a/instrumentation/restclient/lib/opentelemetry/instrumentation/restclient/instrumentation.rb b/instrumentation/restclient/lib/opentelemetry/instrumentation/restclient/instrumentation.rb deleted file mode 100644 index 15d3c10ece..0000000000 --- a/instrumentation/restclient/lib/opentelemetry/instrumentation/restclient/instrumentation.rb +++ /dev/null @@ -1,36 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module RestClient - # The Instrumentation class contains logic to detect and install the RestClient - # instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - install do |_config| - require_dependencies - patch_request - end - - present do - defined?(::RestClient) - end - - option :peer_service, default: nil, validate: :string - - private - - def require_dependencies - require_relative 'patches/request' - end - - def patch_request - ::RestClient::Request.prepend(Patches::Request) - end - end - end - end -end diff --git a/instrumentation/restclient/lib/opentelemetry/instrumentation/restclient/patches/request.rb b/instrumentation/restclient/lib/opentelemetry/instrumentation/restclient/patches/request.rb deleted file mode 100644 index 3c647ac2cb..0000000000 --- a/instrumentation/restclient/lib/opentelemetry/instrumentation/restclient/patches/request.rb +++ /dev/null @@ -1,65 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module RestClient - module Patches - # Module to prepend to RestClient::Request for instrumentation - module Request - def execute(&block) - trace_request do |_span| - super(&block) - end - end - - private - - def trace_request # rubocop:disable Metrics/AbcSize, Metrics/MethodLength - http_method = method.upcase - instrumentation_attrs = { - 'http.method' => http_method.to_s, - 'http.url' => OpenTelemetry::Common::Utilities.cleanse_url(url) - } - config = RestClient::Instrumentation.instance.config - instrumentation_attrs['peer.service'] = config[:peer_service] if config[:peer_service] - span = tracer.start_span( - "HTTP #{http_method}", - attributes: instrumentation_attrs.merge( - OpenTelemetry::Common::HTTP::ClientContext.attributes - ), - kind: :client - ) - - OpenTelemetry::Trace.with_span(span) do - OpenTelemetry.propagation.inject(processed_headers) - end - - yield(span).tap do |response| - # Verify return value is a response. - # If so, add additional attributes. - if response.is_a?(::RestClient::Response) - span.set_attribute('http.status_code', response.code) - span.status = OpenTelemetry::Trace::Status.error unless (100..399).include?(response.code.to_i) - end - end - rescue ::RestClient::ExceptionWithResponse => e - span.set_attribute('http.status_code', e.http_code) - span.status = OpenTelemetry::Trace::Status.error unless (100..399).include?(e.http_code.to_i) - - raise e - ensure - span.finish - end - - def tracer - RestClient::Instrumentation.instance.tracer - end - end - end - end - end -end diff --git a/instrumentation/restclient/lib/opentelemetry/instrumentation/restclient/version.rb b/instrumentation/restclient/lib/opentelemetry/instrumentation/restclient/version.rb deleted file mode 100644 index 0d52702705..0000000000 --- a/instrumentation/restclient/lib/opentelemetry/instrumentation/restclient/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module RestClient - VERSION = '0.20.0' - end - end -end diff --git a/instrumentation/restclient/opentelemetry-instrumentation-restclient.gemspec b/instrumentation/restclient/opentelemetry-instrumentation-restclient.gemspec deleted file mode 100644 index c3b6228468..0000000000 --- a/instrumentation/restclient/opentelemetry-instrumentation-restclient.gemspec +++ /dev/null @@ -1,50 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/restclient/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-restclient' - spec.version = OpenTelemetry::Instrumentation::RestClient::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'REST Client instrumentation for the OpenTelemetry framework' - spec.description = 'REST Client instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-common', '~> 0.19.3' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.21.0' - - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'rest-client', '~> 2.1.0' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'webmock', '~> 3.7.6' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-restclient/v#{OpenTelemetry::Instrumentation::RestClient::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/restclient' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-restclient/v#{OpenTelemetry::Instrumentation::RestClient::VERSION}" - end -end diff --git a/instrumentation/restclient/test/.rubocop.yml b/instrumentation/restclient/test/.rubocop.yml deleted file mode 100644 index dd94258585..0000000000 --- a/instrumentation/restclient/test/.rubocop.yml +++ /dev/null @@ -1,4 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false diff --git a/instrumentation/restclient/test/opentelemetry/instrumentation/restclient/instrumentation_test.rb b/instrumentation/restclient/test/opentelemetry/instrumentation/restclient/instrumentation_test.rb deleted file mode 100644 index c04b12db7b..0000000000 --- a/instrumentation/restclient/test/opentelemetry/instrumentation/restclient/instrumentation_test.rb +++ /dev/null @@ -1,114 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../lib/opentelemetry/instrumentation/restclient' -require_relative '../../../../lib/opentelemetry/instrumentation/restclient/patches/request' - -describe OpenTelemetry::Instrumentation::RestClient::Instrumentation do - let(:instrumentation) { OpenTelemetry::Instrumentation::RestClient::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:span) { exporter.finished_spans.first } - - before do - exporter.reset - stub_request(:get, 'http://example.com/success').to_return(status: 200) - stub_request(:get, 'http://example.com/failure').to_return(status: 500) - - # this is currently a noop but this will future proof the test - @orig_propagation = OpenTelemetry.propagation - propagator = OpenTelemetry::Trace::Propagation::TraceContext.text_map_propagator - OpenTelemetry.propagation = propagator - end - - after do - # Force re-install of instrumentation - instrumentation.instance_variable_set(:@installed, false) - - OpenTelemetry.propagation = @orig_propagation - end - - describe 'tracing' do - before do - instrumentation.install - end - - it 'before request' do - _(exporter.finished_spans.size).must_equal 0 - end - - it 'after request with success code' do - ::RestClient.get('http://username:password@example.com/success') - - _(exporter.finished_spans.size).must_equal 1 - _(span.name).must_equal 'HTTP GET' - _(span.attributes['http.method']).must_equal 'GET' - _(span.attributes['http.status_code']).must_equal 200 - _(span.attributes['http.url']).must_equal 'http://example.com/success' - assert_requested( - :get, - 'http://example.com/success', - headers: { 'Traceparent' => "00-#{span.hex_trace_id}-#{span.hex_span_id}-01" } - ) - end - - it 'after request with failure code' do - expect do - ::RestClient.get('http://username:password@example.com/failure') - end.must_raise RestClient::InternalServerError - - _(exporter.finished_spans.size).must_equal 1 - _(span.name).must_equal 'HTTP GET' - _(span.attributes['http.method']).must_equal 'GET' - _(span.attributes['http.status_code']).must_equal 500 - _(span.attributes['http.url']).must_equal 'http://example.com/failure' - assert_requested( - :get, - 'http://example.com/failure', - headers: { 'Traceparent' => "00-#{span.hex_trace_id}-#{span.hex_span_id}-01" } - ) - end - - it 'merges HTTP client context' do - client_context_attrs = { - 'test.attribute' => 'test.value', 'http.method' => 'OVERRIDE' - } - OpenTelemetry::Common::HTTP::ClientContext.with_attributes(client_context_attrs) do - ::RestClient.get('http://username:password@example.com/success') - end - - _(span.attributes['http.method']).must_equal 'OVERRIDE' - _(span.attributes['test.attribute']).must_equal 'test.value' - _(span.attributes['http.url']).must_equal 'http://example.com/success' - end - - it 'accepts peer service name from config' do - instrumentation.instance_variable_set(:@installed, false) - instrumentation.install(peer_service: 'example:faraday') - - ::RestClient.get('http://example.com/success') - _(span.attributes['peer.service']).must_equal 'example:faraday' - end - - it 'prioritizes context attributes over config for peer service name' do - instrumentation.instance_variable_set(:@installed, false) - instrumentation.install(peer_service: 'example:faraday') - - client_context_attrs = { 'peer.service' => 'example:custom' } - OpenTelemetry::Common::HTTP::ClientContext.with_attributes(client_context_attrs) do - ::RestClient.get('http://example.com/success') - end - _(span.attributes['peer.service']).must_equal 'example:custom' - end - - it 'creates valid http method span attribute when method is a Symbol' do - ::RestClient::Request.execute(method: :get, url: 'http://username:password@example.com/success') - - _(span.attributes['http.method']).must_equal 'GET' - end - end -end diff --git a/instrumentation/restclient/test/test_helper.rb b/instrumentation/restclient/test/test_helper.rb deleted file mode 100644 index 257467c012..0000000000 --- a/instrumentation/restclient/test/test_helper.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'rest-client' - -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' - -require 'minitest/autorun' -require 'webmock/minitest' - -# global opentelemetry-sdk setup: -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry::SDK.configure do |c| - c.add_span_processor span_processor -end diff --git a/instrumentation/rspec/.rubocop.yml b/instrumentation/rspec/.rubocop.yml deleted file mode 100644 index 3c3bcd71e4..0000000000 --- a/instrumentation/rspec/.rubocop.yml +++ /dev/null @@ -1,5 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-rspec.rb" diff --git a/instrumentation/rspec/.yardopts b/instrumentation/rspec/.yardopts deleted file mode 100644 index e8f0e1eaff..0000000000 --- a/instrumentation/rspec/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Rspec Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/rspec/CHANGELOG.md b/instrumentation/rspec/CHANGELOG.md deleted file mode 100644 index 45be57056b..0000000000 --- a/instrumentation/rspec/CHANGELOG.md +++ /dev/null @@ -1,11 +0,0 @@ -# Release History: opentelemetry-instrumentation-rspec - -### v0.2.0 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Strip console codes from RSpec messages and better handle multiple failures -* FIXED: Broken test file requirements - -### v0.1.0 / 2021-12-01 - -* Initial release. diff --git a/instrumentation/rspec/Gemfile b/instrumentation/rspec/Gemfile deleted file mode 100644 index 2baf57ac47..0000000000 --- a/instrumentation/rspec/Gemfile +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :test do - gem 'opentelemetry-instrumentation-base', path: '../base' -end diff --git a/instrumentation/rspec/LICENSE b/instrumentation/rspec/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/rspec/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/rspec/README.md b/instrumentation/rspec/README.md deleted file mode 100644 index d3cd38f3ce..0000000000 --- a/instrumentation/rspec/README.md +++ /dev/null @@ -1,76 +0,0 @@ -# OpenTelemetry RSpec Instrumentation - -The RSpec instrumentation is a community-maintained instrumentation for the [RSpec][rspec-home] BDD testing framework. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-rspec -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-rspec` in your `Gemfile`. - -## Usage - -To use the instrumentation, call `use` with the name of the instrumentation: - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Rspec' -end -``` - -Alternatively, you can add it directly to RSpec as a customer formatter: - -```ruby -RSpec.configure do |config| - config.formatter = OpenTelemetry::Instrumentation::RSpec::Formatter -end -``` - -### Using multiple tracer providers - -By default the instrumentation will use the global tracer provider. - -If you want the instrumentation to use something other than the global tracer provider you can configure the instrumentation with a custom tracer provider using the `OpenTelemetry::Instrumentation::RSpec::Formatter` constructor: - -```ruby -exporter = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(exporter) -tracer_provider = OpenTelemetry::SDK::Trace::TracerProvider.new -tracer_provider.add_span_processor(span_processor) - -RSpec.configure do |config| - config.formatter = OpenTelemetry::Instrumentation::RSpec::Formatter.new(config.output_stream, tracer_provider) -end -``` - -If you need to test trace behaviour in your specs then you should be able to use a custom tracer provider and the instrumentation's output should not interfere with your specs. - -### Sampling - -To avoid spans from being dropped, which will mean you lose insight into your specs, you may want to set sampling to 'ALWAYS_ON'. The easiest way to do this is by setting the `OTEL_TRACES_SAMPLER` environment variable to `always_on`. - -## Examples - -Example usage can be seen in the `/example` directory [here](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/instrumentation/rspec/example) - -## How can I get involved? - -The `opentelemetry-instrumentation-rspec` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -The `opentelemetry-instrumentation-rspec` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information. - -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions -[rspec-home]: https://rspec.info diff --git a/instrumentation/rspec/Rakefile b/instrumentation/rspec/Rakefile deleted file mode 100644 index 1a64ba842e..0000000000 --- a/instrumentation/rspec/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/rspec/example/Gemfile b/instrumentation/rspec/example/Gemfile deleted file mode 100644 index 69be4857a9..0000000000 --- a/instrumentation/rspec/example/Gemfile +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -source 'https://rubygems.org' - -gem 'opentelemetry-api' -gem 'opentelemetry-common' -gem 'opentelemetry-instrumentation-concurrent_ruby' -gem 'opentelemetry-sdk' - -gem 'rspec' diff --git a/instrumentation/rspec/example/rspec_with_rspec_formatter_configuration.rb b/instrumentation/rspec/example/rspec_with_rspec_formatter_configuration.rb deleted file mode 100644 index 17b8f5be44..0000000000 --- a/instrumentation/rspec/example/rspec_with_rspec_formatter_configuration.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -require 'rubygems' -require 'bundler/setup' - -Bundler.require - -ENV['OTEL_TRACES_EXPORTER'] = 'console' -OpenTelemetry::SDK.configure - -require 'rspec/autorun' - -require_relative '../lib/opentelemetry/instrumentation/rspec/formatter' - -RSpec.configure do |config| - config.formatter = OpenTelemetry::Instrumentation::RSpec::Formatter -end - -RSpec.describe OpenTelemetry::Instrumentation::RSpec::Formatter do - describe 'when configured' do - it 'exports spans when configured as a formatter' do - tracer = OpenTelemetry.tracer_provider.tracer('default') - tracer.in_span('trace inside example') do - expect(true).to eql false - end - end - end -end diff --git a/instrumentation/rspec/example/rspec_with_sdk_configure.rb b/instrumentation/rspec/example/rspec_with_sdk_configure.rb deleted file mode 100644 index 6418765b0c..0000000000 --- a/instrumentation/rspec/example/rspec_with_sdk_configure.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -require 'rubygems' -require 'bundler/setup' - -Bundler.require - -require 'rspec/autorun' - -ENV['OTEL_TRACES_EXPORTER'] = 'console' -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::RSpec' -end - -require_relative '../lib/opentelemetry/instrumentation/rspec/formatter' - -RSpec.configure do |config| - config.formatter = OpenTelemetry::Instrumentation::RSpec::Formatter -end - -RSpec.describe OpenTelemetry::Instrumentation::RSpec::Formatter do - describe 'when configured' do - it 'exports spans when configured as a formatter' do - tracer = OpenTelemetry.tracer_provider.tracer('default') - tracer.in_span('trace inside example') do - expect(true).to eql false - end - end - end -end diff --git a/instrumentation/rspec/lib/opentelemetry-instrumentation-rspec.rb b/instrumentation/rspec/lib/opentelemetry-instrumentation-rspec.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/rspec/lib/opentelemetry-instrumentation-rspec.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/rspec/lib/opentelemetry/instrumentation.rb b/instrumentation/rspec/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index 7988cc7b8b..0000000000 --- a/instrumentation/rspec/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/rspec' diff --git a/instrumentation/rspec/lib/opentelemetry/instrumentation/rspec.rb b/instrumentation/rspec/lib/opentelemetry/instrumentation/rspec.rb deleted file mode 100644 index 55a5a5fa6d..0000000000 --- a/instrumentation/rspec/lib/opentelemetry/instrumentation/rspec.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the Rspec gem - module RSpec - end - end -end - -require_relative './rspec/instrumentation' -require_relative './rspec/version' diff --git a/instrumentation/rspec/lib/opentelemetry/instrumentation/rspec/formatter.rb b/instrumentation/rspec/lib/opentelemetry/instrumentation/rspec/formatter.rb deleted file mode 100644 index a75c87140e..0000000000 --- a/instrumentation/rspec/lib/opentelemetry/instrumentation/rspec/formatter.rb +++ /dev/null @@ -1,129 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry-api' -require_relative './version' - -module OpenTelemetry - module Instrumentation - module RSpec - # An RSpec Formatter that outputs Otel spans - class Formatter - attr_reader :output - - ::RSpec::Core::Formatters.register self, :example_started, :example_finished, :example_group_started, :example_group_finished, :start, :stop - - @clock = Time.method(:now) - - def self.current_timestamp - @clock.call - end - - def initialize(output = StringIO.new, tracer_provider = OpenTelemetry.tracer_provider) - @spans_and_tokens = [] - @output = output - @tracer_provider = tracer_provider - end - - def tracer - @tracer ||= @tracer_provider.tracer('OpenTelemetry::Instrumentation::RSpec', OpenTelemetry::Instrumentation::RSpec::VERSION) - end - - def current_timestamp - self.class.current_timestamp - end - - def start(notification) - span = tracer.start_span('RSpec suite', start_timestamp: current_timestamp) - track_span(span) - end - - def stop(notification) - pop_and_finalize_span - end - - def example_group_started(notification) - description = notification.group.description - span = tracer.start_span(description, start_timestamp: current_timestamp) - track_span(span) - end - - def example_group_finished(notification) - pop_and_finalize_span - end - - def example_started(notification) - example = notification.example - attributes = { - 'rspec.example.location' => example.location.to_s, - 'rspec.example.full_description' => example.full_description.to_s, - 'rspec.example.described_class' => example.metadata[:described_class].to_s - } - span = tracer.start_span(example.description, attributes: attributes, start_timestamp: current_timestamp) - track_span(span) - end - - def example_finished(notification) - pop_and_finalize_span do |span| - result = notification.example.execution_result - - span.set_attribute('rspec.example.result', result.status.to_s) - - add_exception_and_failures(span, result.exception) - end - end - - def add_exception_and_failures(span, exception) - return if exception.nil? - - exception_message = strip_console_codes(exception.message) - span.status = OpenTelemetry::Trace::Status.error(exception_message) - - span.set_attribute('rspec.example.failure_message', exception_message) if exception.is_a? ::RSpec::Expectations::ExpectationNotMetError - - if exception.is_a? ::RSpec::Core::MultipleExceptionError - exception.all_exceptions.each do |error| - record_stripped_exception(span, error) - end - span.set_attribute('rspec.example.failure_message', multiple_failure_message(exception)) if exception.failures.any? - else - span.record_exception(exception, attributes: { 'exception.message' => exception_message }) - end - end - - def track_span(span) - token = OpenTelemetry::Context.attach( - OpenTelemetry::Trace.context_with_span(span) - ) - @spans_and_tokens.unshift([span, token]) - end - - def pop_and_finalize_span - span, token = *@spans_and_tokens.shift - return unless span.recording? - - yield span if block_given? - - span.finish(end_timestamp: current_timestamp) - OpenTelemetry::Context.detach(token) - end - - def record_stripped_exception(span, error) - error_message = strip_console_codes(error.message) - span.record_exception(error, attributes: { 'exception.message' => error_message }) - end - - def strip_console_codes(string) - string.gsub(/\e\[([;\d]+)?m/, '') - end - - def multiple_failure_message(exception) - exception.failures.map(&:message).map(&method(:strip_console_codes)).join("\n\n") - end - end - end - end -end diff --git a/instrumentation/rspec/lib/opentelemetry/instrumentation/rspec/instrumentation.rb b/instrumentation/rspec/lib/opentelemetry/instrumentation/rspec/instrumentation.rb deleted file mode 100644 index 5efa46f952..0000000000 --- a/instrumentation/rspec/lib/opentelemetry/instrumentation/rspec/instrumentation.rb +++ /dev/null @@ -1,35 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module RSpec - # The Instrumentation class contains logic to detect and install the Rspec instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - install do |_config| - require_dependencies - add_formatter! - end - - present do - defined?(::RSpec) - end - - private - - def require_dependencies - require_relative './formatter' - end - - def add_formatter! - ::RSpec.configure do |config| - config.add_formatter(Formatter) - end - end - end - end - end -end diff --git a/instrumentation/rspec/lib/opentelemetry/instrumentation/rspec/version.rb b/instrumentation/rspec/lib/opentelemetry/instrumentation/rspec/version.rb deleted file mode 100644 index 9c830c4586..0000000000 --- a/instrumentation/rspec/lib/opentelemetry/instrumentation/rspec/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module RSpec - VERSION = '0.2.0' - end - end -end diff --git a/instrumentation/rspec/opentelemetry-instrumentation-rspec.gemspec b/instrumentation/rspec/opentelemetry-instrumentation-rspec.gemspec deleted file mode 100644 index e15b360fbf..0000000000 --- a/instrumentation/rspec/opentelemetry-instrumentation-rspec.gemspec +++ /dev/null @@ -1,50 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/rspec/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-rspec' - spec.version = OpenTelemetry::Instrumentation::RSpec::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'Rspec instrumentation for the OpenTelemetry framework' - spec.description = 'Rspec instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.21.0' - - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-sdk' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'rake', '~> 12.3.3' - spec.add_development_dependency 'rspec', '~> 3.10.0' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'webmock', '~> 3.7.6' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-rspec/v#{OpenTelemetry::Instrumentation::RSpec::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/rspec' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-rspec/v#{OpenTelemetry::Instrumentation::RSpec::VERSION}" - end -end diff --git a/instrumentation/rspec/test/.rubocop.yml b/instrumentation/rspec/test/.rubocop.yml deleted file mode 100644 index dd94258585..0000000000 --- a/instrumentation/rspec/test/.rubocop.yml +++ /dev/null @@ -1,4 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false diff --git a/instrumentation/rspec/test/opentelemetry/instrumentation/rspec/formatter_test.rb b/instrumentation/rspec/test/opentelemetry/instrumentation/rspec/formatter_test.rb deleted file mode 100644 index 6566263338..0000000000 --- a/instrumentation/rspec/test/opentelemetry/instrumentation/rspec/formatter_test.rb +++ /dev/null @@ -1,375 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../lib/opentelemetry/instrumentation/rspec/formatter' - -describe OpenTelemetry::Instrumentation::RSpec::Formatter do - before(:each) do - EXPORTER.reset - end - - def run_rspec_configured_with_otel_formatter(formatter = OpenTelemetry::Instrumentation::RSpec::Formatter) - options = RSpec::Core::ConfigurationOptions.new([]) - - configuration = RSpec::Core::Configuration.new - - runner = RSpec::Core::Runner.new(options, configuration, RSpec::Core::World.new) - runner.configuration.formatter = formatter - yield runner if block_given? - end - - def run_rspec_with_tracing - run_rspec_configured_with_otel_formatter do |runner| - groups = yield - runner.run_specs(Array(groups)) - end - spans = EXPORTER.finished_spans - EXPORTER.reset - spans - end - - it 'exports spans for suites' do - spans = run_rspec_with_tracing do - group_string = RSpec.describe(String) do - example('example string') {} - end - group_one = RSpec.describe('group one') do - example('example one') {} - end - group_two = RSpec.describe('group two') do - example('example two') {} - end - [group_string, group_one, group_two] - end - _(spans.map(&:name)).must_equal ['example string', 'String', 'example one', 'group one', 'example two', 'group two', 'RSpec suite'] - end - - it 'will not be affected by tests that mock time' do - current_time = Time.now - Time.stub(:now, Time.at(0)) do - spans = run_rspec_with_tracing do - RSpec.describe('group one') do - example('example one') { expect(Time.now).to eq Time.at(0) } - end - end - _(spans.first.name).must_equal 'example one' - _(spans.first.attributes['rspec.example.result']).must_equal 'passed' - _(spans.first.start_timestamp).wont_equal 0 - _(spans.first.start_timestamp / 1_000_000_000).must_be_close_to(current_time.to_i, 10) - _(spans.first.end_timestamp / 1_000_000_000).must_be_close_to(current_time.to_i, 10) - end - end - - describe 'exports spans for example groups' do - it 'describes the class if specified' do - spans = run_rspec_with_tracing do - RSpec.describe(String) do - describe('group description') do - example('example one') {} - end - end - end - _(spans.map(&:name)).must_equal ['example one', 'group description', 'String', 'RSpec suite'] - end - - it 'describes the group description if specified' do - spans = run_rspec_with_tracing do - RSpec.describe('group description') do - example('example one') {} - end - end - _(spans.map(&:name)).must_equal ['example one', 'group description', 'RSpec suite'] - end - - it 'passes context onto child spans' do - spans = run_rspec_with_tracing do - RSpec.describe('group one') do - example('example one') do - expect(true).to equal true - end - end - end - example_span = spans[0] - _(example_span.name).must_equal('example one') - group_span = spans[1] - _(group_span.name).must_equal('group one') - _(example_span.hex_parent_span_id).must_equal(group_span.hex_span_id) - end - end - - describe 'exports spans for examples' do - def run_example(&blk) - spans = run_rspec_with_tracing do - RSpec.describe('group one') do - instance_eval(&blk) - end - end - spans.first - end - - describe 'that pass' do - subject do - run_example do - example('example one') {} - end - end - - it 'has a name that matches the example description' do - _(subject.name).must_equal 'example one' - end - - it 'has a description attribute matches the full example description' do - _(subject.attributes['rspec.example.full_description']).must_equal 'group one example one' - end - - it 'has a description attribute matches the full example description' do - _(subject.attributes['rspec.example.location']).must_match %r{\./test/opentelemetry/instrumentation/rspec/formatter_test.rb:\d+} - end - - it 'records when the example passes' do - _(subject.attributes['rspec.example.result']).must_equal 'passed' - end - end - - it 'passes context onto child spans' do - spans = run_rspec_with_tracing do - RSpec.describe('group one') do - example('example one') do - OpenTelemetry.tracer_provider.tracer('example child span').in_span('child span') do - expect(true).to equal true - end - end - end - end - child = spans[0] - example_span = spans[1] - _(child.name).must_equal('child span') - _(example_span.name).must_equal('example one') - _(child.hex_parent_span_id).must_equal(example_span.hex_span_id) - end - - describe 'that fail' do - subject do - run_example do - example('example one') { expect(true).to eql false } - end - end - - it 'records when the example fails' do - _(subject.attributes['rspec.example.result']).must_equal 'failed' - end - - it 'records the span status as error' do - _(subject.status.ok?).must_equal false - _(subject.status.code).must_equal OpenTelemetry::Trace::Status::ERROR - end - - it 'records the failure message' do - message = <<~MESSAGE - - expected: false - got: true - - (compared using eql?) - - Diff: - @@ -1 +1 @@ - -false - +true - MESSAGE - _(subject.attributes['rspec.example.failure_message']).must_equal message - _(subject.status.description).must_equal message - _(subject.events.first.attributes['exception.message']).must_equal message - end - - it 'records the exception' do - _(subject.events.first.attributes['exception.type']).must_equal 'RSpec::Expectations::ExpectationNotMetError' - end - end - - describe 'that fail and error' do - subject do - run_example do - example('example one') { expect(true).to eql false } - after { raise 'my-error-message' } - end - end - - it 'records when the example fails' do - _(subject.attributes['rspec.example.result']).must_equal 'failed' - end - - it 'records the span status as error' do - _(subject.status.ok?).must_equal false - _(subject.status.code).must_equal OpenTelemetry::Trace::Status::ERROR - end - - it 'records the failure message' do - message = <<~MESSAGE - - expected: false - got: true - - (compared using eql?) - - Diff: - @@ -1 +1 @@ - -false - +true - MESSAGE - _(subject.attributes['rspec.example.failure_message']).must_equal message - _(subject.status.description).must_equal "#{message}\n\nmy-error-message" - _(subject.events[0].attributes['exception.message']).must_equal message - _(subject.events[1].attributes['exception.message']).must_equal 'my-error-message' - end - - it 'records the exception' do - _(subject.events.first.attributes['exception.type']).must_equal 'RSpec::Expectations::ExpectationNotMetError' - end - end - - describe 'that fail twice' do - subject do - run_example do - example('example one') { expect(true).to eql false } - after { expect(true).to eql false } - end - end - - it 'records when the example fails' do - _(subject.attributes['rspec.example.result']).must_equal 'failed' - end - - it 'records the span status as error' do - _(subject.status.ok?).must_equal false - _(subject.status.code).must_equal OpenTelemetry::Trace::Status::ERROR - end - - it 'records the failure message' do - message = <<~MESSAGE - - expected: false - got: true - - (compared using eql?) - - Diff: - @@ -1 +1 @@ - -false - +true - MESSAGE - expected_failure_message = "#{message}\n\n#{message}" - _(subject.attributes['rspec.example.failure_message']).must_equal expected_failure_message - _(subject.events[0].attributes['exception.message']).must_equal message - _(subject.events[1].attributes['exception.message']).must_equal message - _(subject.status.description).must_equal expected_failure_message - end - - it 'records the exception' do - _(subject.events.first.attributes['exception.type']).must_equal 'RSpec::Expectations::ExpectationNotMetError' - end - end - - describe 'that error' do - subject do - run_example do - example('example one') { raise 'my-error-message' } - end - end - - it 'records when the example fails' do - _(subject.attributes['rspec.example.result']).must_equal 'failed' - end - - it 'records the span status as error' do - _(subject.status.ok?).must_equal false - _(subject.status.code).must_equal OpenTelemetry::Trace::Status::ERROR - _(subject.status.description).must_equal 'my-error-message' - end - - it 'records the exception' do - _(subject.events[0].attributes['exception.type']).must_equal 'RuntimeError' - _(subject.events[0].attributes['exception.message']).must_equal 'my-error-message' - end - end - - describe 'that error twice' do - subject do - run_example do - example('example one') { raise 'my-error-message' } - after { raise 'another-error' } - end - end - - it 'records when the example fails' do - _(subject.attributes['rspec.example.result']).must_equal 'failed' - end - - it 'records the span status as error' do - _(subject.status.ok?).must_equal false - _(subject.status.code).must_equal OpenTelemetry::Trace::Status::ERROR - _(subject.status.description).must_equal "my-error-message\n\nanother-error" - end - - it 'records the first exception' do - _(subject.events[0].attributes['exception.type']).must_equal 'RuntimeError' - _(subject.events[0].attributes['exception.message']).must_equal 'my-error-message' - end - - it 'records the second exception' do - _(subject.events[1].attributes['exception.type']).must_equal 'RuntimeError' - _(subject.events[1].attributes['exception.message']).must_equal 'another-error' - end - end - end - - describe 'using a custom tracer provider' do - describe 'with the formatter' do - it 'will sends spans to the connected exporter' do - exporter = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new - span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(exporter) - tracer_provider = OpenTelemetry::SDK::Trace::TracerProvider.new - tracer_provider.add_span_processor(span_processor) - formatter = OpenTelemetry::Instrumentation::RSpec::Formatter.new(StringIO.new, tracer_provider) - run_rspec_configured_with_otel_formatter(formatter) do |runner| - group_string = RSpec.describe(String) do - example('example string') {} - end - runner.run_specs([group_string]) - end - spans = exporter.finished_spans - _(spans.map(&:name)).must_equal ['example string', 'String', 'RSpec suite'] - _(EXPORTER.finished_spans).must_equal [] - end - - it 'will sends spans to the connected exporter' do - exporter = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new - span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(exporter) - tracer_provider = OpenTelemetry::SDK::Trace::TracerProvider.new - tracer_provider.add_span_processor(span_processor) - tracer = tracer_provider.tracer('foo') - - spans = run_rspec_with_tracing do - group_one = RSpec.describe('group one') do - example('example one') do - tracer.in_span('my first test span') - end - end - group_string = RSpec.describe(String) do - example('example string') do - tracer.in_span('my second test span') - end - end - [group_one, group_string] - end - _(exporter.finished_spans.map(&:name)).must_equal ['my first test span', 'my second test span'] - _(spans.map(&:name)).must_equal ['example one', 'group one', 'example string', 'String', 'RSpec suite'] - end - end - end -end diff --git a/instrumentation/rspec/test/opentelemetry/instrumentation/rspec/instrumentation_test.rb b/instrumentation/rspec/test/opentelemetry/instrumentation/rspec/instrumentation_test.rb deleted file mode 100644 index 1ff4ac8257..0000000000 --- a/instrumentation/rspec/test/opentelemetry/instrumentation/rspec/instrumentation_test.rb +++ /dev/null @@ -1,34 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../lib/opentelemetry/instrumentation/rspec' - -describe OpenTelemetry::Instrumentation::RSpec do - let(:instrumentation) { OpenTelemetry::Instrumentation::RSpec::Instrumentation.instance } - - it 'has #name' do - _(instrumentation.name).must_equal 'OpenTelemetry::Instrumentation::RSpec' - end - - it 'has #version' do - _(instrumentation.version).wont_be_nil - _(instrumentation.version).wont_be_empty - end - - describe '#install' do - it 'accepts argument' do - _(instrumentation.install({})).must_equal(true) - instrumentation.instance_variable_set(:@installed, false) - end - - it 'adds the formatter to RSpec configuration' do - _(instrumentation.install({})).must_equal(true) - _(RSpec.configuration.formatters.map(&:class)).must_include OpenTelemetry::Instrumentation::RSpec::Formatter - end - end -end diff --git a/instrumentation/rspec/test/rspec_patches.rb b/instrumentation/rspec/test/rspec_patches.rb deleted file mode 100644 index c82fd69219..0000000000 --- a/instrumentation/rspec/test/rspec_patches.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -# patch `RSpec::Core::DSL::change_global_dsl to reliably prevent -# RSpec overriding minitest's global `::describe` method -require 'rspec/core/dsl' -module RSpec - module Core - module DSL - def self.change_global_dsl(&blk) - nil - end - end - end -end diff --git a/instrumentation/rspec/test/test_helper.rb b/instrumentation/rspec/test/test_helper.rb deleted file mode 100644 index 349f6e89e9..0000000000 --- a/instrumentation/rspec/test/test_helper.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' - -require_relative 'rspec_patches' -require 'rspec/core' - -require 'minitest/autorun' -require 'webmock/minitest' - -# global opentelemetry-sdk setup: -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry::SDK.configure do |c| - c.add_span_processor span_processor -end diff --git a/instrumentation/ruby_kafka/.rubocop.yml b/instrumentation/ruby_kafka/.rubocop.yml deleted file mode 100644 index 5ee55e24f1..0000000000 --- a/instrumentation/ruby_kafka/.rubocop.yml +++ /dev/null @@ -1,7 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -Naming/FileName: - Exclude: - - "example/ruby_kafka.rb" - - "lib/opentelemetry-instrumentation-ruby_kafka.rb" - - "lib/opentelemetry/instrumentation/ruby_kafka.rb" diff --git a/instrumentation/ruby_kafka/.yardopts b/instrumentation/ruby_kafka/.yardopts deleted file mode 100644 index 97722e2b66..0000000000 --- a/instrumentation/ruby_kafka/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry RubyKafka Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/ruby_kafka/Appraisals b/instrumentation/ruby_kafka/Appraisals deleted file mode 100644 index fe22b6fba6..0000000000 --- a/instrumentation/ruby_kafka/Appraisals +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -appraise 'ruby-kafka-1.3.0' do - gem 'ruby-kafka', '~> 1.3.0' -end - -# Producer test is timing out on Ruby 3 -if RUBY_VERSION < '3' - appraise 'ruby-kafka-1.2.0' do - gem 'ruby-kafka', '~> 1.2.0' - end - - appraise 'ruby-kafka-1.0.0' do - gem 'ruby-kafka', '~> 1.0.0' - end -end diff --git a/instrumentation/ruby_kafka/CHANGELOG.md b/instrumentation/ruby_kafka/CHANGELOG.md deleted file mode 100644 index 830ad12153..0000000000 --- a/instrumentation/ruby_kafka/CHANGELOG.md +++ /dev/null @@ -1,63 +0,0 @@ -# Release History: opentelemetry-instrumentation-ruby_kafka - -### v0.19.0 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Broken test file requirements - -### v0.18.6 / 2022-05-02 - -* FIXED: RubyGems Fallback - -### v0.18.5 / 2021-12-02 - -* (No significant changes) - -### v0.18.4 / 2021-09-29 - -* (No significant changes) - -### v0.18.3 / 2021-09-29 - -* FIXED: Use Kafka::VERSION fallback for compatibility - -### v0.18.2 / 2021-08-12 - -* DOCS: Update docs to rely more on environment variable configuration - -### v0.18.1 / 2021-06-23 - -* (No significant changes) - -### v0.18.0 / 2021-05-21 - -* ADDED: Updated API depedency for 1.0.0.rc1 - -### v0.17.0 / 2021-04-22 - -* (No significant changes) - -### v0.16.0 / 2021-03-17 - -* FIXED: Example scripts now reference local common lib -* DOCS: Replace Gitter with GitHub Discussions - -### v0.15.0 / 2021-02-18 - -* (No significant changes) - -### v0.14.0 / 2021-02-03 - -* BREAKING CHANGE: Replace getter and setter callables and remove rack specific propagators - -* ADDED: Replace getter and setter callables and remove rack specific propagators - -### v0.13.0 / 2021-01-29 - -* FIXED: Add minimum gem version for ruby-kafka -* FIXED: Ruby_kafka baggage propagation -* FIXED: Remove unused ruby-kafka events file - -### v0.12.0 / 2020-12-24 - -* Initial release. diff --git a/instrumentation/ruby_kafka/Gemfile b/instrumentation/ruby_kafka/Gemfile deleted file mode 100644 index 5b7d54b645..0000000000 --- a/instrumentation/ruby_kafka/Gemfile +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :test do - gem 'opentelemetry-instrumentation-base', path: '../base' - gem 'pry-byebug' -end diff --git a/instrumentation/ruby_kafka/LICENSE b/instrumentation/ruby_kafka/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/ruby_kafka/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/ruby_kafka/README.md b/instrumentation/ruby_kafka/README.md deleted file mode 100644 index bedb86061a..0000000000 --- a/instrumentation/ruby_kafka/README.md +++ /dev/null @@ -1,76 +0,0 @@ -# OpenTelemetry RubyKafka Instrumentation - -The RubyKafka instrumentation is a community-maintained instrumentation for [RubyKafka][ruby_kafka-home], a client library for Apache Kafka. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-ruby_kafka -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-ruby_kafka` in your `Gemfile`. - -## Usage - -To use the instrumentation, call `use` with the name of the instrumentation: - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::RubyKafka' -end -``` - -Alternatively, you can also call `use_all` to install all the available instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` - -## Examples - -Example usage can be seen in the `./example/ruby_kafka.rb` file [here](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/instrumentation/ruby_kafka/example/ruby_kafka.rb) - -## How can I get involved? - -The `opentelemetry-instrumentation-ruby_kafka` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -### Running Tests - -Tests in this package require a running instance of Kafka and Zookeeper, which are made available via `docker-compose`: - -```bash -ruby-kafka $> docker-compose up -d kafka - Creating network "ruby_kafka_default" with the default driver - Creating ruby_kafka_zookeeper_1 ... done - Creating ruby_kafka_kafka_1 ... done -``` - -The run tests using `rake` - -```bash -ruby-kafka $> bundle exec rake test -``` - -To stop the dependent services - -```bash -ruby-kafka $> docker-compose down -``` - -## License - -The `opentelemetry-instrumentation-ruby_kafka` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information. - -[ruby_kafka-home]: https://github.com/zendesk/ruby-kafka -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/instrumentation/ruby_kafka/Rakefile b/instrumentation/ruby_kafka/Rakefile deleted file mode 100644 index 1a64ba842e..0000000000 --- a/instrumentation/ruby_kafka/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/ruby_kafka/docker-compose.yml b/instrumentation/ruby_kafka/docker-compose.yml deleted file mode 100644 index 5be91ad8fd..0000000000 --- a/instrumentation/ruby_kafka/docker-compose.yml +++ /dev/null @@ -1,25 +0,0 @@ -version: "3.5" - -services: - zookeeper: - image: confluentinc/cp-zookeeper:latest - ports: - - 2181:2181 - environment: - ZOOKEEPER_CLIENT_PORT: 2181 - ZOOKEEPER_TICK_TIME: 2000 - - kafka: - image: confluentinc/cp-kafka:latest - ports: - - "9092:9092" - - "29092:29092" - environment: - KAFKA_BROKER_ID: 1 - KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 - KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:29092,PLAINTEXT_HOST://kafka:9092 - KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT - KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT - KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 - depends_on: - - zookeeper diff --git a/instrumentation/ruby_kafka/example/Gemfile b/instrumentation/ruby_kafka/example/Gemfile deleted file mode 100644 index c0c4bdd401..0000000000 --- a/instrumentation/ruby_kafka/example/Gemfile +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -source 'https://rubygems.org' - -gem 'activesupport' -gem 'opentelemetry-api' -gem 'opentelemetry-common' -gem 'opentelemetry-instrumentation-ruby_kafka' -gem 'opentelemetry-sdk' -gem 'ruby-kafka' diff --git a/instrumentation/ruby_kafka/example/ruby_kafka.rb b/instrumentation/ruby_kafka/example/ruby_kafka.rb deleted file mode 100644 index bf0ae8726d..0000000000 --- a/instrumentation/ruby_kafka/example/ruby_kafka.rb +++ /dev/null @@ -1,36 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'rubygems' -require 'bundler/setup' - -Bundler.require - -require 'kafka' -require 'active_support' - -ENV['OTEL_TRACES_EXPORTER'] = 'console' -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::RubyKafka' -end - -# Assumes kafka is available -kafka = Kafka.new(['kafka:9092', 'kafka:9092'], client_id: 'opentelemetry-ruby-demonstration') - -# Instantiate a new producer. -producer = kafka.producer - -# Add a message to the producer buffer. -producer.produce('hello example', topic: 'greetings') - -# Deliver the messages to Kafka. -producer.deliver_messages - -# Consume the message and break the loop -kafka.each_message(topic: 'greetings') do |message| - puts message.offset, message.key, message.value - break -end diff --git a/instrumentation/ruby_kafka/lib/opentelemetry-instrumentation-ruby_kafka.rb b/instrumentation/ruby_kafka/lib/opentelemetry-instrumentation-ruby_kafka.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/ruby_kafka/lib/opentelemetry-instrumentation-ruby_kafka.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/ruby_kafka/lib/opentelemetry/instrumentation.rb b/instrumentation/ruby_kafka/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index bcd0b719d5..0000000000 --- a/instrumentation/ruby_kafka/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/ruby_kafka' diff --git a/instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka.rb b/instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka.rb deleted file mode 100644 index 7398fd108f..0000000000 --- a/instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the Ruby-Kafka gem - module RubyKafka - end - end -end - -require_relative './ruby_kafka/instrumentation' -require_relative './ruby_kafka/version' diff --git a/instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka/instrumentation.rb b/instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka/instrumentation.rb deleted file mode 100644 index 795f2d9a16..0000000000 --- a/instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka/instrumentation.rb +++ /dev/null @@ -1,48 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module RubyKafka - # The Instrumentation class contains logic to detect and install the - # KafkaRuby instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - MINIMUM_VERSION = Gem::Version.new('0.7.0') - - install do |_config| - require_patches - patch - end - - present do - !defined?(::Kafka).nil? - end - - compatible do - (!gem_version.nil? && gem_version >= MINIMUM_VERSION) - end - - private - - def gem_version - Gem::Version.new(Kafka::VERSION) - end - - def require_patches - require_relative 'patches/producer' - require_relative 'patches/consumer' - require_relative 'patches/client' - end - - def patch - ::Kafka::Producer.prepend(Patches::Producer) - ::Kafka::Consumer.prepend(Patches::Consumer) - ::Kafka::Client.prepend(Patches::Client) - end - end - end - end -end diff --git a/instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka/patches/client.rb b/instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka/patches/client.rb deleted file mode 100644 index 111d27a404..0000000000 --- a/instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka/patches/client.rb +++ /dev/null @@ -1,63 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative '../utils' - -module OpenTelemetry - module Instrumentation - module RubyKafka - module Patches - # The Client module contains the instrumentation patch the Client#deliver_message and Client#each_message methods. - module Client - def deliver_message(value, key: nil, headers: {}, topic:, partition: nil, partition_key: nil, retries: 1) - attributes = { - 'messaging.system' => 'kafka', - 'messaging.destination' => topic, - 'messaging.destination_kind' => 'topic' - } - - message_key = Utils.extract_message_key(key) - attributes['messaging.kafka.message_key'] = message_key if message_key - - attributes['messaging.kafka.partition'] = partition if partition - - tracer.in_span("#{topic} send", attributes: attributes, kind: :producer) do - OpenTelemetry.propagation.inject(headers) - super - end - end - - def each_message(topic:, start_from_beginning: true, max_wait_time: 5, min_bytes: 1, max_bytes: 1_048_576, &block) - super do |message| - attributes = { - 'messaging.system' => 'kafka', - 'messaging.destination' => message.topic, - 'messaging.destination_kind' => 'topic', - 'messaging.kafka.partition' => message.partition - } - - message_key = Utils.extract_message_key(message.key) - attributes['messaging.kafka.message_key'] = message_key if message_key - - parent_context = OpenTelemetry.propagation.extract(message.headers) - OpenTelemetry::Context.with_current(parent_context) do - tracer.in_span("#{topic} process", attributes: attributes, kind: :consumer) do - yield message - end - end - end - end - - private - - def tracer - RubyKafka::Instrumentation.instance.tracer - end - end - end - end - end -end diff --git a/instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka/patches/consumer.rb b/instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka/patches/consumer.rb deleted file mode 100644 index e44b878855..0000000000 --- a/instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka/patches/consumer.rb +++ /dev/null @@ -1,71 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module RubyKafka - module Patches - # The Consumer module contains the instrumentation patch for the Consumer class - module Consumer - def each_message(min_bytes: 1, max_bytes: 10_485_760, max_wait_time: 1, automatically_mark_as_processed: true) - super do |message| - attributes = { - 'messaging.system' => 'kafka', - 'messaging.destination' => message.topic, - 'messaging.destination_kind' => 'topic', - 'messaging.kafka.partition' => message.partition, - 'messaging.kafka.offset' => message.offset - } - - message_key = Utils.extract_message_key(message.key) - attributes['messaging.kafka.message_key'] = message_key if message_key - - parent_context = OpenTelemetry.propagation.extract(message.headers) - span_context = OpenTelemetry::Trace.current_span(parent_context).context - links = [OpenTelemetry::Trace::Link.new(span_context)] if span_context.valid? - - OpenTelemetry::Context.with_current(parent_context) do - tracer.in_span("#{message.topic} process", links: links, attributes: attributes, kind: :consumer) do - yield message - end - end - end - end - - def each_batch(min_bytes: 1, max_bytes: 10_485_760, max_wait_time: 1, automatically_mark_as_processed: true) # rubocop:disable Metrics/AbcSize - super do |batch| - attributes = { - 'messaging.system' => 'kafka', - 'messaging.destination' => batch.topic, - 'messaging.destination_kind' => 'topic', - 'messaging.kafka.partition' => batch.partition, - 'messaging.kafka.offset_lag' => batch.offset_lag, - 'messaging.kafka.highwater_mark_offset' => batch.highwater_mark_offset, - 'messaging.kafka.message_count' => batch.messages.count - } - - links = batch.messages.map do |message| - span_context = OpenTelemetry::Trace.current_span(OpenTelemetry.propagation.extract(message.headers)).context - OpenTelemetry::Trace::Link.new(span_context) if span_context.valid? - end - links.compact! - - tracer.in_span("#{batch.topic} process", attributes: attributes, links: links, kind: :consumer) do - yield batch - end - end - end - - private - - def tracer - RubyKafka::Instrumentation.instance.tracer - end - end - end - end - end -end diff --git a/instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka/patches/producer.rb b/instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka/patches/producer.rb deleted file mode 100644 index 16ce2fcd50..0000000000 --- a/instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka/patches/producer.rb +++ /dev/null @@ -1,35 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module RubyKafka - module Patches - # The Producer module contains the instrumentation patch the Producer#produce method - module Producer - def produce(value, key: nil, headers: {}, topic:, partition: nil, partition_key: nil, create_time: Time.now) - attributes = { - 'messaging.system' => 'kafka', - 'messaging.destination' => topic, - 'messaging.destination_kind' => 'topic' - } - - tracer.in_span("#{topic} send", attributes: attributes, kind: :producer) do - OpenTelemetry.propagation.inject(headers) - super - end - end - - private - - def tracer - RubyKafka::Instrumentation.instance.tracer - end - end - end - end - end -end diff --git a/instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka/utils.rb b/instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka/utils.rb deleted file mode 100644 index 7ece5dcd2d..0000000000 --- a/instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka/utils.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module RubyKafka - # Utilities to help with instrumenting kafka - module Utils - module_function - - def extract_message_key(key) - # skip encode if already valid utf8 - return key if key.nil? || (key.encoding == Encoding::UTF_8 && key.valid_encoding?) - - key.encode(Encoding::UTF_8) - rescue Encoding::UndefinedConversionError - nil - end - end - end - end -end diff --git a/instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka/version.rb b/instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka/version.rb deleted file mode 100644 index 589da0b126..0000000000 --- a/instrumentation/ruby_kafka/lib/opentelemetry/instrumentation/ruby_kafka/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module RubyKafka - VERSION = '0.19.0' - end - end -end diff --git a/instrumentation/ruby_kafka/opentelemetry-instrumentation-ruby_kafka.gemspec b/instrumentation/ruby_kafka/opentelemetry-instrumentation-ruby_kafka.gemspec deleted file mode 100644 index 927b5db2e2..0000000000 --- a/instrumentation/ruby_kafka/opentelemetry-instrumentation-ruby_kafka.gemspec +++ /dev/null @@ -1,49 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/ruby_kafka/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-ruby_kafka' - spec.version = OpenTelemetry::Instrumentation::RubyKafka::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'RubyKafka instrumentation for the OpenTelemetry framework' - spec.description = 'RubyKafka instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.21.0' - - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'rspec-mocks' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'ruby-kafka' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-ruby_kafka/v#{OpenTelemetry::Instrumentation::RubyKafka::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/ruby_kafka' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-ruby_kafka/v#{OpenTelemetry::Instrumentation::RubyKafka::VERSION}" - end -end diff --git a/instrumentation/ruby_kafka/test/.rubocop.yml b/instrumentation/ruby_kafka/test/.rubocop.yml deleted file mode 100644 index e97eda560f..0000000000 --- a/instrumentation/ruby_kafka/test/.rubocop.yml +++ /dev/null @@ -1,6 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false -Style/MultilineIfModifier: - Enabled: false diff --git a/instrumentation/ruby_kafka/test/opentelemetry/instrumentation/ruby-kafka/instrumentation_test.rb b/instrumentation/ruby_kafka/test/opentelemetry/instrumentation/ruby-kafka/instrumentation_test.rb deleted file mode 100644 index 57ce1f98fa..0000000000 --- a/instrumentation/ruby_kafka/test/opentelemetry/instrumentation/ruby-kafka/instrumentation_test.rb +++ /dev/null @@ -1,66 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../lib/opentelemetry/instrumentation/ruby_kafka' - -describe OpenTelemetry::Instrumentation::RubyKafka::Instrumentation do - let(:instrumentation) { OpenTelemetry::Instrumentation::RubyKafka::Instrumentation.instance } - - it 'has #name' do - _(instrumentation.name).must_equal 'OpenTelemetry::Instrumentation::RubyKafka' - end - - it 'has #version' do - _(instrumentation.version).wont_be_nil - _(instrumentation.version).wont_be_empty - end - - describe 'present' do - it 'when ruby-kafka gem installed' do - _(instrumentation.present?).must_equal true - end - - it 'when ruby-kafka gem not installed' do - hide_const('Kafka') - _(instrumentation.present?).must_equal false - end - end - - describe 'compatible' do - it 'when older gem version installed' do - stub_const('Kafka::VERSION', '0.6.8') - _(instrumentation.compatible?).must_equal false - end - - it 'when future gem version installed' do - _(instrumentation.compatible?).must_equal true - end - - describe 'when the installing application bypasses RubyGems' do - it 'falls back to the VERSION constant' do - stub_const('Kafka::VERSION', '0.6.9') - Gem.stub(:loaded_specs, 'ruby-kafka' => nil) do - _(instrumentation.compatible?).must_equal false - end - - version = ::OpenTelemetry::Instrumentation::RubyKafka::Instrumentation::MINIMUM_VERSION.version - stub_const('Kafka::VERSION', version) - Gem.stub(:loaded_specs, 'ruby-kafka' => nil) do - _(instrumentation.compatible?).must_equal true - end - end - end - end - - describe '#install' do - it 'accepts arguments' do - instrumentation.instance_variable_set(:@installed, false) - _(instrumentation.install({})).must_equal(true) - end - end -end diff --git a/instrumentation/ruby_kafka/test/opentelemetry/instrumentation/ruby-kafka/patches/client_test.rb b/instrumentation/ruby_kafka/test/opentelemetry/instrumentation/ruby-kafka/patches/client_test.rb deleted file mode 100644 index 524f60404f..0000000000 --- a/instrumentation/ruby_kafka/test/opentelemetry/instrumentation/ruby-kafka/patches/client_test.rb +++ /dev/null @@ -1,70 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../../lib/opentelemetry/instrumentation/ruby_kafka' -require_relative '../../../../../lib/opentelemetry/instrumentation/ruby_kafka/patches/client' - -describe OpenTelemetry::Instrumentation::RubyKafka::Patches::Client do - let(:instrumentation) { OpenTelemetry::Instrumentation::RubyKafka::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:spans) { exporter.finished_spans } - let(:host) { ENV.fetch('TEST_KAFKA_HOST') { '127.0.0.1' } } - let(:port) { (ENV.fetch('TEST_KAFKA_PORT') { 29_092 }) } - let(:kafka) { Kafka.new(["#{host}:#{port}"], client_id: 'opentelemetry-kafka-test') } - let(:topic) { "topic-#{SecureRandom.uuid}" } - - before do - kafka.create_topic(topic) - - # Clear spans - exporter.reset - - instrumentation.install - end - - after do - # Force re-install of instrumentation - instrumentation.instance_variable_set(:@installed, false) - - # Clean up - kafka.close - end - - it 'traces produce and consuming' do - kafka.deliver_message('hello', topic: topic) - kafka.each_message(topic: topic) { |_msg| break } - - _(spans.size).must_equal(2) - _(spans[0].name).must_equal("#{topic} send") - _(spans[0].kind).must_equal(:producer) - - _(spans[1].name).must_equal("#{topic} process") - _(spans[1].kind).must_equal(:consumer) - end - - it 'encodes message keys' do - invalid_utf8_key = String.new("\xAF\x0F\xEF", encoding: 'ASCII-8BIT') - kafka.deliver_message('hello', key: invalid_utf8_key, topic: topic) - kafka.deliver_message('hello2', key: 'foobarbaz', topic: topic) - begin - counter = 0 - kafka.each_message(topic: topic) do |_msg| - counter += 1 - break if counter >= 2 - end - end - - send_spans = spans.select { |s| s.name == "#{topic} send" } - _(send_spans[0].attributes).wont_include('messaging.kafka.message_key') - _(send_spans[1].attributes['messaging.kafka.message_key']).must_equal('foobarbaz') - - process_spans = spans.select { |s| s.name == "#{topic} process" } - _(process_spans[0].attributes).wont_include('messaging.kafka.message_key') - _(process_spans[1].attributes['messaging.kafka.message_key']).must_equal('foobarbaz') - end -end unless ENV['OMIT_SERVICES'] diff --git a/instrumentation/ruby_kafka/test/opentelemetry/instrumentation/ruby-kafka/patches/consumer_test.rb b/instrumentation/ruby_kafka/test/opentelemetry/instrumentation/ruby-kafka/patches/consumer_test.rb deleted file mode 100644 index cd56d14481..0000000000 --- a/instrumentation/ruby_kafka/test/opentelemetry/instrumentation/ruby-kafka/patches/consumer_test.rb +++ /dev/null @@ -1,157 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../../lib/opentelemetry/instrumentation/ruby_kafka' -require_relative '../../../../../lib/opentelemetry/instrumentation/ruby_kafka/patches/consumer' - -describe OpenTelemetry::Instrumentation::RubyKafka::Patches::Consumer do - let(:instrumentation) { OpenTelemetry::Instrumentation::RubyKafka::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:spans) { exporter.finished_spans } - - let(:host) { ENV.fetch('TEST_KAFKA_HOST') { '127.0.0.1' } } - let(:port) { (ENV.fetch('TEST_KAFKA_PORT') { 29_092 }) } - - let(:kafka) { Kafka.new(["#{host}:#{port}"], client_id: 'opentelemetry-kafka-test') } - let(:topic) { "topic-#{SecureRandom.uuid}" } - let(:producer) { kafka.producer } - let(:consumer) { kafka.consumer(group_id: SecureRandom.uuid, fetcher_max_queue_size: 1) } - - before do - kafka.create_topic(topic) - consumer.subscribe(topic) - - # Clear spans - exporter.reset - - instrumentation.install - end - - after do - # Force re-install of instrumentation - instrumentation.instance_variable_set(:@installed, false) - - # Clean up - producer.shutdown - consumer.stop - kafka.close - end - - describe '#each_message' do - it 'traces each_meassage call' do - kafka.deliver_message('hello', topic: topic) - kafka.deliver_message('hello2', topic: topic) - - begin - counter = 0 - consumer.each_message do |_msg| - counter += 1 - raise 'oops' if counter >= 2 - end - rescue StandardError # rubocop:disable Lint/HandleExceptions - end - - process_spans = spans.select { |s| s.name == "#{topic} process" } - - # First pair for send and process spans - first_process_span = process_spans[0] - _(first_process_span.name).must_equal("#{topic} process") - _(first_process_span.kind).must_equal(:consumer) - _(first_process_span.attributes['messaging.destination']).must_equal(topic) - _(first_process_span.attributes['messaging.kafka.partition']).must_equal(0) - - first_process_span_link = first_process_span.links[0] - linked_span_context = first_process_span_link.span_context - - linked_send_span = spans.find { |s| s.span_id == linked_span_context.span_id } - _(linked_send_span.name).must_equal("#{topic} send") - _(linked_send_span.trace_id).must_equal(first_process_span.trace_id) - _(linked_send_span.trace_id).must_equal(linked_span_context.trace_id) - - # Second pair of send and process spans - second_process_span = process_spans[1] - _(second_process_span.name).must_equal("#{topic} process") - _(second_process_span.kind).must_equal(:consumer) - - second_process_span_link = second_process_span.links[0] - linked_span_context = second_process_span_link.span_context - - linked_send_span = spans.find { |s| s.span_id == linked_span_context.span_id } - _(linked_send_span.name).must_equal("#{topic} send") - _(linked_send_span.trace_id).must_equal(second_process_span.trace_id) - _(linked_send_span.trace_id).must_equal(linked_span_context.trace_id) - - event = second_process_span.events.first - _(event.name).must_equal('exception') - _(event.attributes['exception.type']).must_equal('RuntimeError') - _(event.attributes['exception.message']).must_equal('oops') - - _(spans.size).must_equal(4) - end - - it 'encodes messages keys depending on input format' do - kafka.deliver_message('hello', key: "\xAF\x0F\xEF", topic: topic) - kafka.deliver_message('hello2', key: 'foobarbaz', topic: topic) - - begin - counter = 0 - consumer.each_message do |_msg| - counter += 1 - break if counter >= 2 - end - end - - process_spans = spans.select { |s| s.name == "#{topic} process" } - - # First pair for send and process spans - first_process_span = process_spans[0] - _(first_process_span.attributes).wont_include('messaging.kafka.message_key') - - second_process_span = process_spans[1] - _(second_process_span.attributes['messaging.kafka.message_key']).must_equal('foobarbaz') - - _(spans.size).must_equal(4) - end - end - - describe '#each_batch' do - it 'traces each_batch call' do - kafka.deliver_message('hello', topic: topic) - kafka.deliver_message('hello2', topic: topic) - - begin - consumer.each_batch { |_b| raise 'oops' } - rescue StandardError # rubocop:disable Lint/HandleExceptions - end - - span = spans.find { |s| s.name == "#{topic} process" } - _(span.name).must_equal("#{topic} process") - _(span.kind).must_equal(:consumer) - _(span.attributes['messaging.destination']).must_equal(topic) - _(span.attributes['messaging.kafka.partition']).must_equal(0) - _(span.attributes['messaging.kafka.message_count']).must_equal(2) - - event = span.events.first - _(event.name).must_equal('exception') - _(event.attributes['exception.type']).must_equal('RuntimeError') - _(event.attributes['exception.message']).must_equal('oops') - - first_link = span.links[0] - linked_span_context = first_link.span_context - _(linked_span_context.trace_id).must_equal(spans[0].trace_id) - _(linked_span_context.span_id).must_equal(spans[0].span_id) - - second_link = span.links[1] - linked_span_context = second_link.span_context - _(linked_span_context.trace_id).must_equal(spans[1].trace_id) - _(linked_span_context.span_id).must_equal(spans[1].span_id) - - _(spans.size).must_equal(3) - end - end -end unless ENV['OMIT_SERVICES'] diff --git a/instrumentation/ruby_kafka/test/opentelemetry/instrumentation/ruby-kafka/patches/producer_test.rb b/instrumentation/ruby_kafka/test/opentelemetry/instrumentation/ruby-kafka/patches/producer_test.rb deleted file mode 100644 index 4c8b26197f..0000000000 --- a/instrumentation/ruby_kafka/test/opentelemetry/instrumentation/ruby-kafka/patches/producer_test.rb +++ /dev/null @@ -1,75 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../../lib/opentelemetry/instrumentation/ruby_kafka' -require_relative '../../../../../lib/opentelemetry/instrumentation/ruby_kafka/patches/producer' - -describe OpenTelemetry::Instrumentation::RubyKafka::Patches::Producer do - let(:instrumentation) { OpenTelemetry::Instrumentation::RubyKafka::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:spans) { exporter.finished_spans } - - let(:host) { ENV.fetch('TEST_KAFKA_HOST') { '127.0.0.1' } } - let(:port) { (ENV.fetch('TEST_KAFKA_PORT') { 29_092 }) } - - let(:kafka) { Kafka.new(["#{host}:#{port}"], client_id: 'opentelemetry-kafka-test') } - let(:topic) { "topic-#{SecureRandom.uuid}" } - let(:async_topic) { "async-#{topic}" } - let(:producer) { kafka.producer } - let(:consumer) { kafka.consumer(group_id: SecureRandom.uuid, fetcher_max_queue_size: 1) } - let(:async_producer) { kafka.async_producer(delivery_threshold: 1000) } - - before do - kafka.create_topic(topic) - kafka.create_topic(async_topic) - consumer.subscribe(async_topic) - - # Clear spans - exporter.reset - - instrumentation.install - end - - after do - # Force re-install of instrumentation - instrumentation.instance_variable_set(:@installed, false) - - # Clean up - producer.shutdown - async_producer.shutdown - consumer.stop - kafka.close - end - - describe 'tracing' do - it 'traces sync produce calls' do - producer.produce('hello', topic: topic) - producer.deliver_messages - - _(spans.first.name).must_equal("#{topic} send") - _(spans.first.kind).must_equal(:producer) - - _(spans.first.attributes['messaging.system']).must_equal('kafka') - _(spans.first.attributes['messaging.destination']).must_equal(topic) - end - - it 'traces async produce calls' do - async_producer.produce('hello async', topic: async_topic) - async_producer.deliver_messages - - # Wait for the async calls to produce spans - wait_for(error_message: 'Max wait time exceeded for async producer') { EXPORTER.finished_spans.size.positive? } - - _(spans.first.name).must_equal("#{async_topic} send") - _(spans.first.kind).must_equal(:producer) - - _(spans.first.attributes['messaging.system']).must_equal('kafka') - _(spans.first.attributes['messaging.destination']).must_equal(async_topic) - end - end -end unless ENV['OMIT_SERVICES'] diff --git a/instrumentation/ruby_kafka/test/opentelemetry/instrumentation/ruby-kafka/utils_test.rb b/instrumentation/ruby_kafka/test/opentelemetry/instrumentation/ruby-kafka/utils_test.rb deleted file mode 100644 index 30832ad978..0000000000 --- a/instrumentation/ruby_kafka/test/opentelemetry/instrumentation/ruby-kafka/utils_test.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative '../../../test_helper' - -require_relative '../../../../lib/opentelemetry/instrumentation/ruby_kafka/utils' - -describe OpenTelemetry::Instrumentation::RubyKafka::Utils do - it 'returns input as itself if it is valid utf_8' do - input = 'foobarbaz' - _(OpenTelemetry::Instrumentation::RubyKafka::Utils.extract_message_key(input).object_id).must_equal(input.object_id) - end - - it 'returns input utf_8 encoded if it is encoded differently but not encoded' do - input = String.new('foobarbaz', encoding: 'ASCII-8BIT') - _(OpenTelemetry::Instrumentation::RubyKafka::Utils.extract_message_key(input)).must_equal('foobarbaz') - _(OpenTelemetry::Instrumentation::RubyKafka::Utils.extract_message_key(input).encoding).must_equal(Encoding::UTF_8) - end - - it 'returns input as a hexstring if it is not valid utf_8' do - input = String.new("\x00\x00\x00\x00\x00\xAC\xBA\xC4", encoding: 'ASCII-8BIT') - _(OpenTelemetry::Instrumentation::RubyKafka::Utils.extract_message_key(input)).must_be_nil - end -end diff --git a/instrumentation/ruby_kafka/test/test_helper.rb b/instrumentation/ruby_kafka/test/test_helper.rb deleted file mode 100644 index 01cedc4734..0000000000 --- a/instrumentation/ruby_kafka/test/test_helper.rb +++ /dev/null @@ -1,34 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'kafka' - -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' - -require 'pry' -require 'minitest/autorun' -require 'rspec/mocks/minitest_integration' - -# global opentelemetry-sdk setup: -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -SPAN_PROCESSOR = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry::SDK.configure do |c| - c.add_span_processor SPAN_PROCESSOR -end - -def wait_for(max_attempts: 10, retry_delay: 0.10, error_message:) - attempts = 0 - while attempts < max_attempts - return if yield - - attempts += 1 - raise error_message if attempts >= max_attempts - - sleep retry_delay - end -end diff --git a/instrumentation/sidekiq/.rubocop.yml b/instrumentation/sidekiq/.rubocop.yml deleted file mode 100644 index dfba591b17..0000000000 --- a/instrumentation/sidekiq/.rubocop.yml +++ /dev/null @@ -1,9 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -Style/AsciiComments: - Enabled: false -Naming/AsciiIdentifiers: - Enabled: false -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-sidekiq.rb" diff --git a/instrumentation/sidekiq/.yardopts b/instrumentation/sidekiq/.yardopts deleted file mode 100644 index 9f610acacb..0000000000 --- a/instrumentation/sidekiq/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Sidekiq Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/sidekiq/Appraisals b/instrumentation/sidekiq/Appraisals deleted file mode 100644 index fb1c05ee17..0000000000 --- a/instrumentation/sidekiq/Appraisals +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -appraise 'sidekiq-6.5' do - gem 'sidekiq', '~> 6.5' -end - -appraise 'sidekiq-6.4' do - gem 'sidekiq', '~> 6.4' -end - -appraise 'sidekiq-6.3' do - gem 'sidekiq', '~> 6.3' -end - -appraise 'sidekiq-6.1' do - gem 'sidekiq', '~> 6.1' -end - -appraise 'sidekiq-6.0' do - gem 'sidekiq', '~> 6.0' -end - -appraise 'sidekiq-5.2' do - gem 'sidekiq', '~> 5.2' -end - -appraise 'sidekiq-4.2' do - gem 'sidekiq', '~> 4.2' -end diff --git a/instrumentation/sidekiq/CHANGELOG.md b/instrumentation/sidekiq/CHANGELOG.md deleted file mode 100644 index d306fbfe78..0000000000 --- a/instrumentation/sidekiq/CHANGELOG.md +++ /dev/null @@ -1,107 +0,0 @@ -# Release History: opentelemetry-instrumentation-sidekiq - -### v0.22.0 / 2022-06-09 - -* Upgrading Base dependency version - -### v0.21.1 / 2022-06-09 - -* FIXED: Broken test file requirements -* FIXED: Make sidekiq instrumentation compatible with sidekiq 6.5.0 - -### v0.21.0 / 2022-05-02 - -* ADDED: Validate Using Enums -* FIXED: RubyGems Fallback - -### v0.20.2 / 2021-12-02 - -* (No significant changes) - -### v0.20.1 / 2021-09-29 - -* (No significant changes) - -### v0.20.0 / 2021-08-18 - -* ADDED: Gracefully flush provider on sidekiq shutdown event - -### v0.19.1 / 2021-08-12 - -* (No significant changes) - -### v0.19.0 / 2021-06-23 - -* BREAKING CHANGE: Sidekiq propagation config - - Config option enable_job_class_span_names renamed to span_naming and now expects a symbol of value :job_class, or :queue - - The default behaviour is no longer to have one continuous trace for the enqueue and process spans, using links is the new default. To maintain the previous behaviour the config option propagation_style must be set to :child. -* BREAKING CHANGE: Total order constraint on span.status= - -* FIXED: Sidekiq propagation config -* FIXED: Total order constraint on span.status= - -### v0.18.0 / 2021-05-21 - -* ADDED: Updated API depedency for 1.0.0.rc1 -* TEST: update test for redis instrumentation refactor [#760](https://github.com/open-telemetry/opentelemetry-ruby/pull/760) -* BREAKING CHANGE: Remove optional parent_context from in_span - -* FIXED: Remove optional parent_context from in_span -* FIXED: Instrument Redis more thoroughly by patching Client#process. - -### v0.17.0 / 2021-04-22 - -* ADDED: Accept config for sidekiq peer service attribute - -### v0.16.0 / 2021-03-17 - -* FIXED: Example scripts now reference local common lib -* DOCS: Replace Gitter with GitHub Discussions - -### v0.15.0 / 2021-02-18 - -* ADDED: Add instrumentation config validation - -### v0.14.0 / 2021-02-03 - -* BREAKING CHANGE: Replace getter and setter callables and remove rack specific propagators - -* ADDED: Replace getter and setter callables and remove rack specific propagators - -### v0.13.0 / 2021-01-29 - -* ADDED: Instrument sidekiq background work -* FIXED: Adjust Sidekiq middlewares to match semantic conventions -* FIXED: Set minimum compatible version and use untraced helper - -### v0.12.0 / 2020-12-24 - -* (No significant changes) - -### v0.11.0 / 2020-12-11 - -* FIXED: Copyright comments to not reference year - -### v0.10.0 / 2020-12-03 - -* (No significant changes) - -### v0.9.0 / 2020-11-27 - -* BREAKING CHANGE: Add timeout for force_flush and shutdown - -* ADDED: Add timeout for force_flush and shutdown - -### v0.8.0 / 2020-10-27 - -* (No significant changes) - -### v0.7.0 / 2020-10-07 - -* DOCS: Adding README for Sidekiq instrumentation -* DOCS: Remove duplicate reference in Sidekiq README -* DOCS: Standardize toplevel docs structure and readme - -### v0.6.0 / 2020-09-10 - -* (No significant changes) diff --git a/instrumentation/sidekiq/Gemfile b/instrumentation/sidekiq/Gemfile deleted file mode 100644 index 84efc8a188..0000000000 --- a/instrumentation/sidekiq/Gemfile +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :test do - gem 'opentelemetry-instrumentation-base', path: '../base' - gem 'opentelemetry-instrumentation-redis', path: '../redis' - gem 'pry-byebug' -end diff --git a/instrumentation/sidekiq/LICENSE b/instrumentation/sidekiq/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/sidekiq/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/sidekiq/README.md b/instrumentation/sidekiq/README.md deleted file mode 100644 index 392c073654..0000000000 --- a/instrumentation/sidekiq/README.md +++ /dev/null @@ -1,61 +0,0 @@ -# OpenTelemetry Sidekiq Instrumentation - -The Sidekiq instrumentation is a community-maintained instrumentation for the [Sidekiq][sidekiq-home] Ruby jobs system. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-sidekiq -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-sidekiq` in your `Gemfile`. - -## Usage - -To use the instrumentation, call `use` with the name of the instrumentation: - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Sidekiq' -end -``` - -Alternatively, you can also call `use_all` to install all the available instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` -## Examples - -Example usage can be seen in the `./example/sidekiq.rb` file [here](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/instrumentation/sidekiq/example/sidekiq.rb) - -## Development - -You'll need Redis installed locally to run the test suite. Once you've -installed it, it will start and stop automatically when you run `rake`. - -``` -redis-server test/redis.conf -``` - -## How can I get involved? - -The `opentelemetry-instrumentation-sidekiq` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -The `opentelemetry-instrumentation-sidekiq` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information. - -[sidekiq-home]: https://github.com/mperham/sidekiq -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/instrumentation/sidekiq/Rakefile b/instrumentation/sidekiq/Rakefile deleted file mode 100644 index a37e94eb76..0000000000 --- a/instrumentation/sidekiq/Rakefile +++ /dev/null @@ -1,36 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -task :start_redis do - @redis_pid = fork { exec 'redis-server test/redis.conf' } -end - -Rake::TestTask.new test: :start_redis do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] - t.warning = false - at_exit do - Process.kill('USR1', @redis_pid) if @redis_pid - end -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/sidekiq/example/Gemfile b/instrumentation/sidekiq/example/Gemfile deleted file mode 100644 index 930ee6b044..0000000000 --- a/instrumentation/sidekiq/example/Gemfile +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -source 'https://rubygems.org' - -gem 'opentelemetry-api' -gem 'opentelemetry-common' -gem 'opentelemetry-instrumentation-base' -gem 'opentelemetry-instrumentation-sidekiq' -gem 'opentelemetry-sdk' - -gem 'sidekiq' diff --git a/instrumentation/sidekiq/example/sidekiq.rb b/instrumentation/sidekiq/example/sidekiq.rb deleted file mode 100644 index e19ec24b54..0000000000 --- a/instrumentation/sidekiq/example/sidekiq.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -require 'rubygems' -require 'bundler/setup' - -Bundler.require - -# Export traces to console by default -ENV['OTEL_TRACES_EXPORTER'] ||= 'console' - -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Sidekiq' -end - -# A basic Sidekiq job worker example -class SimpleJob - include Sidekiq::Worker - - def perform - puts "Workin'" - end -end - -SimpleJob.perform_async diff --git a/instrumentation/sidekiq/lib/opentelemetry-instrumentation-sidekiq.rb b/instrumentation/sidekiq/lib/opentelemetry-instrumentation-sidekiq.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/sidekiq/lib/opentelemetry-instrumentation-sidekiq.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/sidekiq/lib/opentelemetry/instrumentation.rb b/instrumentation/sidekiq/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index a1f91cbea5..0000000000 --- a/instrumentation/sidekiq/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # "Instrumentation" are specified by - # https://github.com/open-telemetry/opentelemetry-specification/blob/784635d01d8690c8f5fcd1f55bdbc8a13cf2f4f2/specification/glossary.md#instrumentation-library - # - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/sidekiq' diff --git a/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq.rb b/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq.rb deleted file mode 100644 index e9290bb875..0000000000 --- a/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the Sidekiq gem - module Sidekiq - end - end -end - -require_relative './sidekiq/instrumentation' -require_relative './sidekiq/version' -require 'opentelemetry/common' diff --git a/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/instrumentation.rb b/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/instrumentation.rb deleted file mode 100644 index 0101c5fd98..0000000000 --- a/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/instrumentation.rb +++ /dev/null @@ -1,94 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Sidekiq - # The Instrumentation class contains logic to detect and install the Sidekiq - # instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - MINIMUM_VERSION = Gem::Version.new('4.2.10') - - install do |_config| - require_dependencies - add_client_middleware - add_server_middleware - patch_on_startup - end - - present do - defined?(::Sidekiq) - end - - compatible do - gem_version >= MINIMUM_VERSION - end - - option :span_naming, default: :queue, validate: %I[job_class queue] - option :propagation_style, default: :link, validate: %i[link child none] - option :trace_launcher_heartbeat, default: false, validate: :boolean - option :trace_poller_enqueue, default: false, validate: :boolean - option :trace_poller_wait, default: false, validate: :boolean - option :trace_processor_process_one, default: false, validate: :boolean - option :peer_service, default: nil, validate: :string - - private - - def gem_version - Gem::Version.new(::Sidekiq::VERSION) - end - - def require_dependencies - require_relative 'middlewares/client/tracer_middleware' - require_relative 'middlewares/server/tracer_middleware' - - require_relative 'patches/processor' - require_relative 'patches/launcher' - require_relative 'patches/poller' - end - - def patch_on_startup - ::Sidekiq.configure_server do |config| - config.on(:startup) do - ::Sidekiq::Processor.prepend(Patches::Processor) - ::Sidekiq::Launcher.prepend(Patches::Launcher) - ::Sidekiq::Scheduled::Poller.prepend(Patches::Poller) - end - - config.on(:shutdown) do - OpenTelemetry.tracer_provider.shutdown - end - end - end - - def add_client_middleware - ::Sidekiq.configure_client do |config| - config.client_middleware do |chain| - chain.add Middlewares::Client::TracerMiddleware - end - end - end - - def add_server_middleware - ::Sidekiq.configure_server do |config| - config.client_middleware do |chain| - chain.add Middlewares::Client::TracerMiddleware - end - config.server_middleware do |chain| - chain.add Middlewares::Server::TracerMiddleware - end - end - - if defined?(::Sidekiq::Testing) # rubocop:disable Style/GuardClause - ::Sidekiq::Testing.server_middleware do |chain| - chain.add Middlewares::Server::TracerMiddleware - end - end - end - end - end - end -end diff --git a/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/middlewares/client/tracer_middleware.rb b/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/middlewares/client/tracer_middleware.rb deleted file mode 100644 index ee745400a7..0000000000 --- a/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/middlewares/client/tracer_middleware.rb +++ /dev/null @@ -1,51 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Sidekiq - module Middlewares - module Client - # TracerMiddleware propagates context and instruments Sidekiq client - # by way of its middleware system - class TracerMiddleware - def call(_worker_class, job, _queue, _redis_pool) # rubocop:disable Metrics/AbcSize - attributes = { - 'messaging.system' => 'sidekiq', - 'messaging.sidekiq.job_class' => job['wrapped']&.to_s || job['class'], - 'messaging.message_id' => job['jid'], - 'messaging.destination' => job['queue'], - 'messaging.destination_kind' => 'queue' - } - attributes['peer.service'] = instrumentation_config[:peer_service] if instrumentation_config[:peer_service] - - span_name = case instrumentation_config[:span_naming] - when :job_class then "#{job['wrapped']&.to_s || job['class']} send" - else "#{job['queue']} send" - end - - tracer.in_span(span_name, attributes: attributes, kind: :producer) do |span| - OpenTelemetry.propagation.inject(job) - span.add_event('created_at', timestamp: job['created_at']) - yield - end - end - - private - - def instrumentation_config - Sidekiq::Instrumentation.instance.config - end - - def tracer - Sidekiq::Instrumentation.instance.tracer - end - end - end - end - end - end -end diff --git a/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/middlewares/server/tracer_middleware.rb b/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/middlewares/server/tracer_middleware.rb deleted file mode 100644 index c773ad60b3..0000000000 --- a/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/middlewares/server/tracer_middleware.rb +++ /dev/null @@ -1,73 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Sidekiq - module Middlewares - module Server - # TracerMiddleware propagates context and instruments Sidekiq requests - # by way of its middleware system - class TracerMiddleware - def call(_worker, msg, _queue) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity - attributes = { - 'messaging.system' => 'sidekiq', - 'messaging.sidekiq.job_class' => msg['wrapped']&.to_s || msg['class'], - 'messaging.message_id' => msg['jid'], - 'messaging.destination' => msg['queue'], - 'messaging.destination_kind' => 'queue', - 'messaging.operation' => 'process' - } - attributes['peer.service'] = instrumentation_config[:peer_service] if instrumentation_config[:peer_service] - - span_name = case instrumentation_config[:span_naming] - when :job_class then "#{msg['wrapped']&.to_s || msg['class']} process" - else "#{msg['queue']} process" - end - - extracted_context = OpenTelemetry.propagation.extract(msg) - OpenTelemetry::Context.with_current(extracted_context) do - if instrumentation_config[:propagation_style] == :child - tracer.in_span(span_name, attributes: attributes, kind: :consumer) do |span| - span.add_event('created_at', timestamp: msg['created_at']) - span.add_event('enqueued_at', timestamp: msg['enqueued_at']) - yield - end - else - links = [] - span_context = OpenTelemetry::Trace.current_span(extracted_context).context - links << OpenTelemetry::Trace::Link.new(span_context) if instrumentation_config[:propagation_style] == :link && span_context.valid? - span = tracer.start_root_span(span_name, attributes: attributes, links: links, kind: :consumer) - OpenTelemetry::Trace.with_span(span) do - span.add_event('created_at', timestamp: msg['created_at']) - span.add_event('enqueued_at', timestamp: msg['enqueued_at']) - yield - rescue Exception => e # rubocop:disable Lint/RescueException - span.record_exception(e) - span.status = OpenTelemetry::Trace::Status.error("Unhandled exception of type: #{e.class}") - raise e - ensure - span.finish - end - end - end - end - - private - - def instrumentation_config - Sidekiq::Instrumentation.instance.config - end - - def tracer - Sidekiq::Instrumentation.instance.tracer - end - end - end - end - end - end -end diff --git a/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/patches/launcher.rb b/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/patches/launcher.rb deleted file mode 100644 index 0ede355bea..0000000000 --- a/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/patches/launcher.rb +++ /dev/null @@ -1,36 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Sidekiq - module Patches - # The Launcher module contains the instrumentation for the Sidekiq heartbeat - module Launcher - private - - def ❤ # rubocop:disable Naming/MethodName - if instrumentation_config[:trace_launcher_heartbeat] - attributes = {} - attributes['peer.service'] = instrumentation_config[:peer_service] if instrumentation_config[:peer_service] - tracer.in_span('Sidekiq::Launcher#heartbeat', attributes: attributes) { super } - else - OpenTelemetry::Common::Utilities.untraced { super } - end - end - - def tracer - Sidekiq::Instrumentation.instance.tracer - end - - def instrumentation_config - Sidekiq::Instrumentation.instance.config - end - end - end - end - end -end diff --git a/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/patches/poller.rb b/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/patches/poller.rb deleted file mode 100644 index e0b64aacfa..0000000000 --- a/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/patches/poller.rb +++ /dev/null @@ -1,44 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Sidekiq - module Patches - # The Poller module contains instrumentation for the enqueue and wait methods - module Poller - def enqueue - if instrumentation_config[:trace_poller_enqueue] - attributes = {} - attributes['peer.service'] = instrumentation_config[:peer_service] if instrumentation_config[:peer_service] - tracer.in_span('Sidekiq::Scheduled::Poller#enqueue', attributes: attributes) { super } - else - OpenTelemetry::Common::Utilities.untraced { super } - end - end - - private - - def wait - if instrumentation_config[:trace_poller_wait] - tracer.in_span('Sidekiq::Scheduled::Poller#wait') { super } - else - OpenTelemetry::Common::Utilities.untraced { super } - end - end - - def tracer - Sidekiq::Instrumentation.instance.tracer - end - - def instrumentation_config - Sidekiq::Instrumentation.instance.config - end - end - end - end - end -end diff --git a/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/patches/processor.rb b/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/patches/processor.rb deleted file mode 100644 index b9845bd509..0000000000 --- a/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/patches/processor.rb +++ /dev/null @@ -1,36 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Sidekiq - module Patches - # The Processor module contains the instrumentation for the process_one method - module Processor - private - - def process_one - if instrumentation_config[:trace_processor_process_one] - attributes = {} - attributes['peer.service'] = instrumentation_config[:peer_service] if instrumentation_config[:peer_service] - tracer.in_span('Sidekiq::Processor#process_one', attributes: attributes) { super } - else - OpenTelemetry::Common::Utilities.untraced { super } - end - end - - def tracer - Sidekiq::Instrumentation.instance.tracer - end - - def instrumentation_config - Sidekiq::Instrumentation.instance.config - end - end - end - end - end -end diff --git a/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/version.rb b/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/version.rb deleted file mode 100644 index b366b0294a..0000000000 --- a/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Sidekiq - VERSION = '0.22.0' - end - end -end diff --git a/instrumentation/sidekiq/opentelemetry-instrumentation-sidekiq.gemspec b/instrumentation/sidekiq/opentelemetry-instrumentation-sidekiq.gemspec deleted file mode 100644 index ee4cc850a2..0000000000 --- a/instrumentation/sidekiq/opentelemetry-instrumentation-sidekiq.gemspec +++ /dev/null @@ -1,51 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/sidekiq/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-sidekiq' - spec.version = OpenTelemetry::Instrumentation::Sidekiq::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'Sidekiq instrumentation for the OpenTelemetry framework' - spec.description = 'Sidekiq instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-common', '~> 0.19.3' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.21.0' - - spec.add_development_dependency 'activejob', '>= 5.2' - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'rspec-mocks' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'sidekiq', '~> 5.2.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-sidekiq/v#{OpenTelemetry::Instrumentation::Sidekiq::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/sidekiq' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-sidekiq/v#{OpenTelemetry::Instrumentation::Sidekiq::VERSION}" - end -end diff --git a/instrumentation/sidekiq/test/.rubocop.yml b/instrumentation/sidekiq/test/.rubocop.yml deleted file mode 100644 index e97eda560f..0000000000 --- a/instrumentation/sidekiq/test/.rubocop.yml +++ /dev/null @@ -1,6 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false -Style/MultilineIfModifier: - Enabled: false diff --git a/instrumentation/sidekiq/test/helpers/mock_loader.rb b/instrumentation/sidekiq/test/helpers/mock_loader.rb deleted file mode 100644 index f099bd6cdc..0000000000 --- a/instrumentation/sidekiq/test/helpers/mock_loader.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'sidekiq/cli' -require 'sidekiq/launcher' - -class MockLoader - include Sidekiq::Util - - attr_reader :launcher - - def initialize - fire_event(:startup) - options = ::Sidekiq.options - options[:queues] << 'default' - @launcher = Sidekiq::Launcher.new(options) - end - - def poller - launcher.poller - end - - def manager - launcher.manager - end -end diff --git a/instrumentation/sidekiq/test/helpers/mock_loader_new_launcher.rb b/instrumentation/sidekiq/test/helpers/mock_loader_new_launcher.rb deleted file mode 100644 index 91d93c784f..0000000000 --- a/instrumentation/sidekiq/test/helpers/mock_loader_new_launcher.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'sidekiq/cli' -require 'sidekiq/launcher' - -class MockLoader - attr_reader :launcher - - def initialize - Sidekiq[:queues] << 'default' - - @launcher = Sidekiq::Launcher.new(Sidekiq) - @launcher.fire_event(:startup) - end - - def poller - launcher.poller - end - - def manager - launcher.manager - end -end diff --git a/instrumentation/sidekiq/test/opentelemetry/instrumentation/sidekiq/instrumentation_test.rb b/instrumentation/sidekiq/test/opentelemetry/instrumentation/sidekiq/instrumentation_test.rb deleted file mode 100644 index 72d50e62b5..0000000000 --- a/instrumentation/sidekiq/test/opentelemetry/instrumentation/sidekiq/instrumentation_test.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' -require_relative '../../../../lib/opentelemetry/instrumentation/sidekiq' - -describe OpenTelemetry::Instrumentation::Sidekiq::Instrumentation do - let(:instrumentation) { OpenTelemetry::Instrumentation::Sidekiq::Instrumentation.instance } - - it 'has #name' do - _(instrumentation.name).must_equal 'OpenTelemetry::Instrumentation::Sidekiq' - end - - it 'has #version' do - _(instrumentation.version).wont_be_nil - _(instrumentation.version).wont_be_empty - end - - describe 'compatible' do - it 'when older gem version installed' do - stub_const('::Sidekiq::VERSION', '4.2.8') - _(instrumentation.compatible?).must_equal false - end - - it 'when future gem version installed' do - _(instrumentation.compatible?).must_equal true - end - end -end diff --git a/instrumentation/sidekiq/test/opentelemetry/instrumentation/sidekiq/middlewares/client/tracer_middleware_test.rb b/instrumentation/sidekiq/test/opentelemetry/instrumentation/sidekiq/middlewares/client/tracer_middleware_test.rb deleted file mode 100644 index b76c490c4a..0000000000 --- a/instrumentation/sidekiq/test/opentelemetry/instrumentation/sidekiq/middlewares/client/tracer_middleware_test.rb +++ /dev/null @@ -1,85 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' -require_relative '../../../../../../lib/opentelemetry/instrumentation/sidekiq' -require_relative '../../../../../../lib/opentelemetry/instrumentation/sidekiq/middlewares/client/tracer_middleware' - -describe OpenTelemetry::Instrumentation::Sidekiq::Middlewares::Client::TracerMiddleware do - let(:instrumentation) { OpenTelemetry::Instrumentation::Sidekiq::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:spans) { exporter.finished_spans } - let(:enqueue_span) { spans.first } - let(:config) { {} } - - before do - instrumentation.install(config) - exporter.reset - end - - after do - instrumentation.instance_variable_set(:@installed, false) - Sidekiq::Worker.drain_all - end - - describe 'process spans' do - it 'before performing any jobs' do - _(exporter.finished_spans.size).must_equal 0 - end - - it 'traces enqueing' do - job_id = SimpleJob.perform_async - - _(exporter.finished_spans.size).must_equal 1 - - _(enqueue_span.name).must_equal 'default send' - _(enqueue_span.kind).must_equal :producer - _(enqueue_span.parent_span_id).must_equal OpenTelemetry::Trace::INVALID_SPAN_ID - _(enqueue_span.attributes['messaging.system']).must_equal 'sidekiq' - _(enqueue_span.attributes['messaging.sidekiq.job_class']).must_equal 'SimpleJob' - _(enqueue_span.attributes['messaging.message_id']).must_equal job_id - _(enqueue_span.attributes['messaging.destination']).must_equal 'default' - _(enqueue_span.attributes['messaging.destination_kind']).must_equal 'queue' - _(enqueue_span.events.size).must_equal(1) - _(enqueue_span.events[0].name).must_equal('created_at') - end - - it 'traces when enqueued with Active Job' do - SimpleJobWithActiveJob.perform_later(1, 2) - _(enqueue_span.name).must_equal('default send') - _(enqueue_span.attributes['messaging.system']).must_equal('sidekiq') - _(enqueue_span.attributes['messaging.sidekiq.job_class']).must_equal('SimpleJobWithActiveJob') - _(enqueue_span.attributes['messaging.destination']).must_equal('default') - _(enqueue_span.attributes['messaging.destination_kind']).must_equal('queue') - end - - describe 'when span_naming is job_class' do - let(:config) { { span_naming: :job_class } } - - it 'uses the job class name for the span name' do - SimpleJob.perform_async - - _(enqueue_span.name).must_equal('SimpleJob send') - end - - it 'uses the job class name when enqueued with Active Job' do - SimpleJobWithActiveJob.perform_later(1, 2) - _(enqueue_span.name).must_equal('SimpleJobWithActiveJob send') - end - end - - describe 'when peer_service config is set' do - let(:config) { { peer_service: 'MySidekiqService' } } - - it 'after performing a simple job' do - SimpleJob.perform_async - SimpleJob.drain - - _(enqueue_span.attributes['peer.service']).must_equal 'MySidekiqService' - end - end - end -end diff --git a/instrumentation/sidekiq/test/opentelemetry/instrumentation/sidekiq/middlewares/server/tracer_middleware_test.rb b/instrumentation/sidekiq/test/opentelemetry/instrumentation/sidekiq/middlewares/server/tracer_middleware_test.rb deleted file mode 100644 index 716ca83730..0000000000 --- a/instrumentation/sidekiq/test/opentelemetry/instrumentation/sidekiq/middlewares/server/tracer_middleware_test.rb +++ /dev/null @@ -1,256 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' -require_relative '../../../../../../lib/opentelemetry/instrumentation/sidekiq' -require_relative '../../../../../../lib/opentelemetry/instrumentation/sidekiq/middlewares/server/tracer_middleware' - -describe OpenTelemetry::Instrumentation::Sidekiq::Middlewares::Server::TracerMiddleware do - let(:instrumentation) { OpenTelemetry::Instrumentation::Sidekiq::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:spans) { exporter.finished_spans } - let(:enqueuer_span) { spans.first } - let(:job_span) { spans.last } - let(:root_span) { spans.find { |s| s.parent_span_id == OpenTelemetry::Trace::INVALID_SPAN_ID } } - let(:config) { {} } - - before do - instrumentation.install(config) - exporter.reset - end - - after { instrumentation.instance_variable_set(:@installed, false) } - - describe 'enqueue spans' do - it 'before performing any jobs' do - _(exporter.finished_spans.size).must_equal 0 - end - - it 'traces processing' do - job_id = SimpleJob.perform_async - SimpleJob.drain - - _(exporter.finished_spans.size).must_equal 2 - - _(job_span.name).must_equal 'default process' - _(job_span.kind).must_equal :consumer - _(job_span.attributes['messaging.system']).must_equal 'sidekiq' - _(job_span.attributes['messaging.sidekiq.job_class']).must_equal 'SimpleJob' - _(job_span.attributes['messaging.message_id']).must_equal job_id - _(job_span.attributes['messaging.destination']).must_equal 'default' - _(job_span.attributes['messaging.destination_kind']).must_equal 'queue' - _(job_span.attributes['messaging.operation']).must_equal 'process' - _(job_span.attributes['peer.service']).must_be_nil - _(job_span.events.size).must_equal(2) - _(job_span.events[0].name).must_equal('created_at') - _(job_span.events[1].name).must_equal('enqueued_at') - end - - it 'traces when enqueued with Active Job' do - SimpleJobWithActiveJob.perform_later(1, 2) - Sidekiq::Worker.drain_all - - _(job_span.name).must_equal('default process') - _(job_span.attributes['messaging.system']).must_equal('sidekiq') - _(job_span.attributes['messaging.sidekiq.job_class']).must_equal('SimpleJobWithActiveJob') - _(job_span.attributes['messaging.destination']).must_equal('default') - _(job_span.attributes['messaging.destination_kind']).must_equal('queue') - _(job_span.attributes['messaging.operation']).must_equal 'process' - end - - it 'defaults to using links to the enqueing span but does not continue the trace' do - SimpleJob.perform_async - SimpleJob.drain - - _(job_span.links.first.span_context.span_id).must_equal(enqueuer_span.span_id) - _(job_span.links.first.span_context.trace_id).must_equal(enqueuer_span.trace_id) - - _(job_span.parent_span_id).wont_equal(enqueuer_span.span_id) - _(job_span.trace_id).wont_equal(enqueuer_span.trace_id) - end - - describe 'when peer_service config is set' do - let(:config) { { peer_service: 'MySidekiqService' } } - - it 'after performing a simple job' do - SimpleJob.perform_async - SimpleJob.drain - - _(job_span.attributes['peer.service']).must_equal 'MySidekiqService' - end - end - - describe 'when span_naming is job_class' do - let(:config) { { span_naming: :job_class } } - - it 'uses the job class name for the span name' do - SimpleJob.perform_async - SimpleJob.drain - - _(job_span.name).must_equal('SimpleJob process') - end - - it 'uses the job class name when enqueued with Active Job' do - SimpleJobWithActiveJob.perform_later(1, 2) - Sidekiq::Worker.drain_all - - _(job_span.name).must_equal('SimpleJobWithActiveJob process') - end - end - - describe 'when propagation_style is link' do - let(:config) { { propagation_style: :link } } - - it 'continues the enqueuer trace to the job process' do - SimpleJob.perform_async - SimpleJob.drain - - _(job_span.links.first.span_context.span_id).must_equal(enqueuer_span.span_id) - _(job_span.links.first.span_context.trace_id).must_equal(enqueuer_span.trace_id) - - _(job_span.parent_span_id).wont_equal(enqueuer_span.span_id) - _(job_span.trace_id).wont_equal(enqueuer_span.trace_id) - end - - it 'fan out jobs are linked' do - SimpleEnqueueingJob.perform_async - Sidekiq::Worker.drain_all - - _(exporter.finished_spans.size).must_equal 4 - - # root job that enqueues another job - _(root_span.parent_span_id).must_equal OpenTelemetry::Trace::INVALID_SPAN_ID - _(root_span.name).must_equal 'default send' - _(root_span.kind).must_equal :producer - - # process span is linked to the root enqueuing job - child_span1 = spans.find { |s| s.links && s.links.first.span_context.span_id == root_span.span_id } - _(child_span1.name).must_equal 'default process' - _(child_span1.kind).must_equal :consumer - - # enquene span is child to the parent process job - child_span2 = spans.find { |s| s.parent_span_id == child_span1.span_id } - _(child_span2.name).must_equal 'default send' - _(child_span2.kind).must_equal :producer - - # last process job is linked back to the process job that enqueued it - child_span3 = spans.find { |s| s.links && s.links.first.span_context.span_id == child_span2.span_id } - _(child_span3.name).must_equal 'default process' - _(child_span3.kind).must_equal :consumer - end - - it 'propagates baggage' do - ctx = OpenTelemetry::Baggage.set_value('testing_baggage', 'it_worked') - OpenTelemetry::Context.with_current(ctx) do - BaggageTestingJob.perform_async - end - - Sidekiq::Worker.drain_all - - _(job_span.attributes['success']).must_equal(true) - end - - it 'records exceptions' do - ExceptionTestingJob.perform_async - _(-> { Sidekiq::Worker.drain_all }).must_raise(RuntimeError) - - ev = job_span.events - _(ev[2].attributes['exception.type']).must_equal('RuntimeError') - _(ev[2].attributes['exception.message']).must_equal('a little hell') - _(ev[2].attributes['exception.stacktrace']).wont_be_nil - end - end - - describe 'when propagation_style is child' do - let(:config) { { propagation_style: :child } } - - it 'continues the enqueuer trace to the job process' do - SimpleJob.perform_async - SimpleJob.drain - - _(job_span.parent_span_id).must_equal(enqueuer_span.span_id) - _(job_span.trace_id).must_equal(enqueuer_span.trace_id) - end - - it 'fan out jobs are a continous trace' do - SimpleEnqueueingJob.perform_async - Sidekiq::Worker.drain_all - - _(exporter.finished_spans.size).must_equal 4 - - _(root_span.parent_span_id).must_equal OpenTelemetry::Trace::INVALID_SPAN_ID - _(root_span.name).must_equal 'default send' - _(root_span.kind).must_equal :producer - - child_span1 = spans.find { |s| s.parent_span_id == root_span.span_id } - _(child_span1.name).must_equal 'default process' - _(child_span1.kind).must_equal :consumer - - child_span2 = spans.find { |s| s.parent_span_id == child_span1.span_id } - _(child_span2.name).must_equal 'default send' - _(child_span2.kind).must_equal :producer - - child_span3 = spans.find { |s| s.parent_span_id == child_span2.span_id } - _(child_span3.name).must_equal 'default process' - _(child_span3.kind).must_equal :consumer - end - - it 'propagates baggage' do - ctx = OpenTelemetry::Baggage.set_value('testing_baggage', 'it_worked') - OpenTelemetry::Context.with_current(ctx) do - BaggageTestingJob.perform_async - end - - Sidekiq::Worker.drain_all - - _(job_span.attributes['success']).must_equal(true) - end - - it 'records exceptions' do - ExceptionTestingJob.perform_async - _(-> { Sidekiq::Worker.drain_all }).must_raise(RuntimeError) - - ev = job_span.events - _(ev[2].attributes['exception.type']).must_equal('RuntimeError') - _(ev[2].attributes['exception.message']).must_equal('a little hell') - _(ev[2].attributes['exception.stacktrace']).wont_be_nil - end - end - - describe 'when propagation_style is none' do - let(:config) { { propagation_style: :none } } - - it 'continues the enqueuer trace to the job process' do - SimpleJob.perform_async - SimpleJob.drain - - _(job_span.parent_span_id).wont_equal(enqueuer_span.span_id) - _(job_span.trace_id).wont_equal(enqueuer_span.trace_id) - end - - it 'propagates baggage' do - ctx = OpenTelemetry::Baggage.set_value('testing_baggage', 'it_worked') - OpenTelemetry::Context.with_current(ctx) do - BaggageTestingJob.perform_async - end - - Sidekiq::Worker.drain_all - - _(job_span.attributes['success']).must_equal(true) - end - - it 'records exceptions' do - ExceptionTestingJob.perform_async - _(-> { Sidekiq::Worker.drain_all }).must_raise(RuntimeError) - - ev = job_span.events - _(ev[2].attributes['exception.type']).must_equal('RuntimeError') - _(ev[2].attributes['exception.message']).must_equal('a little hell') - _(ev[2].attributes['exception.stacktrace']).wont_be_nil - end - end - end -end diff --git a/instrumentation/sidekiq/test/opentelemetry/instrumentation/sidekiq/patches/launcher_test.rb b/instrumentation/sidekiq/test/opentelemetry/instrumentation/sidekiq/patches/launcher_test.rb deleted file mode 100644 index 3f0c1e230d..0000000000 --- a/instrumentation/sidekiq/test/opentelemetry/instrumentation/sidekiq/patches/launcher_test.rb +++ /dev/null @@ -1,63 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require 'opentelemetry-instrumentation-redis' - -require_relative '../../../../../lib/opentelemetry/instrumentation/sidekiq' -require_relative '../../../../../lib/opentelemetry/instrumentation/sidekiq/patches/launcher' - -describe OpenTelemetry::Instrumentation::Sidekiq::Patches::Launcher do - let(:instrumentation) { OpenTelemetry::Instrumentation::Sidekiq::Instrumentation.instance } - let(:redis_instrumentation) { OpenTelemetry::Instrumentation::Redis::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:spans) { exporter.finished_spans } - let(:span) { spans.first } - let(:config) { {} } - let(:launcher) { MockLoader.new.launcher } - - before do - # Clear spans - exporter.reset - redis_instrumentation.install - instrumentation.install(config) - end - - after do - # Force re-install of instrumentation - redis_instrumentation.instance_variable_set(:@installed, false) - instrumentation.instance_variable_set(:@installed, false) - end - - # The method being tested here is `❤` - describe '#heartbeat' do - it 'does not trace' do - launcher.send(:❤) - _(spans.size).must_equal(0) - end - - describe 'when heartbeat tracing is enabled' do - let(:config) { { trace_launcher_heartbeat: true } } - - it 'traces' do - launcher.send(:❤) - span_names = spans.map(&:name) - _(span_names).must_include('Sidekiq::Launcher#heartbeat') - _(span_names).must_include('PIPELINED') - end - - describe 'when peer_service config is set' do - let(:config) { { trace_launcher_heartbeat: true, peer_service: 'MySidekiqService' } } - it 'add peer.service info' do - launcher.send(:❤) - span = spans.last - _(span.attributes['peer.service']).must_equal 'MySidekiqService' - end - end - end - end -end diff --git a/instrumentation/sidekiq/test/opentelemetry/instrumentation/sidekiq/patches/poller_test.rb b/instrumentation/sidekiq/test/opentelemetry/instrumentation/sidekiq/patches/poller_test.rb deleted file mode 100644 index 31357dbda9..0000000000 --- a/instrumentation/sidekiq/test/opentelemetry/instrumentation/sidekiq/patches/poller_test.rb +++ /dev/null @@ -1,86 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require 'opentelemetry-instrumentation-redis' - -require_relative '../../../../../lib/opentelemetry/instrumentation/sidekiq' -require_relative '../../../../../lib/opentelemetry/instrumentation/sidekiq/patches/poller' - -describe OpenTelemetry::Instrumentation::Sidekiq::Patches::Poller do - let(:instrumentation) { OpenTelemetry::Instrumentation::Sidekiq::Instrumentation.instance } - let(:redis_instrumentation) { OpenTelemetry::Instrumentation::Redis::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:spans) { exporter.finished_spans } - let(:span) { spans.first } - let(:config) { {} } - let(:poller) { MockLoader.new.poller } - - before do - # Clear spans - exporter.reset - redis_instrumentation.install - instrumentation.install(config) - end - - after do - # Force re-install of instrumentation - redis_instrumentation.instance_variable_set(:@installed, false) - instrumentation.instance_variable_set(:@installed, false) - end - - describe '#enqueue' do - it 'does not trace' do - poller.enqueue - _(spans.size).must_equal(0) - end - - describe 'when enqueue tracing is enabled' do - let(:config) { { trace_poller_enqueue: true } } - - it 'traces' do - poller.enqueue - span_names = spans.map(&:name) - _(span_names).must_include('Sidekiq::Scheduled::Poller#enqueue') - # Inline Lua uses a different redis client method in 6.3+ https://github.com/mperham/sidekiq/pull/5044 - _(span_names).must_include('ZRANGEBYSCORE') if Gem.loaded_specs['sidekiq'].version < Gem::Version.new('6.3') - end - - describe 'when peer_service config is set' do - let(:config) { { trace_poller_enqueue: true, peer_service: 'MySidekiqService' } } - it 'add peer.service info' do - poller.enqueue - span = spans.last - _(span.attributes['peer.service']).must_equal 'MySidekiqService' - end - end - end - end unless ENV['OMIT_SERVICES'] - - describe '#wait' do - it 'does not trace' do - poller.stub(:random_poll_interval, 0.0) do - poller.send(:wait) - end - - _(spans.size).must_equal(0) - end - - describe 'when wait tracing is enabled' do - let(:config) { { trace_poller_wait: true } } - - it 'traces' do - poller.stub(:random_poll_interval, 0.0) do - poller.send(:wait) - end - - span_names = spans.map(&:name) - _(span_names).must_include('Sidekiq::Scheduled::Poller#wait') - end - end - end -end diff --git a/instrumentation/sidekiq/test/opentelemetry/instrumentation/sidekiq/patches/processor_test.rb b/instrumentation/sidekiq/test/opentelemetry/instrumentation/sidekiq/patches/processor_test.rb deleted file mode 100644 index 79224e796e..0000000000 --- a/instrumentation/sidekiq/test/opentelemetry/instrumentation/sidekiq/patches/processor_test.rb +++ /dev/null @@ -1,63 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require 'opentelemetry-instrumentation-redis' - -require_relative '../../../../../lib/opentelemetry/instrumentation/sidekiq' -require_relative '../../../../../lib/opentelemetry/instrumentation/sidekiq/patches/processor' - -describe OpenTelemetry::Instrumentation::Sidekiq::Patches::Processor do - let(:instrumentation) { OpenTelemetry::Instrumentation::Sidekiq::Instrumentation.instance } - let(:redis_instrumentation) { OpenTelemetry::Instrumentation::Redis::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:spans) { exporter.finished_spans } - let(:span) { spans.first } - let(:config) { {} } - let(:manager) { MockLoader.new.manager } - let(:processor) { manager.workers.first } - - before do - # Clear spans - exporter.reset - redis_instrumentation.install - instrumentation.install(config) - end - - after do - # Force re-install of instrumentation - redis_instrumentation.instance_variable_set(:@installed, false) - instrumentation.instance_variable_set(:@installed, false) - end - - describe '#process_one' do - it 'does not trace' do - processor.send(:process_one) - _(spans.size).must_equal(0) - end - - describe 'when process_one tracing is enabled' do - let(:config) { { trace_processor_process_one: true } } - - it 'traces' do - processor.send(:process_one) - span_names = spans.map(&:name) - _(span_names).must_include('Sidekiq::Processor#process_one') - _(span_names).must_include('BRPOP') - end - - describe 'when peer_service config is set' do - let(:config) { { trace_processor_process_one: true, peer_service: 'MySidekiqService' } } - it 'add peer.service info' do - processor.send(:process_one) - span = spans.last - _(span.attributes['peer.service']).must_equal 'MySidekiqService' - end - end - end - end unless ENV['OMIT_SERVICES'] -end diff --git a/instrumentation/sidekiq/test/redis.conf b/instrumentation/sidekiq/test/redis.conf deleted file mode 100644 index 83f8fb5d67..0000000000 --- a/instrumentation/sidekiq/test/redis.conf +++ /dev/null @@ -1,6 +0,0 @@ -bind 127.0.0.1 -requirepass passw0rd -databases 16 -appendonly no -save "" -port 16379 diff --git a/instrumentation/sidekiq/test/test_helper.rb b/instrumentation/sidekiq/test/test_helper.rb deleted file mode 100644 index 1fbb7152d7..0000000000 --- a/instrumentation/sidekiq/test/test_helper.rb +++ /dev/null @@ -1,87 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'sidekiq' -require 'sidekiq/testing' - -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' - -require 'minitest/autorun' -require 'rspec/mocks/minitest_integration' -require 'active_job' -require 'pry' - -# Sidekiq changed its loading mechanism in 6.5.0, but we still want to test the -# older versions. We can eliminate the first part of this conditional when we no -# longer support Sidekiq 6.4.x versions. -if Gem::Version.new(Sidekiq::VERSION) < Gem::Version.new('6.5.0') - require 'helpers/mock_loader' -else - require 'helpers/mock_loader_new_launcher' -end - -# OpenTelemetry SDK config for testing -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry::SDK.configure do |c| - c.add_span_processor span_processor -end - -# Sidekiq redis configuration -ENV['TEST_REDIS_HOST'] ||= '127.0.0.1' -ENV['TEST_REDIS_PORT'] ||= '16379' - -redis_url = "redis://#{ENV['TEST_REDIS_HOST']}:#{ENV['TEST_REDIS_PORT']}/0" - -Sidekiq.configure_server do |config| - config.redis = { password: 'passw0rd', url: redis_url } -end - -Sidekiq.configure_client do |config| - config.redis = { password: 'passw0rd', url: redis_url } -end - -# Silence Actibe Job logging noise -ActiveJob::Base.logger = Logger.new('/dev/null') - -class SimpleJobWithActiveJob < ActiveJob::Base - self.queue_adapter = :sidekiq - - def perform(*args); end -end - -# Test jobs -class SimpleEnqueueingJob - include Sidekiq::Worker - - def perform - SimpleJob.perform_async - end -end - -class SimpleJob - include Sidekiq::Worker - - def perform; end -end - -class BaggageTestingJob - include Sidekiq::Worker - - def perform(*args) - OpenTelemetry::Trace.current_span['success'] = true if OpenTelemetry::Baggage.value('testing_baggage') == 'it_worked' - end -end - -class ExceptionTestingJob - include Sidekiq::Worker - - def perform(*args) - raise 'a little hell' - end -end diff --git a/instrumentation/sinatra/.rubocop.yml b/instrumentation/sinatra/.rubocop.yml deleted file mode 100644 index 62c836db47..0000000000 --- a/instrumentation/sinatra/.rubocop.yml +++ /dev/null @@ -1,5 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-sinatra.rb" diff --git a/instrumentation/sinatra/.yardopts b/instrumentation/sinatra/.yardopts deleted file mode 100644 index b141f41bbc..0000000000 --- a/instrumentation/sinatra/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Sinatra Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/sinatra/Appraisals b/instrumentation/sinatra/Appraisals deleted file mode 100644 index fa21229062..0000000000 --- a/instrumentation/sinatra/Appraisals +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -appraise 'sinatra-2.1' do - gem 'sinatra', '2.1.0' -end - -appraise 'sinatra-1.4' do - gem 'sinatra', '1.4.8' -end diff --git a/instrumentation/sinatra/CHANGELOG.md b/instrumentation/sinatra/CHANGELOG.md deleted file mode 100644 index 09458de4ef..0000000000 --- a/instrumentation/sinatra/CHANGELOG.md +++ /dev/null @@ -1,96 +0,0 @@ -# Release History: opentelemetry-instrumentation-sinatra - -### v0.20.0 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Broken test file requirements - -### v0.19.4 / 2022-05-02 - -* FIXED: Update server instrumentation to not reflect 400 status as error - -### v0.19.3 / 2021-12-01 - -* FIXED: Sinatra to stop using api env getter - -### v0.19.2 / 2021-09-29 - -* (No significant changes) - -### v0.19.1 / 2021-08-12 - -* DOCS: Update docs to rely more on environment variable configuration - -### v0.19.0 / 2021-06-23 - -* BREAKING CHANGE: Total order constraint on span.status= - -* FIXED: Total order constraint on span.status= - -### v0.18.0 / 2021-05-21 - -* ADDED: Updated API depedency for 1.0.0.rc1 -* BREAKING CHANGE: Remove optional parent_context from in_span - -* FIXED: Remove optional parent_context from in_span -* FIXED: Removed http.status_text attribute #750 - -### v0.17.0 / 2021-04-22 - -* (No significant changes) - -### v0.16.0 / 2021-03-17 - -* FIXED: Example scripts now reference local common lib -* DOCS: Replace Gitter with GitHub Discussions - -### v0.15.0 / 2021-02-18 - -* (No significant changes) - -### v0.14.0 / 2021-02-03 - -* BREAKING CHANGE: Replace getter and setter callables and remove rack specific propagators - -* ADDED: Replace getter and setter callables and remove rack specific propagators - -### v0.13.0 / 2021-01-29 - -* (No significant changes) - -### v0.12.0 / 2020-12-24 - -* (No significant changes) - -### v0.11.0 / 2020-12-11 - -* FIXED: Copyright comments to not reference year - -### v0.10.0 / 2020-12-03 - -* (No significant changes) - -### v0.9.0 / 2020-11-27 - -* BREAKING CHANGE: Add timeout for force_flush and shutdown - -* ADDED: Add timeout for force_flush and shutdown - -### v0.8.0 / 2020-10-27 - -* BREAKING CHANGE: Remove 'canonical' from status codes - -* FIXED: Remove 'canonical' from status codes - -### v0.7.1 / 2020-10-08 - -* FIXED: Set span name to sinatra.route - -### v0.7.0 / 2020-10-07 - -* FIXED: Default to sinatra.route for span name -* DOCS: Standardize toplevel docs structure and readme - -### v0.6.0 / 2020-09-10 - -* (No significant changes) diff --git a/instrumentation/sinatra/Gemfile b/instrumentation/sinatra/Gemfile deleted file mode 100644 index 2baf57ac47..0000000000 --- a/instrumentation/sinatra/Gemfile +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :test do - gem 'opentelemetry-instrumentation-base', path: '../base' -end diff --git a/instrumentation/sinatra/LICENSE b/instrumentation/sinatra/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/sinatra/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/sinatra/README.md b/instrumentation/sinatra/README.md deleted file mode 100644 index 398084a5ba..0000000000 --- a/instrumentation/sinatra/README.md +++ /dev/null @@ -1,60 +0,0 @@ -# Sinatra Instrumentation - -The Sinatra instrumentation is a community-maintained instrumentation for the [Sinatra][sinatra-home] Web Framework. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-sinatra -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-sinatra` to your `Gemfile`. - -## Usage - -To install the instrumentation, add the gem to your Gemfile: - -```ruby -gem 'opentelemetry-instrumentation-sinatra' -``` - -Then call `use` with the name of the instrumentation: - -```ruby -require 'rubygems' -require 'bundler/setup' - -Bundler.require - -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Sinatra' -end -``` - -Alternatively, you can also call `use_all` to install all the available instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` - -## How can I get involved? - -The `opentelemetry-instrumentation-sinatra` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -The `opentelemetry-instrumentation-sinatra` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information. - -[sinatra-home]: http://sinatrarb.com -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/instrumentation/sinatra/Rakefile b/instrumentation/sinatra/Rakefile deleted file mode 100644 index 1a64ba842e..0000000000 --- a/instrumentation/sinatra/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/sinatra/example/Gemfile b/instrumentation/sinatra/example/Gemfile deleted file mode 100644 index 3c107bc832..0000000000 --- a/instrumentation/sinatra/example/Gemfile +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gem 'opentelemetry-api' -gem 'opentelemetry-common' -gem 'opentelemetry-instrumentation-sinatra' -gem 'opentelemetry-sdk' -gem 'sinatra' diff --git a/instrumentation/sinatra/example/server.rb b/instrumentation/sinatra/example/server.rb deleted file mode 100755 index 61a609e5ef..0000000000 --- a/instrumentation/sinatra/example/server.rb +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env ruby - -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'rubygems' -require 'bundler/setup' - -Bundler.require - -ENV['OTEL_TRACES_EXPORTER'] = 'console' -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Sinatra' -end - -# Example application for the Sinatra instrumentation -class App < Sinatra::Base - set :bind, '0.0.0.0' - set :show_exceptions, false - - template :example_render do - 'Example Render' - end - - get '/example' do - 'Sinatra Instrumentation Example' - end - - # Uses `render` method - get '/example_render' do - erb :example_render - end - - get '/thing/:id' do - 'Thing 1' - end - - run! if app_file == $PROGRAM_NAME -end diff --git a/instrumentation/sinatra/example/sinatra.rb b/instrumentation/sinatra/example/sinatra.rb deleted file mode 100644 index c3b048ac05..0000000000 --- a/instrumentation/sinatra/example/sinatra.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'net/http' - -response = Net::HTTP.get('0.0.0.0', '/example', '4567') -puts response - -response = Net::HTTP.get('0.0.0.0', '/example_render', '4567') -puts response - -response = Net::HTTP.get('0.0.0.0', '/thing/12345', '4567') -puts response diff --git a/instrumentation/sinatra/example/start_server.sh b/instrumentation/sinatra/example/start_server.sh deleted file mode 100755 index 2e4ef5f746..0000000000 --- a/instrumentation/sinatra/example/start_server.sh +++ /dev/null @@ -1,4 +0,0 @@ -#! /bin/bash - -# Start the server, wait a bit, and provide a command line to run the client -./server.rb & (sleep 5; /bin/bash) diff --git a/instrumentation/sinatra/lib/opentelemetry-instrumentation-sinatra.rb b/instrumentation/sinatra/lib/opentelemetry-instrumentation-sinatra.rb deleted file mode 100644 index baceb3cb76..0000000000 --- a/instrumentation/sinatra/lib/opentelemetry-instrumentation-sinatra.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/sinatra/lib/opentelemetry/instrumentation.rb b/instrumentation/sinatra/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index bbb3d85fe4..0000000000 --- a/instrumentation/sinatra/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # "Instrumentation" are specified by - # https://github.com/open-telemetry/opentelemetry-specification/blob/784635d01d8690c8f5fcd1f55bdbc8a13cf2f4f2/specification/glossary.md#instrumentation-library - # - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/sinatra' diff --git a/instrumentation/sinatra/lib/opentelemetry/instrumentation/sinatra.rb b/instrumentation/sinatra/lib/opentelemetry/instrumentation/sinatra.rb deleted file mode 100644 index d2ce8c87a8..0000000000 --- a/instrumentation/sinatra/lib/opentelemetry/instrumentation/sinatra.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the Sinatra gem - module Sinatra - end - end -end - -require_relative './sinatra/instrumentation' -require_relative './sinatra/version' diff --git a/instrumentation/sinatra/lib/opentelemetry/instrumentation/sinatra/extensions/tracer_extension.rb b/instrumentation/sinatra/lib/opentelemetry/instrumentation/sinatra/extensions/tracer_extension.rb deleted file mode 100644 index c17eafdbc2..0000000000 --- a/instrumentation/sinatra/lib/opentelemetry/instrumentation/sinatra/extensions/tracer_extension.rb +++ /dev/null @@ -1,38 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative '../middlewares/tracer_middleware' - -module OpenTelemetry - module Instrumentation - module Sinatra - module Extensions - # Sinatra extension that installs TracerMiddleware and provides - # tracing for template rendering - module TracerExtension - # Sinatra hook after extension is registered - def self.registered(app) - # Create tracing `render` method - ::Sinatra::Base.module_eval do - def render(_engine, data, *) - template_name = data.is_a?(Symbol) ? data : :literal - - Sinatra::Instrumentation.instance.tracer.in_span( - 'sinatra.render_template', - attributes: { 'sinatra.template_name' => template_name.to_s } - ) do - super - end - end - end - - app.use Middlewares::TracerMiddleware - end - end - end - end - end -end diff --git a/instrumentation/sinatra/lib/opentelemetry/instrumentation/sinatra/instrumentation.rb b/instrumentation/sinatra/lib/opentelemetry/instrumentation/sinatra/instrumentation.rb deleted file mode 100644 index cc447457f9..0000000000 --- a/instrumentation/sinatra/lib/opentelemetry/instrumentation/sinatra/instrumentation.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative 'extensions/tracer_extension' - -module OpenTelemetry - module Instrumentation - module Sinatra - # The Instrumentation class contains logic to detect and install the Sinatra - # instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - install do |_| - ::Sinatra::Base.register Extensions::TracerExtension - end - - present do - defined?(::Sinatra) - end - end - end - end -end diff --git a/instrumentation/sinatra/lib/opentelemetry/instrumentation/sinatra/middlewares/tracer_middleware.rb b/instrumentation/sinatra/lib/opentelemetry/instrumentation/sinatra/middlewares/tracer_middleware.rb deleted file mode 100644 index c7b0ab55d8..0000000000 --- a/instrumentation/sinatra/lib/opentelemetry/instrumentation/sinatra/middlewares/tracer_middleware.rb +++ /dev/null @@ -1,52 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Sinatra - module Middlewares - # Middleware to trace Sinatra requests - class TracerMiddleware - def initialize(app) - @app = app - end - - def call(env) - extracted_context = OpenTelemetry.propagation.extract( - env, - getter: OpenTelemetry::Common::Propagation.rack_env_getter - ) - OpenTelemetry::Context.with_current(extracted_context) do - tracer.in_span( - env['PATH_INFO'], - attributes: { 'http.method' => env['REQUEST_METHOD'], - 'http.url' => env['PATH_INFO'] }, - kind: :server - ) do |span| - @app.call(env).tap { |resp| trace_response(span, env, resp) } - end - end - end - - private - - def tracer - OpenTelemetry::Instrumentation::Sinatra::Instrumentation.instance.tracer - end - - def trace_response(span, env, resp) - status, _headers, _response_body = resp - - span.set_attribute('http.status_code', status) - span.set_attribute('http.route', env['sinatra.route'].split.last) if env['sinatra.route'] - span.name = env['sinatra.route'] if env['sinatra.route'] - span.status = OpenTelemetry::Trace::Status.error unless (100..499).include?(status.to_i) - end - end - end - end - end -end diff --git a/instrumentation/sinatra/lib/opentelemetry/instrumentation/sinatra/version.rb b/instrumentation/sinatra/lib/opentelemetry/instrumentation/sinatra/version.rb deleted file mode 100644 index bf2d506973..0000000000 --- a/instrumentation/sinatra/lib/opentelemetry/instrumentation/sinatra/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Sinatra - VERSION = '0.20.0' - end - end -end diff --git a/instrumentation/sinatra/opentelemetry-instrumentation-sinatra.gemspec b/instrumentation/sinatra/opentelemetry-instrumentation-sinatra.gemspec deleted file mode 100644 index 6f3e901d7d..0000000000 --- a/instrumentation/sinatra/opentelemetry-instrumentation-sinatra.gemspec +++ /dev/null @@ -1,51 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/sinatra/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-sinatra' - spec.version = OpenTelemetry::Instrumentation::Sinatra::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'Sinatra instrumentation for the OpenTelemetry framework' - spec.description = 'Sinatra instrumentation for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-common', '~> 0.19.3' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.21.0' - - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'rack-test', '~> 1.1.0' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'sinatra', '~> 2.0.7' - spec.add_development_dependency 'webmock', '~> 3.7.6' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-sinatra/v#{OpenTelemetry::Instrumentation::Sinatra::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/sinatra' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-sinatra/v#{OpenTelemetry::Instrumentation::Sinatra::VERSION}" - end -end diff --git a/instrumentation/sinatra/test/.rubocop.yml b/instrumentation/sinatra/test/.rubocop.yml deleted file mode 100644 index dd94258585..0000000000 --- a/instrumentation/sinatra/test/.rubocop.yml +++ /dev/null @@ -1,4 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false diff --git a/instrumentation/sinatra/test/opentelemetry/instrumentation/sinatra_test.rb b/instrumentation/sinatra/test/opentelemetry/instrumentation/sinatra_test.rb deleted file mode 100644 index 05c7cc4009..0000000000 --- a/instrumentation/sinatra/test/opentelemetry/instrumentation/sinatra_test.rb +++ /dev/null @@ -1,137 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -describe OpenTelemetry::Instrumentation::Sinatra do - include Rack::Test::Methods - - let(:instrumentation) { OpenTelemetry::Instrumentation::Sinatra::Instrumentation.instance } - let(:exporter) { EXPORTER } - - let(:app_one) do - Class.new(Sinatra::Application) do - get '/endpoint' do - '1' - end - - template :foo_template do - 'Foo Template' - end - - get '/with_template' do - erb :foo_template - end - - get '/api/v1/foo/:myname/?' do - 'Some name' - end - end - end - - let(:app_two) do - Class.new(Sinatra::Application) do - get '/endpoint' do - '2' - end - end - end - - let(:apps) do - { - '/one' => app_one, - '/two' => app_two - } - end - - let(:app) do - apps_to_build = apps - - Rack::Builder.new do - apps_to_build.each do |root, app| - map root do - run app - end - end - end.to_app - end - - before do - instrumentation.install - exporter.reset - end - - describe 'tracing' do - it 'before request' do - _(exporter.finished_spans.size).must_equal 0 - end - - it 'after request' do - get '/one/endpoint' - - _(exporter.finished_spans.size).must_equal 1 - end - - it 'traces all apps' do - get '/two/endpoint' - - _(exporter.finished_spans.size).must_equal 1 - end - - it 'records attributes' do - get '/one/endpoint' - - _(exporter.finished_spans.first.attributes).must_equal( - 'http.method' => 'GET', - 'http.url' => '/endpoint', - 'http.status_code' => 200, - 'http.route' => '/endpoint' - ) - end - - it 'traces templates' do - get '/one/with_template' - - _(exporter.finished_spans.size).must_equal 3 - _(exporter.finished_spans.map(&:name)) - .must_equal [ - 'sinatra.render_template', - 'sinatra.render_template', - 'GET /with_template' - ] - _(exporter.finished_spans[0..1].map(&:attributes) - .map { |h| h['sinatra.template_name'] }) - .must_equal %w[layout foo_template] - end - - it 'correctly name spans' do - get '/one//api/v1/foo/janedoe/' - - _(exporter.finished_spans.size).must_equal 1 - _(exporter.finished_spans.first.attributes).must_equal( - 'http.method' => 'GET', - 'http.url' => '/api/v1/foo/janedoe/', - 'http.status_code' => 200, - 'http.route' => '/api/v1/foo/:myname/?' - ) - _(exporter.finished_spans.map(&:name)) - .must_equal [ - 'GET /api/v1/foo/:myname/?' - ] - end - - it 'does not create unhandled exceptions for missing routes' do - get '/one/missing_example/not_present' - - _(exporter.finished_spans.first.status.code).must_equal OpenTelemetry::Trace::Status::UNSET - _(exporter.finished_spans.first.attributes).must_equal( - 'http.method' => 'GET', - 'http.url' => '/missing_example/not_present', - 'http.status_code' => 404 - ) - end - end -end diff --git a/instrumentation/sinatra/test/test_helper.rb b/instrumentation/sinatra/test/test_helper.rb deleted file mode 100644 index 242d63c9ed..0000000000 --- a/instrumentation/sinatra/test/test_helper.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'sinatra' - -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' - -require 'minitest/autorun' -require 'rack/test' - -require_relative '../lib/opentelemetry-instrumentation-sinatra' - -# global opentelemetry-sdk setup: -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry::SDK.configure do |c| - c.add_span_processor span_processor -end diff --git a/instrumentation/trilogy/.rubocop.yml b/instrumentation/trilogy/.rubocop.yml deleted file mode 100644 index 5fa7c8faf8..0000000000 --- a/instrumentation/trilogy/.rubocop.yml +++ /dev/null @@ -1,5 +0,0 @@ -inherit_from: ../.rubocop-examples.yml - -Naming/FileName: - Exclude: - - "lib/opentelemetry-instrumentation-trilogy.rb" diff --git a/instrumentation/trilogy/.yardopts b/instrumentation/trilogy/.yardopts deleted file mode 100644 index 849098b728..0000000000 --- a/instrumentation/trilogy/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Trilogy Instrumentation ---markup=markdown ---main=README.md -./lib/opentelemetry/instrumentation/**/*.rb -./lib/opentelemetry/instrumentation.rb -- -README.md -CHANGELOG.md diff --git a/instrumentation/trilogy/Appraisals b/instrumentation/trilogy/Appraisals deleted file mode 100644 index 8f525fee35..0000000000 --- a/instrumentation/trilogy/Appraisals +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -appraise 'trilogy-2.0' do - gem 'trilogy', '~> 2.0' -end diff --git a/instrumentation/trilogy/CHANGELOG.md b/instrumentation/trilogy/CHANGELOG.md deleted file mode 100644 index 6e300b55bd..0000000000 --- a/instrumentation/trilogy/CHANGELOG.md +++ /dev/null @@ -1,18 +0,0 @@ -# Release History: opentelemetry-instrumentation-trilogy - -### v0.51.0 / 2022-06-09 - -* Upgrading Base dependency version -* FIXED: Broken test file requirements - -### v0.50.2 / 2022-05-05 - -* (No significant changes) - -### v0.50.1 / 2022-01-07 - -* FIXED: Trilogy Driver Options - -### v0.50.0 / 2021-12-31 - -* Initial release. diff --git a/instrumentation/trilogy/Gemfile b/instrumentation/trilogy/Gemfile deleted file mode 100644 index 2baf57ac47..0000000000 --- a/instrumentation/trilogy/Gemfile +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :test do - gem 'opentelemetry-instrumentation-base', path: '../base' -end diff --git a/instrumentation/trilogy/LICENSE b/instrumentation/trilogy/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/instrumentation/trilogy/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/instrumentation/trilogy/README.md b/instrumentation/trilogy/README.md deleted file mode 100644 index ce7fa7407f..0000000000 --- a/instrumentation/trilogy/README.md +++ /dev/null @@ -1,59 +0,0 @@ -# OpenTelemetry Trilogy Instrumentation - -The OpenTelemetry Trilogy Ruby gem provides instrumentation for [Trilogy][trilogy-home] and -was `COPY+PASTE+MODIFIED` from the [`OpenTelemetry MySQL`][opentelemetry-mysql]. - -Some key differences in this instrumentation are: - -- `Trilogy` does not expose [`MySql#query_options`](https://github.com/brianmario/mysql2/blob/ca08712c6c8ea672df658bb25b931fea22555f27/lib/mysql2/client.rb#L78), therefore there is limited support for database semantic conventions. -- SQL Obfuscation is enabled by default to mitigate restricted data leaks. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-instrumentation-trilogy -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-trilogy` in your `Gemfile`. - -## Usage - -To use the instrumentation, call `use` with the name of the instrumentation: - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::Trilogy', { - # The obfuscation of SQL in the db.statement attribute is disabled by default. - # To enable, set db_statement to :obfuscate. - db_statement: :obfuscate, - } -end -``` - -Alternatively, you can also call `use_all` to install all the available instrumentation. - -```ruby -OpenTelemetry::SDK.configure do |c| - c.use_all -end -``` - -## How can I get involved? - -The `opentelemetry-instrumentation-trilogy` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -The `opentelemetry-instrumentation-trilogy` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information. - -[trilogy-home]: https://github.com/github/trilogy -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/instrumentation/trilogy/Rakefile b/instrumentation/trilogy/Rakefile deleted file mode 100644 index 1a64ba842e..0000000000 --- a/instrumentation/trilogy/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/instrumentation/trilogy/lib/opentelemetry-instrumentation-trilogy.rb b/instrumentation/trilogy/lib/opentelemetry-instrumentation-trilogy.rb deleted file mode 100644 index 57a6574272..0000000000 --- a/instrumentation/trilogy/lib/opentelemetry-instrumentation-trilogy.rb +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry-semantic_conventions' -require_relative './opentelemetry/instrumentation' diff --git a/instrumentation/trilogy/lib/opentelemetry/instrumentation.rb b/instrumentation/trilogy/lib/opentelemetry/instrumentation.rb deleted file mode 100644 index d22bf5c081..0000000000 --- a/instrumentation/trilogy/lib/opentelemetry/instrumentation.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # Instrumentation should be able to handle the case when the library is not installed on a user's system. - module Instrumentation - end -end - -require_relative './instrumentation/trilogy' diff --git a/instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy.rb b/instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy.rb deleted file mode 100644 index 9167808d42..0000000000 --- a/instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry' -require 'opentelemetry-instrumentation-base' - -module OpenTelemetry - module Instrumentation - # Contains the OpenTelemetry instrumentation for the Trilogy gem - module Trilogy - end - end -end - -require_relative './trilogy/instrumentation' -require_relative './trilogy/version' diff --git a/instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy/instrumentation.rb b/instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy/instrumentation.rb deleted file mode 100644 index bdbb1cd5f7..0000000000 --- a/instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy/instrumentation.rb +++ /dev/null @@ -1,40 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Trilogy - # The Instrumentation class contains logic to detect and install the Trilogy instrumentation - class Instrumentation < OpenTelemetry::Instrumentation::Base - install do |_config| - require_dependencies - patch_client - end - - present do - defined?(::Trilogy) - end - - compatible do - Gem::Requirement.create('>= 2.0', '< 3.0').satisfied_by?(Gem::Version.new(::Trilogy::VERSION)) - end - - option :peer_service, default: nil, validate: :string - option :db_statement, default: :obfuscate, validate: %I[omit include obfuscate] - - private - - def require_dependencies - require_relative 'patches/client' - end - - def patch_client - ::Trilogy.prepend(Patches::Client) - end - end - end - end -end diff --git a/instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy/patches/client.rb b/instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy/patches/client.rb deleted file mode 100644 index f84046fa14..0000000000 --- a/instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy/patches/client.rb +++ /dev/null @@ -1,148 +0,0 @@ -# frozen_string_literal: true - -module OpenTelemetry - module Instrumentation - module Trilogy - module Patches - # Module to prepend to Trilogy for instrumentation - module Client # rubocop:disable Metrics/ModuleLength - QUERY_NAMES = [ - 'set names', - 'select', - 'insert', - 'update', - 'delete', - 'begin', - 'commit', - 'rollback', - 'savepoint', - 'release savepoint', - 'explain', - 'drop database', - 'drop table', - 'create database', - 'create table' - ].freeze - - QUERY_NAME_RE = Regexp.new("^(#{QUERY_NAMES.join('|')})", Regexp::IGNORECASE) - - COMPONENTS_REGEX_MAP = { - single_quotes: /'(?:[^']|'')*?(?:\\'.*|'(?!'))/, - double_quotes: /"(?:[^"]|"")*?(?:\\".*|"(?!"))/, - numeric_literals: /-?\b(?:[0-9]+\.)?[0-9]+([eE][+-]?[0-9]+)?\b/, - boolean_literals: /\b(?:true|false|null)\b/i, - hexadecimal_literals: /0x[0-9a-fA-F]+/, - comments: /(?:#|--).*?(?=\r|\n|$)/i, - multi_line_comments: %r{\/\*(?:[^\/]|\/[^*])*?(?:\*\/|\/\*.*)} - }.freeze - - MYSQL_COMPONENTS = %i[ - single_quotes - double_quotes - numeric_literals - boolean_literals - hexadecimal_literals - comments - multi_line_comments - ].freeze - - FULL_SQL_REGEXP = Regexp.union(MYSQL_COMPONENTS.map { |component| COMPONENTS_REGEX_MAP[component] }) - - def initialize(args) - @_otel_net_peer_name = args[:host] - super - end - - def query(sql) - tracer.in_span( - database_span_name(sql), - attributes: client_attributes(sql), - kind: :client - ) do - super(sql) - end - end - - private - - def client_attributes(sql) - attributes = { - ::OpenTelemetry::SemanticConventions::Trace::DB_SYSTEM => 'mysql', - ::OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME => net_peer_name - } - - attributes[::OpenTelemetry::SemanticConventions::Trace::PEER_SERVICE] = config[:peer_service] unless config[:peer_service].nil? - - case config[:db_statement] - when :obfuscate - attributes[::OpenTelemetry::SemanticConventions::Trace::DB_STATEMENT] = obfuscate_sql(sql) - when :include - attributes[::OpenTelemetry::SemanticConventions::Trace::DB_STATEMENT] = sql - end - - attributes - end - - def obfuscate_sql(sql) - if sql.size > 2000 - 'SQL query too large to remove sensitive data ...' - else - obfuscated = sql.gsub(FULL_SQL_REGEXP, '?') - obfuscated = 'Failed to obfuscate SQL query - quote characters remained after obfuscation' if detect_unmatched_pairs(obfuscated) - obfuscated - end - end - - def detect_unmatched_pairs(obfuscated) - # We use this to check whether the query contains any quote characters - # after obfuscation. If so, that's a good indication that the original - # query was malformed, and so our obfuscation can't reliably find - # literals. In such a case, we'll replace the entire query with a - # placeholder. - %r{'|"|\/\*|\*\/}.match(obfuscated) - end - - def database_span_name(sql) - # Setting span name to the SQL query without obfuscation would - # result in PII + cardinality issues. - # First attempt to infer the statement type then fallback to - # current Otel approach {database.component_name}.{database_instance_name} - # https://github.com/open-telemetry/opentelemetry-python/blob/39fa078312e6f41c403aa8cad1868264011f7546/ext/opentelemetry-ext-dbapi/tests/test_dbapi_integration.py#L53 - # This creates span names like mysql.default, mysql.replica, postgresql.staging etc. - - statement_type = extract_statement_type(sql) - - return statement_type unless statement_type.nil? - - # fallback - 'mysql' - end - - def net_peer_name - if defined?(@connected_host) - @connected_host - elsif @_otel_net_peer_name - @_otel_net_peer_name - else - 'unknown sock' - end - end - - def tracer - Trilogy::Instrumentation.instance.tracer - end - - def config - Trilogy::Instrumentation.instance.config - end - - def extract_statement_type(sql) - QUERY_NAME_RE.match(sql) { |match| match[1].downcase } unless sql.nil? - rescue StandardError => e - OpenTelemetry.logger.error("Error extracting sql statement type: #{e.message}") - end - end - end - end - end -end diff --git a/instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy/version.rb b/instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy/version.rb deleted file mode 100644 index 8472ce7e64..0000000000 --- a/instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Trilogy - VERSION = '0.51.0' - end - end -end diff --git a/instrumentation/trilogy/opentelemetry-instrumentation-trilogy.gemspec b/instrumentation/trilogy/opentelemetry-instrumentation-trilogy.gemspec deleted file mode 100644 index 5ad5613a86..0000000000 --- a/instrumentation/trilogy/opentelemetry-instrumentation-trilogy.gemspec +++ /dev/null @@ -1,53 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/instrumentation/trilogy/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-instrumentation-trilogy' - spec.version = OpenTelemetry::Instrumentation::Trilogy::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'Trilogy instrumentation for the OpenTelemetry framework' - spec.description = 'Adds auto instrumentation that includes SQL metadata' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = Gem::Requirement.new('>= 2.6.0') - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.21.0' - spec.add_dependency 'opentelemetry-semantic_conventions', '>= 1.8.0' - - spec.add_development_dependency 'appraisal', '~> 2.2.0' - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' - spec.add_development_dependency 'opentelemetry-test-helpers' - spec.add_development_dependency 'pry' - spec.add_development_dependency 'pry-byebug' unless RUBY_ENGINE == 'jruby' - spec.add_development_dependency 'rake', '~> 12.3.3' - spec.add_development_dependency 'rspec-mocks' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'trilogy', '>= 2.0', '< 3.0' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-trilogy/v#{OpenTelemetry::Instrumentation::Trilogy::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/trilogy' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-trilogy/v#{OpenTelemetry::Instrumentation::Trilogy::VERSION}" - end -end diff --git a/instrumentation/trilogy/test/.rubocop.yml b/instrumentation/trilogy/test/.rubocop.yml deleted file mode 100644 index dd94258585..0000000000 --- a/instrumentation/trilogy/test/.rubocop.yml +++ /dev/null @@ -1,4 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false diff --git a/instrumentation/trilogy/test/opentelemetry/instrumentation/trilogy/instrumentation_test.rb b/instrumentation/trilogy/test/opentelemetry/instrumentation/trilogy/instrumentation_test.rb deleted file mode 100644 index ba609b1a46..0000000000 --- a/instrumentation/trilogy/test/opentelemetry/instrumentation/trilogy/instrumentation_test.rb +++ /dev/null @@ -1,249 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -require_relative '../../../../lib/opentelemetry/instrumentation/trilogy' -require_relative '../../../../lib/opentelemetry/instrumentation/trilogy/patches/client' - -describe OpenTelemetry::Instrumentation::Trilogy do - let(:instrumentation) { OpenTelemetry::Instrumentation::Trilogy::Instrumentation.instance } - let(:exporter) { EXPORTER } - let(:span) { exporter.finished_spans.first } - let(:config) { {} } - let(:driver_options) do - { - host: host, - port: port, - username: username, - password: password, - ssl: false - } - end - let(:client) do - ::Trilogy.new(driver_options) - end - - let(:host) { ENV.fetch('TEST_MYSQL_HOST', '127.0.0.1') } - let(:port) { ENV.fetch('TEST_MYSQL_PORT', '3306').to_i } - let(:database) { ENV.fetch('TEST_MYSQL_DB', 'mysql') } - let(:username) { ENV.fetch('TEST_MYSQL_USER', 'root') } - let(:password) { ENV.fetch('TEST_MYSQL_PASSWORD', 'root') } - - before do - exporter.reset - end - - after do - # Force re-install of instrumentation - instrumentation.instance_variable_set(:@installed, false) - end - - it 'has #name' do - _(instrumentation.name).must_equal 'OpenTelemetry::Instrumentation::Trilogy' - end - - it 'has #version' do - _(instrumentation.version).wont_be_nil - _(instrumentation.version).wont_be_empty - end - - describe '#install' do - it 'accepts peer service name from config' do - instrumentation.instance_variable_set(:@installed, false) - instrumentation.install(peer_service: 'readonly:mysql') - client.query('SELECT 1') - - _(span.attributes[::OpenTelemetry::SemanticConventions::Trace::PEER_SERVICE]).must_equal 'readonly:mysql' - end - - it 'omits peer service by default' do - instrumentation.instance_variable_set(:@installed, false) - instrumentation.install({}) - client.query('SELECT 1') - - _(span.attributes.keys).wont_include(::OpenTelemetry::SemanticConventions::Trace::PEER_SERVICE) - end - end - - describe '#compatible?' do - describe 'when an unsupported version is installed' do - it 'is incompatible' do - stub_const('Trilogy::VERSION', '2.0.0.beta') do - _(instrumentation.compatible?).must_equal false - end - - stub_const('Trilogy::VERSION', '3.0.0') do - _(instrumentation.compatible?).must_equal false - end - end - end - - describe 'when supported version is installed' do - it 'is compatible' do - stub_const('Trilogy::VERSION', '2.0.0') do - _(instrumentation.compatible?).must_equal true - end - - stub_const('Trilogy::VERSION', '3.0.0.rc1') do - _(instrumentation.compatible?).must_equal true - end - end - end - end - - describe 'tracing' do - before do - instrumentation.install(config) - end - - describe 'with default options' do - it 'obfuscates sql' do - client.query('SELECT 1') - - _(span.name).must_equal 'select' - _(span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_SYSTEM]).must_equal 'mysql' - _(span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_NAME]).must_be_nil - _(span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_STATEMENT]).must_equal 'SELECT ?' - _(span.attributes[OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME]).must_equal(host) - end - - it 'extracts statement type' do - explain_sql = 'EXPLAIN SELECT 1' - client.query(explain_sql) - - _(span.name).must_equal 'explain' - _(span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_SYSTEM]).must_equal 'mysql' - _(span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_STATEMENT]).must_equal 'EXPLAIN SELECT ?' - end - - it 'uses component.name and instance.name as span.name fallbacks with invalid sql' do - expect do - client.query('DESELECT 1') - end.must_raise Trilogy::DatabaseError - - _(span.name).must_equal 'mysql' - _(span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_SYSTEM]).must_equal 'mysql' - _(span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_STATEMENT]).must_equal 'DESELECT ?' - end - end - - describe 'when quering for the connected host' do - it 'spans will include the net.peer.name attribute' do - _(client.connected_host).wont_be_nil - - _(span.name).must_equal 'select' - _(span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_SYSTEM]).must_equal 'mysql' - _(span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_STATEMENT]).must_equal 'select @@hostname' - _(span.attributes[OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME]).must_equal(host) - - client.query('SELECT 1') - - last_span = exporter.finished_spans.last - - _(last_span.name).must_equal 'select' - _(last_span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_SYSTEM]).must_equal 'mysql' - _(last_span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_STATEMENT]).must_equal 'SELECT ?' - _(last_span.attributes[OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME]).wont_equal(host) - _(last_span.attributes[OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME]).must_equal client.connected_host - end - end - - describe 'when quering using unix domain socket' do - let(:client) do - ::Trilogy.new( - username: username, - password: password, - ssl: false - ) - end - - it 'spans will include the net.peer.name attribute' do - skip 'requires setup of a mysql host using uds connections' - _(client.connected_host).wont_be_nil - - _(span.name).must_equal 'select' - _(span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_SYSTEM]).must_equal 'mysql' - _(span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_STATEMENT]).must_equal 'select @@hostname' - _(span.attributes[OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME]).must_match(/sock/) - - client.query('SELECT 1') - - last_span = exporter.finished_spans.last - - _(last_span.name).must_equal 'select' - _(last_span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_SYSTEM]).must_equal 'mysql' - _(last_span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_STATEMENT]).must_equal 'SELECT ?' - _(last_span.attributes[OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME]).wont_equal(/sock/) - _(last_span.attributes[OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME]).must_equal client.connected_host - end - end - - describe 'when queries fail' do - it 'sets span status to error' do - expect do - client.query('SELECT INVALID') - end.must_raise Trilogy::DatabaseError - - _(span.name).must_equal 'select' - _(span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_SYSTEM]).must_equal 'mysql' - _(span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_NAME]).must_be_nil - _(span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_STATEMENT]).must_equal 'SELECT INVALID' - - _(span.status.code).must_equal( - OpenTelemetry::Trace::Status::ERROR - ) - _(span.events.first.name).must_equal 'exception' - _(span.events.first.attributes['exception.type']).must_equal 'Trilogy::DatabaseError' - _(span.events.first.attributes['exception.message']).wont_be_nil - _(span.events.first.attributes['exception.stacktrace']).wont_be_nil - end - end - - describe 'when db_statement is set to include' do - let(:config) { { db_statement: :include } } - - it 'includes the db query statement' do - sql = 'SELECT * from users where users.id = 1 and users.email = "test@test.com"' - expect do - client.query(sql) - end.must_raise Trilogy::Error - - _(span.name).must_equal 'select' - _(span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_STATEMENT]).must_equal sql - end - end - - describe 'when db_statement is set to obfuscate' do - let(:config) { { db_statement: :obfuscate } } - - it 'obfuscates SQL parameters in db.statement' do - sql = 'SELECT * from users where users.id = 1 and users.email = "test@test.com"' - obfuscated_sql = 'SELECT * from users where users.id = ? and users.email = ?' - expect do - client.query(sql) - end.must_raise Trilogy::Error - - _(span.name).must_equal 'select' - _(span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_STATEMENT]).must_equal obfuscated_sql - end - end - - describe 'when db_statement is set to omit' do - let(:config) { { db_statement: :omit } } - - it 'does not include SQL statement as db.statement attribute' do - sql = 'SELECT * from users where users.id = 1 and users.email = "test@test.com"' - expect do - client.query(sql) - end.must_raise Trilogy::Error - - _(span.name).must_equal 'select' - _(span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_STATEMENT]).must_be_nil - end - end - end -end diff --git a/instrumentation/trilogy/test/test_helper.rb b/instrumentation/trilogy/test/test_helper.rb deleted file mode 100644 index ab1b51188c..0000000000 --- a/instrumentation/trilogy/test/test_helper.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -ENV['OTEL_LOG_LEVEL'] ||= 'fatal' - -require 'trilogy' - -require 'opentelemetry/sdk' -require 'opentelemetry-test-helpers' - -require 'minitest/autorun' -require 'rspec/mocks/minitest_integration' -require 'pry' - -# global opentelemetry-sdk setup: -EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new -span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) - -OpenTelemetry::SDK.configure do |c| - c.add_span_processor span_processor -end diff --git a/propagator/ottrace/.rubocop.yml b/propagator/ottrace/.rubocop.yml deleted file mode 100644 index 958952cac4..0000000000 --- a/propagator/ottrace/.rubocop.yml +++ /dev/null @@ -1,22 +0,0 @@ ---- -AllCops: - TargetRubyVersion: '2.6.0' -Lint/UnusedMethodArgument: - Enabled: false -Metrics/AbcSize: - Max: 18 -Metrics/BlockLength: - Exclude: - - 'test/opentelemetry/propagator/**/*_test.rb' - - 'opentelemetry-propagator-ottrace.gemspec' -Metrics/LineLength: - Enabled: false -Metrics/MethodLength: - Max: 20 -Metrics/ParameterLists: - Enabled: false -Naming/FileName: - Exclude: - - 'lib/opentelemetry-propagator-ottrace.rb' -Style/ModuleFunction: - Enabled: false diff --git a/propagator/ottrace/.yardopts b/propagator/ottrace/.yardopts deleted file mode 100644 index 0d652733f3..0000000000 --- a/propagator/ottrace/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Propagator OTTrace ---markup=markdown ---main=README.md -./lib/opentelemetry/propagator/ottrace/**/*.rb -./lib/opentelemetry/propagator/ottrace.rb -- -README.md -CHANGELOG.md diff --git a/propagator/ottrace/CHANGELOG.md b/propagator/ottrace/CHANGELOG.md deleted file mode 100644 index 76030b2eae..0000000000 --- a/propagator/ottrace/CHANGELOG.md +++ /dev/null @@ -1,41 +0,0 @@ -# Release History: opentelemetry-propagator-ottrace - -### v0.20.0 / 2022-06-09 - -* (No significant changes) - -### v0.19.3 / 2021-10-29 - -* FIXED: Add Support fo OTTrace Bit Encoded Sampled Flags - -### v0.19.2 / 2021-09-29 - -* (No significant changes) - -### v0.19.1 / 2021-08-12 - -* (No significant changes) - -### v0.19.0 / 2021-06-23 - -* BREAKING CHANGE: Refactor Baggage to remove Noop* - -* ADDED: Add Tracer.non_recording_span to API -* FIXED: Support Case Insensitive Trace and Span IDs -* FIXED: Refactor Baggage to remove Noop* - -### v0.18.0 / 2021-05-21 - -* ADDED: Updated API depedency for 1.0.0.rc1 - -### v0.17.0 / 2021-04-22 - -* BREAKING CHANGE: Replace TextMapInjector/TextMapExtractor pairs with a TextMapPropagator. - - [Check the propagator documentation](https://open-telemetry.github.io/opentelemetry-ruby/) for the new usage. - -* FIXED: Refactor propagators to add #fields - -### v0.16.0 / 2021-03-17 - -* Initial release. diff --git a/propagator/ottrace/Gemfile b/propagator/ottrace/Gemfile deleted file mode 100644 index 12150b151b..0000000000 --- a/propagator/ottrace/Gemfile +++ /dev/null @@ -1,6 +0,0 @@ -# frozen_string_literal: true - -source 'https://rubygems.org' - -# Specify your gem's dependencies in opentelemetry-propragator-ottrace.gemspec -gemspec diff --git a/propagator/ottrace/LICENSE b/propagator/ottrace/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/propagator/ottrace/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/propagator/ottrace/README.md b/propagator/ottrace/README.md deleted file mode 100644 index 03959aebe6..0000000000 --- a/propagator/ottrace/README.md +++ /dev/null @@ -1,91 +0,0 @@ -# opentelemetry-propagator-ottrace - -The `opentelemetry-propagator-ottrace` gem contains injectors and extractors for the -[OTTrace context propagation format][ottrace-spec]. - -## OT Trace Format - -| Header Name | Description | Required | -| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | -| `ot-tracer-traceid` | uint64 encoded as a string of 16 hex characters | yes | -| `ot-tracer-spanid` | uint64 encoded as a string of 16 hex characters | yes | -| `ot-tracer-sampled` | boolean or bit encoded as a string with the values `'true'`,`'false'`, `'1'`, or `'0'` | no | -| `ot-baggage-*` | repeated string to string key-value baggage items; keys are prefixed with `ot-baggage-` and the corresponding value is the raw string. | if baggage is present | - -### Sampled Flag vs Bit - -The `ot-tracer-sampled` header is a `boolean` encoded string however the Golang SDK incorrectly sets the `ot-tracer-sampled` header to a `bit` flag. -This and other language SDKs compensate for this by supporting both a `bit` and `boolean` encoded strings upon extraction: - -- [Java](https://github.com/open-telemetry/opentelemetry-java/blob/9cea4ef1f92d3186b1bd8296e9daac4281c0f759/extensions/trace-propagators/src/main/java/io/opentelemetry/extension/trace/propagation/Common.java#L41) -- [Golang](https://github.com/open-telemetry/opentelemetry-go-contrib/blob/b72c2cd63b9a9917554cbcd709e61f5d8541eea5/propagators/ot/ot_propagator.go#L118) - -This issue was [fixed](https://github.com/open-telemetry/opentelemetry-go-contrib/pull/1358) however this SDK supports both for backward compatibility with older versions of the Golang propagator. - -### Interop and trace ids - -The OT trace propagation format expects trace ids to be 64-bits. In order to -interop with OpenTelemetry, trace ids need to be truncated to 64-bits before -sending them on the wire. When truncating, the least significant (right-most) -bits MUST be retained. For example, a trace id of -`3c3039f4d78d5c02ee8e3e41b17ce105` would be truncated to `ee8e3e41b17ce105`. - -### Baggage Notes - -Baggage keys and values are validated according to [rfc7230][rfc7230-url]. Any -keys or values that would result in invalid HTTP headers will be silently -dropped during inject. - -OT Baggage is represented as multiple headers where the -names are carrier dependent. For this reason, they are omitted from the `fields` -method. This behavior should be taken into account if your application relies -on the `fields` functionality. See the [specification][fields-spec-url] for -more details. - -## What is OpenTelemetry? - -[OpenTelemetry][opentelemetry-home] is an open source observability framework, providing a general-purpose API, SDK, and related tools required for the instrumentation of cloud-native software, frameworks, and libraries. - -OpenTelemetry provides a single set of APIs, libraries, agents, and collector services to capture distributed traces and metrics from your application. You can analyze them using Prometheus, Jaeger, and other observability tools. - -## How does this gem fit in? - -This gem can be used with any OpenTelemetry SDK implementation. This can be the official `opentelemetry-sdk` gem or any other concrete implementation. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-propagator-ottrace -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-propagator-ottrace` in your `Gemfile`. - -Configure your application to use this propagator by setting the following [environment variable][envars]: - -``` -OTEL_PROPAGATORS=ottrace -``` - -## How can I get involved? - -The `opentelemetry-propagator-ottrace` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -The `opentelemetry-propagator-ottrace` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information. - -[opentelemetry-home]: https://opentelemetry.io -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions -[ottrace-spec]: https://github.com/opentracing/specification/blob/master/rfc/trace_identifiers.md -[rfc7230-url]: https://tools.ietf.org/html/rfc7230#section-3.2 -[fields-spec-url]: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/context/api-propagators.md#fields -[envars]: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/sdk-environment-variables.md#general-sdk-configuration diff --git a/propagator/ottrace/Rakefile b/propagator/ottrace/Rakefile deleted file mode 100644 index 88f3670a3c..0000000000 --- a/propagator/ottrace/Rakefile +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -ENV['ENABLE_COVERAGE'] ||= '1' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/propagator/ottrace/lib/opentelemetry-propagator-ottrace.rb b/propagator/ottrace/lib/opentelemetry-propagator-ottrace.rb deleted file mode 100644 index b4c080e478..0000000000 --- a/propagator/ottrace/lib/opentelemetry-propagator-ottrace.rb +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry-api' -require_relative './opentelemetry/propagator/ottrace' diff --git a/propagator/ottrace/lib/opentelemetry/propagator/ottrace.rb b/propagator/ottrace/lib/opentelemetry/propagator/ottrace.rb deleted file mode 100644 index cc306c4829..0000000000 --- a/propagator/ottrace/lib/opentelemetry/propagator/ottrace.rb +++ /dev/null @@ -1,35 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry-api' -require 'opentelemetry/propagator/ottrace/version' -require 'opentelemetry/propagator/ottrace/text_map_propagator' - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # Namespace for OpenTelemetry propagator extension libraries - module Propagator - # Namespace for OpenTelemetry OTTrace propagation - module OTTrace - extend self - - TEXT_MAP_PROPAGATOR = TextMapPropagator.new - - private_constant :TEXT_MAP_PROPAGATOR - - # Returns a text map propagator that propagates context using the - # OTTrace format. - def text_map_propagator - TEXT_MAP_PROPAGATOR - end - end - end -end diff --git a/propagator/ottrace/lib/opentelemetry/propagator/ottrace/text_map_propagator.rb b/propagator/ottrace/lib/opentelemetry/propagator/ottrace/text_map_propagator.rb deleted file mode 100644 index 5d23ea5b69..0000000000 --- a/propagator/ottrace/lib/opentelemetry/propagator/ottrace/text_map_propagator.rb +++ /dev/null @@ -1,151 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # Namespace for OpenTelemetry propagator extension libraries - module Propagator - # Namespace for OpenTelemetry OTTrace propagation - module OTTrace - # Propagates context using OTTrace header format - class TextMapPropagator - PADDING = '0' * 16 - VALID_TRACE_ID_REGEX = /^[0-9a-f]{32}$/i.freeze - VALID_SPAN_ID_REGEX = /^[0-9a-f]{16}$/i.freeze - TRACE_ID_64_BIT_WIDTH = 64 / 4 - TRACE_ID_HEADER = 'ot-tracer-traceid' - SPAN_ID_HEADER = 'ot-tracer-spanid' - SAMPLED_HEADER = 'ot-tracer-sampled' - BAGGAGE_HEADER_PREFIX = 'ot-baggage-' - FIELDS = [TRACE_ID_HEADER, SPAN_ID_HEADER, SAMPLED_HEADER].freeze - - # https://github.com/open-telemetry/opentelemetry-specification/blob/14d123c121b6caa53bffd011292c42a181c9ca26/specification/context/api-propagators.md#textmap-propagator0 - VALID_BAGGAGE_HEADER_NAME_CHARS = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/.freeze - INVALID_BAGGAGE_HEADER_VALUE_CHARS = /[^\t\u0020-\u007E\u0080-\u00FF]/.freeze - - private_constant :PADDING, :VALID_TRACE_ID_REGEX, :VALID_SPAN_ID_REGEX, :TRACE_ID_64_BIT_WIDTH, :TRACE_ID_HEADER, - :SPAN_ID_HEADER, :SAMPLED_HEADER, :BAGGAGE_HEADER_PREFIX, :FIELDS, :VALID_BAGGAGE_HEADER_NAME_CHARS, - :INVALID_BAGGAGE_HEADER_VALUE_CHARS - - # Extract OTTrace context from the supplied carrier and set the active span - # in the given context. The original context will be returned if OTTrace - # cannot be extracted from the carrier. - # - # @param [Carrier] carrier The carrier to get the header from. - # @param [optional Context] context The context to be updated with extracted context - # @param [optional Getter] getter If the optional getter is provided, it - # will be used to read the header from the carrier, otherwise the default - # getter will be used. - # @return [Context] Updated context with active span derived from the header, or the original - # context if parsing fails. - def extract(carrier, context: Context.current, getter: Context::Propagation.text_map_getter) - trace_id = optionally_pad_trace_id(getter.get(carrier, TRACE_ID_HEADER)) - span_id = getter.get(carrier, SPAN_ID_HEADER) - sampled = getter.get(carrier, SAMPLED_HEADER) - - return context unless valid?(trace_id: trace_id, span_id: span_id) - - span_context = Trace::SpanContext.new( - trace_id: Array(trace_id).pack('H*'), - span_id: Array(span_id).pack('H*'), - trace_flags: as_trace_flags(sampled), - remote: true - ) - - span = OpenTelemetry::Trace.non_recording_span(span_context) - Trace.context_with_span(span, parent_context: set_baggage(carrier: carrier, context: context, getter: getter)) - end - - # @param [Object] carrier to update with context. - # @param [optional Context] context The active Context. - # @param [optional Setter] setter If the optional setter is provided, it - # will be used to write context into the carrier, otherwise the default - # setter will be used. - def inject(carrier, context: Context.current, setter: Context::Propagation.text_map_setter) - span_context = Trace.current_span(context).context - return unless span_context.valid? - - inject_span_context(span_context: span_context, carrier: carrier, setter: setter) - inject_baggage(context: context, carrier: carrier, setter: setter) - - nil - end - - # Returns the predefined propagation fields. If your carrier is reused, you - # should delete the fields returned by this method before calling +inject+. - # - # @return [Array] a list of fields that will be used by this propagator. - def fields - FIELDS - end - - private - - def as_trace_flags(sampled) - case sampled - when 'true', '1' - Trace::TraceFlags::SAMPLED - else - Trace::TraceFlags::DEFAULT - end - end - - def valid?(trace_id:, span_id:) - !(VALID_TRACE_ID_REGEX !~ trace_id || VALID_SPAN_ID_REGEX !~ span_id) - end - - def optionally_pad_trace_id(trace_id) - if trace_id&.length == 16 - "#{PADDING}#{trace_id}" - else - trace_id - end - end - - def set_baggage(carrier:, context:, getter:) - baggage.build(context: context) do |builder| - prefix = BAGGAGE_HEADER_PREFIX - getter.keys(carrier).each do |carrier_key| - baggage_key = carrier_key.start_with?(prefix) && carrier_key[prefix.length..-1] - next unless baggage_key - next unless VALID_BAGGAGE_HEADER_NAME_CHARS =~ baggage_key - - value = getter.get(carrier, carrier_key) - next unless INVALID_BAGGAGE_HEADER_VALUE_CHARS !~ value - - builder.set_value(baggage_key, value) - end - end - end - - def baggage - OpenTelemetry::Baggage - end - - def inject_span_context(span_context:, carrier:, setter:) - setter.set(carrier, TRACE_ID_HEADER, span_context.hex_trace_id[TRACE_ID_64_BIT_WIDTH, TRACE_ID_64_BIT_WIDTH]) - setter.set(carrier, SPAN_ID_HEADER, span_context.hex_span_id) - setter.set(carrier, SAMPLED_HEADER, span_context.trace_flags.sampled?.to_s) - end - - def inject_baggage(context:, carrier:, setter:) - baggage.values(context: context) - .select { |key, value| valid_baggage_entry?(key, value) } - .each { |key, value| setter.set(carrier, "#{BAGGAGE_HEADER_PREFIX}#{key}", value) } - end - - def valid_baggage_entry?(key, value) - VALID_BAGGAGE_HEADER_NAME_CHARS =~ key && INVALID_BAGGAGE_HEADER_VALUE_CHARS !~ value - end - end - end - end -end diff --git a/propagator/ottrace/lib/opentelemetry/propagator/ottrace/version.rb b/propagator/ottrace/lib/opentelemetry/propagator/ottrace/version.rb deleted file mode 100644 index 6172f45fb7..0000000000 --- a/propagator/ottrace/lib/opentelemetry/propagator/ottrace/version.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # Namespace for OpenTelemetry propagator extension libraries - module Propagator - # Namespace for OpenTelemetry OTTrace propagation - module OTTrace - VERSION = '0.20.0' - end - end -end diff --git a/propagator/ottrace/opentelemetry-propagator-ottrace.gemspec b/propagator/ottrace/opentelemetry-propagator-ottrace.gemspec deleted file mode 100644 index 92a551579f..0000000000 --- a/propagator/ottrace/opentelemetry-propagator-ottrace.gemspec +++ /dev/null @@ -1,42 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative 'lib/opentelemetry/propagator/ottrace/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-propagator-ottrace' - spec.version = OpenTelemetry::Propagator::OTTrace::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'OTTrace Context Propagation Extension for the OpenTelemetry framework' - spec.description = 'OTTrace Context Propagation Extension for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'rake', '~> 12.0' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-propagator-ottrace/v#{OpenTelemetry::Propagator::OTTrace::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/propagator/ottrace' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-propagator-ottrace/v#{OpenTelemetry::Propagator::OTTrace::VERSION}" - end -end diff --git a/propagator/ottrace/test/opentelemetry/propagator/ottrace/text_map_propagator_test.rb b/propagator/ottrace/test/opentelemetry/propagator/ottrace/text_map_propagator_test.rb deleted file mode 100644 index fa7775464a..0000000000 --- a/propagator/ottrace/test/opentelemetry/propagator/ottrace/text_map_propagator_test.rb +++ /dev/null @@ -1,412 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -describe OpenTelemetry::Propagator::OTTrace::TextMapPropagator do - class FakeGetter - def get(carrier, key) - case key - when 'ot-tracer-traceid', 'ot-tracer-spanid' - carrier[key].reverse - when 'ot-tracer-sampled' - carrier[key] != 'true' - end - end - - def keys(carrier) - [] - end - end - - class FakeSetter - def set(carrier, key, value) - carrier[key] = "#{key} = #{value}" - end - end - - let(:span_id) do - 'e457b5a2e4d86bd1' - end - - let(:truncated_trace_id) do - '64fe8b2a57d3eff7' - end - - let(:trace_id) do - '80f198ee56343ba864fe8b2a57d3eff7' - end - - let(:trace_flags) do - OpenTelemetry::Trace::TraceFlags::DEFAULT - end - - let(:context) do - OpenTelemetry::Trace.context_with_span( - OpenTelemetry::Trace.non_recording_span( - OpenTelemetry::Trace::SpanContext.new( - trace_id: Array(trace_id).pack('H*'), - span_id: Array(span_id).pack('H*'), - trace_flags: trace_flags - ) - ) - ) - end - - let(:baggage) do - OpenTelemetry::Baggage - end - - let(:propagator) do - OpenTelemetry::Propagator::OTTrace::TextMapPropagator.new - end - - let(:parent_context) do - OpenTelemetry::Context.empty - end - - let(:trace_id_header) do - '80f198ee56343ba864fe8b2a57d3eff7' - end - - let(:span_id_header) do - 'e457b5a2e4d86bd1' - end - - let(:sampled_header) do - 'true' - end - - let(:carrier) do - { - 'ot-tracer-traceid' => trace_id_header, - 'ot-tracer-spanid' => span_id_header, - 'ot-tracer-sampled' => sampled_header - } - end - - describe '#extract' do - describe 'given an empty context' do - let(:carrier) do - {} - end - - it 'skips context extraction' do - context = propagator.extract(carrier, context: parent_context) - extracted_context = OpenTelemetry::Trace.current_span(context).context - - _(extracted_context.hex_trace_id).must_equal('0' * 32) - _(extracted_context.hex_span_id).must_equal('0' * 16) - _(extracted_context.trace_flags).must_equal(OpenTelemetry::Trace::TraceFlags::DEFAULT) - _(extracted_context).wont_be(:remote?) - end - end - - describe 'given a minimal context' do - it 'extracts parent context' do - context = propagator.extract(carrier, context: parent_context) - extracted_context = OpenTelemetry::Trace.current_span(context).context - - _(extracted_context.hex_trace_id).must_equal('80f198ee56343ba864fe8b2a57d3eff7') - _(extracted_context.hex_span_id).must_equal('e457b5a2e4d86bd1') - _(extracted_context.trace_flags).must_equal(OpenTelemetry::Trace::TraceFlags::SAMPLED) - _(extracted_context).must_be(:remote?) - end - end - - describe 'given a minimal context with uppercase fields' do - let(:carrier) do - { - 'ot-tracer-traceid' => trace_id_header.upcase, - 'ot-tracer-spanid' => span_id_header.upcase, - 'ot-tracer-sampled' => sampled_header - } - end - - it 'extracts parent context' do - context = propagator.extract(carrier, context: parent_context) - extracted_context = OpenTelemetry::Trace.current_span(context).context - - _(extracted_context.hex_trace_id).must_equal('80f198ee56343ba864fe8b2a57d3eff7') - _(extracted_context.hex_span_id).must_equal('e457b5a2e4d86bd1') - _(extracted_context.trace_flags).must_equal(OpenTelemetry::Trace::TraceFlags::SAMPLED) - _(extracted_context).must_be(:remote?) - end - end - - describe 'given a context with sampling disabled' do - let(:sampled_header) do - 'false' - end - - it 'extracts parent context' do - context = propagator.extract(carrier, context: parent_context) - extracted_context = OpenTelemetry::Trace.current_span(context).context - - _(extracted_context.hex_trace_id).must_equal('80f198ee56343ba864fe8b2a57d3eff7') - _(extracted_context.hex_span_id).must_equal('e457b5a2e4d86bd1') - _(extracted_context.trace_flags).must_equal(OpenTelemetry::Trace::TraceFlags::DEFAULT) - _(extracted_context).must_be(:remote?) - end - end - - describe 'given a context with sampling bit set to enabled' do - let(:sampled_header) do - '1' - end - - it 'extracts sampled trace flag' do - context = propagator.extract(carrier, context: parent_context) - extracted_context = OpenTelemetry::Trace.current_span(context).context - - _(extracted_context.hex_trace_id).must_equal('80f198ee56343ba864fe8b2a57d3eff7') - _(extracted_context.hex_span_id).must_equal('e457b5a2e4d86bd1') - _(extracted_context.trace_flags).must_equal(OpenTelemetry::Trace::TraceFlags::SAMPLED) - _(extracted_context).must_be(:remote?) - end - end - - describe 'given a context with a sampling bit set to disabled' do - let(:sampled_header) do - '0' - end - - it 'extracts a default trace flag' do - context = propagator.extract(carrier, context: parent_context) - extracted_context = OpenTelemetry::Trace.current_span(context).context - - _(extracted_context.hex_trace_id).must_equal('80f198ee56343ba864fe8b2a57d3eff7') - _(extracted_context.hex_span_id).must_equal('e457b5a2e4d86bd1') - _(extracted_context.trace_flags).must_equal(OpenTelemetry::Trace::TraceFlags::DEFAULT) - _(extracted_context).must_be(:remote?) - end - end - - describe 'given context with a 64 bit/16 HEXDIGIT trace id' do - let(:trace_id_header) do - '64fe8b2a57d3eff7' - end - - it 'pads the trace id' do - context = propagator.extract(carrier, context: parent_context) - extracted_context = OpenTelemetry::Trace.current_span(context).context - - _(extracted_context.hex_trace_id).must_equal('000000000000000064fe8b2a57d3eff7') - _(extracted_context.hex_span_id).must_equal('e457b5a2e4d86bd1') - _(extracted_context.trace_flags).must_equal(OpenTelemetry::Trace::TraceFlags::SAMPLED) - _(extracted_context).must_be(:remote?) - end - end - - describe 'given context with a malformed trace id' do - let(:trace_id_header) do - 'abc123' - end - - it 'skips content extraction' do - context = propagator.extract(carrier, context: parent_context) - extracted_context = OpenTelemetry::Trace.current_span(context).context - - _(extracted_context).must_be_same_as(OpenTelemetry::Trace::SpanContext::INVALID) - end - end - - describe 'given context with a malformed span id' do - let(:span_id_header) do - 'abc123' - end - - it 'skips content extraction' do - context = propagator.extract(carrier, context: parent_context) - extracted_context = OpenTelemetry::Trace.current_span(context).context - - _(extracted_context).must_be_same_as(OpenTelemetry::Trace::SpanContext::INVALID) - end - end - - describe 'baggage handling' do - describe 'given valid baggage items' do - it 'extracts baggage items' do - carrier_with_baggage = carrier.merge( - 'ot-baggage-foo' => 'bar', - 'ot-baggage-bar' => 'baz' - ) - - context = propagator.extract(carrier_with_baggage, context: parent_context) - _(OpenTelemetry::Baggage.value('foo', context: context)).must_equal('bar') - _(OpenTelemetry::Baggage.value('bar', context: context)).must_equal('baz') - end - end - - describe 'given invalid baggage keys' do - it 'omits entries' do - carrier_with_baggage = carrier.merge( - 'ot-baggage-f00' => 'bar', - 'ot-baggage-bar' => 'baz' - ) - - context = propagator.extract(carrier_with_baggage, context: parent_context) - _(OpenTelemetry::Baggage.value('fθθ', context: context)).must_be_nil - _(OpenTelemetry::Baggage.value('bar', context: context)).must_equal('baz') - end - end - - describe 'given invalid baggage values' do - it 'omits entries' do - carrier_with_baggage = carrier.merge( - 'ot-baggage-foo' => 'bαr', - 'ot-baggage-bar' => 'baz' - ) - - context = propagator.extract(carrier_with_baggage, context: parent_context) - _(OpenTelemetry::Baggage.value('foo', context: context)).must_be_nil - _(OpenTelemetry::Baggage.value('bar', context: context)).must_equal('baz') - end - end - end - - describe 'given an alternative getter parameter' do - it 'will use the alternative getter instead of the constructor provided one' do - context = propagator.extract(carrier, context: parent_context, getter: FakeGetter.new) - extracted_context = OpenTelemetry::Trace.current_span(context).context - - _(extracted_context.hex_trace_id).must_equal('7ffe3d75a2b8ef468ab34365ee891f08') - _(extracted_context.hex_span_id).must_equal('1db68d4e2a5b754e') - _(extracted_context.trace_flags).must_equal(OpenTelemetry::Trace::TraceFlags::DEFAULT) - _(extracted_context).must_be(:remote?) - end - end - end - - describe '#inject' do - describe 'when provided invalid trace ids' do - let(:trace_id) do - '0' * 32 - end - - it 'skips injecting context' do - carrier = {} - propagator.inject(carrier, context: context) - - _(carrier).must_be_empty - end - end - - describe 'when provided invalid span ids' do - let(:span_id) do - '0' * 16 - end - - it 'skips injecting context' do - carrier = {} - propagator.inject(carrier, context: context) - - _(carrier).must_be_empty - end - end - - describe 'given a minimal context' do - it 'injects OpenTracing headers' do - carrier = {} - propagator.inject(carrier, context: context) - - _(carrier.fetch('ot-tracer-traceid')).must_equal(truncated_trace_id) - _(carrier.fetch('ot-tracer-spanid')).must_equal(span_id) - _(carrier.fetch('ot-tracer-sampled')).must_equal('false') - end - end - - describe 'given a sampled trace flag' do - let(:trace_flags) do - OpenTelemetry::Trace::TraceFlags::SAMPLED - end - - it 'injects OpenTracing headers' do - carrier = {} - propagator.inject(carrier, context: context) - - _(carrier.fetch('ot-tracer-traceid')).must_equal(truncated_trace_id) - _(carrier.fetch('ot-tracer-spanid')).must_equal(span_id) - _(carrier.fetch('ot-tracer-sampled')).must_equal('true') - end - end - - describe 'given a trace id that exceeds the 64 BIT/16 HEXDIG limit' do - let(:trace_id) do - '80f198ee56343ba864fe8b2a57d3eff7' - end - - it 'injects truncates the trace id header' do - carrier = {} - propagator.inject(carrier, context: context) - - _(carrier.fetch('ot-tracer-traceid')).must_equal('64fe8b2a57d3eff7') - _(carrier.fetch('ot-tracer-spanid')).must_equal(span_id) - _(carrier.fetch('ot-tracer-sampled')).must_equal('false') - end - end - - describe 'baggage handling' do - describe 'given valid baggage items' do - it 'injects baggage items' do - context_with_baggage = baggage.build(context: context) do |builder| - builder.set_value('foo', 'bar') - builder.set_value('bar', 'baz') - end - - carrier = {} - propagator.inject(carrier, context: context_with_baggage) - - _(carrier.fetch('ot-baggage-foo')).must_equal('bar') - _(carrier.fetch('ot-baggage-bar')).must_equal('baz') - end - end - - describe 'given invalid baggage keys' do - it 'omits entries' do - context_with_baggage = baggage.build(context: context) do |builder| - builder.set_value('fθθ', 'bar') - builder.set_value('bar', 'baz') - end - - carrier = {} - propagator.inject(carrier, context: context_with_baggage) - - _(carrier.keys).wont_include('ot-baggage-f00') - _(carrier.fetch('ot-baggage-bar')).must_equal('baz') - end - end - - describe 'given invalid baggage values' do - it 'omits entries' do - context_with_baggage = baggage.build(context: context) do |builder| - builder.set_value('foo', 'bαr') - builder.set_value('bar', 'baz') - end - - carrier = {} - propagator.inject(carrier, context: context_with_baggage) - - _(carrier.keys).wont_include('ot-baggage-foo') - _(carrier.fetch('ot-baggage-bar')).must_equal('baz') - end - end - end - - describe 'given an alternative setter parameter' do - it 'will use the alternative setter instead of the constructor provided one' do - carrier = {} - - alternate_setter = FakeSetter.new - propagator.inject(carrier, context: context, setter: alternate_setter) - - _(carrier.fetch('ot-tracer-traceid')).must_equal('ot-tracer-traceid = 64fe8b2a57d3eff7') - _(carrier.fetch('ot-tracer-spanid')).must_equal('ot-tracer-spanid = e457b5a2e4d86bd1') - _(carrier.fetch('ot-tracer-sampled')).must_equal('ot-tracer-sampled = false') - end - end - end -end diff --git a/propagator/ottrace/test/opentelemetry/propagator/ottrace_test.rb b/propagator/ottrace/test/opentelemetry/propagator/ottrace_test.rb deleted file mode 100644 index 722e090eae..0000000000 --- a/propagator/ottrace/test/opentelemetry/propagator/ottrace_test.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -describe OpenTelemetry::Propagator::OTTrace do - describe '#text_map_propagator' do - it 'returns an instance of TextMapPropagator' do - propagator = OpenTelemetry::Propagator::OTTrace.text_map_propagator - _(propagator).must_be_instance_of( - OpenTelemetry::Propagator::OTTrace::TextMapPropagator - ) - end - end -end diff --git a/propagator/ottrace/test/test_helper.rb b/propagator/ottrace/test/test_helper.rb deleted file mode 100644 index ebdae41909..0000000000 --- a/propagator/ottrace/test/test_helper.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -if ENV['ENABLE_COVERAGE'].to_i.positive? - require 'simplecov' - SimpleCov.start - SimpleCov.minimum_coverage 85 -end - -$LOAD_PATH.unshift File.expand_path('../lib', __dir__) -require 'minitest/autorun' -require 'opentelemetry-api' -require 'opentelemetry-propagator-ottrace' - -OpenTelemetry.logger = Logger.new(File::NULL) diff --git a/propagator/xray/.rubocop.yml b/propagator/xray/.rubocop.yml deleted file mode 100644 index ca08f89cec..0000000000 --- a/propagator/xray/.rubocop.yml +++ /dev/null @@ -1,17 +0,0 @@ -AllCops: - TargetRubyVersion: '2.6.0' -Lint/UnusedMethodArgument: - Enabled: false -Metrics/AbcSize: - Max: 18 -Metrics/LineLength: - Enabled: false -Metrics/MethodLength: - Max: 20 -Metrics/ParameterLists: - Enabled: false -Naming/FileName: - Exclude: - - 'lib/opentelemetry-propagator-xray.rb' -Style/ModuleFunction: - Enabled: false diff --git a/propagator/xray/.yardopts b/propagator/xray/.yardopts deleted file mode 100644 index e59552bddf..0000000000 --- a/propagator/xray/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Propagator XRay ---markup=markdown ---main=README.md -./lib/opentelemetry/propagator/xray/**/*.rb -./lib/opentelemetry/propagator/xray.rb -- -README.md -CHANGELOG.md diff --git a/propagator/xray/CHANGELOG.md b/propagator/xray/CHANGELOG.md deleted file mode 100644 index e9249b5e3b..0000000000 --- a/propagator/xray/CHANGELOG.md +++ /dev/null @@ -1,31 +0,0 @@ -# Release History: opentelemetry-propagator-xray - -### v0.21.0 / 2022-06-09 - -* (No significant changes) - -### v0.20.1 / 2021-09-29 - -* (No significant changes) - -### v0.20.0 / 2021-08-12 - -* ADDED: Xray compliant ids - -### v0.19.0 / 2021-06-23 - -* FIXED: XRay propagator null exception (#833) -* ADDED: Add Tracer.non_recording_span to API - -### v0.18.0 / 2021-05-21 - -* ADDED: Updated API depedency for 1.0.0.rc1 -* FIXED: XRay trace_id parsing length - -### v0.17.0 / 2021-04-22 - -* Initial release. - -### v0.1.0 / 2021-02-26 - -* Initial release. diff --git a/propagator/xray/Gemfile b/propagator/xray/Gemfile deleted file mode 100644 index b32179c8b2..0000000000 --- a/propagator/xray/Gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -# Copyright OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec diff --git a/propagator/xray/LICENSE b/propagator/xray/LICENSE deleted file mode 100644 index ada534dc97..0000000000 --- a/propagator/xray/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/propagator/xray/README.md b/propagator/xray/README.md deleted file mode 100644 index 4b7d0f4cff..0000000000 --- a/propagator/xray/README.md +++ /dev/null @@ -1,60 +0,0 @@ -# opentelemetry-propagator-xray - -The `opentelemetry-propagator-xray` gem contains injectors and extractors for the -[AWS XRay propagation format][aws-xray]. - -## What is OpenTelemetry? - -[OpenTelemetry][opentelemetry-home] is an open source observability framework, providing a general-purpose API, SDK, and related tools required for the instrumentation of cloud-native software, frameworks, and libraries. - -OpenTelemetry provides a single set of APIs, libraries, agents, and collector services to capture distributed traces and metrics from your application. You can analyze them using Prometheus, Jaeger, and other observability tools. - -## How does this gem fit in? - -This gem can be used with any OpenTelemetry SDK implementation. This can be the official `opentelemetry-sdk` gem or any other concrete implementation. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-propagator-xray -``` - -Or, if you use [bundler][bundler-home], include `opentelemetry-propagator-xray` in your `Gemfile`. - -In your application: -``` -require 'opentelemetry/propagator/xray' -# Optional -ENV['OTEL_PROPAGATORS'] ||= 'xray' # Or you can set this as an environment variable outside of the application -``` - -## To generate AWS XRay compliant IDs use the 'OpenTelemetry::AWSXRayTrace' module: -``` -require 'opentelemetry/propagator/xray' - -OpenTelemetry::SDK.configure do |c| - c.id_generator = OpenTelemetry::Propagator::XRay::IDGenerator -end -``` -The propagator and ID generation are independent and do not need to be used in conjunction but can be. - -## How can I get involved? - -The `opentelemetry-propagator-xray` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. - -## License - -The `opentelemetry-propagator-xray` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information. - -[opentelemetry-home]: https://opentelemetry.io -[bundler-home]: https://bundler.io -[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby -[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE -[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig -[community-meetings]: https://github.com/open-telemetry/community#community-meetings -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions -[aws-xray]: https://docs.aws.amazon.com/xray/latest/devguide/aws-xray.html diff --git a/propagator/xray/Rakefile b/propagator/xray/Rakefile deleted file mode 100644 index fcb1f9afa4..0000000000 --- a/propagator/xray/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/propagator/xray/lib/opentelemetry-propagator-xray.rb b/propagator/xray/lib/opentelemetry-propagator-xray.rb deleted file mode 100644 index d044dad2a5..0000000000 --- a/propagator/xray/lib/opentelemetry-propagator-xray.rb +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -# Copyright OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry-api' -require_relative './opentelemetry/propagator/xray' diff --git a/propagator/xray/lib/opentelemetry/propagator/xray.rb b/propagator/xray/lib/opentelemetry/propagator/xray.rb deleted file mode 100644 index 3b8ff076b0..0000000000 --- a/propagator/xray/lib/opentelemetry/propagator/xray.rb +++ /dev/null @@ -1,49 +0,0 @@ -# frozen_string_literal: true - -# Copyright OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. - -require_relative './xray/text_map_propagator' - -module OpenTelemetry - # Namespace for OpenTelemetry propagator extension libraries - module Propagator - # Namespace for OpenTelemetry XRay propagation - module XRay - extend self - - DEBUG_CONTEXT_KEY = Context.create_key('xray-debug-key') - TEXT_MAP_PROPAGATOR = TextMapPropagator.new - private_constant :DEBUG_CONTEXT_KEY, :TEXT_MAP_PROPAGATOR - - # @api private - # Returns a new context with the xray debug flag enabled - def context_with_debug(context) - context.set_value(DEBUG_CONTEXT_KEY, true) - end - - # @api private - # Read the XRay debug flag from the provided context - def debug?(context) - !context.value(DEBUG_CONTEXT_KEY).nil? - end - - # Returns a text map propagator that propagates context in the XRay - # format. - def text_map_propagator - TEXT_MAP_PROPAGATOR - end - end - end -end - -require_relative './xray/version' -require_relative './xray/id_generator' diff --git a/propagator/xray/lib/opentelemetry/propagator/xray/id_generator.rb b/propagator/xray/lib/opentelemetry/propagator/xray/id_generator.rb deleted file mode 100644 index 8da284dc4c..0000000000 --- a/propagator/xray/lib/opentelemetry/propagator/xray/id_generator.rb +++ /dev/null @@ -1,44 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Propagator - module XRay - # This module is intended to only be used as an override for how to generate IDs to be compliant with XRay - module IDGenerator - extend self - - # Generates a valid trace identifier, a 16-byte string with at least one - # non-zero byte. - # AWS Docs: https://docs.aws.amazon.com/xray/latest/api/API_PutTraceSegments.html - # hi - 4 bytes timestamp, 4 bytes random (Mid) - # low - 8 bytes random. - # Since we include timestamp, impossible to be invalid. - # @return [bytes] a valid trace ID that is compliant with AWS XRay. - def generate_trace_id - time_hi = generate_time_bytes - mid_and_low = Random.bytes(12) - time_hi << mid_and_low - end - - # Generates a valid span identifier, an 8-byte string with at least one - # non-zero byte. - # - # @return [bytes] a valid span ID. - def generate_span_id - OpenTelemetry::Trace.generate_span_id - end - - private - - # Seconds since epoch converted to 4 bytes in big-endian order. - def generate_time_bytes - [Time.now.to_i].pack('N') - end - end - end - end -end diff --git a/propagator/xray/lib/opentelemetry/propagator/xray/text_map_propagator.rb b/propagator/xray/lib/opentelemetry/propagator/xray/text_map_propagator.rb deleted file mode 100644 index bc7714b998..0000000000 --- a/propagator/xray/lib/opentelemetry/propagator/xray/text_map_propagator.rb +++ /dev/null @@ -1,127 +0,0 @@ -# frozen_string_literal: true - -# Copyright OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - # Namespace for OpenTelemetry propagator extension libraries - module Propagator - # Namespace for OpenTelemetry XRay propagation - module XRay - # Propagates context in carriers in the xray single header format - class TextMapPropagator - XRAY_CONTEXT_KEY = 'X-Amzn-Trace-Id' - XRAY_CONTEXT_REGEX = /\ARoot=(?([a-z0-9\-]{35}))(?:;Parent=(?([a-z0-9]{16})))?(?:;Sampled=(?[01d](?![0-9a-f])))?(?:;(?.*))?\Z/.freeze - SAMPLED_VALUES = %w[1 d].freeze - FIELDS = [XRAY_CONTEXT_KEY].freeze - - private_constant :XRAY_CONTEXT_KEY, :XRAY_CONTEXT_REGEX, :SAMPLED_VALUES, :FIELDS - - # Extract trace context from the supplied carrier. - # If extraction fails, the original context will be returned - # - # @param [Carrier] carrier The carrier to get the header from - # @param [optional Context] context Context to be updated with the trace context - # extracted from the carrier. Defaults to +Context.current+. - # @param [optional Getter] getter If the optional getter is provided, it - # will be used to read the header from the carrier, otherwise the default - # text map getter will be used. - # - # @return [Context] context updated with extracted baggage, or the original context - # if extraction fails - def extract(carrier, context: Context.current, getter: Context::Propagation.text_map_getter) - header = getter.get(carrier, XRAY_CONTEXT_KEY) - return context unless header - - match = parse_header(header) - return context unless match - - span_context = Trace::SpanContext.new( - trace_id: to_trace_id(match['trace_id']), - span_id: to_span_id(match['span_id']), - trace_flags: to_trace_flags(match['sampling_state']), - tracestate: to_trace_state(match['trace_state']), - remote: true - ) - - span = OpenTelemetry::Trace.non_recording_span(span_context) - context = XRay.context_with_debug(context) if match['sampling_state'] == 'd' - Trace.context_with_span(span, parent_context: context) - rescue OpenTelemetry::Error - context - end - - # Inject trace context into the supplied carrier. - # - # @param [Carrier] carrier The mutable carrier to inject trace context into - # @param [Context] context The context to read trace context from - # @param [optional Setter] setter If the optional setter is provided, it - # will be used to write context into the carrier, otherwise the default - # text map setter will be used. - def inject(carrier, context: Context.current, setter: Context::Propagation.text_map_setter) - span_context = Trace.current_span(context).context - return unless span_context.valid? - - sampling_state = if XRay.debug?(context) - 'd' - elsif span_context.trace_flags.sampled? - '1' - else - '0' - end - - ot_trace_id = span_context.hex_trace_id - xray_trace_id = "1-#{ot_trace_id[0..7]}-#{ot_trace_id[8..ot_trace_id.length]}" - parent_id = span_context.hex_span_id - - xray_value = "Root=#{xray_trace_id};Parent=#{parent_id};Sampled=#{sampling_state}" - - setter.set(carrier, XRAY_CONTEXT_KEY, xray_value) - nil - end - - private - - def parse_header(header) - return nil unless (match = header.match(XRAY_CONTEXT_REGEX)) - return nil unless match['trace_id'] - return nil unless match['span_id'] - - match - end - - # Convert an id from a hex encoded string to byte array. Assumes the input id has already been - # validated to be 35 characters in length. - def to_trace_id(hex_id) - Array(hex_id[2..9] + hex_id[11..hex_id.length]).pack('H*') - end - - # Convert an id from a hex encoded string to byte array. - def to_span_id(hex_id) - Array(hex_id).pack('H*') - end - - def to_trace_flags(sampling_state) - if SAMPLED_VALUES.include?(sampling_state) - Trace::TraceFlags::SAMPLED - else - Trace::TraceFlags::DEFAULT - end - end - - def to_trace_state(trace_state) - return nil unless trace_state - - Trace::Tracestate.from_string(trace_state.gsub(';', ',')) - end - end - end - end -end diff --git a/propagator/xray/lib/opentelemetry/propagator/xray/version.rb b/propagator/xray/lib/opentelemetry/propagator/xray/version.rb deleted file mode 100644 index 34fa77b306..0000000000 --- a/propagator/xray/lib/opentelemetry/propagator/xray/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Propagator - module XRay - VERSION = '0.21.0' - end - end -end diff --git a/propagator/xray/opentelemetry-propagator-xray.gemspec b/propagator/xray/opentelemetry-propagator-xray.gemspec deleted file mode 100644 index 2e0c119b32..0000000000 --- a/propagator/xray/opentelemetry-propagator-xray.gemspec +++ /dev/null @@ -1,45 +0,0 @@ -# frozen_string_literal: true - -# Copyright OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) - -require 'opentelemetry/propagator/xray/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-propagator-xray' - spec.version = OpenTelemetry::Propagator::XRay::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'XRay Context Propagation Extension for the OpenTelemetry framework' - spec.description = 'XRay Context Propagation Extension for the OpenTelemetry framework' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'opentelemetry-api', '~> 1.0' - - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'rake', '~> 12.0' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17.1' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-propagator-xray/v#{OpenTelemetry::Propagator::XRay::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/master/propagator/xray' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-propagator-xray/v#{OpenTelemetry::Propagator::XRay::VERSION}" - end -end diff --git a/propagator/xray/test/.rubocop.yml b/propagator/xray/test/.rubocop.yml deleted file mode 100644 index dd94258585..0000000000 --- a/propagator/xray/test/.rubocop.yml +++ /dev/null @@ -1,4 +0,0 @@ -inherit_from: ../.rubocop.yml - -Metrics/BlockLength: - Enabled: false diff --git a/propagator/xray/test/aws_xray_trace_test.rb b/propagator/xray/test/aws_xray_trace_test.rb deleted file mode 100644 index 5e0b9fd1e6..0000000000 --- a/propagator/xray/test/aws_xray_trace_test.rb +++ /dev/null @@ -1,35 +0,0 @@ -# frozen_string_literal: true - -require 'date' -require 'test_helper' - -describe OpenTelemetry::Trace::SpanContext do - let(:id_generator) { OpenTelemetry::Propagator::XRay::IDGenerator } - - describe 'generate trace id in the correct format' do - it 'must generate 16 in length' do - trace_id = id_generator.generate_trace_id - _(trace_id.length).must_equal(16) - end - it 'first 4 bytes should be a valid epoch date' do - trace_id = id_generator.generate_trace_id - # Convert to hex - hex = trace_id[0..3].unpack1('H*') - # Convert to int - time_int = hex.to_i(16) - # Convert to datetime - begin - date = Time.at(time_int).to_datetime - rescue ArgumentError - date = nil - end - # Make sure it's valid - _(date).wont_be_nil - end - it 'generate_span_id still works' do - trace_id = id_generator.generate_span_id - # Make sure it's valid - _(trace_id).wont_be_nil - end - end -end diff --git a/propagator/xray/test/test_helper.rb b/propagator/xray/test/test_helper.rb deleted file mode 100644 index 2737475443..0000000000 --- a/propagator/xray/test/test_helper.rb +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -# Copyright OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'minitest/autorun' -require 'opentelemetry-propagator-xray' diff --git a/propagator/xray/test/text_map_propagator_test.rb b/propagator/xray/test/text_map_propagator_test.rb deleted file mode 100644 index 656d294fb0..0000000000 --- a/propagator/xray/test/text_map_propagator_test.rb +++ /dev/null @@ -1,178 +0,0 @@ -# frozen_string_literal: true - -# Copyright OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -describe OpenTelemetry::Propagator::XRay::TextMapPropagator do - Span = OpenTelemetry::Trace::Span - SpanContext = OpenTelemetry::Trace::SpanContext - TraceFlags = OpenTelemetry::Trace::TraceFlags - - let(:propagator) { OpenTelemetry::Propagator::XRay::TextMapPropagator.new } - - describe('#extract') do - it 'extracts context with trace id, span id, sampling flag, trace state' do - parent_context = OpenTelemetry::Context.empty - carrier = { 'X-Amzn-Trace-Id' => 'Root=1-80f198ea-e56343ba864fe8b2a57d3eff;Parent=e457b5a2e4d86bd1;Sampled=1;Foo=Bar;Fizz=Buzz' } - - context = propagator.extract(carrier, context: parent_context) - extracted_context = OpenTelemetry::Trace.current_span(context).context - - _(extracted_context.hex_trace_id).must_equal('80f198eae56343ba864fe8b2a57d3eff') - _(extracted_context.hex_span_id).must_equal('e457b5a2e4d86bd1') - _(extracted_context.trace_flags).must_equal(OpenTelemetry::Trace::TraceFlags::SAMPLED) - _(extracted_context.tracestate.to_s).must_equal(OpenTelemetry::Trace::Tracestate.from_string('Foo=Bar,Fizz=Buzz').to_s) - _(extracted_context).must_be(:remote?) - end - - it 'extracts context with trace id, span id, sampling flag' do - parent_context = OpenTelemetry::Context.empty - carrier = { 'X-Amzn-Trace-Id' => 'Root=1-80f198ea-e56343ba864fe8b2a57d3eff;Parent=e457b5a2e4d86bd1;Sampled=1' } - - context = propagator.extract(carrier, context: parent_context) - extracted_context = OpenTelemetry::Trace.current_span(context).context - - _(extracted_context.hex_trace_id).must_equal('80f198eae56343ba864fe8b2a57d3eff') - _(extracted_context.hex_span_id).must_equal('e457b5a2e4d86bd1') - _(extracted_context.trace_flags).must_equal(OpenTelemetry::Trace::TraceFlags::SAMPLED) - _(extracted_context).must_be(:remote?) - end - - it 'extracts context with trace id, span id' do - parent_context = OpenTelemetry::Context.empty - carrier = { 'X-Amzn-Trace-Id' => 'Root=1-80f198ea-e56343ba864fe8b2a57d3eff;Parent=e457b5a2e4d86bd1' } - - context = propagator.extract(carrier, context: parent_context) - extracted_context = OpenTelemetry::Trace.current_span(context).context - - _(extracted_context.hex_trace_id).must_equal('80f198eae56343ba864fe8b2a57d3eff') - _(extracted_context.hex_span_id).must_equal('e457b5a2e4d86bd1') - _(extracted_context.trace_flags).must_equal(OpenTelemetry::Trace::TraceFlags::DEFAULT) - _(extracted_context).must_be(:remote?) - end - - it 'converts debug flag to sampled' do - parent_context = OpenTelemetry::Context.empty - carrier = { 'X-Amzn-Trace-Id' => 'Root=1-80f198ea-e56343ba864fe8b2a57d3eff;Parent=e457b5a2e4d86bd1;Sampled=d' } - - context = propagator.extract(carrier, context: parent_context) - extracted_context = OpenTelemetry::Trace.current_span(context).context - - _(extracted_context.trace_flags).must_equal(OpenTelemetry::Trace::TraceFlags::SAMPLED) - end - - it 'handles malformed trace id' do - parent_context = OpenTelemetry::Context.empty - carrier = { 'X-Amzn-Trace-Id' => 'Root=180f198ea-e56343ba864fe8b2a57d3eff;Parent=e457b5a2e4d86bd1;Sampled=1' } - - context = propagator.extract(carrier, context: parent_context) - - _(context).must_equal(parent_context) - end - - it 'handles malformed span id' do - parent_context = OpenTelemetry::Context.empty - carrier = { 'X-Amzn-Trace-Id' => 'Root=1-80f198ea-e56343ba864fe8b2a57d3eff;Parent=457b5a2e4d86bd1;Sampled=1' } - - context = propagator.extract(carrier, context: parent_context) - - _(context).must_equal(parent_context) - end - it 'handles missing header gracefully' do - parent_context = OpenTelemetry::Context.empty - carrier = {} - - context = propagator.extract(carrier, context: parent_context) - - _(context).must_equal(parent_context) - end - end - - describe '#inject' do - it 'injects context with sampled trace flags' do - context = create_context( - trace_id: '80f198eae56343ba864fe8b2a57d3eff', - span_id: 'e457b5a2e4d86bd1', - trace_flags: TraceFlags::SAMPLED - ) - - carrier = {} - propagator.inject(carrier, context: context) - - expected_xray = 'Root=1-80f198ea-e56343ba864fe8b2a57d3eff;Parent=e457b5a2e4d86bd1;Sampled=1' - _(carrier['X-Amzn-Trace-Id']).must_equal(expected_xray) - end - - it 'injects context with default trace flags' do - context = create_context( - trace_id: '80f198eae56343ba864fe8b2a57d3eff', - span_id: 'e457b5a2e4d86bd1', - trace_flags: TraceFlags::DEFAULT - ) - - carrier = {} - propagator.inject(carrier, context: context) - - expected_xray = 'Root=1-80f198ea-e56343ba864fe8b2a57d3eff;Parent=e457b5a2e4d86bd1;Sampled=0' - _(carrier['X-Amzn-Trace-Id']).must_equal(expected_xray) - end - - it 'injects debug flag when present' do - context = create_context( - trace_id: '80f198eae56343ba864fe8b2a57d3eff', - span_id: 'e457b5a2e4d86bd1', - xray_debug: true - ) - - carrier = {} - propagator.inject(carrier, context: context) - - expected_xray = 'Root=1-80f198ea-e56343ba864fe8b2a57d3eff;Parent=e457b5a2e4d86bd1;Sampled=d' - _(carrier['X-Amzn-Trace-Id']).must_equal(expected_xray) - end - - it 'no-ops if trace id invalid' do - context = create_context( - trace_id: '0' * 32, - span_id: 'e457b5a2e4d86bd1' - ) - - carrier = {} - propagator.inject(carrier, context: context) - - _(carrier.key?('X-Amzn-Trace-Id')).must_equal(false) - end - - it 'no-ops if span id invalid' do - context = create_context( - trace_id: '80f198eae56343ba864fe8b2a57d3eff', - span_id: '0' * 16 - ) - - carrier = {} - propagator.inject(carrier, context: context) - - _(carrier.key?('X-Amzn-Trace-Id')).must_equal(false) - end - end - - def create_context(trace_id:, - span_id:, - trace_flags: TraceFlags::DEFAULT, - xray_debug: false) - context = OpenTelemetry::Trace.context_with_span( - OpenTelemetry::Trace.non_recording_span( - SpanContext.new( - trace_id: Array(trace_id).pack('H*'), - span_id: Array(span_id).pack('H*'), - trace_flags: trace_flags - ) - ) - ) - context = OpenTelemetry::Propagator::XRay.context_with_debug(context) if xray_debug - context - end -end diff --git a/propagator/xray/test/xray_test.rb b/propagator/xray/test/xray_test.rb deleted file mode 100644 index b7f7b867b0..0000000000 --- a/propagator/xray/test/xray_test.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -# Copyright OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -describe OpenTelemetry::Propagator::XRay do - describe '#text_map_propagator' do - it 'returns an instance of TextMapPropagator' do - propagator = OpenTelemetry::Propagator::XRay.text_map_propagator - _(propagator).must_be_instance_of( - OpenTelemetry::Propagator::XRay::TextMapPropagator - ) - end - end -end diff --git a/resource_detectors/.rubocop.yml b/resource_detectors/.rubocop.yml deleted file mode 100644 index f47183dcd1..0000000000 --- a/resource_detectors/.rubocop.yml +++ /dev/null @@ -1,29 +0,0 @@ -AllCops: - TargetRubyVersion: '2.6.0' - -Bundler/OrderedGems: - Exclude: - - gemfiles/**/* -Lint/UnusedMethodArgument: - Enabled: false -Metrics/AbcSize: - Max: 18 -Metrics/LineLength: - Enabled: false -Metrics/MethodLength: - Max: 20 -Metrics/ParameterLists: - Enabled: false -Style/FrozenStringLiteralComment: - Exclude: - - gemfiles/**/* -Style/ModuleFunction: - Enabled: false -Style/StringLiterals: - Exclude: - - gemfiles/**/* -Metrics/BlockLength: - Enabled: false -Naming/FileName: - Exclude: - - "lib/opentelemetry-resource_detectors.rb" diff --git a/resource_detectors/.yardopts b/resource_detectors/.yardopts deleted file mode 100644 index 1b25699e21..0000000000 --- a/resource_detectors/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Resource Detectors ---markup=markdown ---main=README.md -./lib/opentelemetry/resource/detectors/**/*.rb -./lib/opentelemetry/resource/detectors.rb -- -README.md -CHANGELOG.md diff --git a/resource_detectors/CHANGELOG.md b/resource_detectors/CHANGELOG.md deleted file mode 100644 index f9abc46bd6..0000000000 --- a/resource_detectors/CHANGELOG.md +++ /dev/null @@ -1,82 +0,0 @@ -# Release History: opentelemetry-resource_detectors - -### v0.21.0 / 2022-06-09 - -* BREAKING CHANGE: This requires upgrading both the SDK and Instrumentation gem in tandem - - -### v0.20.0 / 2022-05-02 - -* ADDED: Added Google Cloud Function Resource Detection - -### v0.19.1 / 2021-09-29 - -* (No significant changes) - -### v0.19.0 / 2021-08-12 - -* BREAKING CHANGE: Use auto-generated resource constants in sdk and resource_detectors - -* ADDED: Use auto-generated resource constants in sdk and resource_detectors - -### v0.18.1 / 2021-06-23 - -* (No significant changes) - -### v0.18.0 / 2021-05-21 - -* FIXED: Rename cloud.zone to cloud.availability_zone - -### v0.17.0 / 2021-04-22 - -* (No significant changes) - -### v0.16.0 / 2021-03-17 - -* ADDED: Add k8s node to gcp resource detector -* DOCS: Replace Gitter with GitHub Discussions - -### v0.15.0 / 2021-02-18 - -* (No significant changes) - -### v0.14.0 / 2021-02-03 - -* DOCS: Updated gem name to match gemspec - -### v0.13.0 / 2021-01-29 - -* (No significant changes) - -### v0.12.0 / 2020-12-24 - -* (No significant changes) - -### v0.11.0 / 2020-12-11 - -* FIXED: Copyright comments to not reference year - -### v0.10.0 / 2020-12-03 - -* (No significant changes) - -### v0.9.0 / 2020-11-27 - -* BREAKING CHANGE: Add timeout for force_flush and shutdown - -* ADDED: Add timeout for force_flush and shutdown - -### v0.8.0 / 2020-10-27 - -* (No significant changes) - -### v0.7.0 / 2020-10-07 - -* DOCS: Standardize toplevel docs structure and readme - -### v0.6.0 / 2020-09-10 - -* BREAKING CHANGE: Rename Resource labels to attributes - -* FIXED: Rename Resource labels to attributes -* ADDED: Environment variable resource detection diff --git a/resource_detectors/Gemfile b/resource_detectors/Gemfile deleted file mode 100644 index 6ae9e48bcd..0000000000 --- a/resource_detectors/Gemfile +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :development, :test do - gem 'byebug' unless RUBY_PLATFORM == 'java' - gem 'pry' -end diff --git a/resource_detectors/LICENSE b/resource_detectors/LICENSE deleted file mode 100644 index 1ef7dad2c5..0000000000 --- a/resource_detectors/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright The OpenTelemetry Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/resource_detectors/README.md b/resource_detectors/README.md deleted file mode 100644 index a0ffaa622e..0000000000 --- a/resource_detectors/README.md +++ /dev/null @@ -1,51 +0,0 @@ -# Opentelemetry::Resource::Detectors - -The `opentelemetry-resource_detectors` gem provides resource detectors for OpenTelemetry. - -## What is OpenTelemetry? - -OpenTelemetry is an open source observability framework, providing a general-purpose API, SDK, and related tools required for the instrumentation of cloud-native software, frameworks, and libraries. - -OpenTelemetry provides a single set of APIs, libraries, agents, and collector services to capture distributed traces and metrics from your application. You can analyze them using Prometheus, Jaeger, and other observability tools. - -## How does this gem fit in? - -The `opentelemetry-resource-detectors` gem provides a means of retrieving a resource for supported environments following the resource semantic conventions. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-sdk -gem install opentelemetry-resource_detectors -``` - -Or, if you use Bundler, include `opentelemetry-sdk` and `opentelemetry-resource_detectors` in your `Gemfile`. - -```rb -require 'opentelemetry/sdk' -require 'opentelemetry/resource/detectors' - -# For a specific platform -OpenTelemetry::SDK.configure do |c| - c.resource = OpenTelemetry::Resource::Detectors::GoogleCloudPlatform.detect -end - -# Or if you would like for it to run all detectors available -OpenTelemetry::SDK.configure do |c| - c.resource = OpenTelemetry::Resource::Detectors::AutoDetector.detect -end -``` - -## How can I get involved? - -The `opentelemetry-resource_detectors` gem source is on github, along with related gems. - -The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the meeting calendar for dates and times. For more information on this and other language SIGs, see the OpenTelemetry community page. - -## License - -The `opentelemetry-resource_detectors` gem is distributed under the Apache 2.0 license. See LICENSE for more information. - -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/resource_detectors/Rakefile b/resource_detectors/Rakefile deleted file mode 100644 index 1a64ba842e..0000000000 --- a/resource_detectors/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/gem_tasks' -require 'rake/testtask' -require 'yard' -require 'rubocop/rake_task' - -RuboCop::RakeTask.new - -Rake::TestTask.new :test do |t| - t.libs << 'test' - t.libs << 'lib' - t.test_files = FileList['test/**/*_test.rb'] -end - -YARD::Rake::YardocTask.new do |t| - t.stats_options = ['--list-undoc'] -end - -if RUBY_ENGINE == 'truffleruby' - task default: %i[test] -else - task default: %i[test rubocop yard] -end diff --git a/resource_detectors/lib/opentelemetry-resource_detectors.rb b/resource_detectors/lib/opentelemetry-resource_detectors.rb deleted file mode 100644 index 09e0ec72fa..0000000000 --- a/resource_detectors/lib/opentelemetry-resource_detectors.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative './opentelemetry/resource/detectors' diff --git a/resource_detectors/lib/opentelemetry/resource/detectors.rb b/resource_detectors/lib/opentelemetry/resource/detectors.rb deleted file mode 100644 index 96208d6774..0000000000 --- a/resource_detectors/lib/opentelemetry/resource/detectors.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry/sdk' -require 'opentelemetry/resource/detectors/version' -require 'opentelemetry/resource/detectors/google_cloud_platform' -require 'opentelemetry/resource/detectors/auto_detector' - -# OpenTelemetry is an open source observability framework, providing a -# general-purpose API, SDK, and related tools required for the instrumentation -# of cloud-native software, frameworks, and libraries. -# -# The OpenTelemetry module provides global accessors for telemetry objects. -# See the documentation for the `opentelemetry-api` gem for details. -module OpenTelemetry - module Resource - # Detectors contains the resource detectors as well as the AutoDetector - # that can run all the detectors and return an accumlated resource - module Detectors - end - end -end diff --git a/resource_detectors/lib/opentelemetry/resource/detectors/auto_detector.rb b/resource_detectors/lib/opentelemetry/resource/detectors/auto_detector.rb deleted file mode 100644 index 1d509cd5c2..0000000000 --- a/resource_detectors/lib/opentelemetry/resource/detectors/auto_detector.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Resource - module Detectors - # AutoDetector contains detect class method for running all detectors - module AutoDetector - extend self - - DETECTORS = [ - OpenTelemetry::Resource::Detectors::GoogleCloudPlatform - ].freeze - - def detect - DETECTORS.map(&:detect).reduce(:merge) - end - end - end - end -end diff --git a/resource_detectors/lib/opentelemetry/resource/detectors/google_cloud_platform.rb b/resource_detectors/lib/opentelemetry/resource/detectors/google_cloud_platform.rb deleted file mode 100644 index 626b121236..0000000000 --- a/resource_detectors/lib/opentelemetry/resource/detectors/google_cloud_platform.rb +++ /dev/null @@ -1,72 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'google-cloud-env' - -module OpenTelemetry - module Resource - module Detectors - # GoogleCloudPlatform contains detect class method for determining gcp environment resource attributes - module GoogleCloudPlatform - extend self - - def detect # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity - gcp_env = Google::Cloud::Env.new - resource_attributes = {} - - if gcp_env.compute_engine? - resource_attributes[OpenTelemetry::SemanticConventions::Resource::CLOUD_PROVIDER] = 'gcp' - resource_attributes[OpenTelemetry::SemanticConventions::Resource::CLOUD_ACCOUNT_ID] = gcp_env.project_id - resource_attributes[OpenTelemetry::SemanticConventions::Resource::CLOUD_REGION] = gcp_env.instance_attribute('cluster-location') - resource_attributes[OpenTelemetry::SemanticConventions::Resource::CLOUD_AVAILABILITY_ZONE] = gcp_env.instance_zone - - resource_attributes[OpenTelemetry::SemanticConventions::Resource::HOST_ID] = gcp_env.lookup_metadata('instance', 'id') - resource_attributes[OpenTelemetry::SemanticConventions::Resource::HOST_NAME] = ENV['HOSTNAME'] || - gcp_env.lookup_metadata('instance', 'hostname') || - safe_gethostname - end - - if gcp_env.kubernetes_engine? - resource_attributes[OpenTelemetry::SemanticConventions::Resource::K8S_CLUSTER_NAME] = gcp_env.instance_attribute('cluster-name') - resource_attributes[OpenTelemetry::SemanticConventions::Resource::K8S_NAMESPACE_NAME] = gcp_env.kubernetes_engine_namespace_id - resource_attributes[OpenTelemetry::SemanticConventions::Resource::K8S_POD_NAME] = ENV['HOSTNAME'] || safe_gethostname - resource_attributes[OpenTelemetry::SemanticConventions::Resource::K8S_NODE_NAME] = gcp_env.lookup_metadata('instance', 'hostname') - - resource_attributes[OpenTelemetry::SemanticConventions::Resource::CONTAINER_NAME] = ENV['CONTAINER_NAME'] - end - - if gcp_env.knative? - resource_attributes[OpenTelemetry::SemanticConventions::Resource::CLOUD_PROVIDER] = 'gcp' - resource_attributes[OpenTelemetry::SemanticConventions::Resource::CLOUD_ACCOUNT_ID] = gcp_env.project_id - resource_attributes[OpenTelemetry::SemanticConventions::Resource::FAAS_NAME] = gcp_env.knative_service_id - resource_attributes[OpenTelemetry::SemanticConventions::Resource::FAAS_VERSION] = gcp_env.knative_service_revision - zone = gcp_env.instance_zone - resource_attributes[OpenTelemetry::SemanticConventions::Resource::CLOUD_REGION] = get_region zone - resource_attributes[OpenTelemetry::SemanticConventions::Resource::CLOUD_AVAILABILITY_ZONE] = zone - end - - resource_attributes.delete_if { |_key, value| value.nil? || value.empty? } - OpenTelemetry::SDK::Resources::Resource.create(resource_attributes) - end - - private - - def get_region(zone) - return if zone.nil? || zone.empty? - - split_arr = zone.split('-', 3) - split_arr[0].concat('-', split_arr[1]) - end - - def safe_gethostname - Socket.gethostname - rescue StandardError - '' - end - end - end - end -end diff --git a/resource_detectors/lib/opentelemetry/resource/detectors/version.rb b/resource_detectors/lib/opentelemetry/resource/detectors/version.rb deleted file mode 100644 index 3f5cf532b4..0000000000 --- a/resource_detectors/lib/opentelemetry/resource/detectors/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Resource - module Detectors - VERSION = '0.21.0' - end - end -end diff --git a/resource_detectors/opentelemetry-resource_detectors.gemspec b/resource_detectors/opentelemetry-resource_detectors.gemspec deleted file mode 100644 index c6a05dd296..0000000000 --- a/resource_detectors/opentelemetry-resource_detectors.gemspec +++ /dev/null @@ -1,45 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -lib = File.expand_path('lib', __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'opentelemetry/resource/detectors/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-resource_detectors' - spec.version = OpenTelemetry::Resource::Detectors::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'Resource detection helpers for OpenTelemetry' - spec.description = 'Resource detection helpers for OpenTelemetry' - spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby' - spec.license = 'Apache-2.0' - - spec.files = ::Dir.glob('lib/**/*.rb') + - ::Dir.glob('*.md') + - ['LICENSE', '.yardopts'] - spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6.0' - - spec.add_dependency 'google-cloud-env' - spec.add_dependency 'opentelemetry-sdk', '~> 1.0' - - spec.add_development_dependency 'bundler', '>= 1.17' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'rake', '~> 12.0' - spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'simplecov', '~> 0.17' - spec.add_development_dependency 'yard', '~> 0.9' - spec.add_development_dependency 'yard-doctest', '~> 0.1.6' - - if spec.respond_to?(:metadata) - spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-resource_detectors/v#{OpenTelemetry::Resource::Detectors::VERSION}/file.CHANGELOG.html" - spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/tree/main/resource_detectors' - spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby/issues' - spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-resource_detectors/v#{OpenTelemetry::Resource::Detectors::VERSION}" - end -end diff --git a/resource_detectors/test/opentelemetry/detectors/auto_detector_test.rb b/resource_detectors/test/opentelemetry/detectors/auto_detector_test.rb deleted file mode 100644 index 172b88ed6a..0000000000 --- a/resource_detectors/test/opentelemetry/detectors/auto_detector_test.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -describe OpenTelemetry::Resource::Detectors::AutoDetector do - let(:auto_detector) { OpenTelemetry::Resource::Detectors::AutoDetector } - let(:detected_resource) { auto_detector.detect } - let(:detected_resource_attributes) { detected_resource.attribute_enumerator.to_h } - let(:expected_resource_attributes) { {} } - - describe '.detect' do - it 'returns detected resources' do - _(detected_resource).must_be_instance_of(OpenTelemetry::SDK::Resources::Resource) - _(detected_resource_attributes).must_equal(expected_resource_attributes) - end - end -end diff --git a/resource_detectors/test/opentelemetry/detectors/google_cloud_platform_test.rb b/resource_detectors/test/opentelemetry/detectors/google_cloud_platform_test.rb deleted file mode 100644 index e26c346bf6..0000000000 --- a/resource_detectors/test/opentelemetry/detectors/google_cloud_platform_test.rb +++ /dev/null @@ -1,92 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -describe OpenTelemetry::Resource::Detectors::GoogleCloudPlatform do - let(:detector) { OpenTelemetry::Resource::Detectors::GoogleCloudPlatform } - - describe '.detect' do - let(:detected_resource) { detector.detect } - let(:detected_resource_attributes) { detected_resource.attribute_enumerator.to_h } - let(:expected_resource_attributes) { {} } - - it 'returns an empty resource' do - _(detected_resource).must_be_instance_of(OpenTelemetry::SDK::Resources::Resource) - _(detected_resource_attributes).must_equal(expected_resource_attributes) - end - - describe 'when in a gcp environment' do - let(:project_id) { 'opentelemetry' } - - before do - gcp_env_mock = MiniTest::Mock.new - gcp_env_mock.expect(:compute_engine?, true) - gcp_env_mock.expect(:project_id, project_id) - gcp_env_mock.expect(:instance_attribute, 'us-central1', %w[cluster-location]) - gcp_env_mock.expect(:instance_zone, 'us-central1-a') - gcp_env_mock.expect(:lookup_metadata, 'opentelemetry-test', %w[instance id]) - gcp_env_mock.expect(:lookup_metadata, 'opentelemetry-node-1', %w[instance hostname]) - gcp_env_mock.expect(:instance_attribute, 'opentelemetry-cluster', %w[cluster-name]) - gcp_env_mock.expect(:kubernetes_engine?, true) - gcp_env_mock.expect(:kubernetes_engine_namespace_id, 'default') - gcp_env_mock.expect(:knative?, true) - gcp_env_mock.expect(:project_id, project_id) - gcp_env_mock.expect(:knative_service_id, 'test-google-cloud-function') - gcp_env_mock.expect(:knative_service_revision, '2') - gcp_env_mock.expect(:instance_zone, 'us-central1-a') - - Socket.stub(:gethostname, 'opentelemetry-test') do - old_hostname = ENV['HOSTNAME'] - ENV['HOSTNAME'] = 'opentelemetry-host-name-1' - begin - Google::Cloud::Env.stub(:new, gcp_env_mock) { detected_resource } - ensure - ENV['HOSTNAME'] = old_hostname - end - end - end - - let(:expected_resource_attributes) do - { - 'cloud.provider' => 'gcp', - 'cloud.account.id' => 'opentelemetry', - 'cloud.region' => 'us-central1', - 'cloud.availability_zone' => 'us-central1-a', - 'host.id' => 'opentelemetry-test', - 'host.name' => 'opentelemetry-host-name-1', - 'k8s.cluster.name' => 'opentelemetry-cluster', - 'k8s.namespace.name' => 'default', - 'k8s.pod.name' => 'opentelemetry-host-name-1', - 'k8s.node.name' => 'opentelemetry-node-1', - 'faas.name' => 'test-google-cloud-function', - 'faas.version' => '2' - } - end - - it 'returns a resource with gcp attributes' do - _(detected_resource).must_be_instance_of(OpenTelemetry::SDK::Resources::Resource) - _(detected_resource_attributes).must_equal(expected_resource_attributes) - end - - describe 'and a nil resource value is detected' do - let(:project_id) { nil } - - it 'returns a resource without that attribute' do - _(detected_resource_attributes.key?('cloud.account.id')).must_equal(false) - end - end - - describe 'and an empty string resource value is detected' do - let(:project_id) { '' } - - it 'returns a resource without that attribute' do - _(detected_resource_attributes.key?('cloud.account.id')).must_equal(false) - end - end - end - end -end diff --git a/resource_detectors/test/test_helper.rb b/resource_detectors/test/test_helper.rb deleted file mode 100644 index 9a11dc2253..0000000000 --- a/resource_detectors/test/test_helper.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'simplecov' -SimpleCov.start - -require 'opentelemetry/resource/detectors' -require 'minitest/autorun' -require 'pry' From 194a8e9319b31df74c7984274e898e6d7a8c612a Mon Sep 17 00:00:00 2001 From: Ariel Valentin Date: Fri, 17 Jun 2022 01:19:18 +0000 Subject: [PATCH 2/3] chore: Rollback minitest Minitest 5.16 has changes that cause mock verification to fail in our test suite. Reverting to an earlier version allows tests to pass. https://github.com/open-telemetry/opentelemetry-ruby/runs/6928651844?check_suite_focus=true --- sdk/opentelemetry-sdk.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/opentelemetry-sdk.gemspec b/sdk/opentelemetry-sdk.gemspec index 3e90054fff..9e223e6f60 100644 --- a/sdk/opentelemetry-sdk.gemspec +++ b/sdk/opentelemetry-sdk.gemspec @@ -37,7 +37,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'bundler', '>= 1.17' spec.add_development_dependency 'faraday', '~> 0.13' - spec.add_development_dependency 'minitest', '~> 5.0' + spec.add_development_dependency 'minitest', '~> 5.15.0' spec.add_development_dependency 'opentelemetry-exporter-zipkin', '~> 0.19.0' spec.add_development_dependency 'opentelemetry-instrumentation-base', '~> 0.20' spec.add_development_dependency 'opentelemetry-test-helpers' From 0b0b1d9f38d64f6b66c6b4a806ea225eb7911aa5 Mon Sep 17 00:00:00 2001 From: Ariel Valentin Date: Fri, 17 Jun 2022 09:30:48 -0500 Subject: [PATCH 3/3] fix: Apply suggestions from code review --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b633096fc5..e9ece910e0 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,8 @@ The Ruby [OpenTelemetry](https://opentelemetry.io/) client. - [Getting Started][getting-started] - [Contributing](#contributing) -- [Contrib Repository]](#contrib-repository) +- [Contrib Repository](#contrib-repository) +- [Instrumentation Libraries][contrib-instrumentation] - [Versioning](#versioning) - [Useful links](#useful-links) - [License](#license) @@ -45,7 +46,7 @@ Maintainers ([@open-telemetry/ruby-maintainers](https://github.com/orgs/open-tel ## Contrib Repository -The contrib repository contains instrumentation libraries for many popular Ruby gems, including Rails, Rack, Sinatra, and others, so you can start using OpenTelemetry with minimal changes to your application. See the instrumentation [README][contrib-repo] for more details. +The contrib repository contains instrumentation libraries for many popular Ruby gems, including Rails, Rack, Sinatra, and others, so you can start using OpenTelemetry with minimal changes to your application. See the [contrib README][contrib-repo] for more details. ## Versioning @@ -62,6 +63,7 @@ Apache 2.0 - See [LICENSE][license-url] for more information. [ci-image]: https://github.com/open-telemetry/opentelemetry-ruby/workflows/CI/badge.svg?event=push [contrib-repo]: https://github.com/open-telemetry/opentelemetry-ruby-contrib +[contrib-instrumentations]: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation [examples-github]: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/examples [getting-started]: https://opentelemetry.io/docs/ruby/ [issues-good-first-issue]: https://github.com/open-telemetry/opentelemetry-ruby/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22