Skip to content

Commit

Permalink
updated example server
Browse files Browse the repository at this point in the history
  • Loading branch information
mirackara committed Dec 12, 2023
1 parent 4aea45e commit d1769e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions v3/examples/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func message(w http.ResponseWriter, r *http.Request) {

func external(w http.ResponseWriter, r *http.Request) {
txn := newrelic.FromContext(r.Context())
req, _ := http.NewRequest("GET", "http://example.com", nil)
req, _ := http.NewRequest("GET", "https://example.com", nil)

// Using StartExternalSegment is recommended because it does distributed
// tracing header setup, but if you don't have an *http.Request and
Expand Down Expand Up @@ -193,7 +193,7 @@ func roundtripper(w http.ResponseWriter, r *http.Request) {
client := &http.Client{}
client.Transport = newrelic.NewRoundTripper(client.Transport)

request, _ := http.NewRequest("GET", "http://example.com", nil)
request, _ := http.NewRequest("GET", "https://example.com", nil)
// Since the transaction is already added to the inbound request's
// context by WrapHandleFunc, we just need to copy the context from the
// inbound request to the external request.
Expand Down
12 changes: 6 additions & 6 deletions v3/newrelic/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func ExampleNewRoundTripper() {
// requests done by this client with external segments.
client.Transport = newrelic.NewRoundTripper(client.Transport)

request, _ := http.NewRequest("GET", "http://example.com", nil)
request, _ := http.NewRequest("GET", "https://example.com", nil)

// Be sure to add the current Transaction to each request's context so
// the Transport has access to it.
Expand Down Expand Up @@ -160,7 +160,7 @@ func ExampleError() {
func ExampleExternalSegment() {
txn := currentTransaction()
client := &http.Client{}
request, _ := http.NewRequest("GET", "http://www.example.com", nil)
request, _ := http.NewRequest("GET", "https://www.example.com", nil)
segment := newrelic.StartExternalSegment(txn, request)
response, _ := client.Do(request)
segment.Response = response
Expand All @@ -186,7 +186,7 @@ func ExampleExternalSegment_url() {
func ExampleStartExternalSegment() {
txn := currentTransaction()
client := &http.Client{}
request, _ := http.NewRequest("GET", "http://www.example.com", nil)
request, _ := http.NewRequest("GET", "https://www.example.com", nil)
segment := newrelic.StartExternalSegment(txn, request)
response, _ := client.Do(request)
segment.Response = response
Expand All @@ -195,7 +195,7 @@ func ExampleStartExternalSegment() {

func ExampleStartExternalSegment_context() {
txn := currentTransaction()
request, _ := http.NewRequest("GET", "http://www.example.com", nil)
request, _ := http.NewRequest("GET", "https://www.example.com", nil)

// If the transaction is added to the request's context then it does not
// need to be provided as a parameter to StartExternalSegment.
Expand All @@ -214,7 +214,7 @@ func doSendRequest(*http.Request) int { return 418 }
// http.Response and still want to record the response status code.
func ExampleExternalSegment_SetStatusCode() {
txn := currentTransaction()
request, _ := http.NewRequest("GET", "http://www.example.com", nil)
request, _ := http.NewRequest("GET", "https://www.example.com", nil)
segment := newrelic.StartExternalSegment(txn, request)
statusCode := doSendRequest(request)
segment.SetStatusCode(statusCode)
Expand All @@ -234,7 +234,7 @@ func ExampleTransaction_SetWebRequest() {

func ExampleTransaction_SetWebRequestHTTP() {
app := getApp()
inboundRequest, _ := http.NewRequest("GET", "http://example.com", nil)
inboundRequest, _ := http.NewRequest("GET", "https://example.com", nil)
txn := app.StartTransaction("My-Transaction")
// Mark transaction as a web transaction, record attributes based on the
// inbound request, and read any available distributed tracing headers.
Expand Down

0 comments on commit d1769e0

Please sign in to comment.