Documentation ¶
Index ¶
- Constants
- Variables
- type Core
- func (c *Core) Check(entry zapcore.Entry, checked *zapcore.CheckedEntry) *zapcore.CheckedEntry
- func (c *Core) Sync() error
- func (c *Core) With(fields []zapcore.Field) zapcore.Core
- func (c *Core) WithFieldMappers(fieldMappers ...map[string]string) *Core
- func (c *Core) Write(entry zapcore.Entry, fields []zapcore.Field) error
- type Sink
- type SinkConfig
Constants ¶
const (
// SinkScheme is the registerable Sink Scheme for appinsights.
SinkScheme = "appinsights"
)
Variables ¶
var ApplicationContextMappers = map[string]string{
"version": "ai.application.ver",
}
ApplicationContextMappers are the default ApplicationContext tag mappers.
var CloudContextMappers = map[string]string{
"az_role": "ai.cloud.role",
"az_role_instance": "ai.cloud.roleInstance",
}
CloudContextMappers are the default CloudContext tag mappers.
var DefaultMappers = func() map[string]string { m := map[string]string{} for _, mm := range allMappers { for k, v := range mm { m[k] = v } } return m }()
DefaultMappers is a convenience var which is a combined tagMapper of all hardcoded mappers.
var DeviceContextMappers = map[string]string{
"device_id": "ai.device.id",
"locale": "ai.device.locale",
"model": "ai.device.model",
"oem": "ai.device.oemName",
"os_version": "ai.device.osVersion",
"device_type": "ai.device.type",
}
DeviceContextMappers are the default DeviceContext tag mappers.
var InternalContextMappers = map[string]string{
"ai_sdk_version": "ai.internal.sdkVersion",
"ai_agent_version": "ai.internal.agentVersion",
"node_name": "ai.internal.nodeName",
}
InternalContextMappers are the default InternalContext tag mappers.
var LocationContextMappers = map[string]string{
"ip": "ai.location.ip",
}
LocationContextMappers are the default LocationContext tag mappers.
var OperationContextMappers = map[string]string{
"operation_id": "ai.operation.id",
"operation_name": "ai.operation.name",
"parent_id": "ai.operation.parentId",
"synthetic_source": "ai.operation.syntheticSource",
"correlation_id": "ai.operation.correlationVector",
}
OperationContextMappers are the default OperationContext tag mappers.
var SessionContextMappers = map[string]string{
"session_id": "ai.session.id",
"session_is_first": "ai.session.isFirst",
}
SessionContextMappers are the default SessionContext tag mappers.
var UserContextMappers = map[string]string{
"account": "ai.user.accountId",
"anonymous_user_id": "ai.user.id",
"user_id": "ai.user.authUserId",
}
UserContextMappers are the default UserContext tag mappers.
Functions ¶
This section is empty.
Types ¶
type Core ¶
type Core struct { zapcore.LevelEnabler // contains filtered or unexported fields }
Core implements zapcore.Core for appinsights. Core only knows how to write to, and should only be used with, a corresponding appinsights Sink.
Internally, the Core implements Write(zapcore.Entry, []zapcore.Field) by building an appinsights.TraceTelemetry out of the zap inputs, then serializing it to a []byte using a shared common gob.Encoder, and passes that to the Sink.Write([]byte) (which knows how to decode it back in to a TraceTelemetry).
func NewCore ¶
func NewCore(le zapcore.LevelEnabler, out zapcore.WriteSyncer) *Core
NewCore creates a new appinsights zap core. Should only be initialized using an appinsights Sink as the zapcore.WriteSyncer argument - other sinks will not error but will also not produce meaningful output.
func (*Core) Check ¶
func (c *Core) Check(entry zapcore.Entry, checked *zapcore.CheckedEntry) *zapcore.CheckedEntry
Check implements zapcore.Core
func (*Core) WithFieldMappers ¶
type Sink ¶
type Sink struct { *SinkConfig // contains filtered or unexported fields }
Sink implements zap.Sink for appinsights. Sink is not inherently safe for concurrent use - the zap constructors will wrap it for concurrency.
To conform to the zap.Sink interface, Sink implements Write([]byte), where it expects that the passed []byte is an encoded gob that can be decoded in to a valid appinsights.TraceTelemetry. Passing any other []byte input is an error.
type SinkConfig ¶
type SinkConfig struct { GracePeriod time.Duration appinsights.TelemetryConfiguration }
SinkConfig is a container struct for an appinsights Sink configuration.
func (*SinkConfig) URI ¶
func (sc *SinkConfig) URI() string
URI builds an appinsights Sink URI string suitable for passing to zap.Open.