Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log.WithSuffix, appends kvs to those passed to Log #992

Merged
merged 1 commit into from Jul 4, 2020

Commits on Jul 3, 2020

  1. log.WithSuffix, appends kvs to those passed to Log

    enhancement suggested in:
    go-kit#991
    
    why?
    
    if a human is reading logfmt output on the
    shell or in the web browser, it helps to
    have certain fields prefixed, e.g. ts,
    but certain fields are better suffixed,
    e.g. caller, environment, so that more
    important information appears first.
    
    benchmarks suggest an additional cost
    only if WithSuffix is used.
    
    goos: darwin
    goarch: amd64
    pkg: github.com/go-kit/kit/log
    BenchmarkDiscard-4               	32230156	        38 ns/op	      32 B/op	       1 allocs/op
    BenchmarkOneWith-4               	 9647907	       122 ns/op	      96 B/op	       2 allocs/op
    BenchmarkTwoWith-4               	 8935790	       134 ns/op	     160 B/op	       2 allocs/op
    BenchmarkTenWith-4               	 5016836	       236 ns/op	     672 B/op	       2 allocs/op
    BenchmarkOneWithPrefix-4         	 9907198	       123 ns/op	      96 B/op	       2 allocs/op
    BenchmarkTenWithPrefix-4         	 5076309	       239 ns/op	     672 B/op	       2 allocs/op
    BenchmarkOneWithSuffix-4         	 6432942	       189 ns/op	     128 B/op	       3 allocs/op
    BenchmarkTenWithSuffix-4         	 4899711	       246 ns/op	     416 B/op	       3 allocs/op
    BenchmarkOneWithPrefixSuffix-4   	 6111750	       197 ns/op	     160 B/op	       3 allocs/op
    BenchmarkTenWithPrefixSuffix-4   	 2172066	       555 ns/op	    1952 B/op	       3 allocs/op
    PASS
    ok  	github.com/go-kit/kit/log	14.224s
    Vinay P committed Jul 3, 2020
    Copy the full SHA
    0268ca8 View commit details
    Browse the repository at this point in the history