contrib/net/http
Those integrations are enabled by having the
following import
in the project’s orchestrion.tool.go
file:
import (
_ "github.com/DataDog/orchestrion"
_ "github.com/DataDog/dd-trace-go/contrib/net/http/v2" // integration
//...
)
github.com/DataDog/dd-trace-go/contrib/net/http/v2
HTTP stack implementation.
Transport.DD__tracer_internal
Definition of
http.Transport
Transport.DD__tracer_internal=true
All of
- Struct literal
http.Transport
- Pointer or Value
- One of
- Import path
github.com/
DataDog/ dd-trace-go/ v2/ ddtrace/ tracer - Import path
github.com/
DataDog/ dd-trace-go/ v2/ profiler
Replace the expression using the template:
{{- .AST.Type -}}{
DD__tracer_internal: true,
{{ range .AST.Elts }}{{ . }},
{{ end }}
}
Transport.RoundTrip
Function body
- Function declaration
- Function name
RoundTrip
- Is method of
*http.Transport
Introduce new declarations:
type ddAfterRoundTrip = func(*Response, error) (*Response, error)
//go:linkname __dd_httptrace_ObserveRoundTrip github.com/DataDog/dd-trace-go/contrib/net/http/v2/internal/orchestrion.ObserveRoundTrip
func __dd_httptrace_ObserveRoundTrip(*Request) (*Request, ddAfterRoundTrip, error)
Record link-time dependencies on:
Prepend statements produced by the following template:
{{- $t := .Function.Receiver -}}
{{- $req := .Function.Argument 0 -}}
{{- $res := .Function.Result 0 -}}
{{- $err := .Function.Result 1 -}}
if !{{ $t }}.DD__tracer_internal {
var (
__after__ ddAfterRoundTrip
__err__ error
)
{{ $req }}, __after__, __err__ = __dd_httptrace_ObserveRoundTrip({{ $req }})
if __err__ != nil {
return nil, __err__
}
defer func(){
{{ $res }}, {{ $err }} = __after__({{ $res }}, {{ $err }})
}()
}
Get|Head|Post|PostForm
All of
- Not
- Import path
net/
http
- One of
- Call to
http.Get
- Call to
http.Head
- Call to
http.Post
- Call to
http.PostForm
Replace the expression using the template:
// Using the following synthetic imports:
import (
client "github.com/DataDog/dd-trace-go/contrib/net/http/v2/client"
)
{{- $ctx := .Function.ArgumentOfType "context.Context" -}}
{{- $req := .Function.ArgumentOfType "*net/http.Request" }}
{{- if $ctx -}}
client.{{ .AST.Fun.Name }}(
{{ $ctx }},
{{ range .AST.Args }}{{ . }},
{{ end }}
)
{{- else if $req -}}
client.{{ .AST.Fun.Name }}(
{{ $req }}.Context(),
{{ range .AST.Args }}{{ . }},
{{ end }}
)
{{- else -}}
{{ . }}
{{- end -}}
Server.Serve
Function body
- Function declaration
- Is method of
*http.Server
- Function name
Serve
Introduce new declarations:
//go:linkname __dd_contrib_net_http_internal_orchestrion_WrapHandler github.com/DataDog/dd-trace-go/contrib/net/http/v2/internal/orchestrion.WrapHandler
func __dd_contrib_net_http_internal_orchestrion_WrapHandler(Handler) Handler
Record link-time dependencies on:
Prepend statements produced by the following template:
{{- $srv := .Function.Receiver -}}
if {{ $srv }}.Handler == nil {
{{ $srv }}.Handler = __dd_contrib_net_http_internal_orchestrion_WrapHandler(DefaultServeMux)
} else {
{{ $srv }}.Handler = __dd_contrib_net_http_internal_orchestrion_WrapHandler({{ $srv }}.Handler)
}
github.com/DataDog/dd-trace-go/contrib/net/http/v2.Client
HTTP client implementation.
Transport.DD__tracer_internal
Definition of
http.Transport
Transport.DD__tracer_internal=true
All of
- Struct literal
http.Transport
- Pointer or Value
- One of
- Import path
github.com/
DataDog/ dd-trace-go/ v2/ ddtrace/ tracer - Import path
github.com/
DataDog/ dd-trace-go/ v2/ profiler
Replace the expression using the template:
{{- .AST.Type -}}{
DD__tracer_internal: true,
{{ range .AST.Elts }}{{ . }},
{{ end }}
}
Transport.RoundTrip
Function body
- Function declaration
- Function name
RoundTrip
- Is method of
*http.Transport
Introduce new declarations:
type ddAfterRoundTrip = func(*Response, error) (*Response, error)
//go:linkname __dd_httptrace_ObserveRoundTrip github.com/DataDog/dd-trace-go/contrib/net/http/v2/internal/orchestrion.ObserveRoundTrip
func __dd_httptrace_ObserveRoundTrip(*Request) (*Request, ddAfterRoundTrip, error)
Record link-time dependencies on:
Prepend statements produced by the following template:
{{- $t := .Function.Receiver -}}
{{- $req := .Function.Argument 0 -}}
{{- $res := .Function.Result 0 -}}
{{- $err := .Function.Result 1 -}}
if !{{ $t }}.DD__tracer_internal {
var (
__after__ ddAfterRoundTrip
__err__ error
)
{{ $req }}, __after__, __err__ = __dd_httptrace_ObserveRoundTrip({{ $req }})
if __err__ != nil {
return nil, __err__
}
defer func(){
{{ $res }}, {{ $err }} = __after__({{ $res }}, {{ $err }})
}()
}
Get|Head|Post|PostForm
All of
- Not
- Import path
net/
http
- One of
- Call to
http.Get
- Call to
http.Head
- Call to
http.Post
- Call to
http.PostForm
Replace the expression using the template:
// Using the following synthetic imports:
import (
client "github.com/DataDog/dd-trace-go/contrib/net/http/v2/client"
)
{{- $ctx := .Function.ArgumentOfType "context.Context" -}}
{{- $req := .Function.ArgumentOfType "*net/http.Request" }}
{{- if $ctx -}}
client.{{ .AST.Fun.Name }}(
{{ $ctx }},
{{ range .AST.Args }}{{ . }},
{{ end }}
)
{{- else if $req -}}
client.{{ .AST.Fun.Name }}(
{{ $req }}.Context(),
{{ range .AST.Args }}{{ . }},
{{ end }}
)
{{- else -}}
{{ . }}
{{- end -}}
github.com/DataDog/dd-trace-go/contrib/net/http/v2.Server
HTTP server implementation.
Server.Serve
Function body
- Function declaration
- Is method of
*http.Server
- Function name
Serve
Introduce new declarations:
//go:linkname __dd_contrib_net_http_internal_orchestrion_WrapHandler github.com/DataDog/dd-trace-go/contrib/net/http/v2/internal/orchestrion.WrapHandler
func __dd_contrib_net_http_internal_orchestrion_WrapHandler(Handler) Handler
Record link-time dependencies on:
Prepend statements produced by the following template:
{{- $srv := .Function.Receiver -}}
if {{ $srv }}.Handler == nil {
{{ $srv }}.Handler = __dd_contrib_net_http_internal_orchestrion_WrapHandler(DefaultServeMux)
} else {
{{ $srv }}.Handler = __dd_contrib_net_http_internal_orchestrion_WrapHandler({{ $srv }}.Handler)
}