Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates examples to retrieve transaction using FromContext #105

Merged
merged 1 commit into from Oct 14, 2019

Conversation

@kevburnsjr
Copy link
Contributor

@kevburnsjr kevburnsjr commented Sep 25, 2019

FromContext is the newer method for accessing a transaction from within an http handler.

These examples use a mix of type casting and FromContext. This PR makes them consistent.

I propose that New Relic update all documentation and examples removing type casting in favor of FromContext to help prevent customers from experiencing issues related to the old type cast method.

Details regarding the type of problem type casting creates and why FromContext is strictly superior can be found in the following github issue for a piece of HTTP middleware that is incompatible with many newrelic integrations due to the widespread use of type casting for transaction retrieval: kevburnsjr/microcache#10

@willnewrelic
Copy link

@willnewrelic willnewrelic commented Sep 25, 2019

Hi @kevburnsjr

Thank you! We agree: FromContext is a better way to get the transaction.

This example code was written before Go 1.7. It is very old!

We appreciate your contribution. Expect to see this in the next release.

@willnewrelic willnewrelic merged commit 623ec66 into newrelic:master Oct 14, 2019
@willnewrelic
Copy link

@willnewrelic willnewrelic commented Oct 14, 2019

Hi @kevburnsjr

We just released version 2.14.0 with this change!

Thanks again for giving us this PR!

@purple4reina
Copy link
Contributor

@purple4reina purple4reina commented Oct 18, 2019

@kevburnsjr Thanks for finding those, they have been updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants