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

Release v1.17.0 #956

Merged
merged 25 commits into from May 25, 2021
Merged

Release v1.17.0 #956

merged 25 commits into from May 25, 2021

Conversation

abhinav
Copy link
Collaborator

@abhinav abhinav commented May 25, 2021

This release v1.17.0 of Zap with all changes from master minus the following:

These changes were omitted because we're still in the process of
changing the interface introduced in #897. We will include that in the
next release.

Release changelog: https://github.com/uber-go/zap/blob/release-1-17/CHANGELOG.md#1170-25-may-2021

Using apidiff, the surface area of this release compared to v1.16.0
is:

--- go.uber.org/zap ---
Compatible changes:
- Inline: added

--- go.uber.org/zap/zapcore ---
Compatible changes:
- InlineMarshalerType: added

--- go.uber.org/zap/zapgrpc ---
Compatible changes:
- (*Logger).Error: added
- (*Logger).Errorf: added
- (*Logger).Errorln: added
- (*Logger).Info: added
- (*Logger).Infof: added
- (*Logger).Infoln: added
- (*Logger).V: added
- (*Logger).Warning: added
- (*Logger).Warningf: added
- (*Logger).Warningln: added

--- go.uber.org/zap/zaptest/observer ---
Compatible changes:
- (*ObservedLogs).FilterFieldKey: added

Resolves #942
Refs GO-599

prashantv and others added 25 commits November 12, 2020 13:59
Multiple issues have been opened about missing logs (e.g., #874, #588).

While sampling is mentioned in the API documentation for `NewProductionConfig`,
it may help to add an FAQ question as well.
We shouldn't panic if the `Error()` method of an `error` panics.

```
type T struct{ msg string }

func (t *T) Error() string { return t.msg }

// The following panics.
var n *T = nil
log.Info("panic", zap.Error(n))
```

Co-authored-by: Abhinav Gupta <mail@abhinavg.net>
Support `application/x-www-form-urlencoded` as an additional content
type for `AtomicLevel.ServeHTTP`.

This is the default content type for `curl -X POST`.

With this change, interacting with the HTTP endpoint is a bit more
user friendly:

```
curl -X PUT localhost:8080/log/level -d level=debug
```

Additionally, the unit tests for the HTTP handler are transformed to
a table driven approach.

fixes #902

Co-authored-by: Abhinav Gupta <abg@uber.com>
Currently, the Sugar logger uses fmt.Sprint in all cases when the
template is empty. However, this call is unnecessary if there's
a single string type argument, as we can use it directly.

With this optimization, we reduce the cost and avoid an unnecessary
alloc:
```
> benchcmp pre post
benchmark                         old ns/op     new ns/op     delta
BenchmarkSugarSingleStrArg-10     636           570           -10.38%

benchmark                         old allocs     new allocs     delta
BenchmarkSugarSingleStrArg-10     1              0              -100.00%
```
This moves development tool dependencies to a subdirectory so that
these are not added as dependencies of zap.
gRPC has an updated [logger interface][1] that the v1 API has been
deprecated in favor of.

[1]: https://pkg.go.dev/google.golang.org/grpc/grpclog#LoggerV2

This adds support for it to the existing gRPC adapter in Zap.

Fixes #534 
Closes #538

Co-authored-by: Prashant Varanasi <github@prashantv.com>
Co-authored-by: Abhinav Gupta <abg@uber.com>
Fixes #876

Currently, a `zap.Field` can only represent a single key-value. Add
`zap.Inline` to allow adding multiple fields to the current
namespace from a type implementing `zap.ObjectMarshaler`.

This also solves a more general problem: a single `zap.Field` can now
be used to add multiple key/value pairs.
Adds functionality to filter zap.Field by key. This makes testing for
field existence regardless of value more convenient.

resolves #816
- go.uber.org/atomic@1.6.0
- go.uber.org/multierr@1.5.0.

Removes a lot of no longer needed dependencies and fixes vulnerabilities including the following:

- golang.org/x/crypto (CVE-2020-9283)
- golang.org/x/text (CVE-2020-14040)
The copy was originally in place due to golang/go#7809

Since that issue was fixed in Go 1.3 a few years ago, it seems safe to
drop the copy.
We're deprecating use of Travis for our OSS projects, so switch to
GitHub Actions for it.

Unfortunately, this required dropping tests we had against ppc64le
because [GitHub Workflows doesn't support it][1].

  [1]: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#github-hosted-runners
This utility allows creating a logger with "advanced" filters like in the following example.
It is particularly convenient to use with a CLI flag package or using environment variables.

	core := zap.NewExample().Core()
	// *=myns             => any level, myns namespace
    // info,warn:myns.*   => info or warn level, any namespace matching myns.*
	// error=*            => everything with error level
	logger := zap.New(zapfilter.NewFilteringCore(core, zapfilter.MustParseRules("*:myns info,warn:myns.* error:*")))
	defer logger.Sync()

	logger.Debug("top debug")                                 // no match
	logger.Named("myns").Debug("myns debug")                  // matches *:myns
	logger.Named("bar").Debug("bar debug")                    // no match
	logger.Named("myns").Named("foo").Debug("myns.foo debug") // no match

	logger.Info("top info")                                 // no match
	logger.Named("myns").Info("myns info")                  // matches *:myns
	logger.Named("bar").Info("bar info")                    // no match
	logger.Named("myns").Named("foo").Info("myns.foo info") // matches info,warn:myns.*

	logger.Warn("top warn")                                 // no match
	logger.Named("myns").Warn("myns warn")                  // matches *:myns
	logger.Named("bar").Warn("bar warn")                    // no match
	logger.Named("myns").Named("foo").Warn("myns.foo warn") // matches info,warn:myns.*

	logger.Error("top error")                                 // matches error:*
	logger.Named("myns").Error("myns error")                  // matches *:myns and error:*
	logger.Named("bar").Error("bar error")                    // matches error:*
	logger.Named("myns").Named("foo").Error("myns.foo error") // matches error:*

	// Output:
	// {"level":"debug","logger":"myns","msg":"myns debug"}
	// {"level":"info","logger":"myns","msg":"myns info"}
	// {"level":"info","logger":"myns.foo","msg":"myns.foo info"}
	// {"level":"warn","logger":"myns","msg":"myns warn"}
	// {"level":"warn","logger":"myns.foo","msg":"myns.foo warn"}
	// {"level":"error","msg":"top error"}
	// {"level":"error","logger":"myns","msg":"myns error"}
	// {"level":"error","logger":"bar","msg":"bar error"}
	// {"level":"error","logger":"myns.foo","msg":"myns.foo error"}
Check for "both true" or "both false" is easily implemented as `x == y`.
A recent change to dependencies neglected to run `go mod tidy`.
In #948, we noticed that some `go.sum` files were outdated. To avoid
this in the future, add a `lint` check that verifies that `go mod tidy`
does not cause any changes.

This will fail with a dirty working tree as well, but in CI, we don't
expect that.
Add a FOSSA check to the build steps.

Resolves: GO-468
Although the values of the FieldType enums aren't part of the Zap
contract, changing existing values is still a risky change.

[apidiff] considers this a brekaing change.

```
Incompatible changes:
- BinaryType: value changed from 3 to 4
- BoolType: value changed from 4 to 5
- ByteStringType: value changed from 5 to 6
- Complex128Type: value changed from 6 to 7
- Complex64Type: value changed from 7 to 8
- DurationType: value changed from 8 to 9
- ErrorType: value changed from 26 to 27
- Float32Type: value changed from 10 to 11
- Float64Type: value changed from 9 to 10
- Int16Type: value changed from 13 to 14
- Int32Type: value changed from 12 to 13
- Int64Type: value changed from 11 to 12
- Int8Type: value changed from 14 to 15
- NamespaceType: value changed from 24 to 25
- ReflectType: value changed from 23 to 24
- SkipType: value changed from 27 to 28
- StringType: value changed from 15 to 16
- StringerType: value changed from 25 to 26
- TimeFullType: value changed from 17 to 18
- TimeType: value changed from 16 to 17
- Uint16Type: value changed from 20 to 21
- Uint32Type: value changed from 19 to 20
- Uint64Type: value changed from 18 to 19
- Uint8Type: value changed from 21 to 22
- UintptrType: value changed from 22 to 23
```

  [apidiff]: https://github.com/golang/exp/blob/master/apidiff/README.md

Again, although maintianing these values is not part of the Zap
contract, in the interest of erring on the side of safety, I'm moving
the new FieldType (added in #912) to the bottom to avoid changing the
values of the other items.
This prepares the v1.17.0 release of Zap.
@codecov
Copy link

codecov bot commented May 25, 2021

Codecov Report

Merging #956 (75ac0de) into release (404189c) will decrease coverage by 0.24%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           release     #956      +/-   ##
===========================================
- Coverage    98.36%   98.12%   -0.25%     
===========================================
  Files           43       43              
  Lines         2390     1969     -421     
===========================================
- Hits          2351     1932     -419     
+ Misses          32       29       -3     
- Partials         7        8       +1     
Impacted Files Coverage Δ
field.go 100.00% <100.00%> (ø)
http_handler.go 100.00% <100.00%> (ø)
logger.go 96.15% <100.00%> (+0.84%) ⬆️
sugar.go 100.00% <100.00%> (ø)
zapcore/console_encoder.go 100.00% <100.00%> (ø)
zapcore/error.go 96.77% <100.00%> (+3.02%) ⬆️
zapcore/field.go 100.00% <100.00%> (ø)
zapcore/write_syncer.go 87.50% <100.00%> (-2.98%) ⬇️
zapgrpc/zapgrpc.go 100.00% <100.00%> (ø)
zaptest/observer/observer.go 100.00% <100.00%> (ø)
... and 42 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 404189c...75ac0de. Read the comment docs.

@hexfusion
Copy link

On behalf of the etcd maintainers thank you very much for the timely follow-up on a new release. 👍

@abhinav abhinav merged commit ebebbf3 into release May 25, 2021
@abhinav abhinav deleted the release-1-17 branch May 25, 2021 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet