Sha256: 423eb3dbc84d719446cd9b917010bd505a1365c803d0a4137286d908df673c75

Contents?: true

Size: 963 Bytes

Versions: 17

Compression:

Stored size: 963 Bytes

Contents

require 'spec_helper'

describe Vx::Instrumentation do
  let(:out)  { StringIO.new }
  let(:inst) { described_class }
  let(:result) {
    out.rewind
    JSON.parse out.read
  }

  it "should successfully install" do
    expect(inst.install out).to be
  end

  it "should work with default values" do
    inst.with(x: "y") do
      inst.with(a: "b") do
        expect(inst.default).to eq(
          x: "y",
          a: "b"
        )
      end
      expect(inst.default).to eq(x: "y")
    end
    expect(inst.default).to eq({})
  end

  it "should handle exception" do
    inst::Logger.setup out
    ex = Exception.new("message")
    inst.handle_exception('event.name', ex, {key: "value"})
    expect(result["@event"]).to eq 'event.name'
    expect(result["@tags"]).to eq ["event", "name", "exception"]
    expect(result["@fields"]).to eq("key" => "value")
    expect(result["exception"]).to eq 'Exception'
    expect(result["message"]).to eq 'message'
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
vx-instrumentation-0.1.8 spec/lib/instrumentation_spec.rb
vx-instrumentation-0.1.7 spec/lib/instrumentation_spec.rb
vx-instrumentation-0.1.6 spec/lib/instrumentation_spec.rb
vx-instrumentation-0.1.5 spec/lib/instrumentation_spec.rb
vx-instrumentation-0.1.4 spec/lib/instrumentation_spec.rb
vx-instrumentation-0.1.3 spec/lib/instrumentation_spec.rb
vx-instrumentation-0.1.2 spec/lib/instrumentation_spec.rb
vx-instrumentation-0.1.1 spec/lib/instrumentation_spec.rb
vx-instrumentation-0.1.0 spec/lib/instrumentation_spec.rb
vx-instrumentation-0.0.8 spec/lib/instrumentation_spec.rb
vx-instrumentation-0.0.7 spec/lib/instrumentation_spec.rb
vx-instrumentation-0.0.6 spec/lib/instrumentation_spec.rb
vx-instrumentation-0.0.5 spec/lib/instrumentation_spec.rb
vx-instrumentation-0.0.4 spec/lib/instrumentation_spec.rb
vx-instrumentation-0.0.3 spec/lib/instrumentation_spec.rb
vx-instrumentation-0.0.2 spec/lib/instrumentation_spec.rb
vx-instrumentation-0.0.1 spec/lib/instrumentation_spec.rb