contrib/go.uber.org/zap
Those integration 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/go.uber.org/zap/v2" // integration
//...
)Structured, leveled logging for Go.
Logger.Debug|Info|Warn|Error|DPanic|Panic|Fatal|Log
All of
- Not
- One of
Replace the expression using the template:
// Using the following synthetic imports:
import (
__ddzap "github.com/DataDog/dd-trace-go/contrib/go.uber.org/zap/v2"
){{- $ctx := .Function.ArgumentOfType "context.Context" -}}
{{- if eq $ctx "" -}}
{{- $ctx = .Function.ArgumentThatImplements "context.Context" -}}
{{- end -}}
{{- $req := .Function.ArgumentOfType "*net/http.Request" -}}
{{- $ellipsis := .AST.Ellipsis -}}
{{- if $ctx -}}
{{ .AST.Fun.X }}.With(__ddzap.TraceFields({{ $ctx }})...).{{ .AST.Fun.Name }}({{ range $i, $a := .AST.Args }}{{ if $i }}, {{ end }}{{ $a }}{{ end }}{{ if $ellipsis }}...{{ end }})
{{- else if $req -}}
{{ .AST.Fun.X }}.With(__ddzap.TraceFieldsFromRequest({{ $req }})...).{{ .AST.Fun.Name }}({{ range $i, $a := .AST.Args }}{{ if $i }}, {{ end }}{{ $a }}{{ end }}{{ if $ellipsis }}...{{ end }})
{{- else -}}
{{ . }}
{{- end -}}SugaredLogger.Debug|Info|Warn|Error|DPanic|Panic|Fatal|Log|Logf|Logw|Logln
All of
- Not
- One of
Replace the expression using the template:
// Using the following synthetic imports:
import (
__ddzap "github.com/DataDog/dd-trace-go/contrib/go.uber.org/zap/v2"
){{- $ctx := .Function.ArgumentOfType "context.Context" -}}
{{- if eq $ctx "" -}}
{{- $ctx = .Function.ArgumentThatImplements "context.Context" -}}
{{- end -}}
{{- $req := .Function.ArgumentOfType "*net/http.Request" -}}
{{- $ellipsis := .AST.Ellipsis -}}
{{- if $ctx -}}
{{ .AST.Fun.X }}.Desugar().With(__ddzap.TraceFields({{ $ctx }})...).Sugar().{{ .AST.Fun.Name }}({{ range $i, $a := .AST.Args }}{{ if $i }}, {{ end }}{{ $a }}{{ end }}{{ if $ellipsis }}...{{ end }})
{{- else if $req -}}
{{ .AST.Fun.X }}.Desugar().With(__ddzap.TraceFieldsFromRequest({{ $req }})...).Sugar().{{ .AST.Fun.Name }}({{ range $i, $a := .AST.Args }}{{ if $i }}, {{ end }}{{ $a }}{{ end }}{{ if $ellipsis }}...{{ end }})
{{- else -}}
{{ . }}
{{- end -}}