Documentation
¶
Overview ¶
Package appinsights provides an interface to submit telemetry to Application Insights, a component of Azure Monitor. This package calls the Classic API. See https://learn.microsoft.com/en-us/azure/azure-monitor/app/api-custom-events-metrics
Index ¶
Constants ¶
const (
Version = "v0.0.1"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// The instrumentation key used to identify the application.
// This key is required and must be set before sending any telemetry.
InstrumentationKey string
// The endpoint URL to which telemetry will be sent.
// If empty, it defaults to https://dc.services.visualstudio.com/v2/track.
Endpoint string
// Maximum number of telemetry items that can be submitted in each
// request. If this many items are buffered, the buffer will be
// flushed before MaxBatchInterval expires.
// If zero, it defaults to 1024.
MaxBatchSize int
// Maximum time to wait before sending a batch of telemetry.
// If zero, it defaults to 10 seconds.
MaxBatchInterval time.Duration
// Customized http client.
// If nil, it defaults to http.DefaultClient.
HTTPClient *http.Client
// Tags to be sent with every telemetry item.
// If nil, no additional tags will be sent.
Tags map[string]string
// Logger specifies a structured logger.
// If nil nothing is logged.
Logger *slog.Logger
// Function to filter out telemetry items by name before they are sent.
// If nil, all telemetry items are sent.
UploadFilter func(name string) bool
// contains filtered or unexported fields
}
Client is the main entry point for sending telemetry to Application Insights. Changing its properties after a telemetry item is created will have no effect.
func (*Client) Close ¶
Close flushes and tears down the submission goroutine and closes internal channels. Waits until all pending telemetry items have been submitted.
func (*Client) NewEvent ¶
NewEvent creates a new event with the specified name. If c is nil, returns a usable Event that does not send any telemetry.
func (*Client) Stop ¶
func (c *Client) Stop()
Stop tears down the submission goroutines, closes internal channels. Any telemetry waiting to be sent is discarded. This is a more abrupt version of Client.Close.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
appinsightstest
This package contains test utilities for the Application Insights SDK.
|
This package contains test utilities for the Application Insights SDK. |