Commit 3b486f4b authored by Jacob Vosmaer's avatar Jacob Vosmaer 👋
Browse files

Use proper correlation ID accessor

parent 73333c29
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ module Labkit
            'grpc.method': method_name,
            'grpc.service': service_name,
            pid: Process.pid,
            correlation_id: call.metadata.fetch(CORRELATION_METADATA_KEY, "(missing)"),
            correlation_id: Labkit::Correlation::CorrelationId.current_id.to_s,
            time: Time.now.utc.strftime("%Y-%m-%dT%H:%M:%S.%LZ"),
          )

+1 −13
Original line number Diff line number Diff line
@@ -70,9 +70,9 @@ describe Labkit::Logging::GRPC::ServerInterceptor do
          "grpc.method" => "ReqResMethod",
          "grpc.service" => "labkit_test.TestService",
          "pid" => Process.pid,
          "correlation_id" => "(missing)",
        )

        expect(result["correlation_id"]).to match(/[0-9a-f]{10}/)
        expect(result["time"]).to match(/^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3}Z$/)

        time_ms = result["grpc.time_ms"]
@@ -80,18 +80,6 @@ describe Labkit::Logging::GRPC::ServerInterceptor do
        expect(time_ms.to_s).to match(/^[0-9]\.[0-9]{1,3}$/)
      end

      describe "when a correlation ID is provided" do
        let(:correlation_id) { "the correlation ID" }

        it "logs a correlation id" do
          mock_server do |client|
            client.req_res_method(LabkitTest::Msg.new, metadata: { Labkit::Correlation::GRPC::GRPCCommon::CORRELATION_METADATA_KEY => correlation_id })
          end

          expect(result["correlation_id"]).to eq(correlation_id)
        end
      end

      describe "when default tags are provided" do
        let(:default_tags) { { "foo" => 123, "hello" => "world" } }