forked from influxdata/telegraf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
transmitter.go
27 lines (22 loc) · 723 Bytes
/
transmitter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package application_insights
import (
"github.com/Microsoft/ApplicationInsights-Go/appinsights"
)
type Transmitter struct {
client appinsights.TelemetryClient
}
func NewTransmitter(ikey string, endpointURL string) *Transmitter {
if len(endpointURL) == 0 {
return &Transmitter{client: appinsights.NewTelemetryClient(ikey)}
} else {
telemetryConfig := appinsights.NewTelemetryConfiguration(ikey)
telemetryConfig.EndpointUrl = endpointURL
return &Transmitter{client: appinsights.NewTelemetryClientFromConfig(telemetryConfig)}
}
}
func (t *Transmitter) Track(telemetry appinsights.Telemetry) {
t.client.Track(telemetry)
}
func (t *Transmitter) Close() <-chan struct{} {
return t.client.Channel().Close(0)
}