Skip to content

Commit

Permalink
added stack trace to log record if persistent in log entry
Browse files Browse the repository at this point in the history
  • Loading branch information
suniastar committed Oct 21, 2024
1 parent 253487c commit 1bbaa6b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions bridges/otelzap/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 1bbaa6b

Please sign in to comment.