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 3.17.0 #531

Merged
merged 91 commits into from Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
2f0c15e
Require 1.20.0 of aws-lambda-go
Aug 2, 2021
1aba054
Added intergation for ms sql server with newrelic
Dec 20, 2021
b19f097
formatting
Dec 20, 2021
e7f00b9
updated ci workflow
Dec 20, 2021
a78ca42
Added noop operations for js/wasm build target
taufik-rama Apr 6, 2022
6f2aa06
Merge branch 'develop' of ssh://github.com/taufik-rama/go-agent into …
taufik-rama May 4, 2022
e90e227
bump go version for nrechov4 test
mirackara Jun 2, 2022
e48133c
test commit
mirackara Jun 2, 2022
04f6fe8
Test Commit
mirackara Jun 2, 2022
7254bdb
merge test
mirackara Jun 2, 2022
d12eab7
Added go mod tidying if available in go version
mirackara Jun 3, 2022
a95c5e4
Bumped v3 dependancy number
mirackara Jun 3, 2022
447481a
Update go.mod
sdbedi Jun 3, 2022
571f05f
removed mssql dependency from go.mod
Jun 6, 2022
f799a24
Fixed nrecho-v4 tests
mirackara Jun 6, 2022
c24bac8
go mod file changes
mirackara Jun 6, 2022
7eea244
lint fix
Jun 7, 2022
908cb1a
Added changes to WantTxn to support distributed tracing testing
mirackara Jun 8, 2022
effaaa8
Specified echo version
mirackara Jun 8, 2022
538508c
Merge pull request #509 from mirackara/nrecho-test
iamemilio Jun 13, 2022
b10a13e
harvest log events
iamemilio Apr 25, 2022
9565130
added logging in context metrics
iamemilio May 9, 2022
8be7166
More Configurability and Testing
iamemilio May 10, 2022
2fdbfbf
Zerolog logs in context support
iamemilio May 24, 2022
cc5e7cc
RecordLog documentation
iamemilio May 24, 2022
6b7c071
Supportability Metrics
iamemilio May 26, 2022
22adddd
button up zerolog plugin
iamemilio May 26, 2022
514119b
correct config settings in readme and example
iamemilio May 26, 2022
d71870a
remove changes to short-lived-process-example
iamemilio May 26, 2022
96b4b58
stress-tests
iamemilio May 24, 2022
f0b6b53
dont use time.Now().UnixMillisecond() due to old versions of go not s…
iamemilio May 26, 2022
69e13d2
clean up the implementation of record logs to make it more user friendly
iamemilio May 27, 2022
c87eba3
clean up vet issues
iamemilio May 27, 2022
eaef803
priority inheretence
iamemilio May 27, 2022
d4806f8
fixing scale tests
iamemilio May 27, 2022
320057e
make the linter happy for logging constants
iamemilio May 27, 2022
bcf0c6e
some clean up
iamemilio May 28, 2022
317b6a0
remove scale tests
iamemilio May 31, 2022
6ffb77a
Async Log Event Support
iamemilio May 31, 2022
138d1bd
support timestamps on older go versions
iamemilio May 31, 2022
1d326f4
Safe Reads
iamemilio May 31, 2022
7f28d60
turns out that the synchronization is handled already
iamemilio May 31, 2022
3607461
avoid alloc when creating logEvent
iamemilio Jun 13, 2022
d33379f
improve efficiency of getting harvest data by avoiding memAlloc
iamemilio Jun 14, 2022
cbc801f
Revert "improve efficiency of getting harvest data by avoiding memAlloc"
iamemilio Jun 15, 2022
77fc73b
better benchmarks for log events
iamemilio Jun 15, 2022
e6083ed
more granular benchmarks for pinpointing json buffer writing runtime …
iamemilio Jun 15, 2022
5594e30
logging readme improved
iamemilio Jun 15, 2022
6cf172d
return go.mod to upstream
iamemilio Jun 16, 2022
2e6700e
remove comparison to write string
iamemilio Jun 16, 2022
0901501
group struct fields by type to avoid overallocation of contiguous memory
iamemilio Jun 17, 2022
f3b5b5b
piggyback log events on transactions to pool their priorities
iamemilio Jun 17, 2022
561ab2d
style update for zerolog in context
iamemilio Jun 21, 2022
900b6f4
if statements checking booleans simplified to just check value
iamemilio Jun 21, 2022
9660625
safeguard memory for transaction log events
iamemilio Jun 21, 2022
ace7225
made go vet happy :)
iamemilio Jun 21, 2022
458f9d0
autogenerate timestamps instead of failing
iamemilio Jun 21, 2022
6f02ca7
cleanup and testing for autotimestamps
iamemilio Jun 21, 2022
1f766f4
Fix Spelling mistakes
iamemilio Jun 23, 2022
814b1d6
simplify supportability for zerolog
iamemilio Jun 23, 2022
33f7217
a ConfigZerologEnabled() function call was separated from its heard
iamemilio Jun 23, 2022
0385173
Added Max Samples per Custom Events Setting
mirackara Jun 24, 2022
2bd9ccb
changed DT header JSON marshalling to be faster
nr-swilloughby Jun 27, 2022
e59734c
Changed naming conventions
mirackara Jun 27, 2022
fd44db5
Revert "Added Max Samples per Custom Events Setting"
mirackara Jun 27, 2022
e5543cb
changed buffer alloc
nr-swilloughby Jun 28, 2022
64ec422
code cleanup to conform to dev standards and style guide
nr-swilloughby Jun 28, 2022
c9cc4a1
moved literal to constant value
nr-swilloughby Jun 28, 2022
d916ec5
app log trace id was set to span id
iamemilio Jun 28, 2022
92a4a37
Additional Testing covering Application Function Calls
iamemilio Jun 28, 2022
ad1a864
fix sample size selection for logging
iamemilio Jun 28, 2022
91ca115
cleaner server example
iamemilio Jun 28, 2022
d1385ff
make it more user friendly to record transaction logs
iamemilio Jun 28, 2022
f137814
background logs
iamemilio Jun 28, 2022
136f6b0
Merge pull request #526 from newrelic/json_speed_issue_505
nr-swilloughby Jun 29, 2022
e6316bc
Merge pull request #523 from mirackara/grpcnaming
nr-swilloughby Jun 29, 2022
74b16d1
Merge pull request #425 from ishahid91/ms_sql_server_intergation
nr-swilloughby Jun 29, 2022
665ac98
Merge pull request #514 from sdbedi/master
nr-swilloughby Jun 29, 2022
389d161
Merge pull request #478 from taufik-rama/fix/js_wasm
nr-swilloughby Jun 29, 2022
75785ca
Merge pull request #507 from iamemilio/zerolog_in_context
nr-swilloughby Jun 29, 2022
e95bf52
Merge pull request #356 from MattWhelan/mwhelan/lambdaDepFix
nr-swilloughby Jun 29, 2022
afb86ef
update aws gomod
sdbedi Jun 27, 2022
0083969
Revert "Added noop operations for js/wasm build target"
iamemilio Jun 29, 2022
e084769
Merge pull request #528 from newrelic/revert-478-fix/js_wasm
iamemilio Jun 29, 2022
69c4599
Merge pull request #527 from newrelic/cherry-picked-pr-525
iamemilio Jun 29, 2022
ea1dcf9
Custom Events Limiter (#524)
mirackara Jun 29, 2022
0fd76e6
clean up some style issues and exported functions that should be private
iamemilio Jun 29, 2022
b136918
Merge pull request #529 from iamemilio/cleanup_3.17.0
iamemilio Jun 29, 2022
37765c6
updates to release 3.17.0 of the agent
nr-swilloughby Jun 29, 2022
6206cc3
updated changelog
nr-swilloughby Jun 29, 2022
56d78e8
Merge pull request #530 from nr-swilloughby/release_3_17_0_dev
nr-swilloughby Jun 29, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/ci.yaml
Expand Up @@ -89,6 +89,8 @@ jobs:
dirs: _integrations/nrb3
- go-version: 1.13.x
dirs: _integrations/nrmongo
- go-version: 1.13.x
dirs: _integrations/nrmssql

# v3 agent
- go-version: 1.7.x
Expand Down Expand Up @@ -124,9 +126,10 @@ jobs:
dirs: v3/integrations/nrecho-v3
# Test against the latest v3 Echo:
extratesting: go get -u github.com/labstack/echo@v3
- go-version: 1.15.x
# go/new/http no longer stable under go 1.17.x
- go-version: 1.17.x
dirs: v3/integrations/nrecho-v4
extratesting: go get -u github.com/labstack/echo@master
extratesting: go get -u github.com/labstack/echo/v4@master
- go-version: 1.15.x
dirs: v3/integrations/nrelasticsearch-v7
extratesting: go get -u github.com/elastic/go-elasticsearch/v7@7.x
Expand Down Expand Up @@ -211,6 +214,9 @@ jobs:
- go-version: 1.15.x
dirs: v3/integrations/nrgraphqlgo,v3/integrations/nrgraphqlgo/example
extratesting: go get -u github.com/graphql-go/graphql@master
- go-version: 1.15.x
dirs: v3/integrations/nrmssql
extratesting: go get -u github.com/denisenkom/go-mssqldb@master

steps:
- name: Install Go
Expand Down
25 changes: 25 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,28 @@
## 3.17.0
### Added
* Logs in context now supported for zerolog.
* This is a quick way to view logs no matter where you are in the platform.
* Adds support for logging metrics which shows the rate of log messages by severity in the Logs chart in the APM Summary view. This is enabled by default in this release.
* Adds support for forwarding application logs to New Relic. This automatically sends application logs that have been enriched to power APM logs in context. This is disabled by default in this release. This will be on by default in a future release.
* To learn more about APM logs in context see the documentation [here](https://docs.newrelic.com/docs/logs/logs-context/logs-in-context).
* Includes the `RecordLog` function for recording log data from a single log entry
* An integrated plugin for zerolog to automatically ingest log data with the Go Agent.
* Resolves [issue 178](https://github.com/newrelic/go-agent/issues/178), [issue 488](https://github.com/newrelic/go-agent/issues/488), [issue 489](https://github.com/newrelic/go-agent/issues/489), [issue 490](https://github.com/newrelic/go-agent/issues/490), and [issue 491](https://github.com/newrelic/go-agent/issues/491) .
* Added integration for MS SQL Server ([PR 425](https://github.com/newrelic/go-agent/pull/425); thanks @ishahid91!)
* This introduces the `nrmssql` integration v1.0.0.
* Added config function `ConfigCustomInsightsEventsMaxSamplesStored` for limiting the number of samples stored in a custom insights event. Fixes [issue 476](https://github.com/newrelic/go-agent/issues/476)

### Fixed
* Improved speed of building distributed trace header JSON payload. Fixes [issue 505](https://github.com/newrelic/go-agent/issues/505).
* Renamed the gRPC attribute names from `GrpcStatusLevel`, `GrpcStatusMessage`, and `GrpcStatusCode` to `grpcStatusLevel`, `grpcStatusMessage`, and `grpcStatusCode` respectively, to conform to existing naming conventions for New Relic agents. Fixes [issue 492](https://github.com/newrelic/go-agent/issues/492).
* Updated `go.mod` for the `nrgin` integration to mitigate security issue in 3rd party dependency.
* Updated `go.mod` for the `nrawssdk-v1` integration to properly reflect its dependency on version 3.16.0 of the Go Agent.
* Updated `go.mod` for the `nrlambda` integration to require `aws-lambda-go` version 1.20.0. ([PR 356](https://github.com/newrelic/go-agent/pull/356); thanks MattWhelan!)

### Support Statement
New Relic recommends that you upgrade the agent regularly to ensure that you’re getting the latest features and performance benefits. Additionally, older releases will no longer be supported when they reach end-of-life.
* Note that the oldest supported version of the Go Agent is 3.6.0.

# ChangeLog
## 3.16.1
### Fixed
Expand Down
5 changes: 4 additions & 1 deletion GUIDE.md
Expand Up @@ -67,7 +67,7 @@ Now, add instrumentation to your Go application to get additional performance da
* Import any of our [integration packages](https://github.com/newrelic/go-agent#integrations) for out-of-the box support for many popular Go web
frameworks and libraries.
* [Instrument Transactions](#transactions)
* [Use Distributed Tracing](#distributed-tracing)
* [Use Distributed Tracing](#distributed-tracing) (Note that this is on by default.)
* [(Optional) Instrument Segments](#segments) for an extra level of timing detail
* External segments are needed for Distributed Tracing
* Read through the rest of this GUIDE for more instrumentation
Expand Down Expand Up @@ -102,6 +102,9 @@ app, err := newrelic.NewApplication(

## Logging

For information about logs in context, please see [the documentation here](https://docs.newrelic.com/docs/logs/logs-context/logs-in-context).
As of Go Agent version 3.17.0, we support logs in context with the zerolog integration.

The agent's logging system is designed to be easily extensible. By default, no
logging will occur. To enable logging, use the following config functions
with an [io.Writer](https://godoc.org/github.com/pkg/io/#Writer):
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -15,7 +15,6 @@ Go is a compiled language, and doesn’t use a virtual machine. This means that
### Compatibility and Requirements

For the latest version of the agent, Go 1.7+ is required, due to the use of `context.Context`.
(For versions 2.X and earlier of the Go agent, Go 1.3+ is required.)

Linux, OS X, and Windows (Vista, Server 2008 and later) are supported.

Expand Down Expand Up @@ -91,6 +90,7 @@ package primitives can be found [here](GUIDE.md#datastore-segments).
| ------------- | ------------- | - |
| [lib/pq](https://github.com/lib/pq) | [v3/integrations/nrpq](https://godoc.org/github.com/newrelic/go-agent/v3/integrations/nrpq) | Instrument PostgreSQL driver (`pq` driver for `database/sql`) |
| [jackc/pgx](https://github.com/jackc/pgx) | [v3/integrations/nrpgx](https://godoc.org/github.com/newrelic/go-agent/v3/integrations/nrpgx) | Instrument PostgreSQL driver (`pgx` driver for `database/sql`)|
| [go-mssqldb](github.com/denisenkom/go-mssqldb) | [v3/integrations/nrmssql](https://godoc.org/github.com/newrelic/go-agent/v3/integrations/nrmssql) | Instrument MS SQL driver |
| [go-sql-driver/mysql](https://github.com/go-sql-driver/mysql) | [v3/integrations/nrmysql](https://godoc.org/github.com/newrelic/go-agent/v3/integrations/nrmysql) | Instrument MySQL driver |
| [elastic/go-elasticsearch](https://github.com/elastic/go-elasticsearch) | [v3/integrations/nrelasticsearch-v7](https://godoc.org/github.com/newrelic/go-agent/v3/integrations/nrelasticsearch-v7) | Instrument Elasticsearch datastore calls |
| [database/sql](https://godoc.org/database/sql) | Use a supported database driver or [builtin instrumentation](https://godoc.org/github.com/newrelic/go-agent/v3/newrelic#InstrumentSQLConnector) | Instrument database calls with SQL |
Expand Down
7 changes: 7 additions & 0 deletions build-script.sh
Expand Up @@ -35,6 +35,10 @@ pin_go_dependency() {
fi
}

go_mod_tidy() {
go mod tidy
}

IFS=","
for dir in $DIRS; do
cd "$pwd/$dir"
Expand All @@ -43,6 +47,9 @@ for dir in $DIRS; do
go mod edit -replace github.com/newrelic/go-agent/v3="$pwd"/v3
fi

# Do tidy if we can
go_mod_tidy || true

pin_go_dependency "$PIN"

# avoid testing v3 code when testing v2 newrelic package
Expand Down
24 changes: 24 additions & 0 deletions v3/examples/server/main.go
Expand Up @@ -246,11 +246,22 @@ func browser(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, "browser header page")
}

func logTxnMessage(w http.ResponseWriter, r *http.Request) {
txn := newrelic.FromContext(r.Context())
txn.RecordLog(newrelic.LogData{
Message: "Log Message",
Severity: "info",
})

io.WriteString(w, "A log message was recorded")
}

func main() {
app, err := newrelic.NewApplication(
newrelic.ConfigAppName("Example App"),
newrelic.ConfigFromEnvironment(),
newrelic.ConfigDebugLogger(os.Stdout),
newrelic.ConfigAppLogForwardingEnabled(true),
)
if err != nil {
fmt.Println(err)
Expand All @@ -274,6 +285,7 @@ func main() {
http.HandleFunc(newrelic.WrapHandleFunc(app, "/browser", browser))
http.HandleFunc(newrelic.WrapHandleFunc(app, "/async", async))
http.HandleFunc(newrelic.WrapHandleFunc(app, "/message", message))
http.HandleFunc(newrelic.WrapHandleFunc(app, "/log", logTxnMessage))

http.HandleFunc("/background", func(w http.ResponseWriter, req *http.Request) {
// Transactions started without an http.Request are classified as
Expand All @@ -285,5 +297,17 @@ func main() {
time.Sleep(150 * time.Millisecond)
})

http.HandleFunc("/background_log", func(w http.ResponseWriter, req *http.Request) {
// Logs that occur outside of a transaction are classified as
// background logs.

app.RecordLog(newrelic.LogData{
Message: "Background Log Message",
Severity: "info",
})

io.WriteString(w, "A background log message was recorded")
})

http.ListenAndServe(":8000", nil)
}
95 changes: 95 additions & 0 deletions v3/integrations/logcontext-v2/nrzerolog/Readme.md
@@ -0,0 +1,95 @@
# Zerolog In Context

This plugin for zerolog implements the logs in context tooling for the go agent. This hook
function can be added to any zerolog logger, and will automatically collect the log data
from zerolog, and send it to New Relic through the go agent. The following Logging features
are supported by this plugin in the current release:

| Logging Feature | Supported |
| ------- | --------- |
| Forwarding | :heavy_check_mark: |
| Metrics | :heavy_check_mark: |
| Enrichment | :x: |

## Installation

The nrzerolog plugin, and the go-agent need to be integrated into your code
in order to use this tool. Make sure to set `newrelic.ConfigAppLogForwardingEnabled(true)`
in your config settings for the application. This will enable log forwarding
in the go agent. If you want to disable metrics, set `newrelic.ConfigAppLogMetricsEnabled(false),`.
Note that the agent sets the default number of logs per harverst cycle to 10000, but that
number may be reduced by the server. You can manually set this number by setting
`newrelic.ConfigAppLogForwardingMaxSamplesStored(123),`.

The following example will shows how to install and set up your code to send logs to new relic from zerolog.

```go

import (
"github.com/rs/zerolog"
"github.com/newrelic/go-agent/v3/newrelic"
"github.com/newrelic/go-agent/v3/integrations/logcontext-v2/nrzerolog"
)

func main() {
// Initialize a zerolog logger
baseLogger := zerolog.New(os.Stdout)

app, err := newrelic.NewApplication(
newrelic.ConfigFromEnvironment(),
newrelic.ConfigAppName("NRZerolog Example"),
newrelic.ConfigInfoLogger(os.Stdout),
newrelic.ConfigAppLogForwarding(true),
)
if err != nil {
fmt.Println(err)
os.Exit(1)
}

// Send logs to New Relic outside of a transaction
nrHook := nrzerolog.NewRelicHook{
App: app,
}

// Wrap logger with New Relic Hook
nrLogger := baseLogger.Hook(nrHook)
nrLogger.Info().Msg("Hello World")

// Send logs to New Relic inside of a transaction
txn := app.StartTransaction("My Transaction")
ctx := newrelic.NewContext(context.Background(), txn)

nrTxnHook := nrzerolog.NewRelicHook{
App: app,
Context: ctx,
}

txnLogger := baseLogger.Hook(nrTxnHook)
txnLogger.Debug().Msg("This is a transaction log")

txn.End()
}
```

## Usage

Please enable the agent to ingest your logs by calling newrelic.ConfigAppLogForwardingEnabled(true),
when setting up your application. This is not enabled by default.

This integration for the zerolog logging frameworks uses a built in feature
of the zerolog framework called hook functions. Zerolog loggers can be modified
to have hook functions run on them before each time a write is executed. When a
logger is hooked, meaning a hook function was added to that logger with the Hook()
funciton, a copy of that logger is created with those changes. Note that zerolog
will *never* attempt to verify that any hook functions have not been not duplicated, or
that fields are not repeated in any way. As a result, we recommend that you create
a base logger that is configured in the way you prefer to use zerolog. Then you
create hooked loggers to send log data to New Relic from that base logger.

The plugin captures the log level, and the message from zerolog. It will also collect
distributed tracing data from your transaction context. At the moment the hook function is
called in zerolog, a timestamp will be generated for your log. In most cases, this
timestamp will be the same as the time posted in the zerolog log message, however it is possible that
there could be a slight offset depending on the the performance of your system.


53 changes: 53 additions & 0 deletions v3/integrations/logcontext-v2/nrzerolog/example/main.go
@@ -0,0 +1,53 @@
package main

import (
"context"
"fmt"
"os"
"time"

"github.com/newrelic/go-agent/v3/integrations/logcontext-v2/nrzerolog"
"github.com/newrelic/go-agent/v3/newrelic"
"github.com/rs/zerolog"
)

func main() {
baseLogger := zerolog.New(os.Stdout)

app, err := newrelic.NewApplication(
newrelic.ConfigFromEnvironment(),
newrelic.ConfigAppName("NRZerolog Example"),
newrelic.ConfigInfoLogger(os.Stdout),
newrelic.ConfigAppLogForwardingEnabled(true),
)
if err != nil {
fmt.Println(err)
os.Exit(1)
}

app.WaitForConnection(5 * time.Second)

nrHook := nrzerolog.NewRelicHook{
App: app,
}

nrLogger := baseLogger.Hook(nrHook)
nrLogger.Info().Msg("Hello World")

// With transaction context
txn := app.StartTransaction("My Transaction")
ctx := newrelic.NewContext(context.Background(), txn)

nrTxnHook := nrzerolog.NewRelicHook{
App: app,
Context: ctx,
}

txnLogger := baseLogger.Hook(nrTxnHook)
txnLogger.Debug().Msg("This is a transaction log")

txn.End()

nrLogger.Info().Msg("Goodbye")
app.Shutdown(10 * time.Second)
}
8 changes: 8 additions & 0 deletions v3/integrations/logcontext-v2/nrzerolog/go.mod
@@ -0,0 +1,8 @@
module github.com/newrelic/go-agent/v3/integrations/logcontext-v2/nrzerolog

go 1.15

require (
github.com/newrelic/go-agent/v3 v3.16.0
github.com/rs/zerolog v1.26.1
)
41 changes: 41 additions & 0 deletions v3/integrations/logcontext-v2/nrzerolog/hook.go
@@ -0,0 +1,41 @@
package nrzerolog

import (
"context"

"github.com/newrelic/go-agent/v3/internal"
"github.com/newrelic/go-agent/v3/newrelic"
"github.com/rs/zerolog"
)

func init() { internal.TrackUsage("integration", "logcontext", "zerolog") }

type NewRelicHook struct {
App *newrelic.Application
Context context.Context
}

func (h NewRelicHook) Run(e *zerolog.Event, level zerolog.Level, msg string) {
var txn *newrelic.Transaction
if h.Context != nil {
txn = newrelic.FromContext(h.Context)
}

logLevel := ""
if level == zerolog.NoLevel {
logLevel = newrelic.LogSeverityUnknown
} else {
logLevel = level.String()
}

data := newrelic.LogData{
Severity: logLevel,
Message: msg,
}

if txn != nil {
txn.RecordLog(data)
} else {
h.App.RecordLog(data)
}
}
2 changes: 1 addition & 1 deletion v3/integrations/nrawssdk-v1/go.mod
Expand Up @@ -8,5 +8,5 @@ go 1.7
require (
// v1.15.0 is the first aws-sdk-go version with module support.
github.com/aws/aws-sdk-go v1.15.0
github.com/newrelic/go-agent/v3 v3.0.0
github.com/newrelic/go-agent/v3 v3.16.0
)