Skip to content

Commit

Permalink
Merge pull request #904 from newrelic/iamemilio-patch-4
Browse files Browse the repository at this point in the history
Context Driven Handler slog
  • Loading branch information
nr-swilloughby committed May 1, 2024
2 parents 2982fb8 + 3f71008 commit f437d8b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions v3/integrations/logcontext-v2/nrslog/example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"log/slog"
"os"
"time"
"context"

"github.com/newrelic/go-agent/v3/integrations/logcontext-v2/nrslog"
"github.com/newrelic/go-agent/v3/newrelic"
Expand All @@ -24,8 +25,9 @@ func main() {
log.Info("I am a log message")

txn := app.StartTransaction("example transaction")
txnLogger := nrslog.WithTransaction(txn, log)
txnLogger.Info("I am a log inside a transaction")
ctx := newrelic.NewContext(context.Background(), txn)

txnLogger.InfoContext(ctx, "I am a log inside a transaction")

// pretend to do some work
time.Sleep(500 * time.Millisecond)
Expand Down

0 comments on commit f437d8b

Please sign in to comment.