diff --git a/CHANGELOG.md b/CHANGELOG.md index c2092eb974c..5843d03b8e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm For example, `[]string{"foo", "bar"}` attribute value is now transformed to `log.SliceValue(log.StringValue("foo"), log.StringValue("bar"))` instead of `log.String("[foo bar"])`. (#6254) - Add the `WithSource` option to the `go.opentelemetry.io/contrib/bridges/otelslog` log bridge to set the `code.*` attributes in the log record that includes the source location where the record was emitted. (#6253) - Add caller information in otelzap to the `log.Record` if the `zap.Logger` was created with the `AddCaller()` option. (#6268) +- Add stack trace in otelzap to the `log.Record` if the `zap.Logger` was created with the `AddStackStrace()` option. (#6268) ### Fixed diff --git a/bridges/otelzap/core.go b/bridges/otelzap/core.go index 71be0441c9a..f2c25569152 100644 --- a/bridges/otelzap/core.go +++ b/bridges/otelzap/core.go @@ -208,6 +208,9 @@ func (o *Core) Write(ent zapcore.Entry, fields []zapcore.Field) error { log.String(string(semconv.CodeFunctionKey), ent.Caller.Function), ) } + if ent.Stack != "" { + r.AddAttributes(log.String(string(semconv.CodeStacktraceKey), ent.Stack)) + } if len(fields) > 0 { ctx, attrbuf := convertField(fields) if ctx != nil {