Loading lib/labkit/tracing/external_http/request_instrumenter.rb +4 −13 Original line number Diff line number Diff line Loading @@ -12,20 +12,11 @@ module Labkit def tags(payload) # Duration is calculated by start and end time # Exception is already captured in lib/labkit/tracing/tracing_utils.rb tags = { "component" => "external_http", "method" => payload[:method], "code" => payload[:code], "host" => payload[:host], "port" => payload[:port], "path" => payload[:path], "scheme" => payload[:scheme], } tags = payload.slice(:method, :code, :host, :port, :path, :scheme, :proxy_host, :proxy_port) tags.transform_keys!(&:name) tags["component"] = "external_http" unless payload[:proxy_host].nil? tags["proxy_host"] = payload[:proxy_host] tags["proxy_port"] = payload[:proxy_port] end tags.compact! tags end Loading lib/labkit/tracing/rails/action_view/render_template_instrumenter.rb +6 −1 Original line number Diff line number Diff line Loading @@ -16,7 +16,12 @@ module Labkit end def tags(payload) { "component" => COMPONENT_TAG, "template.id" => payload[:identifier], "template.layout" => payload[:layout] } tags = { "component" => COMPONENT_TAG } # OpenTelemetry rejects nil attributes, and error templates may not # have a layout (e.g., public/406-unsupported-browser.html). tags["template.id"] = payload[:identifier] if payload[:identifier] tags["template.layout"] = payload[:layout] if payload[:layout] tags end end end Loading lib/labkit/tracing/rails/active_record/sql_instrumenter.rb +9 −4 Original line number Diff line number Diff line Loading @@ -19,15 +19,20 @@ module Labkit fingerprint = Labkit::Logging::Sanitizer.sql_fingerprint(sql) end { tags = { "component" => COMPONENT_TAG, "span.kind" => "client", "db.type" => "sql", "db.connection_id" => payload[:connection_id], "db.cached" => payload[:cached] || false, "db.statement" => sql, "db.statement_fingerprint" => fingerprint, } # OpenTelemetry rejects nil attributes, so only add statement fields # when ActiveRecord supplies SQL (schema events may omit it). tags["db.statement"] = sql if sql tags["db.statement_fingerprint"] = fingerprint if fingerprint tags["db.connection_id"] = payload[:connection_id] if payload[:connection_id] tags end end end Loading spec/labkit/tracing/external_http/request_instrumenter_spec.rb +21 −0 Original line number Diff line number Diff line Loading @@ -72,4 +72,25 @@ describe Labkit::Tracing::ExternalHttp::RequestInstrumenter do } end end it_behaves_like "a tracing instrumenter" do let(:expected_span_name) { "external_http:request" } let(:payload) do { method: "GET", host: "gitlab.com", port: 80, path: "/gitlab-org/gitlab", scheme: "https" } end let(:expected_tags) do { "component" => "external_http", "method" => "GET", "host" => "gitlab.com", "port" => 80, "path" => "/gitlab-org/gitlab", "scheme" => "https" } end end end spec/labkit/tracing/rails/action_view/render_template_instrumenter_spec.rb +6 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,12 @@ describe Labkit::Tracing::Rails::ActionView::RenderTemplateInstrumenter do end end it "omits nil layout and template id" do instrumenter = described_class.new expect(instrumenter.tags({})).to eq({ "component" => "ActionView" }) end describe "#span_name" do context "when the template identifier is nil do" do before do Loading Loading
lib/labkit/tracing/external_http/request_instrumenter.rb +4 −13 Original line number Diff line number Diff line Loading @@ -12,20 +12,11 @@ module Labkit def tags(payload) # Duration is calculated by start and end time # Exception is already captured in lib/labkit/tracing/tracing_utils.rb tags = { "component" => "external_http", "method" => payload[:method], "code" => payload[:code], "host" => payload[:host], "port" => payload[:port], "path" => payload[:path], "scheme" => payload[:scheme], } tags = payload.slice(:method, :code, :host, :port, :path, :scheme, :proxy_host, :proxy_port) tags.transform_keys!(&:name) tags["component"] = "external_http" unless payload[:proxy_host].nil? tags["proxy_host"] = payload[:proxy_host] tags["proxy_port"] = payload[:proxy_port] end tags.compact! tags end Loading
lib/labkit/tracing/rails/action_view/render_template_instrumenter.rb +6 −1 Original line number Diff line number Diff line Loading @@ -16,7 +16,12 @@ module Labkit end def tags(payload) { "component" => COMPONENT_TAG, "template.id" => payload[:identifier], "template.layout" => payload[:layout] } tags = { "component" => COMPONENT_TAG } # OpenTelemetry rejects nil attributes, and error templates may not # have a layout (e.g., public/406-unsupported-browser.html). tags["template.id"] = payload[:identifier] if payload[:identifier] tags["template.layout"] = payload[:layout] if payload[:layout] tags end end end Loading
lib/labkit/tracing/rails/active_record/sql_instrumenter.rb +9 −4 Original line number Diff line number Diff line Loading @@ -19,15 +19,20 @@ module Labkit fingerprint = Labkit::Logging::Sanitizer.sql_fingerprint(sql) end { tags = { "component" => COMPONENT_TAG, "span.kind" => "client", "db.type" => "sql", "db.connection_id" => payload[:connection_id], "db.cached" => payload[:cached] || false, "db.statement" => sql, "db.statement_fingerprint" => fingerprint, } # OpenTelemetry rejects nil attributes, so only add statement fields # when ActiveRecord supplies SQL (schema events may omit it). tags["db.statement"] = sql if sql tags["db.statement_fingerprint"] = fingerprint if fingerprint tags["db.connection_id"] = payload[:connection_id] if payload[:connection_id] tags end end end Loading
spec/labkit/tracing/external_http/request_instrumenter_spec.rb +21 −0 Original line number Diff line number Diff line Loading @@ -72,4 +72,25 @@ describe Labkit::Tracing::ExternalHttp::RequestInstrumenter do } end end it_behaves_like "a tracing instrumenter" do let(:expected_span_name) { "external_http:request" } let(:payload) do { method: "GET", host: "gitlab.com", port: 80, path: "/gitlab-org/gitlab", scheme: "https" } end let(:expected_tags) do { "component" => "external_http", "method" => "GET", "host" => "gitlab.com", "port" => 80, "path" => "/gitlab-org/gitlab", "scheme" => "https" } end end end
spec/labkit/tracing/rails/action_view/render_template_instrumenter_spec.rb +6 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,12 @@ describe Labkit::Tracing::Rails::ActionView::RenderTemplateInstrumenter do end end it "omits nil layout and template id" do instrumenter = described_class.new expect(instrumenter.tags({})).to eq({ "component" => "ActionView" }) end describe "#span_name" do context "when the template identifier is nil do" do before do Loading