github.com/lulzWill/go-agent@v2.1.2+incompatible/internal/intrinsics.go (about)

     1  package internal
     2  
     3  import (
     4  	"bytes"
     5  )
     6  
     7  func addOptionalStringField(w *jsonFieldsWriter, key, value string) {
     8  	if value != "" {
     9  		w.stringField(key, value)
    10  	}
    11  }
    12  
    13  func intrinsicsJSON(e *TxnEvent, buf *bytes.Buffer) {
    14  	if e.CrossProcess.Used() {
    15  		buf.WriteByte('{')
    16  		w := jsonFieldsWriter{buf: buf}
    17  
    18  		addOptionalStringField(&w, "client_cross_process_id", e.CrossProcess.ClientID)
    19  		addOptionalStringField(&w, "trip_id", e.CrossProcess.TripID)
    20  		addOptionalStringField(&w, "path_hash", e.CrossProcess.PathHash)
    21  		addOptionalStringField(&w, "referring_transaction_guid", e.CrossProcess.ReferringTxnGUID)
    22  
    23  		if e.CrossProcess.IsSynthetics() {
    24  			addOptionalStringField(&w, "synthetics_resource_id", e.CrossProcess.Synthetics.ResourceID)
    25  			addOptionalStringField(&w, "synthetics_job_id", e.CrossProcess.Synthetics.JobID)
    26  			addOptionalStringField(&w, "synthetics_monitor_id", e.CrossProcess.Synthetics.MonitorID)
    27  		}
    28  
    29  		buf.WriteByte('}')
    30  	} else {
    31  		buf.WriteString(`{}`)
    32  	}
    33  }