Fix auto loading TrackRequest middleware

This commit is contained in:
Jing Li (AI) 2015-02-07 23:40:10 -08:00
Родитель 39aa8d7697
Коммит 931c835cde
4 изменённых файлов: 76 добавлений и 71 удалений

Просмотреть файл

@ -2,4 +2,8 @@ require_relative 'application_insights/telemetry_client'
require_relative 'application_insights/unhandled_exception'
require_relative 'application_insights/version'
autoload :TrackRequest, "application_insights/rack/track_request"
module ApplicationInsights
module Rack
autoload :TrackRequest, "application_insights/rack/track_request"
end
end

Просмотреть файл

@ -1,9 +1,9 @@
require 'rack'
require 'securerandom'
require_relative '../channel/contracts/request_data'
require_relative '../telemetry_client'
module ApplicationInsights
module Rack
# Track every request and sends the request data to Application Insights.
class TrackRequest
# Initializes a new instance of the class.
@ -41,7 +41,7 @@ module ApplicationInsights
@client = TelemetryClient.new @instrumentation_key, channel
end
request = Rack::Request.new env
request = ::Rack::Request.new env
id = rand(16**32).to_s(16)
start_time = start.iso8601(7)
duration = format_request_duration(stop - start)
@ -80,4 +80,5 @@ module ApplicationInsights
Time.at(duration_seconds).gmtime.strftime("0:%H:%M:%S.%7N")
end
end
end
end

Просмотреть файл

@ -167,7 +167,7 @@ module ApplicationInsights
# @param [Hash] options the options to create the {Channel::Contracts::EventData} object.
# @option options [Hash] :properties the set of custom properties the client wants attached to this
# data item. (defaults to: {})
def track_trace(name, severity_level = nil, options={})
def track_trace(name, severity_level = Channel::Contracts::SeverityLevel::INFORMATION, options={})
data_attributes = {
:message => name || 'Null',
:severity_level => severity_level || Channel::Contracts::SeverityLevel::INFORMATION,

Просмотреть файл

@ -3,7 +3,7 @@ require 'rack/mock'
require_relative '../mock_sender'
require_relative '../../../lib/application_insights/rack/track_request'
include ApplicationInsights
include ApplicationInsights::Rack
class TestTrackRequest < Test::Unit::TestCase
def test_call_works_as_expected