Skip to content

Commit 0a47b5f

Browse files
authored
Merge pull request #183 from newrelic/develop
Merge develop for release v3.8.1.
2 parents c3a3f35 + 74ad83e commit 0a47b5f

File tree

15 files changed

+308
-44
lines changed

15 files changed

+308
-44
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
name: "Bug report \U0001F41B"
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: bug
6+
assignees: ''
7+
8+
---
9+
10+
[NOTE]: # ( ^^ Provide a general summary of the issue in the title above. ^^ )
11+
12+
## Description
13+
14+
[NOTE]: # ( Describe the problem you're encountering. )
15+
[TIP]: # ( Do NOT give us access or passwords to your New Relic account or API keys! )
16+
17+
## Steps to Reproduce
18+
19+
[NOTE]: # ( Please be as specific as possible. )
20+
21+
## Expected Behavior
22+
23+
[NOTE]: # ( Tell us what you expected to happen. )
24+
25+
## NR Diag results
26+
27+
[NOTE]: # ( Provide any other relevant log data. )
28+
29+
## Your Environment
30+
31+
[TIP]: # ( Include as many relevant details about your environment as possible including the running version of New Relic software and any relevant configurations. )
32+
33+
## Reproduction case
34+
35+
[TIP]: # ( Link a sample application that demonstrates the issue. )
36+
37+
## Additional context
38+
39+
[TIP]: # ( Add any other context about the problem here. )

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: Troubleshooting
4+
url: https://github.com/newrelic/go-agent/blob/master/README.md#support
5+
about: checkout the README for troubleshooting directions
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
name: "Enhancement request \U0001F4A1"
3+
about: Suggest an idea for a future version of this project
4+
title: ''
5+
labels: enhancement
6+
assignees: ''
7+
8+
---
9+
10+
[NOTE]: # ( ^^ Provide a general summary of the request in the title above. ^^ )
11+
12+
## Summary
13+
14+
[NOTE]: # ( Provide a brief overview of what the new feature is all about. )
15+
16+
## Desired Behaviour
17+
18+
[NOTE]: # ( Tell us how the new feature should work. Be specific. )
19+
[TIP]: # ( Do NOT give us access or passwords to your New Relic account or API keys! )
20+
21+
## Possible Solution
22+
23+
[NOTE]: # ( Not required. Suggest how to implement the addition or change. )
24+
25+
## Additional context
26+
27+
[TIP]: # ( Why does this feature matter to you? What unique circumstances do you have? )
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!-- ⚠️⚠️STOP⚠️⚠️ -- PLEASE READ! -->
2+
3+
We use GitHub to track feature requests and bug reports. Please **do not** submit issues for questions about how to configure, use features, troubleshoot, or best practices for using New Relic software.
4+
5+
See the README.md troubleshooting section in this repository for more details on self-service troubleshooting tooling, links to our comprehenive documentation, and how to get further support.
6+

.github/workflows/snyk.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
name: Snyk
22

33
on:
4-
pull_request:
4+
schedule:
5+
# Run once a day at 9AM PDT (16 UTC) on week days (1-5).
6+
# Last commit on default branch.
7+
# https://help.github.com/en/actions/reference/events-that-trigger-workflows#scheduled-events-schedule
8+
- cron: '0 16 * * 1-5'
59

610
jobs:
711
security:
@@ -13,4 +17,4 @@ jobs:
1317
env:
1418
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
1519
with:
16-
args: --all-projects
20+
args: --all-projects --exclude=integrations

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# ChangeLog
22

3+
## 3.8.1
4+
5+
### Bug Fixes
6+
7+
* Fixed an issue that could cause orphaned Distributed Trace spans when using
8+
SQL instrumentation like `nrmysql`.
9+
310
## 3.8.0
411

512
### Changes

GUIDE.md

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
* [Upgrading](#upgrading)
44
* [Installation](#installation)
5-
* [Config and Application](#config-and-application)
5+
* [Full list of `Config` options and `Application` settings](#full-list-of-config-options-and-application-settings)
66
* [Logging](#logging)
77
* [Transactions](#transactions)
88
* [Segments](#segments)
@@ -37,7 +37,10 @@ version 3.0, see our [Migration Guide](MIGRATION.md) for details.
3737

3838
## Installation
3939

40-
Installing the Go Agent is the same as installing any other Go library. The
40+
(Also see [GETTING_STARTED](https://github.com/newrelic/go-agent/blob/master/GETTING_STARTED.md) if you are using the Go agent for the first time).
41+
42+
In order to install the New Relic Go agent, you need a New Relic license key.
43+
Then, installing the Go Agent is the same as installing any other Go library. The
4144
simplest way is to run:
4245

4346
```
@@ -49,12 +52,7 @@ Then import the package in your application:
4952
import "github.com/newrelic/go-agent/v3/newrelic"
5053
```
5154

52-
## Config and Application
53-
54-
* [Config godoc](https://godoc.org/github.com/newrelic/go-agent/v3/newrelic#Config)
55-
* [Application godoc](https://godoc.org/github.com/newrelic/go-agent/v3/newrelic#Application)
56-
57-
In your `main` function or in an `init` block:
55+
Initialize the New Relic Go agent by adding the following `Config` options and `Application` settings in the `main` function or in an `init` block:
5856

5957
```go
6058
app, err := newrelic.NewApplication(
@@ -63,9 +61,23 @@ app, err := newrelic.NewApplication(
6361
)
6462
```
6563

66-
Find your application in the New Relic UI. Click on it to see the Go runtime
67-
page that shows information about goroutine counts, garbage collection, memory,
68-
and CPU usage. Data should show up within 5 minutes.
64+
This will allow you to see Go runtime information.
65+
66+
Now, add instrumentation to your Go application to get additional performance data:
67+
* Import any of our [integration packages](https://github.com/newrelic/go-agent#integrations) for out-of-the box support for many popular Go web
68+
frameworks and libraries.
69+
* [Instrument Transactions](#transactions)
70+
* [Use Distributed Tracing](#distributed-tracing)
71+
* [(Optional) Instrument Segments](#segments) for an extra level of timing detail
72+
* External segments are needed for Distributed Tracing
73+
* Read through the rest of this GUIDE for more instrumentation
74+
75+
Compile and deploy your application.
76+
77+
Find your application in the New Relic UI. Click on it to see application performance,
78+
including the Go runtime page that shows information about goroutine counts, garbage
79+
collection, memory, and CPU usage. Data should show up within 5 minutes.
80+
6981

7082
If you are working in a development environment or running unit tests, you may
7183
not want the Go Agent to spawn goroutines or report to New Relic. You're in
@@ -79,6 +91,15 @@ app, err := newrelic.NewApplication(
7991
)
8092
```
8193

94+
95+
96+
## Full list of `Config` options and `Application` settings
97+
98+
* [Config godoc](https://godoc.org/github.com/newrelic/go-agent/v3/newrelic#Config)
99+
* [Application godoc](https://godoc.org/github.com/newrelic/go-agent/v3/newrelic#Application)
100+
101+
102+
82103
## Logging
83104

84105
The agent's logging system is designed to be easily extensible. By default, no

README.md

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,48 @@
1-
# New Relic Go Agent [![GoDoc](https://godoc.org/github.com/newrelic/go-agent?status.svg)](https://godoc.org/github.com/newrelic/go-agent/v3/newrelic/) [![Go Report Card](https://goreportcard.com/badge/github.com/newrelic/go-agent)](https://goreportcard.com/report/github.com/newrelic/go-agent)
21

3-
## Description
2+
[![Community Project header](https://github.com/newrelic/opensource-website/raw/master/src/images/categories/Community_Project.png)](https://opensource.newrelic.com/oss-category/#community-project)
3+
4+
# New Relic Go Agent [![GoDoc](https://godoc.org/github.com/newrelic/go-agent?status.svg)](https://godoc.org/github.com/newrelic/go-agent/v3/newrelic/) [![Go Report Card](https://goreportcard.com/badge/github.com/newrelic/go-agent)](https://goreportcard.com/report/github.com/newrelic/go-agent)
45

56
The New Relic Go Agent allows you to monitor your Go applications with New
67
Relic. It helps you track transactions, outbound requests, database calls, and
78
other parts of your Go application's behavior and provides a running overview of
89
garbage collection, goroutine activity, and memory use.
910

10-
All pull requests will be reviewed by the New Relic product team. Any questions or issues should be directed to our [support
11-
site](http://support.newrelic.com/) or our [community
12-
forum](https://discuss.newrelic.com).
11+
Go is a compiled language, and doesn’t use a virtual machine. This means that setting up New Relic for your Golang app requires you to use our Go agent API and manually add New Relic methods to your source code. Our API provides exceptional flexibility and control over what gets instrumented.
1312

14-
## Upgrading
15-
If you have already been using version 2.X of the agent and are upgrading to
16-
version 3.0, see our [Migration Guide](MIGRATION.md) for details.
1713

18-
## Requirements
14+
## Compatibility and Requirements
1915

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

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

25-
## Integrations
21+
22+
## Installing and using the Go agent
23+
24+
To install the agent, follow the instructions in our [GETTING_STARTED](https://github.com/newrelic/go-agent/blob/master/GETTING_STARTED.md)
25+
document or our [GUIDE](https://github.com/newrelic/go-agent/blob/master/GUIDE.md).
26+
27+
We recommend instrumenting your Go code to get the maximum benefits from the
28+
New Relic Go agent. But we make it easy to get great data in couple of ways:
29+
30+
* Even without adding instrumentation, just importing the agent and creating an
31+
application will provide useful runtime information about your number of goroutines,
32+
garbage collection statistics, and memory and CPU usage.
33+
* You can use our many [INTEGRATION packages](https://github.com/newrelic/go-agent/tree/master/v3/integrations)
34+
for out-of-the box support for many popular Go web frameworks and libraries. We
35+
continue to add integration packages based on your feedback. You can weigh in on
36+
potential integrations by opening an `Issue` here in our New Relic Go agent GitHub project.
37+
38+
39+
## Upgrading
40+
41+
If you have already been using version 2.X of the agent and are upgrading to
42+
version 3.0, see our [MIGRATION guide](MIGRATION.md) for details.
43+
44+
45+
## Integration Packages
2646

2747
The following [integration packages](https://godoc.org/github.com/newrelic/go-agent/v3/integrations)
2848
extend the base [newrelic](https://godoc.org/github.com/newrelic/go-agent/v3/newrelic/) package
@@ -103,10 +123,6 @@ These integration packages must be imported along
103123
with the [newrelic](https://godoc.org/github.com/newrelic/go-agent/v3/newrelic/) package, as shown in this
104124
[nrgin example](https://github.com/newrelic/go-agent/blob/master/v3/integrations/nrgin/example/main.go).
105125

106-
## Getting Started
107-
108-
Follow the steps in [GETTING_STARTED.md](GETTING_STARTED.md) to instrument your
109-
application.
110126

111127
## Runnable Example
112128

@@ -121,6 +137,7 @@ env NEW_RELIC_LICENSE_KEY=__YOUR_NEW_RELIC_LICENSE_KEY__LICENSE__ \
121137
Some endpoints exposed are [http://localhost:8000/](http://localhost:8000/)
122138
and [http://localhost:8000/notice_error](http://localhost:8000/notice_error)
123139

140+
124141
## Alternatives
125142

126143
If you are already using another open source solution to gather telemetry data, you may find it easier to use one of our open source exporters to send this data to New Relic:
@@ -131,14 +148,21 @@ If you are already using another open source solution to gather telemetry data,
131148
* Istio Adapter: [github.com/newrelic/newrelic-istio-adapter](https://github.com/newrelic/newrelic-istio-adapter)
132149
* Telemetry SDK: [github.com/newrelic/newrelic-telemetry-sdk-go](https://github.com/newrelic/newrelic-telemetry-sdk-go)
133150

151+
134152
## Support
135153

136154
You can find more detailed documentation [in the guide](GUIDE.md) and on
137155
[the New Relic Documentation site](https://docs.newrelic.com/docs/agents/go-agent).
138156

139-
If you can't find what you're looking for there, reach out to us on our [support
140-
site](http://support.newrelic.com/) or our [community
141-
forum](https://discuss.newrelic.com) and we'll be happy to help you.
157+
If you can't find what you need there, New Relic hosts and moderates an online forum where customers can interact with New Relic employees as well as other customers to get help and share best practices. Like all official New Relic open source projects, there's a related Community topic in the New Relic Explorers Hub. You can find this project's topic/threads here:
158+
[Open-Source-Agents-SDKs](https://discuss.newrelic.com/c/build-on-new-relic/Open-Source-Agents-SDKs)
159+
160+
161+
## Contributing
162+
163+
We encourage contributions to improve the Go agent! Keep in mind when you submit your pull request, you'll need to sign the CLA via the click-through using CLA-Assistant. You only have to sign the CLA one time per project.
164+
If you have any questions, or to execute our corporate CLA, required if your contribution is on behalf of a company, please drop us an email at [email protected].
165+
142166

143-
Find a bug? Contact us via [support.newrelic.com](http://support.newrelic.com/),
144-
167+
## License
168+
The New Relic Go agent is licensed under the [Apache 2.0](http://apache.org/licenses/LICENSE-2.0.txt) License.

sql_driver_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func TestDriverStmtQueryContext(t *testing.T) {
112112
dr := InstrumentSQLDriver(testDriver{}, testBuilder)
113113
txn := app.StartTransaction("hello", nil, nil)
114114
conn, _ := dr.Open("myhost,myport,mydatabase")
115-
stmt, _ := conn.(driver.ConnPrepareContext).PrepareContext(nil, "myoperation,mycollection")
115+
stmt, _ := conn.(driver.ConnPrepareContext).PrepareContext(context.Background(), "myoperation,mycollection")
116116
ctx := NewContext(context.Background(), txn)
117117
stmt.(driver.StmtQueryContext).QueryContext(ctx, nil)
118118
txn.End()
@@ -149,7 +149,7 @@ func TestDriverContext(t *testing.T) {
149149
dr := InstrumentSQLDriver(testDriver{}, testBuilder)
150150
txn := app.StartTransaction("hello", nil, nil)
151151
connector, _ := dr.(driver.DriverContext).OpenConnector("myhost,myport,mydatabase")
152-
conn, _ := connector.Connect(nil)
152+
conn, _ := connector.Connect(context.Background())
153153
ctx := NewContext(context.Background(), txn)
154154
conn.(driver.ExecerContext).ExecContext(ctx, "myoperation,mycollection", nil)
155155
txn.End()
@@ -166,7 +166,7 @@ func TestInstrumentSQLConnector(t *testing.T) {
166166
bld.BaseSegment.DatabaseName = "mydatabase"
167167
connector := InstrumentSQLConnector(testConnector{}, bld)
168168
txn := app.StartTransaction("hello", nil, nil)
169-
conn, _ := connector.Connect(nil)
169+
conn, _ := connector.Connect(context.Background())
170170
ctx := NewContext(context.Background(), txn)
171171
conn.(driver.ExecerContext).ExecContext(ctx, "myoperation,mycollection", nil)
172172
txn.End()

v3/newrelic/internal_distributed_trace_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,6 +1566,32 @@ func TestW3CTraceHeadersRoundTrip(t *testing.T) {
15661566

15671567
}
15681568

1569+
func TestW3CTraceHeadersDuplicateTraceState(t *testing.T) {
1570+
app := testApp(distributedTracingReplyFields, enableW3COnly, t)
1571+
txn := app.StartTransaction("hello")
1572+
1573+
hdrs := http.Header{}
1574+
hdrs.Set(DistributedTraceW3CTraceParentHeader,
1575+
"00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01")
1576+
hdrs.Set(DistributedTraceW3CTraceStateHeader,
1577+
"123@nr=0-0-1349956-41346604-27ddd2d8890283b4-b28be285632bbc0a-1-0.246890-1569367663277,congo=congosSecondPosition,rojo=rojosFirstPosition,123@nr=0-0-1349956-41346604-aaaaaaaaaaaaaaaa-b28be285632bbc0a-1-0.246890-1569367663277")
1578+
txn.AcceptDistributedTraceHeaders(TransportHTTP, hdrs)
1579+
outgoingHdrs := http.Header{}
1580+
txn.InsertDistributedTraceHeaders(outgoingHdrs)
1581+
1582+
expected := http.Header{
1583+
DistributedTraceW3CTraceParentHeader: []string{"00-4bf92f3577b34da6a3ce929d0e0e4736-9566c74d10d1e2c6-01"},
1584+
DistributedTraceW3CTraceStateHeader: []string{"123@nr=0-0-123-456-9566c74d10d1e2c6-52fdfc072182654f-1-0.24689-1577830891900,congo=congosSecondPosition,rojo=rojosFirstPosition"},
1585+
}
1586+
verifyHeaders(t, outgoingHdrs, expected)
1587+
1588+
txn.End()
1589+
app.expectNoLoggedErrors(t)
1590+
1591+
app.ExpectMetrics(t, acceptAndSendDT)
1592+
1593+
}
1594+
15691595
func TestW3CTraceHeadersSpansDisabledSampledTrue(t *testing.T) {
15701596
app := testApp(distributedTracingReplyFieldsSpansDisabled, enableW3COnly, t)
15711597
txn := app.StartTransaction("hello")

0 commit comments

Comments
 (0)