Skip to content

Ilanak/zap-applicationinsights-writer

Repository files navigation

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)

About

Writes log message from uber-go/zap to Application Insights as traces

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages