github.com/newrelic/go-agent@v3.26.0+incompatible/CHANGELOG.md (about) 1 ## 3.26.0 2 ### Added 3 * Extended implementation of the `nrpgx5` integration (now v1.2.0). This instruments Postgres database operations using the `jackc/pgx/v5` library, including the direct access mode of operation as opposed to requiring code to use the library compatibly with the standard `database/sql` library. 4 5 ### Corrections 6 * See below for revised release notes for the 3.25.1 and the retracted 3.25.0 releases. We have clarified what was released at those versions; see also the revised notes for 3.22.0 and 3.22.1 for the same reason. 7 8 ### Support statement 9 We use the latest version of the Go language. At minimum, you should be using no version of Go older than what is supported by the Go team themselves. 10 11 See the [Go agent EOL Policy](https://docs.newrelic.com/docs/apm/agents/go-agent/get-started/go-agent-eol-policy/) for details about supported versions of the Go agent and third-party components. 12 13 ## 3.25.1 14 ### Added 15 * Added Support for FastHTTP package 16 * Added newrelic.WrapHandleFuncFastHTTP() and newrelic.StartExternalSegmentFastHTTP() functions to instrument fasthttp context and create wrapped handlers. These functions work similarly to the existing ones for net/http 17 * Added client-fasthttp and server-fasthttp examples to help get started with FastHTTP integration 18 19 ### Fixed 20 * Corrected a bug where the security agent failed to correctly parse the `NEW_RELIC_SECURITY_AGENT_ENABLED` environment variable. 21 22 ### Support statement 23 We use the latest version of the Go language. At minimum, you should be using no version of Go older than what is supported by the Go team themselves. 24 25 See the [Go agent EOL Policy](https://docs.newrelic.com/docs/apm/agents/go-agent/get-started/go-agent-eol-policy/) for details about supported versions of the Go agent and third-party components. 26 27 ## 3.25.0 (retracted) 28 This release was retracted due to an error in the release process which caused the wrong git commit to be tagged. 29 Since the erroneous `v3.25.0` tag was already visible publicly and may already have been picked up by the Go language infrastructure, we retracted the incorrect 3.25.0 version and released the changes intended for 3.25.0 as version 3.25.1, so users of the Go Agent library will reliably get the correct code. 30 31 ### Support statement 32 We use the latest version of the Go language. At minimum, you should be using no version of Go older than what is supported by the Go team themselves (i.e., Go versions 1.19 and later are supported). 33 We recommend updating to the latest agent version as soon as it’s available. If you can’t upgrade to the latest version, update your agents to a version no more than 90 days old. Read more about keeping agents up to date. (https://docs.newrelic.com/docs/new-relic-solutions/new-relic-one/install-configure/update-new-relic-agent/) 34 See the [Go agent EOL Policy](/docs/apm/agents/go-agent/get-started/go-agent-eol-policy/) for details about supported versions of the Go agent and third-party components. 35 36 ## 3.24.1 37 ### Fixed 38 * Performance improvement around calls to security agent. In some cases, unnecessary setup operations were being performed even if there was no security agent present to use that. These are now conditional on the security agent being present in the application (note that this will enable the setup code if the security agent is *present* in the application, regardless of whether it's currently enabled to run). This affects: 39 * Base agent code (updated to v3.24.1) 40 * `nrmongo` integration (updated to v1.1.1) 41 * Resolved a race condition caused by the above-mentioned calls to the security agent. 42 43 * Fixed unit tests for integrations which were failing because code level metrics are enabled by default now: 44 * `nrawssdk-v1` (updated to v1.1.2) 45 * `nrawssdk-v2` (updated to v1.2.2) 46 * `nrecho-v3` (updated to v1.0.2) 47 * `nrecho-v4` (updated to v1.0.4) 48 * `nrhttprouter` (updated to v1.0.2) 49 * `nrlambda` (updated to v1.2.2) 50 * `nrnats` (updated to v1.1.5) 51 * `nrredis-v8` (updated to v1.0.1) 52 53 54 ### Changed 55 * Updated all integration `go.mod` files to reflect supported Go language versions. 56 57 ### Support statement 58 59 We use the latest version of the Go language. At minimum, you should be using no version of Go older than what is supported by the Go team themselves (i.e., Go versions 1.19 and later are supported). 60 61 We recommend updating to the latest agent version as soon as it's available. If you can't upgrade to the latest version, update your agents to a version no more than 90 days old. Read more about keeping agents up to date. (https://docs.newrelic.com/docs/new-relic-solutions/new-relic-one/install-configure/update-new-relic-agent/) 62 63 See the [Go agent EOL Policy](/docs/apm/agents/go-agent/get-started/go-agent-eol-policy/) for details about supported versions of the Go agent and third-party components. 64 65 ## 3.24.0 66 67 ### Added 68 * Turned Code Level Metrics on by default 69 * Added new test case to check if the nrsecurityagent is enabled in the gRPC integration 70 * Added new test case for InfoInterceptorStatusHandler function in the gRPC integration 71 * Added Name() method for Transaction values to get the current transaction name. 72 73 74 ### Fixed 75 * Bumped gin from 1.9.0 to 1.9.1 76 * Bumped gosnowflake from 1.6.16 to 1.6.19 77 * Bumped nrsecurityagent to 1.1.0 with improved reporting of gRPC protocol versions. 78 * Fixed a bug where expected errors weren't being properly marked as expected on new relic dashboards 79 80 ### Support statement 81 82 We use the latest version of the Go language. At minimum, you should be using no version of Go older than what is supported by the Go team themselves (i.e., Go versions 1.19 and later are supported). 83 84 We recommend updating to the latest agent version as soon as it's available. If you can't upgrade to the latest version, update your agents to a version no more than 90 days old. Read more about keeping agents up to date. (https://docs.newrelic.com/docs/new-relic-solutions/new-relic-one/install-configure/update-new-relic-agent/) 85 86 See the [Go agent EOL Policy](/docs/apm/agents/go-agent/get-started/go-agent-eol-policy/) for details about supported versions of the Go agent and third-party components. 87 88 89 90 ## 3.23.1 91 92 ## Added 93 * Added newrelic.ConfigDatastoreRawQuery(true) configuration option to allow raw SQL queries to appear in new relic dashboards 94 * Added license file to nrsecurityagent integration 95 * Added enriched serverless debug logging for faster debugging 96 97 ## Fixed 98 * Removed timeouts on two tests in trace_observer_test.go 99 * Bumped nrnats test to go1.19 100 * Bumped graphql-go to v1.3.0 in the nrgraphgophers integration 101 102 We recommend updating to the latest agent version as soon as it's available. If you can't upgrade to the latest version, update your agents to a version no more than 90 days old. Read more about keeping agents up to date. (https://docs.newrelic.com/docs/new-relic-solutions/new-relic-one/install-configure/update-new-relic-agent/) 103 104 See the [Go agent EOL Policy](https://docs.newrelic.com/docs/apm/agents/go-agent/get-started/go-agent-eol-policy/) for details about supported versions of the Go agent and third-party components. 105 106 ## 3.23.0 107 ### Added 108 * Adds the `nrsecurityagent` integration for performing Interactive Application Security Testing (IAST) of your application. 109 * This action increments the version numbers of the following integrations: 110 * `nrgin` v1.2.0 111 * `nrgrpc` v1.4.0 112 * `nrmicro` v1.2.0 113 * `nrmongo` v1.2.0 114 * `nrsqlite3` v1.2.0 115 116 To learn how to use IAST with the New Relic Go Agent, [check out our documentation](https://docs.newrelic.com/docs/iast/use-iast/). 117 118 ### Support statement 119 120 We use the latest version of the Go language. At minimum, you should be using no version of Go older than what is supported by the Go team themselves (i.e., Go versions 1.19 and later are supported). 121 122 See the [Go agent EOL Policy](https://docs.newrelic.com/docs/apm/agents/go-agent/get-started/go-agent-eol-policy/) for details about supported versions of the Go agent and third-party components. 123 124 125 ## 3.22.1 126 ### Added 127 * New Apache Kafka integration nrsarama that instruments the Sarama library https://github.com/Shopify/sarama 128 * New logs in context integration logcontext-v2/nrzap that instruments the zap logging framework https://github.com/uber-go/zap 129 * Integration tests created for the nrlogrus and nrzapintegrations 130 * Updated integration tests for nrlogxi 131 132 ### Security Fixes 133 * Bumped sys package to v0.1.0 in the nrmssql integration 134 * Bumped net package to v0.7.0 in the nrgrpc, nrmssql , and nrnats integrations 135 * Bumped aws-sdk-go package to v1.34.0 in the nrawssdk-v1 integration 136 * Bumped text package to v0.3.8 in the nrnats, and nrpgx integrations 137 * Bumped gin package to v1.9.0 in the nrgin integration 138 * Bumped crypto package to v0.1.0 in the nrpgx integration 139 * Fixed integration tests in nrnats package not correctly showing code coverage 140 * Corrects an error in the release process for 3.22.0. 141 142 ### Support statement 143 144 We use the latest version of the Go language. At minimum, you should be using no version of Go older than what is supported by the Go team themselves. 145 146 See the [Go agent EOL Policy](https://docs.newrelic.com/docs/apm/agents/go-agent/get-started/go-agent-eol-policy/) for details about supported versions of the Go agent and third-party components. 147 148 ## 3.22.0 (retracted) 149 This release has been retracted due to an error in the release process which caused it to be incorrectly created. Instead, release 3.22.1 was issued with the changes intended for 3.22.0. 150 151 ### Support statement 152 153 We use the latest version of the Go language. At minimum, you should be using no version of Go older than what is supported by the Go team themselves. 154 155 See the [Go agent EOL Policy](https://docs.newrelic.com/docs/apm/agents/go-agent/get-started/go-agent-eol-policy/) for details about supported versions of the Go agent and third-party components. 156 157 ## 3.21.1 158 159 ### Added 160 * nrredis-v9: automatic instrumentation for Go redis v9 161 162 ### Fixed 163 * Agent now requires Go version 1.18 or higher. 164 * Removed support for Go version 1.17. This version of Go is outside of the support window. 165 166 ### Support Statement 167 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. 168 169 We also recommend using the latest version of the Go language. At minimum, you should at least be using no version of Go older than what is supported by the Go team themselves. 170 171 See the [Go Agent EOL Policy](https://docs.newrelic.com/docs/apm/agents/go-agent/get-started/go-agent-eol-policy/) for details about supported versions of the Go Agent and third-party components. 172 173 ## 3.21.0 174 175 ### Added 176 * New Errors inbox features: 177 * User tracking: You can now see the number of users impacted by an error group. Identify the end user with the setUser method. 178 * Error fingerprint: Are your error occurrences grouped poorly? Set your own error fingerprint via a callback function. 179 * Ability to disable reporting parameterized query in nrpgx-5 180 181 ### Fixed 182 * Improved test coverage for gRPC integration, nrgrpc 183 184 ### Support Statement 185 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. 186 187 We also recommend using the latest version of the Go language. At minimum, you should at least be using no version of Go older than what is supported by the Go team themselves. 188 189 See the [Go Agent EOL Policy](https://docs.newrelic.com/docs/apm/agents/go-agent/get-started/go-agent-eol-policy/) for details about supported versions of the Go Agent and third-party components. 190 191 ## 3.20.4 192 193 ### Fixed 194 * nrmssql driver updated to use version maintained by Microsoft 195 * bug where error messages were not truncated to the maximum size, and would get dropped if they were too large 196 * bug where number of span events was hard coded to 1000, and config setting was being ignored 197 198 ### Added 199 * improved performance of ignore error code checks in agent 200 * HTTP error codes can be set as expected by adding them to ErrorCollector.ExpectStatusCodes in the config 201 202 ### Support Statement 203 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. 204 205 We also recommend using the latest version of the Go language. At minimum, you should at least be using no version of Go older than what is supported by the Go team themselves. 206 207 See the [Go Agent EOL Policy](https://docs.newrelic.com/docs/apm/agents/go-agent/get-started/go-agent-eol-policy/) for details about supported versions of the Go Agent and third-party components. 208 209 ## 3.20.3 210 211 Please note that the v2 go agent is no longer supported according to our EOL policy. 212 213 ### Fixed 214 * Performance Improvements for compression 215 * nrsnowflake updated to golang 1.17 versions of packages 216 217 ### Support Statement 218 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. 219 220 We also recommend using the latest version of the Go language. At minimum, you should at least be using no version of Go older than what is supported by the Go team themselves. 221 222 See the [Go Agent EOL Policy](https://docs.newrelic.com/docs/apm/agents/go-agent/get-started/go-agent-eol-policy/) for details about supported versions of the Go Agent and third-party components. 223 224 225 ## 3.20.2 226 227 ### Added 228 * New `NoticeExpectedError()` method allows you to capture errors that you are expecting to handle, without triggering alerts 229 230 ### Fixed 231 * More defensive harvest cycle code that will avoid crashing even in the event of a panic. 232 * Update `nats-server` version to avoid known zip-slip exploit 233 * Update `labstack/echo` version to mitigate known open redirect exploit 234 235 ### Support Statement 236 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. 237 238 We also recommend using the latest version of the Go language. At minimum, you should at least be using no version of Go older than what is supported by the Go team themselves. 239 240 See the [Go Agent EOL Policy](https://docs.newrelic.com/docs/apm/agents/go-agent/get-started/go-agent-eol-policy/) for details about supported versions of the Go Agent and third-party components. 241 242 ## 3.20.1 243 244 ### Added 245 * New integration `nrpgx5` v1.0.0 to instrument `github.com/jackc/pgx/v5`. 246 247 ### Changed 248 249 * Changed the following `TraceOption` function to be consistent with their usage and other related identifier names. The old names remain for backward compatibility, but new code should use the new names. 250 * `WithIgnoredPrefix` -> `WithIgnoredPrefixes` 251 * `WithPathPrefix` -> `WithPathPrefixes` 252 * Implemented better handling of Code Level Metrics reporting when the data (e.g., function names) are excessively long, so that those attributes are suppressed rather than being reported with truncated names. Specifically: 253 * Attributes with values longer than 255 characters are dropped. 254 * No CLM attributes at all will be attached to a trace if the `code.function` attribute is empty or is longer than 255 characters. 255 * No CLM attributes at all will be attached to a trace if both `code.namespace` and `code.filepath` are longer than 255 characters. 256 257 ### Support Statement 258 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. 259 260 We also recommend using the latest version of the Go language. At minimum, you should at least be using no version of Go older than what is supported by the Go team themselves. 261 262 See the [Go Agent EOL Policy](https://docs.newrelic.com/docs/apm/agents/go-agent/get-started/go-agent-eol-policy/) for details about supported versions of the Go Agent and third-party components. 263 264 ## 3.20.0 265 266 **PLEASE READ** these changes, and verify your config settings to ensure your application behaves how you intend it to. This release changes some default behaviors in the go agent. 267 268 ### Added 269 * The Module Dependency Metrics feature was added. This collects the list of modules imported into your application, to aid in management of your application dependencies, enabling easier vulnerability detection and response, etc. 270 * This feature is enabled by default, but may be disabled by explicitly including `ConfigModuleDependencyMetricsEnable(false)` in your application, or setting the equivalent environment variable or `Config` field direclty. 271 * Modules may be explicitly excluded from the report via the `ConfigModuleDependencyMetricsIgnoredPrefixes` option. 272 * Excluded module names may be redacted via the `ConfigModuleDependencyMetricsRedactIgnoredPrefixes` option. This is enabled by default. 273 * Application Log Forwarding will now be **ENABLED** by default 274 * Automatic application log forwarding is now enabled by default. This means that logging frameworks wrapped with one of the [logcontext-v2 integrations](https://docs.newrelic.com/docs/apm/agents/go-agent/get-started/go-agent-compatibility-requirements/) will automatically send enriched application logs to New Relic with this version of the agent. To learn more about this feature, see the [APM logs in context documentation](https://docs.newrelic.com/docs/logs/logs-context/logs-in-context/). For additional configuration options, see the [Go logs in context documentation](https://docs.newrelic.com/docs/logs/logs-context/configure-logs-context-go). To learn about how to toggle log ingestion on or off by account, see our documentation to [disable automatic](https://docs.newrelic.com/docs/logs/logs-context/disable-automatic-logging) logging via the UI or API. 275 * If you are using a logcontext-v2 extension, but don't want the agent to automatically forward logs, please configure `ConfigAppLogForwardingEnabled(false)` in your application. 276 * Environment variables have been added for all application logging config options: 277 * `NEW_RELIC_APPLICATION_LOGGING_ENABLED` 278 * `NEW_RELIC_APPLICATION_LOGGING_FORWARDING_ENABLED` 279 * `NEW_RELIC_APPLICATION_LOGGING_FORWARDING_MAX_SAMPLES_STORED` 280 * `NEW_RELIC_APPLICATION_LOGGING_METRICS_ENABLED` 281 * `NEW_RELIC_APPLICATION_LOGGING_LOCAL_DECORATING_ENABLED` 282 * Custom Event Limit Increase 283 * This version increases the **DEFAULT** limit of custom events from 10,000 events per minute to 30,000 events per minute. In the scenario that custom events were being limited, this change will allow more custom events to be sent to New Relic. There is also a new configurable **MAXIMUM** limit of 100,000 events per minute. To change the limits, set `ConfigCustomInsightsEventsMaxSamplesStored(limit)` to the limit you want in your application. To learn more about the change and how to determine if custom events are being dropped, see our Explorers Hub [post](https://discuss.newrelic.com/t/send-more-custom-events-with-the-latest-apm-agents/190497). 284 * New config option `ConfigCustomInsightsEventsEnabled(false)` can be used to disable the collection of custom events in your application. 285 286 ### Changed 287 * Changed the following names to be consistent with their usage and other related identifier names. The old names remain for backward compatibility, but new code should use the new names. 288 * `ConfigCodeLevelMetricsIgnoredPrefix` -> `ConfigCodeLevelMetricsIgnoredPrefixes` 289 * `ConfigCodeLevelMetricsPathPrefix` -> `ConfigCodeLevelMetricsPathPrefixes` 290 * `NEW_RELIC_CODE_LEVEL_METRICS_PATH_PREFIX` -> `NEW_RELIC_CODE_LEVEL_METRICS_PATH_PREFIXES` 291 * `NEW_RELIC_CODE_LEVEL_METRICS_IGNORED_PREFIX` -> `NEW_RELIC_CODE_LEVEL_METRICS_IGNORED_PREFIXES` 292 293 * When excluding information reported from CodeLevelMetrics via the `IgnoredPrefixes` or `PathPrefixes` configuration fields (e.g., by specifying `ConfigCodeLevelMetricsIgnoredPrefixes` or `ConfigCodeLevelMetricsPathPrefixes`), the names of the ignored prefixes and the configured path prefixes may now be redacted from the agent configuration information sent to New Relic. 294 * This redaction is enabled by default, but may be disabled by supplying a `false` value to `ConfigCodeLevelMetricsRedactPathPrefixes` or `ConfigCodeLevelMetricsRedactIgnoredPrefixes`, or by setting the corresponding `Config` fields or environment variables to `false`. 295 296 ### Fixed 297 * [#583](https://github.com/newrelic/go-agent/issues/583): fixed a bug in zerologWriter where comma separated fields in log message confused the JSON parser and could cause panics. 298 299 ### Support Statement 300 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. 301 302 We also recommend using the latest version of the Go language. At minimum, you should at least be using no version of Go older than what is supported by the Go team themselves. 303 304 See the [Go Agent EOL Policy](https://docs.newrelic.com/docs/apm/agents/go-agent/get-started/go-agent-eol-policy/) for details about supported versions of the Go Agent and third-party components. 305 306 ## 3.19.2 307 308 ### Changed 309 * Updated nrgin integration to more accurately report code locations when code level metrics are enabled. 310 * The Go Agent and all integrations now require Go version 1.17 or later. 311 * Updated minimum versions for third-party modules. 312 * nrawssdk-v2, nrecho-v4, nrgrpc, nrmongo, nrmysql, nrnats, and nrstan now require Go Agent 3.18.2 or later 313 * the Go Agent now requires protobuf 1.5.2 and grpc 1.49.0 314 * Internal dev process and unit test improvements. 315 316 ### Support Statement 317 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. 318 319 We also recommend using the latest version of the Go language. At minimum, you should at least be using no version of Go older than what is supported by the Go team themselves. 320 321 See the [Go Agent EOL Policy](https://docs.newrelic.com/docs/apm/agents/go-agent/get-started/go-agent-eol-policy/) for details about supported versions of the Go Agent and third-party components. 322 323 324 ## 3.19.1 - Hotfix Release 325 326 ### Changed 327 * Moved the v3/internal/logcontext/nrwriter module to v3/integrations/logcontext-v2/nrwriter 328 329 ### Support Statement 330 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. 331 332 See the [Go Agent EOL Policy](https://docs.newrelic.com/docs/apm/agents/go-agent/get-started/go-agent-eol-policy/) for details about supported versions of the Go Agent and third-party components. 333 334 ## 3.19.0 335 336 ### Added 337 * `logcontext-v2/logWriter` plugin: a new logs in context plugin that supports the standard library logging package. 338 * `logcontext-v2/zerologWriter` plugin: a new logs in context plugin for zerolog that will replace the old logcontext-v2/zerolog plugin. This plugin is more robust, and will be able to support a richer set of features than the previous plugin. 339 * see the updated [logs in context documentation](https://docs.newrelic.com/docs/logs/logs-context/configure-logs-context-go) for information about configuration and installation. 340 341 ### Changed 342 * the logcontext-v2/zerolog plugin will be deprecated once the 3.17.0 release EOLs. 343 344 ### Support Statement 345 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. 346 347 See the [Go Agent EOL Policy](https://docs.newrelic.com/docs/apm/agents/go-agent/get-started/go-agent-eol-policy/) for details about supported versions of the Go Agent and third-party components. 348 349 ## 3.18.2 350 351 ### Added 352 * Added `WithDefaultFunctionLocation` trace option. This allows the caller to indicate a fall-back function to use for CLM in case no other location was found first. 353 * Added caching versions of the code-level metrics functions `ThisCodeLocation` and `FunctionLocation` , and trace options `WithThisCodeLocation` and `WithFunctionLocation`. These improve performance by caching the result of computing the source code location, and reuse that cached result on all subsequent calls. 354 * Added a `WithCodeLevelMetrics` trace option to force the collection of CLM data even if it would have been excluded as being out of the configured scope. (Note that CLM data are _never_ collected if CLM is turned off globally or if the `WithoutCodeLevelMetrics` option was specified for the same transaction.) 355 * Added an exported `CodeLevelMetricsScopeLabelToValue` function to convert a list of strings describing CLM scopes in the same manner as the `NEW_RELIC_CODE_LEVEL_METRICS_SCOPE` environment variable (but as individual string parameters), returning the `CodeLevelMetricsScope` value which corresponds to that set of scopes. 356 * Added a new `CodeLevelMetricsScopeLabelListToValue` function which takes a comma-separated list of scope names exactly as the `NEW_RELIC_CODE_LEVEL_METRICS_SCOPE` environment variable does, and returns the `CodeLevelMetrics` value corresponding to that set of scopes. 357 * Added text marshaling and unmarshaling for the `CodeLevelMetricsScope` value, allowing the `CodeLevelMetrics` field of the configuration `struct` to be converted to or from JSON or other text-based encoding representations. 358 359 ### Changed 360 * The `WithPathPrefix` trace option now takes any number of `string` parameters, allowing multiple path prefixes to be recognized rather than just one. 361 * The `FunctionLocation` function now accepts any number of function values instead of just a single one. The first such parameter which indicates a valid function, and for which CLM data are successfully obtained, is the one which will be reported. 362 * The configuration `struct` field `PathPrefix` is now deprecated with the introduction of a new `PathPrefixes` field. This allows for multiple path prefixes to be given to the agent instead of only a single one. 363 * The `NEW_RELIC_CODE_LEVEL_METRICS_SCOPE` environment variable now accepts a comma-separated list of pathnames. 364 365 ### Fixed 366 * Improved the implementation of CLM internals to improve speed, robustness, and thread safety. 367 * Corrected the implementation of the `WrapHandle` and `WrapHandleFunc` functions so that they consistently report the function being invoked by the `http` framework, and improved them to use the new caching functions and ensured they are thread-safe. 368 369 This release fixes [issue #557](https://github.com/newrelic/go-agent/issues/557). 370 371 ### Compatibility Notice 372 As of release 3.18.0, the API was extended by allowing custom options to be added to calls to the `Application.StartTransaction` method and the `WrapHandle` and `WrapHandleFunc` functions. They are implemented as variadic functions such that the new option parameters are optional (i.e., zero or more options may be added to the end of the function calls) to be backward-compatible with pre-3.18.0 usage of those functions. This prevents the changes from breaking existing code for typical usage of the agent. However, it does mean those functions' call signatures have changed: 373 * `StartTransaction(string)` -> `StartTransaction(string, ...TraceOption)` 374 * `WrapHandle(*Application, string, http.Handler)` -> `WrapHandle(*Application, string, http.Handler, ...TraceOption)` 375 * `WrapHandleFunc(*Application, string, func(http.ResponseWriter, *http.Request))` -> `WrapHandleFunc(*Application, string, func(http.ResponseWriter, *http.Request), ...TraceOption)` 376 377 If, for example, you created your own custom interface type which includes the `StartTransaction` method or something that depends on these functions' exact call semantics, that code will need to be updated accordingly before using version 3.18.0 (or later) of the Go Agent. 378 379 ### Support Statement 380 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. 381 382 See the [Go Agent EOL Policy](https://docs.newrelic.com/docs/apm/agents/go-agent/get-started/go-agent-eol-policy/) for details about supported versions of the Go Agent and third-party components. 383 384 385 ## 3.18.1 386 ### Added 387 * Extended the `IgnoredPrefix` configuration value for Code-Level Metrics so that multiple such prefixes may be given instead of a single one. This deprecates the `IgnoredPrefix` configuration field of `Config.CodeLevelMetrics` in favor of a new slice field `IgnoredPrefixes`. The corresponding configuration option-setting functions `ConfigCodeLevelMetricsIgnoredPrefix` and `WithIgnoredPrefix` now take any number of string parameters to set these values. Since those functions used to take a single string value, this change is backward-compatible with pre-3.18.1 code. Accordingly, the `NEW_RELIC_CODE_LEVEL_METRICS_IGNORED_PREFIX` environment variable is now a comma-separated list of prefixes. Fixes [Issue #551](https://github.com/newrelic/go-agent/issues/551). 388 389 ### Fixed 390 * Corrected some small errors in documentation of package features. Fixes [Issue #550](https://github.com/newrelic/go-agent/issues/550) 391 392 ### Compatibility Notice 393 As of release 3.18.0, the API was extended by allowing custom options to be added to calls to the `Application.StartTransaction` method and the `WrapHandle` and `WrapHandleFunc` functions. They are implemented as variadic functions such that the new option parameters are optional (i.e., zero or more options may be added to the end of the function calls) to be backward-compatible with pre-3.18.0 usage of those functions. This prevents the changes from breaking existing code for typical usage of the agent. However, it does mean those functions' call signatures have changed: 394 * `StartTransaction(string)` -> `StartTransaction(string, ...TraceOption)` 395 * `WrapHandle(*Application, string, http.Handler)` -> `WrapHandle(*Application, string, http.Handler, ...TraceOption)` 396 * `WrapHandleFunc(*Application, string, func(http.ResponseWriter, *http.Request))` -> `WrapHandleFunc(*Application, string, func(http.ResponseWriter, *http.Request), ...TraceOption)` 397 398 If, for example, you created your own custom interface type which includes the `StartTransaction` method or something that depends on these functions' exact call semantics, that code will need to be updated accordingly before using version 3.18.0 (or later) of the Go Agent. 399 400 ### Support Statement 401 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. 402 403 See the [Go Agent EOL Policy](https://docs.newrelic.com/docs/apm/agents/go-agent/get-started/go-agent-eol-policy/) for details about supported versions of the Go Agent and third-party components. 404 405 ## 3.18.0 406 ### Added 407 * Code-Level Metrics are now available for instrumented transactions. This is off by default but once enabled via `ConfigCodeLevelMetricsEnabled(true)` transactions will include information about the location in the source code where `StartTransaction` was invoked. 408 * Adds information about where in your source code transaction traces originated. 409 * See the Go Agent documentation for details on [configuring](https://docs.newrelic.com/docs/apm/agents/go-agent/configuration/go-agent-code-level-metrics-config) Code-Level Metrics and how to [instrument](https://docs.newrelic.com/docs/apm/agents/go-agent/instrumentation/go-agent-code-level-metrics-instrument) your code using them. 410 * New V2 logs in context plugin is available for Logrus, packed with all the features you didn't know you wanted: 411 * Automatic Log Forwarding 412 * Log Metrics 413 * Capture logs anywhere in your code; both inside or outside of a transaction. 414 * Use the Logrus formatting package of your choice 415 * Local Log Decorating is now available for the new logcontext-v2/nrlogrus plugin only. This is off by default but can be enabled with `ConfigAppLogForwardingEnabled(true)`. 416 417 ### Fixed 418 * Fixed issue with custom event limits and number of DT Spans to more accurately follow configured limits. 419 420 ### Compatibility Notice 421 This release extends the API by allowing custom options to be added to calls to the `Application.StartTransaction` method and the `WrapHandle` and `WrapHandleFunc` functions. They are implemented as variadic functions such that the new option parameters are optional (i.e., zero or more options may be added to the end of the function calls) to be backward-compatible with pre-3.18.0 usage of those functions. 422 This prevents the changes from breaking existing code for typical usage of the agent. However, it does mean those functions' call signatures have changed: 423 * `StartTransaction(string)` -> `StartTransaction(string, ...TraceOption)` 424 * `WrapHandle(*Application, string, http.Handler)` -> `WrapHandle(*Application, string, http.Handler, ...TraceOption)` 425 * `WrapHandleFunc(*Application, string, func(http.ResponseWriter, *http.Request))` -> `WrapHandleFunc(*Application, string, func(http.ResponseWriter, *http.Request), ...TraceOption)` 426 427 If, for example, you created your own custom interface type which includes the `StartTransaction` method or something that depends on these functions' exact call semantics, that code will need to be updated accordingly before using version 3.18.0 of the Go Agent. 428 429 ### Support Statement 430 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. 431 * Note that the oldest supported version of the Go Agent is 3.6.0. 432 433 ## 3.17.0 434 ### Added 435 * Logs in context now supported for zerolog. 436 * This is a quick way to view logs no matter where you are in the platform. 437 * 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. 438 * 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. 439 * To learn more about APM logs in context see the documentation [here](https://docs.newrelic.com/docs/logs/logs-context/logs-in-context). 440 * Includes the `RecordLog` function for recording log data from a single log entry 441 * An integrated plugin for zerolog to automatically ingest log data with the Go Agent. 442 * 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) . 443 * Added integration for MS SQL Server ([PR 425](https://github.com/newrelic/go-agent/pull/425); thanks @ishahid91!) 444 * This introduces the `nrmssql` integration v1.0.0. 445 * 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) 446 447 ### Fixed 448 * Improved speed of building distributed trace header JSON payload. Fixes [issue 505](https://github.com/newrelic/go-agent/issues/505). 449 * 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). 450 * Updated `go.mod` for the `nrgin` integration to mitigate security issue in 3rd party dependency. 451 * Updated `go.mod` for the `nrawssdk-v1` integration to properly reflect its dependency on version 3.16.0 of the Go Agent. 452 * 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!) 453 454 ### Support Statement 455 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. 456 * Note that the oldest supported version of the Go Agent is 3.6.0. 457 458 # ChangeLog 459 ## 3.16.1 460 ### Fixed 461 * Changed dependency on gRPC from v1.27.0 to v1.39.0. This in turn changes gRPC's dependency on `x/crypto` to v0.0.0-20200622213623-75b288015ac9, which fixes a security vulnerability in the `x/crypto` standard library module. Fixes [issue #451](https://github.com/newrelic/go-agent/issues/451). 462 * Incremented version number of the `nrawssdk-v1` integration from v1.0.1 to v1.1.0 to resolve an incompatibility issue due to changes to underlying code. Fixes [issue #499](https://github.com/newrelic/go-agent/issues/499) 463 464 ### Support Statement 465 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. 466 467 ## 3.16.0 468 ### Added 469 * Distributed Tracing is now the default mode of operation. It may be disabled by user configuration if so desired. [PR #495](https://github.com/newrelic/go-agent/pull/495) 470 * To disable DT, add `newrelic.ConfigDistributedTracerEnabled(false)` to your application configuration. 471 * To change the reservoir limit for how many span events are to be collected per harvest cycle from the default, add `newrelic.ConfigDistributedTracerReservoirLimit(`*newlimit*`)` to your application configuration. 472 * The reservoir limit's default was increased from 1000 to 2000. 473 * The maximum reservoir limit supported is 10,000. 474 * Note that Cross Application Tracing is now deprecated. 475 * Added support for gathering memory statistics via `PhysicalMemoryBytes` functions for OpenBSD. 476 477 ### Fixed 478 * Corrected some example code to be cleaner. 479 * Updated version of nats-streaming-server. [PR #458](https://github.com/newrelic/go-agent/pull/458) 480 * Correction to nrpkgerrors so that `nrpkgerrors.Wrap` now checks if the error it is passed has attributes, and if it does, copies them into the New Relic error it creates. 481 This fixes [issue #409](https://github.com/newrelic/go-agent/issues/409) via [PR #441](https://github.com/newrelic/go-agent/pull/441). 482 * This increments the `nrpkgerrors` version to v1.1.0. 483 484 ### Support Statement 485 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. 486 487 488 ## 3.15.2 489 ### Added 490 * Strings logged via the Go Agent's built-in logger will have strings of the form `license_key=`*hex-string* changed to `license_key=[redacted]` before they are output, regardless of severity level, where *hex-string* means a sequence of upper- or lower-case hexadecimal digits and dots ('.'). This incorporates [PR #415](https://github.com/newrelic/go-agent/pull/415). 491 492 ### Support Statement 493 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. 494 495 ## 3.15.1 496 497 ### Fixed 498 499 * Updated support for SQL database instrumentation across the board for the Go Agent’s database integrations to more accurately extract the database table name from SQL queries. Fixes [Issue #397](https://github.com/newrelic/go-agent/issues/397). 500 501 * Updated the `go.mod` file in the `nrecho-v4` integration to require version 4.5.0 of the `github.com/labstack/echo` package. This addresses a security concern arising from downstream dependencies in older versions of the echo package, as described in the [release notes](https://github.com/labstack/echo/releases/tag/v4.5.0) for `echo` v4.5.0. 502 503 ### ARM64 Compatibility Note 504 505 The New Relic Go Agent is implemented in platform-independent Go, and supports (among the other platforms which run Go) ARM64/Graviton2 using Go 1.17+. 506 507 ### Support Statement 508 509 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. 510 511 512 513 ## 3.15.0 514 515 ### Fixed 516 * Updated mongodb driver version to 1.5.1 to fix security issue in external dependency. Fixes [Issue #358](https://github.com/newrelic/go-agent/issues/358) and [Issue #370](https://github.com/newrelic/go-agent/pull/370). 517 518 * Updated the `go.mod` file in the `nrgin` integration to require version 1.7.0 of the `github.com/gin-gonic/gin` package. This addresses [CVE-2020-28483](https://github.com/advisories/GHSA-h395-qcrw-5vmq) which documents a vulnerability in versions of `github.com/gin-gonic/gin` earlier than 1.7.0. 519 520 521 ### Added 522 * New integration `nrpgx` added to provide the same functionality for instrumenting Postgres database queries as the existing `nrpq` integration, but using the [pgx](https://github.com/jackc/pgx) driver instead. This only covers (at present) the use case of the `pgx` driver with the standard library `database/sql`. Fixes [Issue #142](https://github.com/newrelic/go-agent/issues/142) and [Issue #292](https://github.com/newrelic/go-agent/issues/292) 523 524 ### Changed 525 * Enhanced debugging logs so that New Relic license keys are redacted from the log output. Fixes [Issue #353](https://github.com/newrelic/go-agent/issues/353). 526 527 * Updated the advice in `GUIDE.md` to have correct `go get` commands with explicit reference to `v3`. 528 529 ### Support Statement 530 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. 531 532 ## 3.14.1 533 534 ### Fixed 535 * A typographical error in the nrgrpc unit tests was fixed. Fixes [Issue #344](https://github.com/newrelic/go-agent/issues/344). 536 This updates the nrgrpc integration to version 1.3.1. 537 538 ### Support Statement 539 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. 540 541 542 ## 3.14.0 543 544 ### Fixed 545 * Integration tags and `go.mod` files for integrations were updated so that [pkg.go.dev]() displays the documentation for each integration correctly. 546 * The `nrgrpc` server integration was reporting all non-`OK` grpc statuses as errors. This has now been changed so that only selected grpc status codes will be reported as errors. Others are shown (via transaction attributes) as "warnings" or "informational" messages. There is a built-in set of defaults as to which status codes are reported at which severity levels, but this may be overridden by the caller as desired. Also supports custom grpc error handling functions supplied by the user. 547 * This is implemented by adding `WithStatusHandler()` options to the end of the `UnaryServerInterceptor()` and `StreamServerInterceptor()` calls, thus extending the capability of those functions while retaining the existing functionality and usage syntax for backward compatibility. 548 * Added advice on the recommended usage of the `app.WaitForConnection()` method. Fixes [Issue #296](https://github.com/newrelic/go-agent/issues/296) 549 550 ### Added 551 * Added a convenience function to build distributed trace header set from a JSON string for use with the `AcceptDistributedTraceHeaders()` method. Normally, you must create a valid set of HTTP headers representing the trace identification information from the other trace so the new trace will be associated with it. This needs to be in a Go `http.Header` type value. 552 * If working only in Go, this may be just fine as it is. However, if the other trace information came from another source, possibly in a different language or environment, it is often the case that the trace data is already presented to you in the form of a JSON string. 553 * This new function, `DistributedTraceHeadersFromJSON()`, creates the required `http.Header` value from the JSON string without requiring manual effort on your part. 554 * We also provide a new all-in-one method `AcceptDistributedTraceHeadersFromJSON()` to be used in place of `AcceptDistributedTraceHeaders()`. It accepts a JSON string rather than an `http.Header`, adding its trace info to the new transaction in one step. 555 * Fixes [Issue #331](https://github.com/newrelic/go-agent/issues/331) 556 557 ### Changed 558 * Improved the NR AWS SDK V2 integration to use the current transaction rather than the one passed in during middleware creation, if `nil` is passed into nrawssdk-v2.AppendMiddlewares. Thanks to @HenriBeck for noticing and suggesting improvement, and thanks to @nc-wittj for the fantastic PR! [#328](https://github.com/newrelic/go-agent/pull/328) 559 560 ### Support Statement 561 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. 562 563 ## 3.13.0 564 565 ### Fixed 566 * Replaced the NR AWS SDK V2 integration for the v3 agent with a new version that works. See the v3/integrations/nrawssdk-v2/example/main.go file for an example of how to use it. Issues [#250](https://github.com/newrelic/go-agent/issues/250) and [#288](https://github.com/newrelic/go-agent/issues/288) are fixed by this PR. [#309](https://github.com/newrelic/go-agent/pull/309) 567 568 * Fixes issue [#221](https://github.com/newrelic/go-agent/issues/221): grpc errors reported in code watched by `UnaryServerInterceptor()` or `StreamServerInterceptor()` now create error events which are reported to the UI with the error message string included. [#317](https://github.com/newrelic/go-agent/pull/317) 569 570 * Fixes documentation in `GUIDE.md` for `txn.StartExternalSegment()` to reflect the v3 usage. Thanks to @abeltay for calling this to our attention and submitting PR [#320](https://github.com/newrelic/go-agent/pull/320). 571 572 ### Changes 573 * The v3/examples/server/main.go example now uses `newrelic.ConfigFromEnvironment()`, rather than explicitly pulling in the license key with `newrelic.ConfigLicense(os.Getenv("NEW_RELIC_LICENSE_KEY"))`. The team is starting to use this as a general systems integration testing script, and this facilitates testing with different settings enabled. 574 575 ### Support Statement 576 * 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](https://docs.newrelic.com/docs/using-new-relic/cross-product-functions/install-configure/notification-changes-new-relic-saas-features-distributed-software). 577 578 ## 3.12.0 579 580 ### Changes 581 * Updated `CHANGELOG.md` release notes language, to correct typographical errors and 582 clean up grammar. [#289](https://github.com/newrelic/go-agent/issues/289) 583 584 ### Fixed 585 * When using DAX to query a dynamodb table, the New Relic instrumentation 586 panics with a `nil dereference` error. This was due to the way that the 587 request is made internally such that there is no `HTTPRequest.Header` 588 defined, but one was expected. This correction checks for the existence 589 of that header and takes an appropriate course of action if one is not 590 found. [#287](https://github.com/newrelic/go-agent/issues/287) Thanks to 591 @odannyc for reporting the issue and providing a pull request with a suggested 592 fix. 593 594 ### Support Statement 595 * 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](https://docs.newrelic.com/docs/using-new-relic/cross-product-functions/install-configure/notification-changes-new-relic-saas-features-distributed-software). 596 597 ## 3.11.0 598 599 ### New Features 600 * Aerospike is now included on the list of recognized datastore names. Thanks @vkartik97 for your PR! [#233](https://github.com/newrelic/go-agent/pull/233) 601 * Added support for verison 8 of go-redis. Thanks @ilmimris for adding this instrumentation! [#251](https://github.com/newrelic/go-agent/pull/251) 602 603 ### Changes 604 * Changed logging level for messages resulting from Infinite Tracing load balancing operations. These were previously logged as errors, and now they are debugging messages. [#276](https://github.com/newrelic/go-agent/pull/276) 605 606 ### Fixed 607 * When the agent is configured with `cfg.ErrorCollector.RecordPanics` set to `true`, panics would be recorded by New Relic, but stack traces would not be logged as the Go Runtime usually does. The agent now logs stack traces from within its panic handler, providing similar functionality. [#278](https://github.com/newrelic/go-agent/pull/278) 608 * Added license files to some integrations packages to ensure compatibility with package.go.dev. Now the documentation for our integrations shows up again on go.docs. 609 610 ### Support statement 611 * 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](https://docs.newrelic.com/docs/using-new-relic/cross-product-functions/install-configure/notification-changes-new-relic-saas-features-distributed-software). 612 613 ## 3.10.0 614 615 ### New Features 616 * To keep up with the latest security protocols implemented by Amazon Web 617 Services, the agent now uses [AWS 618 IMDSv2](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-instance-metadata-service.html) 619 to find utilization data. [#249](https://github.com/newrelic/go-agent/pull/249) 620 621 ### Changes 622 * Updated the locations of our license files so that Go docs https://pkg.go.dev 623 will display our agent. Thanks @tydavis for your PR to fix this! [#254](https://github.com/newrelic/go-agent/pull/254) 624 * Added an Open Source repo linter GitHub action that runs on push. [#262](https://github.com/newrelic/go-agent/pull/262) 625 * Updated the README.md file to correctly show the support resources from New Relic. [#255](https://github.com/newrelic/go-agent/pull/255) 626 627 ### Support statement 628 * 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](https://docs.newrelic.com/docs/using-new-relic/cross-product-functions/install-configure/notification-changes-new-relic-saas-features-distributed-software). 629 630 ## 3.9.0 631 632 ### Changes 633 * When sending Serverless telemetry using the `nrlambda` integration, support an externally-managed named pipe. 634 635 ## 3.8.1 636 637 ### Bug Fixes 638 639 * Fixed an issue that could cause orphaned Distributed Trace spans when using 640 SQL instrumentation like `nrmysql`. 641 642 ## 3.8.0 643 644 ### Changes 645 * When marking a transaction as a web transaction using 646 [Transaction.SetWebRequest](https://godoc.org/github.com/newrelic/go-agent/v3/newrelic#Transaction.SetWebRequest), 647 it is now possible to include a `Host` field in the 648 [WebRequest](https://godoc.org/github.com/newrelic/go-agent/v3/newrelic#WebRequest) 649 struct, which defaults to the empty string. 650 651 ### Bug Fixes 652 653 * The `Host` header is now being correctly captured and recorded in the 654 `request.headers.host` attribute, as described 655 [here](https://docs.newrelic.com/docs/agents/go-agent/instrumentation/go-agent-attributes#requestHeadersHost). 656 * Previously, the timestamps on Spans and Transactions were being written 657 using different data types, which sometimes caused rounding errors that 658 could cause spans to be offset incorrectly in the UI. This has been fixed. 659 660 ## 3.7.0 661 662 ### Changes 663 664 * When `Config.Transport` is nil, no longer use the `http.DefaultTransport` 665 when communicating with the New Relic backend. This addresses an issue with 666 shared transports as described in https://github.com/golang/go/issues/33006. 667 668 * If a timeout occurs when attempting to send data to the New Relic backend, 669 instead of dropping the data, we save it and attempt to send it with the 670 next harvest. Note data retention limits still apply and the agent will 671 still start to drop data when these limits are reached. We attempt to keep 672 the highest priority events and traces. 673 674 ## 3.6.0 675 676 ### New Features 677 678 * Added support for [adding custom attributes directly to 679 spans](https://godoc.org/github.com/newrelic/go-agent/v3/newrelic#Segment.AddAttribute). 680 These attributes will be visible when looking at spans in the Distributed 681 Tracing UI. 682 683 Example: 684 ```go 685 txn := newrelic.FromContext(r.Context()) 686 sgmt := txn.StartSegment("segment1") 687 defer sgmt.End() 688 sgmt.AddAttribute("mySpanString", "hello") 689 sgmt.AddAttribute("mySpanInt", 123) 690 ``` 691 692 * Custom attributes added to the transaction with `txn.AddAttribute` are now 693 also added to the root Span Event and will be visible when looking at the 694 span in the Distributed Tracing UI. These custom attributes can be disabled 695 from all destinations using `Config.Attributes.Exclude` or disabled from Span 696 Events specifically using `Config.SpanEvents.Attributes.Exclude`. 697 698 * Agent attributes added to the transaction are now also added to the root Span 699 Event and will be visible when looking at the span in the Distributed Tracing 700 UI. These attributes include the `request.uri` and the `request.method` along 701 with all other attributes listed in the [attributes section of our 702 godocs](https://godoc.org/github.com/newrelic/go-agent/v3/newrelic#pkg-constants). 703 These agent attributes can be disabled from all destinations using 704 `Config.Attributes.Exclude` or disabled from Span Events specifically using 705 `Config.SpanEvents.Attributes.Exclude`. 706 707 ### Bug Fixes 708 709 * Fixed an issue where it was impossible to exclude the attributes 710 `error.class` and `error.message` from the root Span Event. This issue has 711 now been fixed. These attributes can now be excluded from all Span Events 712 using `Config.Attributes.Exclude` or `Config.SpanEvents.Attributes.Exclude`. 713 714 * Fixed an issue that caused Go's data race warnings to trigger in certain situations 715 when using the `newrelic.NewRoundTripper`. There were no reports of actual data corruption, 716 but now the warnings should be resolved. Thank you to @blixt for bringing this to our 717 attention! 718 719 ## 3.5.0 720 721 ### New Features 722 723 * Added support for [Infinite Tracing on New Relic 724 Edge](https://docs.newrelic.com/docs/understand-dependencies/distributed-tracing/enable-configure/enable-distributed-tracing). 725 726 Infinite Tracing observes 100% of your distributed traces and provides 727 visualizations for the most actionable data so you have the examples of errors 728 and long-running traces so you can better diagnose and troubleshoot your systems. 729 730 You [configure your 731 agent](https://docs.newrelic.com/docs/agents/go-agent/configuration/go-agent-configuration#infinite-tracing) 732 to send traces to a trace observer in New Relic Edge. You view your 733 distributed traces through the New Relic’s UI. There is no need to install a 734 collector on your network. 735 736 Infinite Tracing is currently available on a sign-up basis. If you would like to 737 participate, please contact your sales representative. 738 739 **As part of this change, the Go Agent now has an added dependency on gRPC.** 740 This is true whether or not you enable the Infinite Tracing feature. The gRPC dependencies include these two libraries: 741 * [github.com/golang/protobuf](https://github.com/golang/protobuf) v1.3.3 742 * [google.golang.org/grpc](https://github.com/grpc/grpc-go) v1.27.0 743 744 You can see the changes in the [go.mod file](v3/go.mod) 745 746 **As part of this change, the Go Agent now has an added dependency on gRPC.** 747 This is true whether or not you enable the Infinite Tracing feature. The gRPC dependencies include these two libraries: 748 * [github.com/golang/protobuf](https://github.com/golang/protobuf) v1.3.3 749 * [google.golang.org/grpc](https://github.com/grpc/grpc-go) v1.27.0 750 751 You can see the changes in the [go.mod file](v3/go.mod) 752 753 ### Changes 754 755 * [`nrgin.Middleware`](https://godoc.org/github.com/newrelic/go-agent/v3/integrations/nrgin#Middleware) 756 uses 757 [`Context.FullPath()`](https://godoc.org/github.com/gin-gonic/gin#Context.FullPath) 758 for transaction names when using Gin version 1.5.0 or greater. Gin 759 transactions were formerly named after the 760 [`Context.HandlerName()`](https://godoc.org/github.com/gin-gonic/gin#Context.HandlerName), 761 which uses reflection. This change improves transaction naming and reduces 762 overhead. Please note that because your transaction names will change, you 763 may have to update any related dashboards and alerts to match the new name. 764 If you wish to continue using `Context.HandlerName()` for your transaction 765 names, use 766 [`nrgin.MiddlewareHandlerTxnNames`](https://godoc.org/github.com/newrelic/go-agent/v3/integrations/nrgin#MiddlewareHandlerTxnNames) 767 instead. 768 769 ```go 770 // Transactions previously named 771 "GET main.handleGetUsers" 772 // will be change to something like this match the full path 773 "GET /user/:id" 774 ``` 775 776 Note: As part of agent release v3.4.0, a v2.0.0 tag was added to the nrgin 777 package. When using go modules however, it was impossible to install this 778 latest version of nrgin. The v2.0.0 tag has been removed and replaced with 779 v1.1.0. 780 781 ## 3.4.0 782 783 ### New Features 784 785 * Attribute `http.statusCode` has been added to external span events 786 representing the status code on an http response. This attribute will be 787 included when added to an ExternalSegment in one of these three ways: 788 789 1. Using 790 [`NewRoundTripper`](https://godoc.org/github.com/newrelic/go-agent/v3/newrelic#NewRoundTripper) 791 with your http.Client 792 2. Including the http.Response as a field on your 793 [`ExternalSegment`](https://godoc.org/github.com/newrelic/go-agent/v3/newrelic#ExternalSegment) 794 3. Using the new 795 [`ExternalSegment.SetStatusCode`](https://godoc.org/github.com/newrelic/go-agent/v3/newrelic#ExternalSegment.SetStatusCode) 796 API to set the status code directly 797 798 To exclude the `http.statusCode` attribute from span events, update your 799 agent configuration like so, where `cfg` is your [`newrelic.Config`](https://godoc.org/github.com/newrelic/go-agent/v3/newrelic#Config) object. 800 801 ```go 802 cfg.SpanEvents.Attributes.Exclude = append(cfg.SpanEvents.Attributes.Exclude, newrelic.SpanAttributeHTTPStatusCode) 803 ``` 804 805 * Error attributes `error.class` and `error.message` are now included on the 806 span event in which the error was noticed, or on the root span if an error 807 occurs in a transaction with no segments (no chid spans). Only the most recent error 808 information is added to the attributes; prior errors on the same span are 809 overwritten. 810 811 To exclude the `error.class` and/or `error.message` attributes from span events, update your 812 agent configuration like so, where `cfg` is your [`newrelic.Config`](https://godoc.org/github.com/newrelic/go-agent/v3/newrelic#Config) object. 813 814 ```go 815 cfg.SpanEvents.Attributes.Exclude = append(cfg.SpanEvents.Attributes.Exclude, newrelic.newrelic.SpanAttributeErrorClass, newrelic.SpanAttributeErrorMessage) 816 ``` 817 818 ### Changes 819 820 * Use 821 [`Context.FullPath()`](https://godoc.org/github.com/gin-gonic/gin#Context.FullPath) 822 for transaction names when using Gin version 1.5.0 or greater. Gin 823 transactions were formerly named after the 824 [`Context.HandlerName()`](https://godoc.org/github.com/gin-gonic/gin#Context.HandlerName), 825 which uses reflection. This change improves transaction naming and reduces 826 overhead. Please note that because your transaction names will change, you 827 may have to update any related dashboards and alerts to match the new name. 828 829 ```go 830 // Transactions previously named 831 "GET main.handleGetUsers" 832 // will be change to something like this match the full path 833 "GET /user/:id" 834 ``` 835 * If you are using any of these integrations, you must upgrade them when you 836 upgrade the agent: 837 * [nrlambda v1.1.0](https://godoc.org/github.com/newrelic/go-agent/v3/integrations/nrlambda) 838 * [nrmicro v1.1.0](https://godoc.org/github.com/newrelic/go-agent/v3/integrations/nrmicro) 839 * [nrnats v1.1.0](https://godoc.org/github.com/newrelic/go-agent/v3/integrations/nrnats) 840 * [nrstan v1.1.0](https://godoc.org/github.com/newrelic/go-agent/v3/integrations/nrstan) 841 842 ### Known Issues and Workarounds 843 844 * If a .NET agent is initiating distributed traces as the root service, you must 845 update that .NET agent to version 8.24 or later before upgrading your downstream 846 Go New Relic agents to this agent release. 847 848 ## 3.3.0 849 850 ### New Features 851 852 * Added support for GraphQL in two new integrations: 853 * [graph-gophers/graphql-go](https://github.com/graph-gophers/graphql-go) 854 with 855 [v3/integrations/nrgraphgophers](https://godoc.org/github.com/newrelic/go-agent/v3/integrations/nrgraphgophers). 856 * [Documentation](https://godoc.org/github.com/newrelic/go-agent/v3/integrations/nrgraphgophers) 857 * [Example](v3/integrations/nrgraphgophers/example/main.go) 858 * [graphql-go/graphql](https://github.com/graphql-go/graphql) 859 with 860 [v3/integrations/nrgraphqlgo](https://godoc.org/github.com/newrelic/go-agent/v3/integrations/nrgraphqlgo). 861 * [Documentation](https://godoc.org/github.com/newrelic/go-agent/v3/integrations/nrgraphqlgo) 862 * [Example](v3/integrations/nrgraphqlgo/example/main.go) 863 864 * Added database instrumentation support for 865 [snowflakedb/gosnowflake](https://github.com/snowflakedb/gosnowflake). 866 * [Documentation](https://godoc.org/github.com/newrelic/go-agent/v3/integrations/nrsnowflake) 867 * [Example](v3/integrations/nrsnowflake/example/main.go) 868 869 ### Changes 870 871 * When using 872 [`newrelic.StartExternalSegment`](https://godoc.org/github.com/newrelic/go-agent/v3/newrelic#StartExternalSegment) 873 or 874 [`newrelic.NewRoundTripper`](https://godoc.org/github.com/newrelic/go-agent/v3/newrelic#NewRoundTripper), 875 if existing cross application tracing or distributed tracing headers are 876 present on the request, they will be replaced instead of added. 877 878 * The 879 [`FromContext`](https://godoc.org/github.com/newrelic/go-agent/v3/newrelic#FromContext) 880 API which allows you to pull a Transaction from a context.Context will no 881 longer panic if the provided context is nil. In this case, a nil is 882 returned. 883 884 ### Known Issues and Workarounds 885 886 * If a .NET agent is initiating distributed traces as the root service, you must 887 update that .NET agent to version 8.24 or later before upgrading your downstream 888 Go New Relic agents to this agent release. 889 890 ## 3.2.0 891 892 ### New Features 893 894 * Added support for `v7` of [go-redis/redis](https://github.com/go-redis/redis) 895 in the new [v3/integrations/nrredis-v7](https://godoc.org/github.com/newrelic/go-agent/v3/integrations/nrredis-v7) 896 package. 897 * [Documentation](https://godoc.org/github.com/newrelic/go-agent/v3/integrations/nrredis-v7) 898 * [Example](v3/integrations/nrredis-v7/example/main.go) 899 900 ### Changes 901 902 * Updated Gorilla instrumentation to include request time spent in middlewares. 903 Added new `nrgorilla.Middleware` and deprecated `nrgorilla.InstrumentRoutes`. 904 Register the new middleware as your first middleware using 905 [`Router.Use`](https://godoc.org/github.com/gorilla/mux#Router.Use). See the 906 [godocs 907 examples](https://godoc.org/github.com/newrelic/go-agent/v3/integrations/nrgorilla) 908 for more details. 909 910 ```go 911 r := mux.NewRouter() 912 // Always register the nrgorilla.Middleware first. 913 r.Use(nrgorilla.Middleware(app)) 914 915 // All handlers and custom middlewares will be instrumented. The 916 // transaction will be available in the Request's context. 917 r.Use(MyCustomMiddleware) 918 r.Handle("/", makeHandler("index")) 919 920 // The NotFoundHandler and MethodNotAllowedHandler must be instrumented 921 // separately using newrelic.WrapHandle. The second argument to 922 // newrelic.WrapHandle is used as the transaction name; the string returned 923 // from newrelic.WrapHandle should be ignored. 924 _, r.NotFoundHandler = newrelic.WrapHandle(app, "NotFoundHandler", makeHandler("not found")) 925 _, r.MethodNotAllowedHandler = newrelic.WrapHandle(app, "MethodNotAllowedHandler", makeHandler("method not allowed")) 926 927 http.ListenAndServe(":8000", r) 928 ``` 929 930 ### Known Issues and Workarounds 931 932 * If a .NET agent is initiating distributed traces as the root service, you must 933 update that .NET agent to version 8.24 or later before upgrading your downstream 934 Go New Relic agents to this agent release. 935 936 ## 3.1.0 937 938 ### New Features 939 940 * Support for W3C Trace Context, with easy upgrade from New Relic trace context. 941 942 Distributed Tracing now supports W3C Trace Context headers for HTTP and 943 gRPC protocols when distributed tracing is enabled. Our implementation can 944 accept and emit both W3C trace header format and New Relic trace header 945 format. This simplifies agent upgrades, allowing trace context to be 946 propagated between services with older and newer releases of New Relic 947 agents. W3C trace header format will always be accepted and emitted. New 948 Relic trace header format will be accepted, and you can optionally disable 949 emission of the New Relic trace header format. 950 951 When distributed tracing is enabled with 952 `Config.DistributedTracer.Enabled = true`, the Go agent will now accept 953 W3C's `traceparent` and `tracestate` headers when calling 954 [`Transaction.AcceptDistributedTraceHeaders`](https://godoc.org/github.com/newrelic/go-agent/v3/newrelic#Transaction.AcceptDistributedTraceHeaders). When calling 955 [`Transaction.InsertDistributedTraceHeaders`](https://godoc.org/github.com/newrelic/go-agent/v3/newrelic#Transaction.InsertDistributedTraceHeaders), the Go agent will include the 956 W3C headers along with the New Relic distributed tracing header, unless 957 the New Relic trace header format is disabled using 958 `Config.DistributedTracer.ExcludeNewRelicHeader = true`. 959 960 * Added support for [elastic/go-elasticsearch](https://github.com/elastic/go-elasticsearch) 961 in the new [v3/integrations/nrelasticsearch-v7](https://godoc.org/github.com/newrelic/go-agent/v3/integrations/nrelasticsearch-v7) 962 package. 963 964 * At this time, the New Relic backend has enabled support for real time 965 streaming. Versions 2.8 and above will now send data to New Relic every five 966 seconds, instead of every minute. As a result, transaction, error, and custom 967 events will now be available in New Relic One and Insights dashboards in near 968 real time. 969 970 ### Known Issues and Workarounds 971 972 * If a .NET agent is initiating distributed traces as the root service, you must update 973 that .NET agent to version 8.24 or later before upgrading your downstream 974 Go New Relic agents to this agent release. 975 976 ## 3.0.0 977 978 We are pleased to announce the release of Go Agent v3.0.0! This is a major release 979 that includes some breaking changes that will simplify your future use of the Go 980 Agent. 981 982 Please pay close attention to the list of Changes. 983 984 ### Changes 985 986 * A full list of changes and a step by step checklist on how to upgrade can 987 be found in the [v3 Migration Guide](MIGRATION.md). 988 989 ### New Features 990 991 * Support for Go Modules. Our Go agent integration packages support frameworks 992 and libraries which are changing over time. With support for Go Modules, we 993 are now able to release instrumentation packages for multiple versions of 994 frameworks and libraries with a single agent release; and support operation 995 of the Go agent in Go Modules environments. This affects naming of our 996 integration packages, as described in the v3 Migration Guide (see under 997 "Changes" above). 998 999 * Detect and set hostnames based on Heroku dyno names. When deploying an 1000 application in Heroku, the hostnames collected will now match the dyno name. 1001 This serves to greatly improve the usability of the servers list in APM since 1002 dyno names are often sporadic or fleeting in nature. The feature is 1003 controlled by two new configuration options `Config.Heroku.UseDynoNames` and 1004 `Config.Heroku.DynoNamePrefixesToShorten`. 1005 1006 ## 2.16.3 1007 1008 ### New Relic's Go agent v3.0 is currently available for review and beta testing. Your use of this pre-release is at your own risk. New Relic disclaims all warranties, express or implied, regarding the beta release. 1009 1010 ### If you do not manually take steps to use the new v3 folder you will not see any changes in your agent. 1011 1012 This is the third release of the pre-release of Go agent v3.0. It includes 1013 changes due to user feedback during the pre-release. The existing agent in 1014 `"github.com/newrelic/go-agent"` is unchanged. The Go agent v3.0 code in the v3 1015 folder has the following changes: 1016 1017 * A [ConfigFromEnvironment](https://godoc.org/github.com/newrelic/go-agent/v3/newrelic#ConfigFromEnvironment) 1018 bug has been fixed. 1019 1020 ## 2.16.2 1021 1022 ### New Relic's Go agent v3.0 is currently available for review and beta testing. Your use of this pre-release is at your own risk. New Relic disclaims all warranties, express or implied, regarding the beta release. 1023 1024 ### If you do not manually take steps to use the new v3 folder, as described below, you will not see any changes in your agent. 1025 1026 This is the second release of the pre-release of Go agent v3.0. It includes changes due to user feedback during the pre-release. The existing 1027 agent in `"github.com/newrelic/go-agent"` is unchanged. The Go agent v3.0 code 1028 in the v3 folder has the following changes: 1029 1030 * Transaction names created by [`WrapHandle`](https://godoc.org/github.com/newrelic/go-agent/v3/newrelic#WrapHandle), 1031 [`WrapHandleFunc`](https://godoc.org/github.com/newrelic/go-agent/v3/newrelic#WrapHandleFunc), 1032 [nrecho-v3](https://godoc.org/github.com/newrelic/go-agent/v3/integrations/nrecho-v3), 1033 [nrecho-v4](https://godoc.org/github.com/newrelic/go-agent/v3/integrations/nrecho-v4), 1034 [nrgorilla](https://godoc.org/github.com/newrelic/go-agent/v3/integrations/nrgorilla), and 1035 [nrgin](https://godoc.org/github.com/newrelic/go-agent/v3/integrations/nrgin) now 1036 include the HTTP method. For example, the following code: 1037 1038 ```go 1039 http.HandleFunc(newrelic.WrapHandleFunc(app, "/users", usersHandler)) 1040 ``` 1041 1042 now creates a metric called `WebTransaction/Go/GET /users` instead of 1043 `WebTransaction/Go/users`. As a result of this change, you may need to update 1044 your alerts and dashboards. 1045 1046 * The [ConfigFromEnvironment](https://godoc.org/github.com/newrelic/go-agent/v3/newrelic#ConfigFromEnvironment) 1047 config option is now strict. If one of the environment variables, such as 1048 `NEW_RELIC_DISTRIBUTED_TRACING_ENABLED`, cannot be parsed, then `Config.Error` 1049 will be populated and [NewApplication](https://godoc.org/github.com/newrelic/go-agent/v3/newrelic#NewApplication) 1050 will return an error. 1051 1052 * [ConfigFromEnvironment](https://godoc.org/github.com/newrelic/go-agent/v3/newrelic#ConfigFromEnvironment) 1053 now processes `NEW_RELIC_ATTRIBUTES_EXCLUDE` and `NEW_RELIC_ATTRIBUTES_INCLUDE`. 1054 1055 ## 2.16.1 1056 1057 ### New Relic's Go agent v3.0 is currently available for review and beta testing. Your use of this pre-release is at your own risk. New Relic disclaims all warranties, express or implied, regarding the beta release. 1058 1059 ### If you do not manually take steps to use the new v3 folder, as described below, you will not see any changes in your agent. 1060 1061 This 2.16.1 release includes a new v3.0 folder which contains the pre-release of 1062 Go agent v3.0; Go agent v3.0 includes breaking changes. We are seeking 1063 feedback and hope that you will look this over and test out the changes prior 1064 to the official release. 1065 1066 **This is not an official 3.0 release, it is just a vehicle to gather feedback 1067 on proposed changes**. It is not tagged as 3.0 in Github and the 3.0 release is 1068 not yet available to update in your Go mod file. In order to test out these 1069 changes, you will need to clone this repo in your Go source directory, under 1070 `[go-src-dir]/src/github.com/newrelic/go-agent`. Once you have the source 1071 checked out, you will need to follow the steps in the second section of 1072 [v3/MIGRATION.md](v3/MIGRATION.md). 1073 1074 A list of changes and installation instructions is included in the v3 folder 1075 and can be found [here](v3/MIGRATION.md) 1076 1077 For this pre-release (beta) version of Go agent v3.0, please note: 1078 * The changes in the v3 folder represent what we expect to release in ~2 weeks 1079 as our major 3.0 release. However, as we are soliciting feedback on the changes 1080 and there is the possibility of some breaking changes before the official 1081 release. 1082 * This is not an official 3.0 release; it is not tagged as 3.0 in Github and 1083 the 3.0 release is not yet available to update in your Go mod file. 1084 * If you test out these changes and encounter issues, questions, or have 1085 feedback that you would like to pass along, please open up an issue 1086 [here](https://github.com/newrelic/go-agent/issues/new) and be sure to include 1087 the label `3.0`. 1088 * For normal (non-3.0) issues/questions we request that you report them via 1089 our [support site](http://support.newrelic.com/) or our 1090 [community forum](https://discuss.newrelic.com). Please only report 1091 questions related to the 3.0 pre-release directly via GitHub. 1092 1093 1094 ### New Features 1095 1096 * V3 will add support for Go Modules. The go.mod files exist in the v3 folder, 1097 but they will not be usable until we have fully tagged the 3.0 release 1098 officially. Examples of version tags we plan to use for different modules 1099 include: 1100 * `v3.0.0` 1101 * `v3/integrations/nrecho-v3/v1.0.0` 1102 * `v3/integrations/nrecho-v4/v1.0.0` 1103 1104 ### Changes 1105 1106 * The changes are the ones that we have requested feedback previously in 1107 [this issue](https://github.com/newrelic/go-agent/issues/106). 1108 * A full list of changes that are included, along with a checklist for 1109 upgrading, is available in [v3/MIGRATION.md](v3/MIGRATION.md). 1110 1111 ## 2.16.0 1112 1113 ### Upcoming 1114 1115 * The next release of the Go Agent is expected to be a major version release 1116 to improve the API and incorporate Go modules. 1117 Details available here: https://github.com/newrelic/go-agent/issues/106 1118 We would love your feedback! 1119 1120 ### Bug Fixes 1121 1122 * Fixed an issue in the 1123 [`nrhttprouter`](http://godoc.org/github.com/newrelic/go-agent/_integrations/nrhttprouter) 1124 integration where the transaction was not being added to the requests 1125 context. This resulted in an inability to access the transaction from within 1126 an 1127 [`httprouter.Handle`](https://godoc.org/github.com/julienschmidt/httprouter#Handle) 1128 function. This issue has now been fixed. 1129 1130 ## 2.15.0 1131 1132 ### New Features 1133 1134 * Added support for monitoring [MongoDB](https://github.com/mongodb/mongo-go-driver/) queries with the new 1135 [_integrations/nrmongo](https://godoc.org/github.com/newrelic/go-agent/_integrations/nrmongo) 1136 package. 1137 1138 * [Example application](https://github.com/newrelic/go-agent/blob/master/_integrations/nrmongo/example/main.go) 1139 * [Full godocs Documentation](https://godoc.org/github.com/newrelic/go-agent/_integrations/nrmongo) 1140 1141 * Added new method `Transaction.IsSampled()` that returns a boolean that 1142 indicates if the transaction is sampled. A sampled transaction records a 1143 span event for each segment. Distributed tracing must be enabled for 1144 transactions to be sampled. `false` is returned if the transaction has 1145 finished. This sampling flag is needed for B3 trace propagation and 1146 future support of W3C Trace Context. 1147 1148 * Added support for adding [B3 1149 Headers](https://github.com/openzipkin/b3-propagation) to outgoing requests. 1150 This is helpful if the service you are calling uses B3 for trace state 1151 propagation (for example, it uses Zipkin instrumentation). You can use the 1152 new 1153 [_integrations/nrb3](https://godoc.org/github.com/newrelic/go-agent/_integrations/nrb3) 1154 package's 1155 [`nrb3.NewRoundTripper`](https://godoc.org/github.com/newrelic/go-agent/_integrations/nrb3#NewRoundTripper) 1156 like this: 1157 1158 ```go 1159 // When defining the client, set the Transport to the NewRoundTripper. This 1160 // will create ExternalSegments and add B3 headers for each request. 1161 client := &http.Client{ 1162 Transport: nrb3.NewRoundTripper(nil), 1163 } 1164 1165 // Distributed Tracing must be enabled for this application. 1166 // (see https://docs.newrelic.com/docs/understand-dependencies/distributed-tracing/enable-configure/enable-distributed-tracing) 1167 txn := currentTxn() 1168 1169 req, err := http.NewRequest("GET", "http://example.com", nil) 1170 if nil != err { 1171 log.Fatalln(err) 1172 } 1173 1174 // Be sure to add the transaction to the request context. This step is 1175 // required. 1176 req = newrelic.RequestWithTransactionContext(req, txn) 1177 resp, err := client.Do(req) 1178 if nil != err { 1179 log.Fatalln(err) 1180 } 1181 1182 defer resp.Body.Close() 1183 fmt.Println(resp.StatusCode) 1184 ``` 1185 1186 ### Bug Fixes 1187 1188 * Fixed an issue where the 1189 [`nrgin`](https://godoc.org/github.com/newrelic/go-agent/_integrations/nrgin/v1) 1190 integration was not capturing the correct response code in the case where no 1191 response body was sent. This issue has now been fixed but requires Gin 1192 greater than v1.4.0. 1193 1194 ## 2.14.1 1195 1196 ### Bug Fixes 1197 1198 * Removed the hidden `"NEW_RELIC_DEBUG_LOGGING"` environment variable setting 1199 which was broken in release 2.14.0. 1200 1201 ## 2.14.0 1202 1203 ### New Features 1204 1205 * Added support for a new segment type, 1206 [`MessageProducerSegment`](https://godoc.org/github.com/newrelic/go-agent#MessageProducerSegment), 1207 to be used to track time spent adding messages to message queuing systems like 1208 RabbitMQ or Kafka. 1209 1210 ```go 1211 seg := &newrelic.MessageProducerSegment{ 1212 StartTime: newrelic.StartSegmentNow(txn), 1213 Library: "RabbitMQ", 1214 DestinationType: newrelic.MessageExchange, 1215 DestinationName: "myExchange", 1216 } 1217 // add message to queue here 1218 seg.End() 1219 ``` 1220 1221 * Added new attribute constants for use with message consumer transactions. 1222 These attributes can be used to add more detail to a transaction that tracks 1223 time spent consuming a message off a message queuing system like RabbitMQ or Kafka. 1224 They can be added using 1225 [`txn.AddAttribute`](https://godoc.org/github.com/newrelic/go-agent#Transaction). 1226 1227 ```go 1228 // The routing key of the consumed message. 1229 txn.AddAttribute(newrelic.AttributeMessageRoutingKey, "myRoutingKey") 1230 // The name of the queue the message was consumed from. 1231 txn.AddAttribute(newrelic.AttributeMessageQueueName, "myQueueName") 1232 // The type of exchange used for the consumed message (direct, fanout, 1233 // topic, or headers). 1234 txn.AddAttribute(newrelic.AttributeMessageExchangeType, "myExchangeType") 1235 // The callback queue used in RPC configurations. 1236 txn.AddAttribute(newrelic.AttributeMessageReplyTo, "myReplyTo") 1237 // The application-generated identifier used in RPC configurations. 1238 txn.AddAttribute(newrelic.AttributeMessageCorrelationID, "myCorrelationID") 1239 ``` 1240 1241 It is recommended that at most one message is consumed per transaction. 1242 1243 * Added support for [Go 1.13's Error wrapping](https://golang.org/doc/go1.13#error_wrapping). 1244 `Transaction.NoticeError` now uses [Unwrap](https://golang.org/pkg/errors/#Unwrap) 1245 recursively to identify the error's cause (the deepest wrapped error) when generating 1246 the error's class field. This functionality will help group your errors usefully. 1247 1248 For example, when using Go 1.13, the following code: 1249 1250 ```go 1251 type socketError struct{} 1252 1253 func (e socketError) Error() string { return "socket error" } 1254 1255 func gamma() error { return socketError{} } 1256 func beta() error { return fmt.Errorf("problem in beta: %w", gamma()) } 1257 func alpha() error { return fmt.Errorf("problem in alpha: %w", beta()) } 1258 1259 func execute(txn newrelic.Transaction) { 1260 err := alpha() 1261 txn.NoticeError(err) 1262 } 1263 ``` 1264 captures an error with message `"problem in alpha: problem in beta: socket error"` 1265 and class `"main.socketError"`. Previously, the class was recorded as `"*fmt.wrapError"`. 1266 1267 * A `Stack` field has been added to [Error](https://godoc.org/github.com/newrelic/go-agent#Error), 1268 which can be assigned using the new 1269 [NewStackTrace](https://godoc.org/github.com/newrelic/go-agent#NewStackTrace) function. 1270 This allows your error stack trace to show where the error happened, rather 1271 than the location of the `NoticeError` call. 1272 1273 `Transaction.NoticeError` not only checks for a stack trace (using 1274 [StackTracer](https://godoc.org/github.com/newrelic/go-agent#StackTracer)) in 1275 the error parameter, but in the error's cause as well. This means that you 1276 can create an [Error](https://godoc.org/github.com/newrelic/go-agent#Error) 1277 where your error occurred, wrap it multiple times to add information, notice it 1278 with `NoticeError`, and still have a useful stack trace. Take a look! 1279 1280 ```go 1281 func gamma() error { 1282 return newrelic.Error{ 1283 Message: "something went very wrong", 1284 Class: "socketError", 1285 Stack: newrelic.NewStackTrace(), 1286 } 1287 } 1288 1289 func beta() error { return fmt.Errorf("problem in beta: %w", gamma()) } 1290 func alpha() error { return fmt.Errorf("problem in alpha: %w", beta()) } 1291 1292 func execute(txn newrelic.Transaction) { 1293 err := alpha() 1294 txn.NoticeError(err) 1295 } 1296 ``` 1297 1298 In this example, the topmost stack trace frame recorded is `"gamma"`, 1299 rather than `"execute"`. 1300 1301 * Added support for configuring a maximum number of transaction events per minute to be sent to New Relic. 1302 It can be configured as follows: 1303 1304 ```go 1305 config := newrelic.NewConfig("Application Name", os.Getenv("NEW_RELIC_LICENSE_KEY")) 1306 config.TransactionEvents.MaxSamplesStored = 100 1307 ``` 1308 * For additional configuration information, see our [documentation](https://docs.newrelic.com/docs/agents/go-agent/configuration/go-agent-configuration) 1309 1310 1311 ### Miscellaneous 1312 1313 * Updated the 1314 [`nrmicro`](https://godoc.org/github.com/newrelic/go-agent/_integrations/nrmicro) 1315 package to use the new segment type 1316 [`MessageProducerSegment`](https://godoc.org/github.com/newrelic/go-agent#MessageProducerSegment) 1317 and the new attribute constants: 1318 * [`nrmicro.ClientWrapper`](https://godoc.org/github.com/newrelic/go-agent/_integrations/nrmicro#ClientWrapper) 1319 now uses `newrelic.MessageProducerSegment`s instead of 1320 `newrelic.ExternalSegment`s for calls to 1321 [`Client.Publish`](https://godoc.org/github.com/micro/go-micro/client#Client). 1322 * [`nrmicro.SubscriberWrapper`](https://godoc.org/github.com/newrelic/go-agent/_integrations/nrmicro#SubscriberWrapper) 1323 updates transaction names and adds the attribute `message.routingKey`. 1324 1325 * Updated the 1326 [`nrnats`](https://godoc.org/github.com/newrelic/go-agent/_integrations/nrnats) 1327 and 1328 [`nrstan`](https://godoc.org/github.com/newrelic/go-agent/_integrations/nrstan) 1329 packages to use the new segment type 1330 [`MessageProducerSegment`](https://godoc.org/github.com/newrelic/go-agent#MessageProducerSegment) 1331 and the new attribute constants: 1332 * [`nrnats.StartPublishSegment`](https://godoc.org/github.com/newrelic/go-agent/_integrations/nrnats#StartPublishSegment) 1333 now starts and returns a `newrelic.MessageProducerSegment` type. 1334 * [`nrnats.SubWrapper`](https://godoc.org/github.com/newrelic/go-agent/_integrations/nrnats#SubWrapper) 1335 and 1336 [`nrstan.StreamingSubWrapper`](https://godoc.org/github.com/newrelic/go-agent/_integrations/nrstan#StreamingSubWrapper) 1337 updates transaction names and adds the attributes `message.routingKey`, 1338 `message.queueName`, and `message.replyTo`. 1339 1340 ## 2.13.0 1341 1342 ### New Features 1343 1344 * Added support for [HttpRouter](https://github.com/julienschmidt/httprouter) in 1345 the new [_integrations/nrhttprouter](http://godoc.org/github.com/newrelic/go-agent/_integrations/nrhttprouter) package. This package allows you to easily instrument inbound requests through the HttpRouter framework. 1346 1347 * [Documentation](http://godoc.org/github.com/newrelic/go-agent/_integrations/nrhttprouter) 1348 * [Example](_integrations/nrhttprouter/example/main.go) 1349 1350 * Added support for [github.com/uber-go/zap](https://github.com/uber-go/zap) in 1351 the new 1352 [_integrations/nrzap](https://godoc.org/github.com/newrelic/go-agent/_integrations/nrzap) 1353 package. This package allows you to send agent log messages to `zap`. 1354 1355 ## 2.12.0 1356 1357 ### New Features 1358 1359 * Added new methods to expose `Transaction` details: 1360 1361 * `Transaction.GetTraceMetadata()` returns a 1362 [TraceMetadata](https://godoc.org/github.com/newrelic/go-agent#TraceMetadata) 1363 which contains distributed tracing identifiers. 1364 1365 * `Transaction.GetLinkingMetadata()` returns a 1366 [LinkingMetadata](https://godoc.org/github.com/newrelic/go-agent#LinkingMetadata) 1367 which contains the fields needed to link data to a trace or entity. 1368 1369 * Added a new plugin for the [Logrus logging 1370 framework](https://github.com/sirupsen/logrus) with the new 1371 [_integrations/logcontext/nrlogrusplugin](https://github.com/newrelic/go-agent/go-agent/tree/master/_integrations/logcontext/nrlogrusplugin) 1372 package. This plugin leverages the new `GetTraceMetadata` and 1373 `GetLinkingMetadata` above to decorate logs. 1374 1375 To enable, set your log's formatter to the `nrlogrusplugin.ContextFormatter{}` 1376 1377 ```go 1378 logger := logrus.New() 1379 logger.SetFormatter(nrlogrusplugin.ContextFormatter{}) 1380 ``` 1381 1382 The logger will now look for a `newrelic.Transaction` inside its context and 1383 decorate logs accordingly. Therefore, the Transaction must be added to the 1384 context and passed to the logger. For example, this logging call 1385 1386 ```go 1387 logger.Info("Hello New Relic!") 1388 ``` 1389 1390 must be transformed to include the context, such as: 1391 1392 ```go 1393 ctx := newrelic.NewContext(context.Background(), txn) 1394 logger.WithContext(ctx).Info("Hello New Relic!") 1395 ``` 1396 1397 For full documentation see the 1398 [godocs](https://godoc.org/github.com/newrelic/go-agent/_integrations/logcontext/nrlogrusplugin) 1399 or view the 1400 [example](https://github.com/newrelic/go-agent/blob/master/_integrations/logcontext/nrlogrusplugin/example/main.go). 1401 1402 * Added support for [NATS](https://github.com/nats-io/nats.go) and [NATS Streaming](https://github.com/nats-io/stan.go) 1403 monitoring with the new [_integrations/nrnats](https://godoc.org/github.com/newrelic/go-agent/_integrations/nrnats) and 1404 [_integrations/nrstan](https://godoc.org/github.com/newrelic/go-agent/_integrations/nrstan) packages. These packages 1405 support instrumentation of publishers and subscribers. 1406 1407 * [NATS Example](https://github.com/newrelic/go-agent/blob/master/_integrations/nrnats/examples/main.go) 1408 * [NATS Streaming Example](https://github.com/newrelic/go-agent/blob/master/_integrations/nrstan/examples/main.go) 1409 1410 * Enables ability to migrate to [Configurable Security Policies (CSP)](https://docs.newrelic.com/docs/agents/manage-apm-agents/configuration/enable-configurable-security-policies) on a per agent basis for accounts already using [High Security Mode (HSM)](https://docs.newrelic.com/docs/agents/manage-apm-agents/configuration/high-security-mode). 1411 * Previously, if CSP was configured for an account, New Relic would not allow an agent to connect without the `security_policies_token`. This led to agents not being able to connect during the period between when CSP was enabled for an account and when each agent is configured with the correct token. 1412 * With this change, when both HSM and CSP are enabled for an account, an agent (this version or later) can successfully connect with either `high_security: true` or the appropriate `security_policies_token` configured - allowing the agent to continue to connect after CSP is configured on the account but before the appropriate `security_policies_token` is configured for each agent. 1413 1414 ## 2.11.0 1415 1416 ### New Features 1417 1418 * Added support for [Micro](https://github.com/micro/go-micro) monitoring with the new 1419 [_integrations/nrmicro](https://godoc.org/github.com/newrelic/go-agent/_integrations/nrmicro) 1420 package. This package supports instrumentation for servers, clients, publishers, and subscribers. 1421 1422 * [Server Example](https://github.com/newrelic/go-agent/blob/master/_integrations/nrmicro/example/server/server.go) 1423 * [Client Example](https://github.com/newrelic/go-agent/blob/master/_integrations/nrmicro/example/client/client.go) 1424 * [Publisher and Subscriber Example](https://github.com/newrelic/go-agent/blob/master/_integrations/nrmicro/example/pubsub/main.go) 1425 * [Full godocs Documentation](https://godoc.org/github.com/newrelic/go-agent/_integrations/nrmicro) 1426 1427 * Added support for creating static `WebRequest` instances manually via the `NewStaticWebRequest` function. This can be useful when you want to create a web transaction but don't have an `http.Request` object. Here's an example of creating a static `WebRequest` and using it to mark a transaction as a web transaction: 1428 ```go 1429 hdrs := http.Headers{} 1430 u, _ := url.Parse("http://example.com") 1431 webReq := newrelic.NewStaticWebRequest(hdrs, u, "GET", newrelic.TransportHTTP) 1432 txn := app.StartTransaction("My-Transaction", nil, nil) 1433 txn.SetWebRequest(webReq) 1434 ``` 1435 1436 ## 2.10.0 1437 1438 ### New Features 1439 1440 * Added support for custom events when using 1441 [nrlambda](https://godoc.org/github.com/newrelic/go-agent/_integrations/nrlambda). 1442 Example Lambda handler which creates custom event: 1443 1444 ```go 1445 func handler(ctx context.Context) { 1446 if txn := newrelic.FromContext(ctx); nil != txn { 1447 txn.Application().RecordCustomEvent("myEvent", map[string]interface{}{ 1448 "zip": "zap", 1449 }) 1450 } 1451 fmt.Println("hello world!") 1452 } 1453 ``` 1454 1455 ## 2.9.0 1456 1457 ### New Features 1458 1459 * Added support for [gRPC](https://github.com/grpc/grpc-go) monitoring with the new 1460 [_integrations/nrgrpc](https://godoc.org/github.com/newrelic/go-agent/_integrations/nrgrpc) 1461 package. This package supports instrumentation for servers and clients. 1462 1463 * [Server Example](https://github.com/newrelic/go-agent/blob/master/_integrations/nrgrpc/example/server/server.go) 1464 * [Client Example](https://github.com/newrelic/go-agent/blob/master/_integrations/nrgrpc/example/client/client.go) 1465 1466 * Added new 1467 [ExternalSegment](https://godoc.org/github.com/newrelic/go-agent#ExternalSegment) 1468 fields `Host`, `Procedure`, and `Library`. These optional fields are 1469 automatically populated from the segment's `URL` or `Request` if unset. Use 1470 them if you don't have access to a request or URL but still want useful external 1471 metrics, transaction segment attributes, and span attributes. 1472 * `Host` is used for external metrics, transaction trace segment names, and 1473 span event names. The host of segment's `Request` or `URL` is the default. 1474 * `Procedure` is used for transaction breakdown metrics. If set, it should be 1475 set to the remote procedure being called. The HTTP method of the segment's `Request` is the default. 1476 * `Library` is used for external metrics and the `"component"` span attribute. 1477 If set, it should be set to the framework making the call. `"http"` is the default. 1478 1479 With the addition of these new fields, external transaction breakdown metrics 1480 are changed: `External/myhost.com/all` will now report as 1481 `External/myhost.com/http/GET` (provided the HTTP method is `GET`). 1482 1483 * HTTP Response codes below `100`, except `0` and `5`, are now recorded as 1484 errors. This is to support `gRPC` status codes. If you start seeing 1485 new status code errors that you would like to ignore, add them to 1486 `Config.ErrorCollector.IgnoreStatusCodes` or your server side configuration 1487 settings. 1488 1489 * Improve [logrus](https://github.com/sirupsen/logrus) support by introducing 1490 [nrlogrus.Transform](https://godoc.org/github.com/newrelic/go-agent/_integrations/nrlogrus#Transform), 1491 a function which allows you to turn a 1492 [logrus.Logger](https://godoc.org/github.com/sirupsen/logrus#Logger) instance into a 1493 [newrelic.Logger](https://godoc.org/github.com/newrelic/go-agent#Logger). 1494 Example use: 1495 1496 ```go 1497 l := logrus.New() 1498 l.SetLevel(logrus.DebugLevel) 1499 cfg := newrelic.NewConfig("Your Application Name", "__YOUR_NEW_RELIC_LICENSE_KEY__") 1500 cfg.Logger = nrlogrus.Transform(l) 1501 ``` 1502 1503 As a result of this change, the 1504 [nrlogrus](https://godoc.org/github.com/newrelic/go-agent/_integrations/nrlogrus) 1505 package requires [logrus](https://github.com/sirupsen/logrus) version `v1.1.0` 1506 and above. 1507 1508 ## 2.8.1 1509 1510 ### Bug Fixes 1511 1512 * Removed `nrmysql.NewConnector` since 1513 [go-sql-driver/mysql](https://github.com/go-sql-driver/mysql) has not yet 1514 released `mysql.NewConnector`. 1515 1516 ## 2.8.0 1517 1518 ### New Features 1519 1520 * Support for Real Time Streaming 1521 1522 * The agent now has support for sending event data to New Relic every five 1523 seconds, instead of every minute. As a result, transaction, error, and 1524 custom events will now be available in New Relic One and Insights dashboards 1525 in near real time. For more information on how to view your events with a 1526 five-second refresh, see the documentation. 1527 1528 * Note that the overall limits on how many events can be sent per minute have 1529 not changed. Also, span events, metrics, and trace data is unaffected, and 1530 will still be sent every minute. 1531 1532 * Introduce support for databases using 1533 [database/sql](https://golang.org/pkg/database/sql/). This new functionality 1534 allows you to instrument MySQL, PostgreSQL, and SQLite calls without manually 1535 creating 1536 [DatastoreSegment](https://godoc.org/github.com/newrelic/go-agent#DatastoreSegment)s. 1537 1538 | Database Library Supported | Integration Package | 1539 | ------------- | ------------- | 1540 | [go-sql-driver/mysql](https://github.com/go-sql-driver/mysql) | [_integrations/nrmysql](https://godoc.org/github.com/newrelic/go-agent/_integrations/nrmysql) | 1541 | [lib/pq](https://github.com/lib/pq) | [_integrations/nrpq](https://godoc.org/github.com/newrelic/go-agent/_integrations/nrpq) | 1542 | [mattn/go-sqlite3](https://github.com/mattn/go-sqlite3) | [_integrations/nrsqlite3](https://godoc.org/github.com/newrelic/go-agent/_integrations/nrsqlite3) | 1543 1544 Using these database integration packages is easy! First replace the driver 1545 with our integration version: 1546 1547 ```go 1548 import ( 1549 // import our integration package in place of "github.com/go-sql-driver/mysql" 1550 _ "github.com/newrelic/go-agent/_integrations/nrmysql" 1551 ) 1552 1553 func main() { 1554 // open "nrmysql" in place of "mysql" 1555 db, err := sql.Open("nrmysql", "user@unix(/path/to/socket)/dbname") 1556 } 1557 ``` 1558 1559 Second, use the `ExecContext`, `QueryContext`, and `QueryRowContext` methods of 1560 [sql.DB](https://golang.org/pkg/database/sql/#DB), 1561 [sql.Conn](https://golang.org/pkg/database/sql/#Conn), 1562 [sql.Tx](https://golang.org/pkg/database/sql/#Tx), and 1563 [sql.Stmt](https://golang.org/pkg/database/sql/#Stmt) and provide a 1564 transaction-containing context. Calls to `Exec`, `Query`, and `QueryRow` do not 1565 get instrumented. 1566 1567 ```go 1568 ctx := newrelic.NewContext(context.Background(), txn) 1569 row := db.QueryRowContext(ctx, "SELECT count(*) from tables") 1570 ``` 1571 1572 If you are using a [database/sql](https://golang.org/pkg/database/sql/) database 1573 not listed above, you can write your own instrumentation for it using 1574 [InstrumentSQLConnector](https://godoc.org/github.com/newrelic/go-agent#InstrumentSQLConnector), 1575 [InstrumentSQLDriver](https://godoc.org/github.com/newrelic/go-agent#InstrumentSQLDriver), 1576 and 1577 [SQLDriverSegmentBuilder](https://godoc.org/github.com/newrelic/go-agent#SQLDriverSegmentBuilder). 1578 The integration packages act as examples of how to do this. 1579 1580 For more information, see the [Go agent documentation on instrumenting datastore segments](https://docs.newrelic.com/docs/agents/go-agent/instrumentation/instrument-go-segments#go-datastore-segments). 1581 1582 ### Bug Fixes 1583 1584 * The [http.RoundTripper](https://golang.org/pkg/net/http/#RoundTripper) returned 1585 by [NewRoundTripper](https://godoc.org/github.com/newrelic/go-agent#NewRoundTripper) 1586 no longer modifies the request. Our thanks to @jlordiales for the contribution. 1587 1588 ## 2.7.0 1589 1590 ### New Features 1591 1592 * Added support for server side configuration. Server side configuration allows 1593 you to set the following configuration settings in the New Relic APM UI: 1594 1595 * `Config.TransactionTracer.Enabled` 1596 * `Config.ErrorCollector.Enabled` 1597 * `Config.CrossApplicationTracer.Enabled` 1598 * `Config.TransactionTracer.Threshold` 1599 * `Config.TransactionTracer.StackTraceThreshold` 1600 * `Config.ErrorCollector.IgnoreStatusCodes` 1601 1602 For more information see the [server side configuration documentation](https://docs.newrelic.com/docs/agents/manage-apm-agents/configuration/server-side-agent-configuration). 1603 1604 * Added support for AWS Lambda functions in the new 1605 [nrlambda](_integrations/nrlambda) 1606 package. Please email <lambda_preview@newrelic.com> if you are interested in 1607 learning more or previewing New Relic Lambda monitoring. This instrumentation 1608 package requires `aws-lambda-go` version 1609 [v1.9.0](https://github.com/aws/aws-lambda-go/releases) and above. 1610 1611 * [documentation](https://godoc.org/github.com/newrelic/go-agent/_integrations/nrlambda) 1612 * [working example](_integrations/nrlambda/example/main.go) 1613 1614 ## 2.6.0 1615 1616 ### New Features 1617 1618 * Added support for async: the ability to instrument multiple concurrent 1619 goroutines, or goroutines that access or manipulate the same Transaction. 1620 1621 The new `Transaction.NewGoroutine() Transaction` method allows 1622 transactions to create segments in multiple goroutines! 1623 1624 `NewGoroutine` returns a new reference to the `Transaction`. This must be 1625 called any time you are passing the `Transaction` to another goroutine which 1626 makes segments. Each segment-creating goroutine must have its own `Transaction` 1627 reference. It does not matter if you call this before or after the other 1628 goroutine has started. 1629 1630 All `Transaction` methods can be used in any `Transaction` reference. The 1631 `Transaction` will end when `End()` is called in any goroutine. 1632 1633 Example passing a new `Transaction` reference directly to another goroutine: 1634 1635 ```go 1636 go func(txn newrelic.Transaction) { 1637 defer newrelic.StartSegment(txn, "async").End() 1638 time.Sleep(100 * time.Millisecond) 1639 }(txn.NewGoroutine()) 1640 ``` 1641 1642 Example passing a new `Transaction` reference on a channel to another 1643 goroutine: 1644 1645 ```go 1646 ch := make(chan newrelic.Transaction) 1647 go func() { 1648 txn := <-ch 1649 defer newrelic.StartSegment(txn, "async").End() 1650 time.Sleep(100 * time.Millisecond) 1651 }() 1652 ch <- txn.NewGoroutine() 1653 ``` 1654 1655 * Added integration support for 1656 [`aws-sdk-go`](https://github.com/aws/aws-sdk-go) and 1657 [`aws-sdk-go-v2`](https://github.com/aws/aws-sdk-go-v2). 1658 1659 When using these SDKs, a segment will be created for each out going request. 1660 For DynamoDB calls, these will be Datastore segments and for all others they 1661 will be External segments. 1662 * [v1 Documentation](http://godoc.org/github.com/newrelic/go-agent/_integrations/nrawssdk/v1) 1663 * [v2 Documentation](http://godoc.org/github.com/newrelic/go-agent/_integrations/nrawssdk/v2) 1664 1665 * Added span event and transaction trace segment attribute configuration. You 1666 may control which attributes are captured in span events and transaction trace 1667 segments using the `Config.SpanEvents.Attributes` and 1668 `Config.TransactionTracer.Segments.Attributes` settings. For example, if you 1669 want to disable the collection of `"db.statement"` in your span events, modify 1670 your config like this: 1671 1672 ```go 1673 cfg.SpanEvents.Attributes.Exclude = append(cfg.SpanEvents.Attributes.Exclude, 1674 newrelic.SpanAttributeDBStatement) 1675 ``` 1676 1677 To disable the collection of all attributes from your transaction trace 1678 segments, modify your config like this: 1679 1680 ```go 1681 cfg.TransactionTracer.Segments.Attributes.Enabled = false 1682 ``` 1683 1684 ### Bug Fixes 1685 1686 * Fixed a bug that would prevent External Segments from being created under 1687 certain error conditions related to Cross Application Tracing. 1688 1689 ### Miscellaneous 1690 1691 * Improved linking between Cross Application Transaction Traces in the APM UI. 1692 When `Config.CrossApplicationTracer.Enabled = true`, External segments in the 1693 Transaction Traces details will now link to the downstream Transaction Trace 1694 if there is one. Additionally, the segment name will now include the name of 1695 the downstream application and the name of the downstream transaction. 1696 1697 * Update attribute names of Datastore and External segments on Transaction 1698 Traces to be in line with attribute names on Spans. Specifically: 1699 * `"uri"` => `"http.url"` 1700 * `"query"` => `"db.statement"` 1701 * `"database_name"` => `"db.instance"` 1702 * `"host"` => `"peer.hostname"` 1703 * `"port_path_or_id"` + `"host"` => `"peer.address"` 1704 1705 ## 2.5.0 1706 1707 * Added support for [New Relic Browser](https://docs.newrelic.com/docs/browser) 1708 using the new `BrowserTimingHeader` method on the 1709 [`Transaction`](https://godoc.org/github.com/newrelic/go-agent#Transaction) 1710 which returns a 1711 [BrowserTimingHeader](https://godoc.org/github.com/newrelic/go-agent#BrowserTimingHeader). 1712 The New Relic Browser JavaScript code measures page load timing, also known as 1713 real user monitoring. The Pro version of this feature measures AJAX requests, 1714 single-page applications, JavaScript errors, and much more! Example use: 1715 1716 ```go 1717 func browser(w http.ResponseWriter, r *http.Request) { 1718 hdr, err := w.(newrelic.Transaction).BrowserTimingHeader() 1719 if nil != err { 1720 log.Printf("unable to create browser timing header: %v", err) 1721 } 1722 // BrowserTimingHeader() will always return a header whose methods can 1723 // be safely called. 1724 if js := hdr.WithTags(); js != nil { 1725 w.Write(js) 1726 } 1727 io.WriteString(w, "browser header page") 1728 } 1729 ``` 1730 1731 * The Go agent now collects an attribute named `request.uri` on Transaction 1732 Traces, Transaction Events, Error Traces, and Error Events. `request.uri` 1733 will never contain user, password, query parameters, or fragment. To prevent 1734 the request's URL from being collected in any data, modify your `Config` like 1735 this: 1736 1737 ```go 1738 cfg.Attributes.Exclude = append(cfg.Attributes.Exclude, newrelic.AttributeRequestURI) 1739 ``` 1740 1741 ## 2.4.0 1742 1743 * Introduced `Transaction.Application` method which returns the `Application` 1744 that started the `Transaction`. This method is useful since it may prevent 1745 having to pass the `Application` to code that already has access to the 1746 `Transaction`. Example use: 1747 1748 ```go 1749 txn.Application().RecordCustomEvent("customerOrder", map[string]interface{}{ 1750 "numItems": 2, 1751 "totalPrice": 13.75, 1752 }) 1753 ``` 1754 1755 * The `Transaction.AddAttribute` method no longer accepts `nil` values since 1756 our backend ignores them. 1757 1758 ## 2.3.0 1759 1760 * Added support for [Echo](https://echo.labstack.com) in the new `nrecho` 1761 package. 1762 * [Documentation](http://godoc.org/github.com/newrelic/go-agent/_integrations/nrecho) 1763 * [Example](_integrations/nrecho/example/main.go) 1764 1765 * Introduced `Transaction.SetWebResponse(http.ResponseWriter)` method which sets 1766 the transaction's response writer. After calling this method, the 1767 `Transaction` may be used in place of the `http.ResponseWriter` to intercept 1768 the response code. This method is useful when the `http.ResponseWriter` is 1769 not available at the beginning of the transaction (if so, it can be given as a 1770 parameter to `Application.StartTransaction`). This method will return a 1771 reference to the transaction which implements the combination of 1772 `http.CloseNotifier`, `http.Flusher`, `http.Hijacker`, and `io.ReaderFrom` 1773 implemented by the ResponseWriter. Example: 1774 1775 ```go 1776 func setResponseDemo(txn newrelic.Transaction) { 1777 recorder := httptest.NewRecorder() 1778 txn = txn.SetWebResponse(recorder) 1779 txn.WriteHeader(200) 1780 fmt.Println("response code recorded:", recorder.Code) 1781 } 1782 ``` 1783 1784 * The `Transaction`'s `http.ResponseWriter` methods may now be called safely if 1785 a `http.ResponseWriter` has not been set. This allows you to add a response code 1786 to the transaction without using a `http.ResponseWriter`. Example: 1787 1788 ```go 1789 func transactionWithResponseCode(app newrelic.Application) { 1790 txn := app.StartTransaction("hasResponseCode", nil, nil) 1791 defer txn.End() 1792 txn.WriteHeader(200) // Safe! 1793 } 1794 ``` 1795 1796 * The agent now collects environment variables prefixed by 1797 `NEW_RELIC_METADATA_`. Some of these may be added 1798 Transaction events to provide context between your Kubernetes cluster and your 1799 services. For details on the benefits (currently in beta) see [this blog 1800 post](https://blog.newrelic.com/engineering/monitoring-application-performance-in-kubernetes/) 1801 1802 * The agent now collects the `KUBERNETES_SERVICE_HOST` environment variable to 1803 detect when the application is running on Kubernetes. 1804 1805 * The agent now collects the fully qualified domain name of the host and 1806 local IP addresses for improved linking with our infrastructure product. 1807 1808 ## 2.2.0 1809 1810 * The `Transaction` parameter to 1811 [NewRoundTripper](https://godoc.org/github.com/newrelic/go-agent#NewRoundTripper) 1812 and 1813 [StartExternalSegment](https://godoc.org/github.com/newrelic/go-agent#StartExternalSegment) 1814 is now optional: If it is `nil`, then a `Transaction` will be looked for in the 1815 request's context (using 1816 [FromContext](https://godoc.org/github.com/newrelic/go-agent#FromContext)). 1817 Passing a `nil` transaction is **STRONGLY** recommended when using 1818 [NewRoundTripper](https://godoc.org/github.com/newrelic/go-agent#NewRoundTripper) 1819 since it allows one `http.Client.Transport` to be used for multiple 1820 transactions. Example use: 1821 1822 ```go 1823 client := &http.Client{} 1824 client.Transport = newrelic.NewRoundTripper(nil, client.Transport) 1825 request, _ := http.NewRequest("GET", "http://example.com", nil) 1826 request = newrelic.RequestWithTransactionContext(request, txn) 1827 resp, err := client.Do(request) 1828 ``` 1829 1830 * Introduced `Transaction.SetWebRequest(WebRequest)` method which marks the 1831 transaction as a web transaction. If the `WebRequest` parameter is non-nil, 1832 `SetWebRequest` will collect details on request attributes, url, and method. 1833 This method is useful if you don't have access to the request at the beginning 1834 of the transaction, or if your request is not an `*http.Request` (just add 1835 methods to your request that satisfy 1836 [WebRequest](https://godoc.org/github.com/newrelic/go-agent#WebRequest)). To 1837 use an `*http.Request` as the parameter, use the 1838 [NewWebRequest](https://godoc.org/github.com/newrelic/go-agent#NewWebRequest) 1839 transformation function. Example: 1840 1841 ```go 1842 var request *http.Request = getInboundRequest() 1843 txn.SetWebRequest(newrelic.NewWebRequest(request)) 1844 ``` 1845 1846 * Fixed `Debug` in `nrlogrus` package. Previous versions of the New Relic Go Agent incorrectly 1847 logged to Info level instead of Debug. This has now been fixed. Thanks to @paddycarey for catching this. 1848 1849 * [nrgin.Transaction](https://godoc.org/github.com/newrelic/go-agent/_integrations/nrgin/v1#Transaction) 1850 may now be called with either a `context.Context` or a `*gin.Context`. If you were passing a `*gin.Context` 1851 around your functions as a `context.Context`, you may access the Transaction by calling either 1852 [nrgin.Transaction](https://godoc.org/github.com/newrelic/go-agent/_integrations/nrgin/v1#Transaction) 1853 or [FromContext](https://godoc.org/github.com/newrelic/go-agent#FromContext). 1854 These functions now work nicely together. 1855 For example, [FromContext](https://godoc.org/github.com/newrelic/go-agent#FromContext) will return the `Transaction` 1856 added by [nrgin.Middleware](https://godoc.org/github.com/newrelic/go-agent/_integrations/nrgin/v1#Middleware). 1857 Thanks to @rodriguezgustavo for the suggestion. 1858 1859 ## 2.1.0 1860 1861 * The Go Agent now supports distributed tracing. 1862 1863 Distributed tracing lets you see the path that a request takes as it travels through your distributed system. By 1864 showing the distributed activity through a unified view, you can troubleshoot and understand a complex system better 1865 than ever before. 1866 1867 Distributed tracing is available with an APM Pro or equivalent subscription. To see a complete distributed trace, you 1868 need to enable the feature on a set of neighboring services. Enabling distributed tracing changes the behavior of 1869 some New Relic features, so carefully consult the 1870 [transition guide](https://docs.newrelic.com/docs/transition-guide-distributed-tracing) before you enable this 1871 feature. 1872 1873 To enable distributed tracing, set the following fields in your config. Note that distributed tracing and cross 1874 application tracing cannot be used simultaneously. 1875 1876 ``` 1877 config := newrelic.NewConfig("Your Application Name", "__YOUR_NEW_RELIC_LICENSE_KEY__") 1878 config.CrossApplicationTracer.Enabled = false 1879 config.DistributedTracer.Enabled = true 1880 ``` 1881 1882 Please refer to the 1883 [distributed tracing section of the guide](GUIDE.md#distributed-tracing) 1884 for more detail on how to ensure you get the most out of the Go agent's distributed tracing support. 1885 1886 * Added functions [NewContext](https://godoc.org/github.com/newrelic/go-agent#NewContext) 1887 and [FromContext](https://godoc.org/github.com/newrelic/go-agent#FromContext) 1888 for adding and retrieving the Transaction from a Context. Handlers 1889 instrumented by 1890 [WrapHandle](https://godoc.org/github.com/newrelic/go-agent#WrapHandle), 1891 [WrapHandleFunc](https://godoc.org/github.com/newrelic/go-agent#WrapHandleFunc), 1892 and [nrgorilla.InstrumentRoutes](https://godoc.org/github.com/newrelic/go-agent/_integrations/nrgorilla/v1#InstrumentRoutes) 1893 may use [FromContext](https://godoc.org/github.com/newrelic/go-agent#FromContext) 1894 on the request's context to access the Transaction. 1895 Thanks to @caarlos0 for the contribution! Though [NewContext](https://godoc.org/github.com/newrelic/go-agent#NewContext) 1896 and [FromContext](https://godoc.org/github.com/newrelic/go-agent#FromContext) 1897 require Go 1.7+ (when [context](https://golang.org/pkg/context/) was added), 1898 [RequestWithTransactionContext](https://godoc.org/github.com/newrelic/go-agent#RequestWithTransactionContext) is always exported so that it can be used in all framework and library 1899 instrumentation. 1900 1901 ## 2.0.0 1902 1903 * The `End()` functions defined on the `Segment`, `DatastoreSegment`, and 1904 `ExternalSegment` types now receive the segment as a pointer, rather than as 1905 a value. This prevents unexpected behaviour when a call to `End()` is 1906 deferred before one or more fields are changed on the segment. 1907 1908 In practice, this is likely to only affect this pattern: 1909 1910 ```go 1911 defer newrelic.DatastoreSegment{ 1912 // ... 1913 }.End() 1914 ``` 1915 1916 Instead, you will now need to separate the literal from the deferred call: 1917 1918 ```go 1919 ds := newrelic.DatastoreSegment{ 1920 // ... 1921 } 1922 defer ds.End() 1923 ``` 1924 1925 When creating custom and external segments, we recommend using 1926 [`newrelic.StartSegment()`](https://godoc.org/github.com/newrelic/go-agent#StartSegment) 1927 and 1928 [`newrelic.StartExternalSegment()`](https://godoc.org/github.com/newrelic/go-agent#StartExternalSegment), 1929 respectively. 1930 1931 * Added GoDoc badge to README. Thanks to @mrhwick for the contribution! 1932 1933 * `Config.UseTLS` configuration setting has been removed to increase security. 1934 TLS will now always be used in communication with New Relic Servers. 1935 1936 ## 1.11.0 1937 1938 * We've closed the Issues tab on GitHub. Please visit our 1939 [support site](https://support.newrelic.com) to get timely help with any 1940 problems you're having, or to report issues. 1941 1942 * Added support for Cross Application Tracing (CAT). Please refer to the 1943 [CAT section of the guide](GUIDE.md#cross-application-tracing) 1944 for more detail on how to ensure you get the most out of the Go agent's new 1945 CAT support. 1946 1947 * The agent now collects additional metadata when running within Amazon Web 1948 Services, Google Cloud Platform, Microsoft Azure, and Pivotal Cloud Foundry. 1949 This information is used to provide an enhanced experience when the agent is 1950 deployed on those platforms. 1951 1952 ## 1.10.0 1953 1954 * Added new `RecordCustomMetric` method to [Application](https://godoc.org/github.com/newrelic/go-agent#Application). 1955 This functionality can be used to track averages or counters without using 1956 custom events. 1957 * [Custom Metric Documentation](https://docs.newrelic.com/docs/agents/manage-apm-agents/agent-data/collect-custom-metrics) 1958 1959 * Fixed import needed for logrus. The import Sirupsen/logrus had been renamed to sirupsen/logrus. 1960 Thanks to @alfred-landrum for spotting this. 1961 1962 * Added [ErrorAttributer](https://godoc.org/github.com/newrelic/go-agent#ErrorAttributer), 1963 an optional interface that can be implemented by errors provided to 1964 `Transaction.NoticeError` to attach additional attributes. These attributes are 1965 subject to attribute configuration. 1966 1967 * Added [Error](https://godoc.org/github.com/newrelic/go-agent#Error), a type 1968 that allows direct control of error fields. Example use: 1969 1970 ```go 1971 txn.NoticeError(newrelic.Error{ 1972 // Message is returned by the Error() method. 1973 Message: "error message: something went very wrong", 1974 Class: "errors are aggregated by class", 1975 Attributes: map[string]interface{}{ 1976 "important_number": 97232, 1977 "relevant_string": "zap", 1978 }, 1979 }) 1980 ``` 1981 1982 * Updated license to address scope of usage. 1983 1984 ## 1.9.0 1985 1986 * Added support for [github.com/gin-gonic/gin](https://github.com/gin-gonic/gin) 1987 in the new `nrgin` package. 1988 * [Documentation](http://godoc.org/github.com/newrelic/go-agent/_integrations/nrgin/v1) 1989 * [Example](examples/_gin/main.go) 1990 1991 ## 1.8.0 1992 1993 * Fixed incorrect metric rule application when the metric rule is flagged to 1994 terminate and matches but the name is unchanged. 1995 1996 * `Segment.End()`, `DatastoreSegment.End()`, and `ExternalSegment.End()` methods now return an 1997 error which may be helpful in diagnosing situations where segment data is unexpectedly missing. 1998 1999 ## 1.7.0 2000 2001 * Added support for [gorilla/mux](http://github.com/gorilla/mux) in the new `nrgorilla` 2002 package. 2003 * [Documentation](http://godoc.org/github.com/newrelic/go-agent/_integrations/nrgorilla/v1) 2004 * [Example](examples/_gorilla/main.go) 2005 2006 ## 1.6.0 2007 2008 * Added support for custom error messages and stack traces. Errors provided 2009 to `Transaction.NoticeError` will now be checked to see if 2010 they implement [ErrorClasser](https://godoc.org/github.com/newrelic/go-agent#ErrorClasser) 2011 and/or [StackTracer](https://godoc.org/github.com/newrelic/go-agent#StackTracer). 2012 Thanks to @fgrosse for this proposal. 2013 2014 * Added support for [pkg/errors](https://github.com/pkg/errors). Thanks to 2015 @fgrosse for this work. 2016 * [documentation](https://godoc.org/github.com/newrelic/go-agent/_integrations/nrpkgerrors) 2017 * [example](https://github.com/newrelic/go-agent/blob/master/_integrations/nrpkgerrors/nrpkgerrors.go) 2018 2019 * Fixed tests for Go 1.8. 2020 2021 ## 1.5.0 2022 2023 * Added support for Windows. Thanks to @ianomad and @lvxv for the contributions. 2024 2025 * The number of heap objects allocated is recorded in the 2026 `Memory/Heap/AllocatedObjects` metric. This will soon be displayed on the "Go 2027 runtime" page. 2028 2029 * If the [DatastoreSegment](https://godoc.org/github.com/newrelic/go-agent#DatastoreSegment) 2030 fields `Host` and `PortPathOrID` are not provided, they will no longer appear 2031 as `"unknown"` in transaction traces and slow query traces. 2032 2033 * Stack traces will now be nicely aligned in the APM UI. 2034 2035 ## 1.4.0 2036 2037 * Added support for slow query traces. Slow datastore segments will now 2038 generate slow query traces viewable on the datastore tab. These traces include 2039 a stack trace and help you to debug slow datastore activity. 2040 [Slow Query Documentation](https://docs.newrelic.com/docs/apm/applications-menu/monitoring/viewing-slow-query-details) 2041 2042 * Added new 2043 [DatastoreSegment](https://godoc.org/github.com/newrelic/go-agent#DatastoreSegment) 2044 fields `ParameterizedQuery`, `QueryParameters`, `Host`, `PortPathOrID`, and 2045 `DatabaseName`. These fields will be shown in transaction traces and in slow 2046 query traces. 2047 2048 ## 1.3.0 2049 2050 * Breaking Change: Added a timeout parameter to the `Application.Shutdown` method. 2051 2052 ## 1.2.0 2053 2054 * Added support for instrumenting short-lived processes: 2055 * The new `Application.Shutdown` method allows applications to report 2056 data to New Relic without waiting a full minute. 2057 * The new `Application.WaitForConnection` method allows your process to 2058 defer instrumentation until the application is connected and ready to 2059 gather data. 2060 * Full documentation here: [application.go](application.go) 2061 * Example short-lived process: [examples/short-lived-process/main.go](examples/short-lived-process/main.go) 2062 2063 * Error metrics are no longer created when `ErrorCollector.Enabled = false`. 2064 2065 * Added support for [github.com/mgutz/logxi](github.com/mgutz/logxi). See 2066 [_integrations/nrlogxi/v1/nrlogxi.go](_integrations/nrlogxi/v1/nrlogxi.go). 2067 2068 * Fixed bug where Transaction Trace thresholds based upon Apdex were not being 2069 applied to background transactions. 2070 2071 ## 1.1.0 2072 2073 * Added support for Transaction Traces. 2074 2075 * Stack trace filenames have been shortened: Any thing preceding the first 2076 `/src/` is now removed. 2077 2078 ## 1.0.0 2079 2080 * Removed `BetaToken` from the `Config` structure. 2081 2082 * Breaking Datastore Change: `datastore` package contents moved to top level 2083 `newrelic` package. `datastore.MySQL` has become `newrelic.DatastoreMySQL`. 2084 2085 * Breaking Attributes Change: `attributes` package contents moved to top 2086 level `newrelic` package. `attributes.ResponseCode` has become 2087 `newrelic.AttributeResponseCode`. Some attribute name constants have been 2088 shortened. 2089 2090 * Added "runtime.NumCPU" to the environment tab. Thanks sergeylanzman for the 2091 contribution. 2092 2093 * Prefixed the environment tab values "Compiler", "GOARCH", "GOOS", and 2094 "Version" with "runtime.". 2095 2096 ## 0.8.0 2097 2098 * Breaking Segments API Changes: The segments API has been rewritten with the 2099 goal of being easier to use and to avoid nil Transaction checks. See: 2100 2101 * [segments.go](segments.go) 2102 * [examples/server/main.go](examples/server/main.go) 2103 * [GUIDE.md#segments](GUIDE.md#segments) 2104 2105 * Updated LICENSE.txt with contribution information. 2106 2107 ## 0.7.1 2108 2109 * Fixed a bug causing the `Config` to fail to serialize into JSON when the 2110 `Transport` field was populated. 2111 2112 ## 0.7.0 2113 2114 * Eliminated `api`, `version`, and `log` packages. `Version`, `Config`, 2115 `Application`, and `Transaction` now live in the top level `newrelic` package. 2116 If you imported the `attributes` or `datastore` packages then you will need 2117 to remove `api` from the import path. 2118 2119 * Breaking Logging Changes 2120 2121 Logging is no longer controlled though a single global. Instead, logging is 2122 configured on a per-application basis with the new `Config.Logger` field. The 2123 logger is an interface described in [log.go](log.go). See 2124 [GUIDE.md#logging](GUIDE.md#logging). 2125 2126 ## 0.6.1 2127 2128 * No longer create "GC/System/Pauses" metric if no GC pauses happened. 2129 2130 ## 0.6.0 2131 2132 * Introduced beta token to support our beta program. 2133 2134 * Rename `Config.Development` to `Config.Enabled` (and change boolean 2135 direction). 2136 2137 * Fixed a bug where exclusive time could be incorrect if segments were not 2138 ended. 2139 2140 * Fix unit tests broken in 1.6. 2141 2142 * In `Config.Enabled = false` mode, the license must be the proper length or empty. 2143 2144 * Added runtime statistics for CPU/memory usage, garbage collection, and number 2145 of goroutines. 2146 2147 ## 0.5.0 2148 2149 * Added segment timing methods to `Transaction`. These methods must only be 2150 used in a single goroutine. 2151 2152 * The license length check will not be performed in `Development` mode. 2153 2154 * Rename `SetLogFile` to `SetFile` to reduce redundancy. 2155 2156 * Added `DebugEnabled` logging guard to reduce overhead. 2157 2158 * `Transaction` now implements an `Ignore` method which will prevent 2159 any of the transaction's data from being recorded. 2160 2161 * `Transaction` now implements a subset of the interfaces 2162 `http.CloseNotifier`, `http.Flusher`, `http.Hijacker`, and `io.ReaderFrom` 2163 to match the behavior of its wrapped `http.ResponseWriter`. 2164 2165 * Changed project name from `go-sdk` to `go-agent`. 2166 2167 ## 0.4.0 2168 2169 * Queue time support added: if the inbound request contains an 2170 `"X-Request-Start"` or `"X-Queue-Start"` header with a unix timestamp, the 2171 agent will report queue time metrics. Queue time will appear on the 2172 application overview chart. The timestamp may fractional seconds, 2173 milliseconds, or microseconds: the agent will deduce the correct units.