Class: ApplicationInsights::Channel::TelemetryContext

Inherits:
Object
  • Object
show all
Defined in:
lib/application_insights/channel/telemetry_context.rb

Overview

Represents the context for sending telemetry to the Application Insights service.

Examples:

require 'application_insights'
context = ApplicationInsights::Channel::TelemetryContext.new
context.instrumentation_key = '<YOUR INSTRUMENTATION KEY GOES HERE>'
context.application.id = 'My application'
context.application.ver = '1.2.3'
context.device.id = 'My current device'
context.device.oem_name = 'Asus'
context.device.model = 'X31A'
context.device.type = "Other"
context.user.id = '[email protected]'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTelemetryContext

Initializes a new instance of the class.



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/application_insights/channel/telemetry_context.rb', line 27

def initialize
  @instrumentation_key = nil
  @application = Contracts::Application.new
  @cloud = Contracts::Cloud.new
  @device = Contracts::Device.new
  @user = Contracts::User.new
  @session = Contracts::Session.new
  @operation = Contracts::Operation.new
  @location = Contracts::Location.new
  @properties = {}
end

Instance Attribute Details

#applicationContracts::Application

The application context. This contains properties of the application you are running.

Returns:



47
48
49
# File 'lib/application_insights/channel/telemetry_context.rb', line 47

def application
  @application
end

#cloudContracts::Cloud

The cloud context. This contains properties of the cloud role you are generating telemetry for.

Returns:



52
53
54
# File 'lib/application_insights/channel/telemetry_context.rb', line 52

def cloud
  @cloud
end

#deviceContracts::Device

The device context. This contains properties of the device you are running on.

Returns:



57
58
59
# File 'lib/application_insights/channel/telemetry_context.rb', line 57

def device
  @device
end

#instrumentation_keyString

The instrumentation key that is used to identify which Application Insights application this data is for.

Returns:

  • (String)

    the instrumentation key.



42
43
44
# File 'lib/application_insights/channel/telemetry_context.rb', line 42

def instrumentation_key
  @instrumentation_key
end

#locationContracts::Location

The location context. This contains properties of the location you are generating telemetry from.

Returns:



77
78
79
# File 'lib/application_insights/channel/telemetry_context.rb', line 77

def location
  @location
end

#operationContracts::Operation

The operation context. This contains properties of the operation you are generating telemetry for.

Returns:



72
73
74
# File 'lib/application_insights/channel/telemetry_context.rb', line 72

def operation
  @operation
end

#propertiesHash<String, String>

The property context. This contains free-form properties that you can add to your telemetry.

Returns:

  • (Hash<String, String>)

    the context object.



82
83
84
# File 'lib/application_insights/channel/telemetry_context.rb', line 82

def properties
  @properties
end

#sessionContracts::Session

The session context. This contains properties of the session you are generating telemetry for.

Returns:



67
68
69
# File 'lib/application_insights/channel/telemetry_context.rb', line 67

def session
  @session
end

#userContracts::User

The user context. This contains properties of the user you are generating telemetry for.

Returns:



62
63
64
# File 'lib/application_insights/channel/telemetry_context.rb', line 62

def user
  @user
end