Skip to content

Commit

Permalink
Merge pull request #183 from newrelic/develop
Browse files Browse the repository at this point in the history
Merge develop for release v3.8.1.
  • Loading branch information
purple4reina authored Jul 15, 2020
2 parents c3a3f35 + 74ad83e commit 0a47b5f
Show file tree
Hide file tree
Showing 15 changed files with 308 additions and 44 deletions.
39 changes: 39 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report---.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
name: "Bug report \U0001F41B"
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''

---

[NOTE]: # ( ^^ Provide a general summary of the issue in the title above. ^^ )

## Description

[NOTE]: # ( Describe the problem you're encountering. )
[TIP]: # ( Do NOT give us access or passwords to your New Relic account or API keys! )

## Steps to Reproduce

[NOTE]: # ( Please be as specific as possible. )

## Expected Behavior

[NOTE]: # ( Tell us what you expected to happen. )

## NR Diag results

[NOTE]: # ( Provide any other relevant log data. )

## Your Environment

[TIP]: # ( Include as many relevant details about your environment as possible including the running version of New Relic software and any relevant configurations. )

## Reproduction case

[TIP]: # ( Link a sample application that demonstrates the issue. )

## Additional context

[TIP]: # ( Add any other context about the problem here. )
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Troubleshooting
url: https://github.com/newrelic/go-agent/blob/master/README.md#support
about: checkout the README for troubleshooting directions
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE/enhancement-request---.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: "Enhancement request \U0001F4A1"
about: Suggest an idea for a future version of this project
title: ''
labels: enhancement
assignees: ''

---

[NOTE]: # ( ^^ Provide a general summary of the request in the title above. ^^ )

## Summary

[NOTE]: # ( Provide a brief overview of what the new feature is all about. )

## Desired Behaviour

[NOTE]: # ( Tell us how the new feature should work. Be specific. )
[TIP]: # ( Do NOT give us access or passwords to your New Relic account or API keys! )

## Possible Solution

[NOTE]: # ( Not required. Suggest how to implement the addition or change. )

## Additional context

[TIP]: # ( Why does this feature matter to you? What unique circumstances do you have? )
6 changes: 6 additions & 0 deletions .github/ISSUE_TEMPLATE/troubleshooting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!-- ⚠️⚠️STOP⚠️⚠️ -- PLEASE READ! -->

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.

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.

8 changes: 6 additions & 2 deletions .github/workflows/snyk.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
name: Snyk

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

jobs:
security:
Expand All @@ -13,4 +17,4 @@ jobs:
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
args: --all-projects
args: --all-projects --exclude=integrations
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# ChangeLog

## 3.8.1

### Bug Fixes

* Fixed an issue that could cause orphaned Distributed Trace spans when using
SQL instrumentation like `nrmysql`.

## 3.8.0

### Changes
Expand Down
43 changes: 32 additions & 11 deletions GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

## Installation

Installing the Go Agent is the same as installing any other Go library. The
(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).

In order to install the New Relic Go agent, you need a New Relic license key.
Then, installing the Go Agent is the same as installing any other Go library. The
simplest way is to run:

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

## Config and Application

* [Config godoc](https://godoc.org/github.com/newrelic/go-agent/v3/newrelic#Config)
* [Application godoc](https://godoc.org/github.com/newrelic/go-agent/v3/newrelic#Application)

In your `main` function or in an `init` block:
Initialize the New Relic Go agent by adding the following `Config` options and `Application` settings in the `main` function or in an `init` block:

```go
app, err := newrelic.NewApplication(
Expand All @@ -63,9 +61,23 @@ app, err := newrelic.NewApplication(
)
```

Find your application in the New Relic UI. Click on it to see the Go runtime
page that shows information about goroutine counts, garbage collection, memory,
and CPU usage. Data should show up within 5 minutes.
This will allow you to see Go runtime information.

Now, add instrumentation to your Go application to get additional performance data:
* Import any of our [integration packages](https://github.com/newrelic/go-agent#integrations) for out-of-the box support for many popular Go web
frameworks and libraries.
* [Instrument Transactions](#transactions)
* [Use Distributed Tracing](#distributed-tracing)
* [(Optional) Instrument Segments](#segments) for an extra level of timing detail
* External segments are needed for Distributed Tracing
* Read through the rest of this GUIDE for more instrumentation

Compile and deploy your application.

Find your application in the New Relic UI. Click on it to see application performance,
including the Go runtime page that shows information about goroutine counts, garbage
collection, memory, and CPU usage. Data should show up within 5 minutes.


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



## Full list of `Config` options and `Application` settings

* [Config godoc](https://godoc.org/github.com/newrelic/go-agent/v3/newrelic#Config)
* [Application godoc](https://godoc.org/github.com/newrelic/go-agent/v3/newrelic#Application)



## Logging

The agent's logging system is designed to be easily extensible. By default, no
Expand Down
62 changes: 43 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,48 @@
# 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)

## Description
[![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)

# 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)

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

All pull requests will be reviewed by the New Relic product team. Any questions or issues should be directed to our [support
site](http://support.newrelic.com/) or our [community
forum](https://discuss.newrelic.com).
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.

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

## Requirements
## Compatibility and Requirements

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

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

## Integrations

## Installing and using the Go agent

To install the agent, follow the instructions in our [GETTING_STARTED](https://github.com/newrelic/go-agent/blob/master/GETTING_STARTED.md)
document or our [GUIDE](https://github.com/newrelic/go-agent/blob/master/GUIDE.md).

We recommend instrumenting your Go code to get the maximum benefits from the
New Relic Go agent. But we make it easy to get great data in couple of ways:

* Even without adding instrumentation, just importing the agent and creating an
application will provide useful runtime information about your number of goroutines,
garbage collection statistics, and memory and CPU usage.
* You can use our many [INTEGRATION packages](https://github.com/newrelic/go-agent/tree/master/v3/integrations)
for out-of-the box support for many popular Go web frameworks and libraries. We
continue to add integration packages based on your feedback. You can weigh in on
potential integrations by opening an `Issue` here in our New Relic Go agent GitHub project.


## Upgrading

If you have already been using version 2.X of the agent and are upgrading to
version 3.0, see our [MIGRATION guide](MIGRATION.md) for details.


## Integration Packages

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

## Getting Started

Follow the steps in [GETTING_STARTED.md](GETTING_STARTED.md) to instrument your
application.

## Runnable Example

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


## Alternatives

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:
Expand All @@ -131,14 +148,21 @@ If you are already using another open source solution to gather telemetry data,
* Istio Adapter: [github.com/newrelic/newrelic-istio-adapter](https://github.com/newrelic/newrelic-istio-adapter)
* Telemetry SDK: [github.com/newrelic/newrelic-telemetry-sdk-go](https://github.com/newrelic/newrelic-telemetry-sdk-go)


## Support

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

If you can't find what you're looking for there, reach out to us on our [support
site](http://support.newrelic.com/) or our [community
forum](https://discuss.newrelic.com) and we'll be happy to help you.
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:
[Open-Source-Agents-SDKs](https://discuss.newrelic.com/c/build-on-new-relic/Open-Source-Agents-SDKs)


## Contributing

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.
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].


Find a bug? Contact us via [support.newrelic.com](http://support.newrelic.com/),
or email [email protected].
## License
The New Relic Go agent is licensed under the [Apache 2.0](http://apache.org/licenses/LICENSE-2.0.txt) License.
6 changes: 3 additions & 3 deletions sql_driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func TestDriverStmtQueryContext(t *testing.T) {
dr := InstrumentSQLDriver(testDriver{}, testBuilder)
txn := app.StartTransaction("hello", nil, nil)
conn, _ := dr.Open("myhost,myport,mydatabase")
stmt, _ := conn.(driver.ConnPrepareContext).PrepareContext(nil, "myoperation,mycollection")
stmt, _ := conn.(driver.ConnPrepareContext).PrepareContext(context.Background(), "myoperation,mycollection")
ctx := NewContext(context.Background(), txn)
stmt.(driver.StmtQueryContext).QueryContext(ctx, nil)
txn.End()
Expand Down Expand Up @@ -149,7 +149,7 @@ func TestDriverContext(t *testing.T) {
dr := InstrumentSQLDriver(testDriver{}, testBuilder)
txn := app.StartTransaction("hello", nil, nil)
connector, _ := dr.(driver.DriverContext).OpenConnector("myhost,myport,mydatabase")
conn, _ := connector.Connect(nil)
conn, _ := connector.Connect(context.Background())
ctx := NewContext(context.Background(), txn)
conn.(driver.ExecerContext).ExecContext(ctx, "myoperation,mycollection", nil)
txn.End()
Expand All @@ -166,7 +166,7 @@ func TestInstrumentSQLConnector(t *testing.T) {
bld.BaseSegment.DatabaseName = "mydatabase"
connector := InstrumentSQLConnector(testConnector{}, bld)
txn := app.StartTransaction("hello", nil, nil)
conn, _ := connector.Connect(nil)
conn, _ := connector.Connect(context.Background())
ctx := NewContext(context.Background(), txn)
conn.(driver.ExecerContext).ExecContext(ctx, "myoperation,mycollection", nil)
txn.End()
Expand Down
26 changes: 26 additions & 0 deletions v3/newrelic/internal_distributed_trace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1566,6 +1566,32 @@ func TestW3CTraceHeadersRoundTrip(t *testing.T) {

}

func TestW3CTraceHeadersDuplicateTraceState(t *testing.T) {
app := testApp(distributedTracingReplyFields, enableW3COnly, t)
txn := app.StartTransaction("hello")

hdrs := http.Header{}
hdrs.Set(DistributedTraceW3CTraceParentHeader,
"00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01")
hdrs.Set(DistributedTraceW3CTraceStateHeader,
"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")
txn.AcceptDistributedTraceHeaders(TransportHTTP, hdrs)
outgoingHdrs := http.Header{}
txn.InsertDistributedTraceHeaders(outgoingHdrs)

expected := http.Header{
DistributedTraceW3CTraceParentHeader: []string{"00-4bf92f3577b34da6a3ce929d0e0e4736-9566c74d10d1e2c6-01"},
DistributedTraceW3CTraceStateHeader: []string{"123@nr=0-0-123-456-9566c74d10d1e2c6-52fdfc072182654f-1-0.24689-1577830891900,congo=congosSecondPosition,rojo=rojosFirstPosition"},
}
verifyHeaders(t, outgoingHdrs, expected)

txn.End()
app.expectNoLoggedErrors(t)

app.ExpectMetrics(t, acceptAndSendDT)

}

func TestW3CTraceHeadersSpansDisabledSampledTrue(t *testing.T) {
app := testApp(distributedTracingReplyFieldsSpansDisabled, enableW3COnly, t)
txn := app.StartTransaction("hello")
Expand Down
4 changes: 2 additions & 2 deletions v3/newrelic/internal_txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -700,12 +700,12 @@ func (txn *txn) Ignore() error {
return nil
}

func (thd *thread) StartSegmentNow() SegmentStartTime {
func (thd *thread) startSegmentAt(at time.Time) SegmentStartTime {
var s segmentStartTime
txn := thd.txn
txn.Lock()
if !txn.finished {
s = startSegment(&txn.txnData, thd.thread, time.Now())
s = startSegment(&txn.txnData, thd.thread, at)
}
txn.Unlock()
return SegmentStartTime{
Expand Down
Loading

0 comments on commit 0a47b5f

Please sign in to comment.