All Projects → microsoft → ApplicationInsights-Ruby

microsoft / ApplicationInsights-Ruby

Licence: other
Microsoft Application Insights SDK for Ruby

Programming Languages

ruby
36898 projects - #4 most used programming language
powershell
5483 projects

Projects that are alternatives of or similar to ApplicationInsights-Ruby

Applicationinsights Python
Application Insights SDK for Python
Stars: ✭ 114 (+280%)
Mutual labels:  application-insights, telemetry, trace
appinsights-rs
Application Insights SDK for Rust
Stars: ✭ 29 (-3.33%)
Mutual labels:  application-insights, telemetry
arcus.observability
Observability with Microsoft Azure in a breeze.
Stars: ✭ 24 (-20%)
Mutual labels:  application-insights, telemetry
Applicationinsights Aspnetcore
ASP.NET Core web applications monitoring
Stars: ✭ 306 (+920%)
Mutual labels:  application-insights, telemetry
TraceEvent
Trace events in real time sessions
Stars: ✭ 26 (-13.33%)
Mutual labels:  telemetry, trace
Applicationinsights Go
Microsoft Application Insights SDK for Go
Stars: ✭ 113 (+276.67%)
Mutual labels:  application-insights, telemetry
Orchard-Azure-Application-Insights
This Orchard CMS module enables easy integration of Azure Application Insights telemetry into Orchard. Useful for Azure-based cloud hsoting.
Stars: ✭ 17 (-43.33%)
Mutual labels:  application-insights, telemetry
Applicationinsights Dotnet
ApplicationInsights-dotnet
Stars: ✭ 367 (+1123.33%)
Mutual labels:  application-insights, telemetry
Applicationinsights Dotnet Logging
.NET Logging adaptors
Stars: ✭ 100 (+233.33%)
Mutual labels:  application-insights, telemetry
Applicationinsights Php
Azure Application Insights SDK for PHP
Stars: ✭ 98 (+226.67%)
Mutual labels:  application-insights, telemetry
Applicationinsights Dotnet Server
Microsoft Application Insights for .NET Web Applications
Stars: ✭ 130 (+333.33%)
Mutual labels:  application-insights, telemetry
Applicationinsights Home
Application Insights main repository for documentation of overall SDK offerings for all platforms.
Stars: ✭ 221 (+636.67%)
Mutual labels:  application-insights, telemetry
profiler
Continuous profiling based on pprof
Stars: ✭ 221 (+636.67%)
Mutual labels:  trace
orb
Orb is a dynamic network observability platform
Stars: ✭ 437 (+1356.67%)
Mutual labels:  telemetry
browser-telemetry
A Telemetry module for collecting errors, logs, metrics, uncaught exceptions etc on browser side.
Stars: ✭ 20 (-33.33%)
Mutual labels:  telemetry
probe-scraper
Scrape and publish Telemetry probe data from Firefox
Stars: ✭ 18 (-40%)
Mutual labels:  telemetry
go-gin-logrus
Gin Web Framework for using Logrus as the Gin logger with Tracing middleware
Stars: ✭ 38 (+26.67%)
Mutual labels:  trace
cpp client telemetry
1DS C++ SDK
Stars: ✭ 62 (+106.67%)
Mutual labels:  telemetry
ets2-mobile-route-advisor
ETS2 / ATS's Route Advisor, for mobile devices
Stars: ✭ 119 (+296.67%)
Mutual labels:  telemetry
QuickTraceiOSLogger
A real time iOS log trace tool, view iOS log with pc web browser under local area network, which will automatically scroll like xcode. 一个实时的iOS日志跟踪工具,在局域网中使用 PC Web 浏览器查看 iOS 日志,它将像xcode一样自动滚动。
Stars: ✭ 16 (-46.67%)
Mutual labels:  trace

Application Insights SDK for Ruby

Gem Version Build Status

Ruby is a dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write. -- Ruby - Official Site

This project extends the Application Insights API surface to support Ruby. Application Insights is a service that allows developers to keep their application available, performing and succeeding. This Ruby gem will allow you to send telemetry of various kinds (event, trace, exception, etc.) to the Application Insights service where they can be visualized in the Azure Portal.

Status

This SDK is NOT maintained or supported by Microsoft even though we've contributed to it in the past. Note that Azure Monitor only provides support when using the supported SDKs. We’re constantly assessing opportunities to expand our support for other languages, so follow our GitHub Announcements page to receive the latest SDK news.

Requirements

Ruby 1.9.3 and above are currently supported by this gem.

Installation

To install the latest release you can use gem.

$ gem install application_insights

Usage

Once installed, you can send telemetry to Application Insights. Here are a few samples.

Note: before you can send data to you will need an instrumentation key. Please see the Getting an Application Insights Instrumentation Key section for more information.

Sending a simple event telemetry item

require 'application_insights'
tc = ApplicationInsights::TelemetryClient.new '<YOUR INSTRUMENTATION KEY GOES HERE>'
tc.track_event 'My event'
tc.flush

Sending an event telemetry item with custom properties and measurements

require 'application_insights'
tc = ApplicationInsights::TelemetryClient.new '<YOUR INSTRUMENTATION KEY GOES HERE>'
tc.track_event 'My event', :properties => { 'custom property' => 'some value' }, :measurements => { 'custom metric' => 13 }
tc.flush

Sending a trace telemetry item with custom properties

require 'application_insights'
tc = ApplicationInsights::TelemetryClient.new '<YOUR INSTRUMENTATION KEY GOES HERE>'
tc.track_trace 'My trace statement', ApplicationInsights::Channel::Contracts::SeverityLevel::INFORMATION, :properties => { 'custom property' => 'some value' }
tc.flush

Sending a metric telemetry item (without and with optional values)

require 'application_insights'
tc = ApplicationInsights::TelemetryClient.new '<YOUR INSTRUMENTATION KEY GOES HERE>'
tc.track_metric 'My metric', 42
# with all optional values set
tc.track_metric 'My metric', 42, :kind => ApplicationInsights::Channel::Contracts::DataPointType::AGGREGATION, :count => 3, :min => 1, :max => 100, :std_dev => 10, :properties => { 'custom property' => 'some value' }
tc.flush

Sending an exception telemetry item with custom properties and measurements

require 'application_insights'
tc = ApplicationInsights::TelemetryClient.new '<YOUR INSTRUMENTATION KEY GOES HERE>'
begin
  raise ArgumentError, 'Something has gone wrong!'
rescue => e
  tc.track_exception e
end
tc.flush

Configuring context for a telemetry client instance

require 'application_insights'
tc = ApplicationInsights::TelemetryClient.new '<YOUR INSTRUMENTATION KEY GOES HERE>'
tc.context.application.ver = '1.2.3'
tc.context.device.id = 'My current device'
tc.context.device.oem_name = 'Asus'
tc.context.device.model = 'X31A'
tc.context.device.type = "Other"
tc.context.user.id = '[email protected]'
tc.track_trace 'My trace with context'
tc.flush

Configuring synchronous (default) channel properties

require 'application_insights'
tc = ApplicationInsights::TelemetryClient.new
# flush telemetry if we have 10 or more telemetry items in our queue
tc.channel.queue.max_queue_length = 10
# send telemetry to the service in batches of 5
tc.channel.sender.send_buffer_size = 5

Configuring an asynchronous channel instead of the synchronous default

require 'application_insights'
sender = ApplicationInsights::Channel::AsynchronousSender.new
queue = ApplicationInsights::Channel::AsynchronousQueue.new sender
channel = ApplicationInsights::Channel::TelemetryChannel.new nil, queue
tc = ApplicationInsights::TelemetryClient.new '<YOUR INSTRUMENTATION KEY GOES HERE>', channel
# Note: the event will be sent on a separate thread; if the app finishes before
#       the thread finishes, the data is lost
tc.track_event 'My event'

Configuring asynchronous channel properties

require 'application_insights'
sender = ApplicationInsights::Channel::AsynchronousSender.new
queue = ApplicationInsights::Channel::AsynchronousQueue.new sender
channel = ApplicationInsights::Channel::TelemetryChannel.new nil, queue
tc = ApplicationInsights::TelemetryClient.new '<YOUR INSTRUMENTATION KEY GOES HERE>', channel
# flush telemetry if we have 10 or more telemetry items in our queue
tc.channel.queue.max_queue_length = 10
# send telemetry to the service in batches of 5
tc.channel.sender.send_buffer_size = 5
# the background worker thread will be active for 5 seconds before it shuts down. if
# during this time items are picked up from the queue, the timer is reset.
tc.channel.sender.send_time = 5
# the background worker thread will poll the queue every 0.5 seconds for new items
tc.channel.sender.send_interval = 0.5

Collecting unhandled exceptions

require 'application_insights'
# setup unhandled exception handler
ApplicationInsights::UnhandledException.collect('<YOUR INSTRUMENTATION KEY GOES HERE>')
# raise an exception and this would be send to Application Insights Service
raise Exception, 'Boom!'

Collecting requests for rack applications

# set up the TrackRequest middleware in the rackup (config.ru) file
require 'application_insights'
use ApplicationInsights::Rack::TrackRequest, '<YOUR INSTRUMENTATION KEY GOES HERE>', <buffer size>
# For rails, suggest to set up this middleware in application.rb so that unhandled exceptions from controllers are also collected
config.middleware.use 'ApplicationInsights::Rack::TrackRequest', '<YOUR INSTRUMENTATION KEY GOES HERE>', <buffer size>

Rerieving the Request-Id value from ApplicationInsights

# from time to time you may need to access a request's id from within your app
application_insights_request_id = request.env['ApplicationInsights.request.id']

# this can be used for a number of different purposes, including telemetry correlation
uri = URI('http://api.example.com/search/?q=test')

req = Net::HTTP::Get.new(uri)
req['Request-Id'] = "#{application_insights_request_id}1" if application_insights_request_id

Net::HTTP.start(uri.hostname, uri.port) { |http| http.request(req) }
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].