From 352812e023851db1fa20cc9a083a864b75f51189 Mon Sep 17 00:00:00 2001 From: Jimmy Bourassa Date: Sun, 17 Sep 2023 10:34:53 -0400 Subject: [PATCH 1/6] Micro optimization: build Hash w/ `{}` (#665) --- .../graphql/tracers/graphql_trace.rb | 46 +++++++++++-------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/instrumentation/graphql/lib/opentelemetry/instrumentation/graphql/tracers/graphql_trace.rb b/instrumentation/graphql/lib/opentelemetry/instrumentation/graphql/tracers/graphql_trace.rb index 3f470685d..881aa10ec 100644 --- a/instrumentation/graphql/lib/opentelemetry/instrumentation/graphql/tracers/graphql_trace.rb +++ b/instrumentation/graphql/lib/opentelemetry/instrumentation/graphql/tracers/graphql_trace.rb @@ -75,10 +75,11 @@ def execute_field(field:, query:, ast_node:, arguments:, object:, &block) platform_key = _otel_execute_field_key(field: field) return super unless platform_key - attributes = {} - attributes['graphql.field.parent'] = field.owner&.graphql_name - attributes['graphql.field.name'] = field.graphql_name - attributes['graphql.lazy'] = false + attributes = { + 'graphql.field.parent' => field.owner&.graphql_name, + 'graphql.field.name' => field.graphql_name, + 'graphql.lazy' => false + } tracer.in_span(platform_key, attributes: attributes, &block) end @@ -87,10 +88,11 @@ def execute_field_lazy(field:, query:, ast_node:, arguments:, object:, &block) platform_key = _otel_execute_field_key(field: field) return super unless platform_key - attributes = {} - attributes['graphql.field.parent'] = field.owner&.graphql_name - attributes['graphql.field.name'] = field.graphql_name - attributes['graphql.lazy'] = true + attributes = { + 'graphql.field.parent' => field.owner&.graphql_name, + 'graphql.field.name' => field.graphql_name, + 'graphql.lazy' => true + } tracer.in_span(platform_key, attributes: attributes, &block) end @@ -99,9 +101,10 @@ def authorized(query:, type:, object:, &block) platform_key = @_otel_authorized_key_cache[type] return super unless platform_key - attributes = {} - attributes['graphql.type.name'] = type.graphql_name - attributes['graphql.lazy'] = false + attributes = { + 'graphql.type.name' => type.graphql_name, + 'graphql.lazy' => false + } tracer.in_span(platform_key, attributes: attributes, &block) end @@ -110,9 +113,10 @@ def authorized_lazy(query:, type:, object:, &block) platform_key = @_otel_authorized_key_cache[type] return super unless platform_key - attributes = {} - attributes['graphql.type.name'] = type.graphql_name - attributes['graphql.lazy'] = true + attributes = { + 'graphql.type.name' => type.graphql_name, + 'graphql.lazy' => true + } tracer.in_span(platform_key, attributes: attributes, &block) end @@ -120,9 +124,10 @@ def authorized_lazy(query:, type:, object:, &block) def resolve_type(query:, type:, object:, &block) platform_key = @_otel_resolve_type_key_cache[type] - attributes = {} - attributes['graphql.type.name'] = type.graphql_name - attributes['graphql.lazy'] = false + attributes = { + 'graphql.type.name' => type.graphql_name, + 'graphql.lazy' => false + } tracer.in_span(platform_key, attributes: attributes, &block) end @@ -130,9 +135,10 @@ def resolve_type(query:, type:, object:, &block) def resolve_type_lazy(query:, type:, object:, &block) platform_key = @_otel_resolve_type_key_cache[type] - attributes = {} - attributes['graphql.type.name'] = type.graphql_name - attributes['graphql.lazy'] = true + attributes = { + 'graphql.type.name' => type.graphql_name, + 'graphql.lazy' => true + } tracer.in_span(platform_key, attributes: attributes, &block) end From 0b560e215be158cd511fbc33f89d5d6626b0fcec Mon Sep 17 00:00:00 2001 From: Maciej Moleda Date: Sun, 24 Sep 2023 16:51:07 +0100 Subject: [PATCH 2/6] fix(bunny): headers property needs to exist (#661) * [bunny] fix: headers property needs to exist * add test for nil headers from producer --- .../instrumentation/bunny/patch_helpers.rb | 1 + .../bunny/patch_helpers_test.rb | 36 +++++++++++++++++++ instrumentation/bunny/test/test_helper.rb | 1 + 3 files changed, 38 insertions(+) create mode 100644 instrumentation/bunny/test/opentelemetry/instrumentation/bunny/patch_helpers_test.rb diff --git a/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/patch_helpers.rb b/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/patch_helpers.rb index 4cb67b884..043a17569 100644 --- a/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/patch_helpers.rb +++ b/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/patch_helpers.rb @@ -35,6 +35,7 @@ def self.destination_name(exchange, routing_key) def self.extract_context(properties) # use the receive span as parent context parent_context = OpenTelemetry.propagation.extract(properties[:tracer_receive_headers]) + return [parent_context, nil] if properties[:headers].nil? # link to the producer context producer_context = OpenTelemetry.propagation.extract(properties[:headers]) diff --git a/instrumentation/bunny/test/opentelemetry/instrumentation/bunny/patch_helpers_test.rb b/instrumentation/bunny/test/opentelemetry/instrumentation/bunny/patch_helpers_test.rb new file mode 100644 index 000000000..522f555a2 --- /dev/null +++ b/instrumentation/bunny/test/opentelemetry/instrumentation/bunny/patch_helpers_test.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +require_relative '../../../../lib/opentelemetry/instrumentation/bunny/patch_helpers' + +describe OpenTelemetry::Instrumentation::Bunny::PatchHelpers do + let(:properties) do + { + headers: { + 'traceparent' => '00-eab67ae26433f603121bd5674149d9e1-2007f3325d3cb6d6-01' + }, + tracer_receive_headers: { + 'traceparent' => '00-cd52775b3cb38931adf5fa880f890c25-cddb52a470027489-01' + } + } + end + + describe '.extract_context' do + it 'returns the parent context with links when headers from producer exists' do + parent_context, links = OpenTelemetry::Instrumentation::Bunny::PatchHelpers.extract_context(properties) + _(parent_context).must_be_instance_of(OpenTelemetry::Context) + _(links).must_be_instance_of(Array) + _(links.first).must_be_instance_of(OpenTelemetry::Trace::Link) + end + + it 'returns the parent context with no links when headers from producer not present' do + properties.delete(:headers) + parent_context, links = OpenTelemetry::Instrumentation::Bunny::PatchHelpers.extract_context(properties) + _(parent_context).must_be_instance_of(OpenTelemetry::Context) + _(links).must_be_nil + end + end +end diff --git a/instrumentation/bunny/test/test_helper.rb b/instrumentation/bunny/test/test_helper.rb index 835bba61b..0c2839200 100644 --- a/instrumentation/bunny/test/test_helper.rb +++ b/instrumentation/bunny/test/test_helper.rb @@ -19,4 +19,5 @@ c.error_handler = ->(exception:, message:) { raise(exception || message) } c.logger = Logger.new($stderr, level: ENV.fetch('OTEL_LOG_LEVEL', 'fatal').to_sym) c.add_span_processor SPAN_PROCESSOR + c.propagators = [OpenTelemetry::Trace::Propagation::TraceContext.text_map_propagator] end From 6d7af22f4072c02e173d31fe31b68911e1ddd8b1 Mon Sep 17 00:00:00 2001 From: Ariel Valentin Date: Tue, 26 Sep 2023 19:58:11 -0500 Subject: [PATCH 3/6] chore: use stable toys version --- .toys/.toys.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.toys/.toys.rb b/.toys/.toys.rb index 0131aac9c..b74dbff54 100644 --- a/.toys/.toys.rb +++ b/.toys/.toys.rb @@ -1,4 +1,4 @@ -toys_version! ">= 0.14.5" +toys_version! "0.14.7" load_git remote: "https://github.com/dazuma/toys.git", path: ".toys/release", From 48baa03246865db68a5804bcc4147ca059aacc79 Mon Sep 17 00:00:00 2001 From: Ariel Valentin Date: Tue, 26 Sep 2023 20:01:22 -0500 Subject: [PATCH 4/6] chore: use stable version of toys release code --- .toys/.toys.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/.toys/.toys.rb b/.toys/.toys.rb index b74dbff54..76d3765c5 100644 --- a/.toys/.toys.rb +++ b/.toys/.toys.rb @@ -3,4 +3,5 @@ load_git remote: "https://github.com/dazuma/toys.git", path: ".toys/release", as: "release", + commit: "toys/v0.14.7", update: 3600 From d89b68e77297fd7ce99fb9fd0de329a5544a1ba3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 27 Sep 2023 04:52:26 -0500 Subject: [PATCH 5/6] release: Release 2 gems (#675) --- instrumentation/bunny/CHANGELOG.md | 4 ++++ .../bunny/lib/opentelemetry/instrumentation/bunny/version.rb | 2 +- instrumentation/graphql/CHANGELOG.md | 4 ++++ .../lib/opentelemetry/instrumentation/graphql/version.rb | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/instrumentation/bunny/CHANGELOG.md b/instrumentation/bunny/CHANGELOG.md index 8f51168d3..303b724da 100644 --- a/instrumentation/bunny/CHANGELOG.md +++ b/instrumentation/bunny/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-instrumentation-bunny +### v0.21.1 / 2023-09-27 + +* FIXED: Headers property needs to exist + ### v0.21.0 / 2023-09-07 * FIXED: Align messaging instrumentation operation names diff --git a/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/version.rb b/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/version.rb index 579cb36a4..c567843e5 100644 --- a/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/version.rb +++ b/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Instrumentation module Bunny - VERSION = '0.21.0' + VERSION = '0.21.1' end end end diff --git a/instrumentation/graphql/CHANGELOG.md b/instrumentation/graphql/CHANGELOG.md index b184ab690..1fb6b31a0 100644 --- a/instrumentation/graphql/CHANGELOG.md +++ b/instrumentation/graphql/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-instrumentation-graphql +### v0.26.7 / 2023-09-27 + +* FIXED: Micro optimization: build Hash w/ {} (https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/665) + ### v0.26.6 / 2023-08-26 * FIXED: Improve GraphQL tracing compatibility with other tracers diff --git a/instrumentation/graphql/lib/opentelemetry/instrumentation/graphql/version.rb b/instrumentation/graphql/lib/opentelemetry/instrumentation/graphql/version.rb index ba51dd6b3..aca6963d2 100644 --- a/instrumentation/graphql/lib/opentelemetry/instrumentation/graphql/version.rb +++ b/instrumentation/graphql/lib/opentelemetry/instrumentation/graphql/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Instrumentation module GraphQL - VERSION = '0.26.6' + VERSION = '0.26.7' end end end From 1e8fd4eb7eeea33a351923667ff5b35ce549e653 Mon Sep 17 00:00:00 2001 From: Sam Bostock Date: Sat, 30 Sep 2023 07:27:52 -0400 Subject: [PATCH 6/6] fix: Fix "uses cases" typo in `CONTRIBUTING.md` (#679) --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 554628cf7..391929061 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,7 +16,7 @@ As with other OpenTelemetry clients, opentelemetry-ruby follows the ### Focus on Capabilities, Not Structure Compliance OpenTelemetry is an evolving specification, one where the desires and -use cases are clear, but the method to satisfy those uses cases are not. +use cases are clear, but the method to satisfy those use cases are not. As such, Contributions should provide functionality and behavior that conforms to the specification, but the interface and structure are flexible.