From cf02a49c38e230f805dcfd9bbb39b8b9a8caabfb Mon Sep 17 00:00:00 2001
From: Robert Laurin <robert.laurin@shopify.com>
Date: Tue, 16 Jun 2020 13:33:57 -0400
Subject: [PATCH] Set tracer resource in initializer

---
 sdk/lib/opentelemetry/sdk/trace/tracer.rb | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sdk/lib/opentelemetry/sdk/trace/tracer.rb b/sdk/lib/opentelemetry/sdk/trace/tracer.rb
index ac3f1a3040..3fa998fea9 100644
--- a/sdk/lib/opentelemetry/sdk/trace/tracer.rb
+++ b/sdk/lib/opentelemetry/sdk/trace/tracer.rb
@@ -24,6 +24,7 @@ def initialize(name, version)
           @name = name
           @version = version
           @instrumentation_library = InstrumentationLibrary.new(name, version)
+          @resource = OpenTelemetry.tracer_provider.resource
         end
 
         def start_root_span(name, attributes: nil, links: nil, start_timestamp: nil, kind: nil)
@@ -55,8 +56,7 @@ def internal_create_span(result, name, kind, trace_id, span_id, parent_span_id,
             attributes = attributes&.merge(result.attributes) || result.attributes
             active_trace_config = OpenTelemetry.tracer_provider.active_trace_config
             active_span_processor = OpenTelemetry.tracer_provider.active_span_processor
-            resource = OpenTelemetry.tracer_provider.resource
-            Span.new(context, name, kind, parent_span_id, active_trace_config, active_span_processor, attributes, links, start_timestamp || Time.now, resource, @instrumentation_library)
+            Span.new(context, name, kind, parent_span_id, active_trace_config, active_span_processor, attributes, links, start_timestamp || Time.now, @resource, @instrumentation_library)
           else
             OpenTelemetry::Trace::Span.new(span_context: OpenTelemetry::Trace::SpanContext.new(trace_id: trace_id))
           end