2018-05-16 07:05:59 +08:00
|
|
|
package application_insights
|
|
|
|
|
|
2020-08-20 06:04:24 +08:00
|
|
|
import (
|
2021-04-28 06:01:45 +08:00
|
|
|
"github.com/microsoft/ApplicationInsights-Go/appinsights"
|
2020-08-20 06:04:24 +08:00
|
|
|
)
|
2018-05-16 07:05:59 +08:00
|
|
|
|
|
|
|
|
type Transmitter struct {
|
|
|
|
|
client appinsights.TelemetryClient
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-12 03:57:14 +08:00
|
|
|
func NewTransmitter(ikey, endpointURL string) *Transmitter {
|
2020-08-20 06:04:24 +08:00
|
|
|
if len(endpointURL) == 0 {
|
|
|
|
|
return &Transmitter{client: appinsights.NewTelemetryClient(ikey)}
|
|
|
|
|
}
|
2021-02-09 00:18:40 +08:00
|
|
|
|
|
|
|
|
telemetryConfig := appinsights.NewTelemetryConfiguration(ikey)
|
|
|
|
|
telemetryConfig.EndpointUrl = endpointURL
|
|
|
|
|
return &Transmitter{client: appinsights.NewTelemetryClientFromConfig(telemetryConfig)}
|
2018-05-16 07:05:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t *Transmitter) Track(telemetry appinsights.Telemetry) {
|
|
|
|
|
t.client.Track(telemetry)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t *Transmitter) Close() <-chan struct{} {
|
|
|
|
|
return t.client.Channel().Close(0)
|
|
|
|
|
}
|