-
Notifications
You must be signed in to change notification settings - Fork 295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable DT by Default for the Go Agent #495
Merged
nr-swilloughby
merged 10 commits into
newrelic:develop
from
nr-swilloughby:dt_by_default_reservoir_size
May 19, 2022
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0e5b79d
wip on dt test cases
nr-swilloughby c6b4c2d
DT by default passing all unit tests
nr-swilloughby e8ef576
(unstable commit) work in progress on changing reservoir size
nr-swilloughby bdd5584
Merge branch 'develop' into dt_by_default_reservoir_size
nr-swilloughby fdab64d
updates to several integration examples
nr-swilloughby f6ab494
checkpoint
nr-swilloughby 24918bf
tests passing
nr-swilloughby bb325e0
corrected collector negotiation for DT reservoir size
nr-swilloughby c2426df
updated nrredis example
nr-swilloughby a08d833
fixed nrgrpc and nrsqlite3 examples
nr-swilloughby File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,12 @@ | |
package main | ||
|
||
import ( | ||
"bufio" | ||
"context" | ||
"fmt" | ||
"os" | ||
"strconv" | ||
"strings" | ||
"time" | ||
|
||
redis "github.com/go-redis/redis/v8" | ||
|
@@ -20,10 +23,15 @@ func main() { | |
newrelic.ConfigLicense(os.Getenv("NEW_RELIC_LICENSE_KEY")), | ||
newrelic.ConfigDebugLogger(os.Stdout), | ||
) | ||
if nil != err { | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// normally, production code wouldn't require the WaitForConnection call, | ||
// but for an extremely short-lived script, we want to be sure we are | ||
// connected before we've already exited. | ||
app.WaitForConnection(10 * time.Second) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this one-shot redis example work without that WaitForConnection in here? |
||
|
||
txn := app.StartTransaction("ping txn") | ||
|
||
opts := &redis.Options{ | ||
|
@@ -47,6 +55,32 @@ func main() { | |
_, err = pipe.Exec(ctx) | ||
fmt.Println(incr.Val(), err) | ||
|
||
result, err := client.Do(ctx, "INFO", "STATS").Result() | ||
if err != nil { | ||
panic(err) | ||
} | ||
hits := 0 | ||
misses := 0 | ||
if stats, ok := result.(string); ok { | ||
sc := bufio.NewScanner(strings.NewReader(stats)) | ||
for sc.Scan() { | ||
fields := strings.Split(sc.Text(), ":") | ||
if len(fields) == 2 { | ||
if v, err := strconv.Atoi(fields[1]); err == nil { | ||
switch fields[0] { | ||
case "keyspace_hits": | ||
hits = v | ||
case "keyspace_misses": | ||
misses = v | ||
} | ||
} | ||
} | ||
} | ||
} | ||
if hits+misses > 0 { | ||
app.RecordCustomMetric("Custom/RedisCache/HitRatio", float64(hits)/(float64(hits+misses))) | ||
} | ||
|
||
txn.End() | ||
app.Shutdown(5 * time.Second) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for fixing this, these always bothered me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a matter of principle I've been fixing those as I encounter them. when doing other fixes.