Sha256: b27338f566a4a9fb7f2e88405dfe1645a7cfdd6ec1371fbbc376f4c65a4276c6
Contents?: true
Size: 1.23 KB
Versions: 1
Compression:
Stored size: 1.23 KB
Contents
require 'spec_helper' describe Grape::Datadog::Middleware do class TestAPI < Grape::API use Grape::Datadog::Middleware, hostname: "test.host", tags: ["custom:tag", lambda {|env| "scheme:#{Rack::Request.new(env).scheme}" }] get 'echo/:key1/:key2' do "#{params['key1']} #{params['key2']}" end end def app; TestAPI; end before { $statsd.buffer.clear } it 'should be configurable' do subject = described_class.new(nil, hostname: "test.host") expect(subject.instance_variable_get(:@tags)).to eq(["host:test.host"]) expect(subject.instance_variable_get(:@statsd)).to be_instance_of(MockStatsd) subject = described_class.new(nil, prefer_global: false) expect(subject.instance_variable_get(:@statsd)).to be_instance_of(Statsd) end it 'should send an increment and timing event for each request' do get '/echo/1/1234' expect(last_response.status).to eq(200) expect(last_response.body).to eq('1 1234') expect($statsd.buffer).to eq([ "grape.request:1|c|#custom:tag,scheme:http,host:test.host,method:GET,path:echo.{key1}.{key2},status:200", "grape.request.time:333|ms|#custom:tag,scheme:http,host:test.host,method:GET,path:echo.{key1}.{key2},status:200" ]) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
grape-datadog-1.1.0 | spec/grape/datadog/middleware_spec.rb |