zapappinsigths

package module
v0.0.0-...-edd4457 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 24, 2018 License: MIT Imports: 8 Imported by: 1

README

zap-applicationinsights-writer

Writes log messages from go.uber.org/zap to application insights as traces.

A complete example for setting up zap with application insights integreation:

package main

import (
    "time"

    "go.uber.org/zap"

    "github.com/Ilanak/zap-applicationinsights-writer"
)

var baseLogger *zap.Logger

func init() {
    core, fieldsOption, _ := zapappinsigths.NewAppInsightsCore(zapappinsigths.Config{
        InstrumentationKey: "Enter your Ikey",
        MaxBatchSize:       10,              // optional
        MaxBatchInterval:   time.Second * 5, // optional
    })
    baseLogger = zap.New(core, fieldsOption)
    defer baseLogger.Sync()

}

func main() {
    for i := 0; i < 10; i++ {
        baseLogger.Info("new trace", zap.Int("MessageId", i), zap.String("source", "main func"))
    }
    time.Sleep(5000 * time.Millisecond)
}

Notes

  • currently only custom dimension supported for traces (custom metrics are not supported)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildTrace

func BuildTrace(data map[string]interface{}) *appinsights.TraceTelemetry

func New

func New(appInsightsConfig *AppInsightsConfig) zapcore.WriteSyncer

New returns an implementation of ZapWriteSyncer which should be compatible with zap.WriteSyncer

func NewAppInsightsCore

func NewAppInsightsCore(conf Config, fs ...zapcore.Field) (zapcore.Core, zap.Option, error)

Types

type AppInsightsConfig

type AppInsightsConfig struct {
	// contains filtered or unexported fields
}

func (*AppInsightsConfig) Sync

func (appInsightsConfig *AppInsightsConfig) Sync() error

func (*AppInsightsConfig) Write

func (appInsightsConfig *AppInsightsConfig) Write(p []byte) (int, error)

type Config

type Config struct {
	InstrumentationKey string
	EndpointURL        string
	MaxBatchSize       int
	MaxBatchInterval   time.Duration
}

Config for application insights

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL