contrib/gin-gonic/gin

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/gin-gonic/gin/v2" // integration
	//...
)

Gin is a web framework written in Go.

New

Join Point
One of
Advice
Replace the expression using the template:
// Using the following synthetic imports:
import (
	gin "github.com/gin-gonic/gin"
	gintrace "github.com/DataDog/dd-trace-go/contrib/gin-gonic/gin/v2"
)
func() *gin.Engine {
	e := {{ . }}
	e.Use(gintrace.Middleware(""))
	return e
}()

gin.Context.[Must]Bind

Join Point
Function body
  • One of
    • Function declaration
    • Function declaration
    • Function declaration
    • Function declaration
    • Function declaration
    • Function declaration
    • Function declaration
    • Function declaration
    • Function declaration
    • Function declaration
Advice
Prepend statements produced by the following template:
// Using the following synthetic imports:
import (
	appsec "github.com/DataDog/dd-trace-go/v2/appsec"
)
{{- $c := .Function.Receiver -}}
{{- $i := .Function.Argument 0 -}}
{{- $err := .Function.Result 0 -}}
defer func() {
	if {{ $err }} != nil {
		return
	}
	{{ $err }} = appsec.MonitorParsedHTTPBody({{ $c }}.Request.Context(), {{ $i }})
}()

Response.Body

Join Point
Function body
  • One of
    • Function declaration
    • Function declaration
    • Function declaration
    • Function declaration
    • Function declaration
    • Function declaration
    • Function declaration
    • Function declaration
    • Function declaration
    • Function declaration
Advice
Prepend statements produced by the following template:
// Using the following synthetic imports:
import (
	appsec "github.com/DataDog/dd-trace-go/v2/appsec"
)
{{- $c := .Function.Receiver -}}
{{- $i := .Function.Argument 1 -}}
if __err__ := appsec.MonitorHTTPResponseBody({{ $c }}.Request.Context(), {{ $i }}); __err__ != nil {
	// Request has been blocked by AppSec; aborting this handler right away. The AppSec
	// handlers in the middleware chain will send the configured blocking response.
	return
}