lib/opentelemetry/instrumentation/ethon/patches/easy.rb in opentelemetry-instrumentation-ethon-0.16.0 vs lib/opentelemetry/instrumentation/ethon/patches/easy.rb in opentelemetry-instrumentation-ethon-0.17.0

- old
+ new

@@ -68,14 +68,11 @@ 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: { - 'http.method' => method, - 'http.url' => OpenTelemetry::Common::Utilities.cleanse_url(url) - }, + attributes: span_creation_attributes(method), kind: :client ) @otel_original_headers ||= {} OpenTelemetry::Trace.with_span(@otel_span) do @@ -87,9 +84,21 @@ 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