Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion source/code/go/src/plugins/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const (
envAKSResourceID = "AKS_RESOURCE_ID"
envACSResourceName = "ACS_RESOURCE_NAME"
envAppInsightsAuth = "APPLICATIONINSIGHTS_AUTH"
envAppInsightsEndpoint = "APPLICATIONINSIGHTS_ENDPOINT"
metricNameAvgFlushRate = "ContainerLogAvgRecordsFlushedPerSec"
metricNameAvgLogGenerationRate = "ContainerLogsGeneratedPerSec"
metricNameLogSize = "ContainerLogsSize"
Expand Down Expand Up @@ -141,7 +142,15 @@ func InitializeTelemetryClient(agentVersion string) (int, error) {
return -1, err
}

TelemetryClient = appinsights.NewTelemetryClient(string(decIkey))
appInsightsEndpoint := os.Getenv(envAppInsightsEndpoint)
telemetryClientConfig := appinsights.NewTelemetryConfiguration(string(decIkey))
// endpoint override required only for sovereign clouds
if appInsightsEndpoint != "" {
Log("Overriding the default AppInsights EndpointUrl with %s", appInsightsEndpoint)
telemetryClientConfig.EndpointUrl = envAppInsightsEndpoint
}
TelemetryClient = appinsights.NewTelemetryClientFromConfig(telemetryClientConfig)

telemetryOffSwitch := os.Getenv("DISABLE_TELEMETRY")
if strings.Compare(strings.ToLower(telemetryOffSwitch), "true") == 0 {
Log("Appinsights telemetry is disabled \n")
Expand Down
13 changes: 12 additions & 1 deletion source/code/plugin/ApplicationInsightsUtility.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class ApplicationInsightsUtility
@@EnvAksRegion = "AKS_REGION"
@@EnvAgentVersion = "AGENT_VERSION"
@@EnvApplicationInsightsKey = "APPLICATIONINSIGHTS_AUTH"
@@EnvApplicationInsightsEndpoint = "APPLICATIONINSIGHTS_ENDPOINT"
@@EnvControllerType = "CONTROLLER_TYPE"

@@CustomProperties = {}
Expand Down Expand Up @@ -62,6 +63,7 @@ def initializeUtility()
@@CustomProperties["AgentVersion"] = ENV[@@EnvAgentVersion]
@@CustomProperties["ControllerType"] = ENV[@@EnvControllerType]
encodedAppInsightsKey = ENV[@@EnvApplicationInsightsKey]
appInsightsEndpoint = ENV[@@EnvApplicationInsightsEndpoint]

#Check if telemetry is turned off
telemetryOffSwitch = ENV["DISABLE_TELEMETRY"]
Expand All @@ -70,7 +72,16 @@ def initializeUtility()
@@Tc = ApplicationInsights::TelemetryClient.new
elsif !encodedAppInsightsKey.nil?
decodedAppInsightsKey = Base64.decode64(encodedAppInsightsKey)
@@Tc = ApplicationInsights::TelemetryClient.new decodedAppInsightsKey
#override ai endpoint if its available otherwise use default.
if appInsightsEndpoint && !appInsightsEndpoint.nil? && !appInsightsEndpoint.empty?
$log.info("AppInsightsUtility: Telemetry client uses overrided endpoint url : #{appInsightsEndpoint}")
telemetrySynchronousSender = ApplicationInsights::Channel::SynchronousSender.new appInsightsEndpoint
telemetrySynchronousQueue = ApplicationInsights::Channel::SynchronousQueue.new(telemetrySynchronousSender)
telemetryChannel = ApplicationInsights::Channel::TelemetryChannel.new nil, telemetrySynchronousQueue
@@Tc = ApplicationInsights::TelemetryClient.new decodedAppInsightsKey, telemetryChannel
else
@@Tc = ApplicationInsights::TelemetryClient.new decodedAppInsightsKey
end
end
rescue => errorStr
$log.warn("Exception in AppInsightsUtility: initilizeUtility - error: #{errorStr}")
Expand Down