You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: recorder_default.go
    path of file: ./repos/sharingan/plugins
    
    the code of the file until where you have to start completion: package plugins

import (
	"bytes"
	"encoding/json"
	"io/ioutil"
	"log"
	"net"
	"net/http"
	"os"
	"path"
	"time"

	"github.com/didi/sharingan/recorder"
	"github.com/didi/sharingan/recorder/koala/recording"
	"github.com/didi/s
    
func (r *DefaultRecorder) Record(session *recording.Session) {
	defer func() {
		if err := recover(); err != nil {
			countlog.Fatal("event!kafka_recorder.panic", "err", err,
				"stacktrace", countlog.ProvideStacktrace)
		}
	}()

	// set trace Info
	{
		http := utils.NewHTTP()
		http.ParseRequest(session.CallFromInbound.Request)
		session.TraceID = http.Header["xxx-header-traceid"] // can custom
		session.SpanID = http.Header["xxx-header-spanid"]   // can custom
	}

	// set hostname
	{
		session.Context += r.hostname + " "
	}

	var (
		b   []byte // session bytes which tobe recorder
		err error
	)

	// Marshal session to b
	if b, err = json.Marshal(session); err != nil {
		countlog.Error("event!recorder.failed to marshal session", "err", err, "session", session)
		return
	}

	// case 1: recorder to local dir [offline use]
	if r.localDir != "" {
		err := ioutil.WriteFile(path.Join(r.localDir, session.SessionID), b, 0666)
		if err != nil {
			countlog.Error("event!recorder.failed to record to localDir", "err", err, "localDir", r.localDir)
			return
		}
	}

	// case 2: recorder to local file [offline use]
	if r.localFile != "" {
		f, err := os.OpenFile(r.localFile, os.O_CREATE|os.O_APPEND|os.O_RDWR, 0666)
		if err != nil {
			countlog.Error("event!recorder.failed to record to localFile", "err", err, "localFile", r.localFile)
			return
		}
		defer f.Close()
		f.Write(b)
		f.WriteString("\n")
	}

	// case 3: recorder to remote agent [to recorder-agent or ES]
	if r.agentAddr != "" {
		recorder.SetDelegatedFromGoRoutineID(-1)
		defer recorder.SetDelegatedFromGoRoutineID(0)

		resp, err := r.agentClient.Post(r.agentAddr, "application/json", bytes.NewBuffer(b))
		if err != nil {
			countlog.Warn("event!recorder.failed to record to agent", "err", err, "agentAddr", r.agentAddr)
			return
		}
		resp.Body.Close()
	}

	// default console output
	if r.localDir == "" && r.localFile == "" && r.agentAddr == "" {
		log.Println(string(b))
	}
}