Skip to content

Fast Go library for writing GELF log messages to UDP endpoint.

License

Notifications You must be signed in to change notification settings

cezarsa/fastgelf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FastGELF is an experimental GELF library

This is a Go library for writing log messages in the GELF format to a remote endpoint.

What this library doesn't do:

  • No chunking support.
  • No compression support.
  • No TCP support.
  • No support for listening and reading messages.

If you are looking for a feature complete GELF library try https://github.com/Graylog2/go-gelf.

What it does

This library is optimized for writing a large number of UDP GELF messages on Linux.

It uses the sendmmsg syscall, which is only available on Linux, to reduce the number of times we cross kernel boundaries when sending a huge amount of log messages.

This library will still work on non-linux environments (tested on Darwin) but the performance improvement won't be so noticeable.

Benchmarks

These benchmarks compare this library to the Graylog2/go-gelf library.

Linux:

$ go test -test.bench . -test.benchmem -test.benchtime 3s
goos: linux
goarch: amd64
pkg: github.com/cezarsa/fastgelf/experiments
Benchmark_FastGELF_WriteMessageExtra/simple         	  500000	      7633 ns/op	     203 B/op	       4 allocs/op
Benchmark_FastGELF_WriteMessageExtra/with_extra     	 1000000	      7535 ns/op	     200 B/op	       4 allocs/op
Benchmark_gogelf_WriteMessageExtra/simple           	  500000	     10941 ns/op	     176 B/op	       1 allocs/op
Benchmark_gogelf_WriteMessageExtra/with_extra       	  300000	     17108 ns/op	     752 B/op	      14 allocs/op
PASS

Darwin:

$ go test -test.bench . -test.benchmem -test.benchtime 3s
goos: darwin
goarch: amd64
pkg: github.com/cezarsa/fastgelf/experiments
Benchmark_FastGELF_WriteMessageExtra/simple-4         	  300000	     13937 ns/op	     241 B/op	       8 allocs/op
Benchmark_FastGELF_WriteMessageExtra/with_extra-4     	  300000	     13383 ns/op	     242 B/op	       8 allocs/op
Benchmark_gogelf_WriteMessageExtra/simple-4           	  500000	     14276 ns/op	     176 B/op	       1 allocs/op
Benchmark_gogelf_WriteMessageExtra/with_extra-4       	  300000	     15290 ns/op	     752 B/op	      14 allocs/op
PASS

About

Fast Go library for writing GELF log messages to UDP endpoint.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages