Instana tracer implementation
This commit is contained in:
parent
c2c6aee18a
commit
aef24dd74b
43 changed files with 4502 additions and 2 deletions
37
vendor/github.com/instana/go-sensor/eum.go
generated
vendored
Normal file
37
vendor/github.com/instana/go-sensor/eum.go
generated
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
package instana
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const eumTemplate string = "eum.js"
|
||||
|
||||
// EumSnippet generates javascript code to initialize JavaScript agent
|
||||
func EumSnippet(apiKey string, traceID string, meta map[string]string) string {
|
||||
|
||||
if len(apiKey) == 0 || len(traceID) == 0 {
|
||||
return ""
|
||||
}
|
||||
|
||||
b, err := ioutil.ReadFile(eumTemplate)
|
||||
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
var snippet = string(b)
|
||||
var metaBuffer bytes.Buffer
|
||||
|
||||
snippet = strings.Replace(snippet, "$apiKey", apiKey, -1)
|
||||
snippet = strings.Replace(snippet, "$traceId", traceID, -1)
|
||||
|
||||
for key, value := range meta {
|
||||
metaBuffer.WriteString(" ineum('meta', '" + key + "', '" + value + "');\n")
|
||||
}
|
||||
|
||||
snippet = strings.Replace(snippet, "$meta", metaBuffer.String(), -1)
|
||||
|
||||
return snippet
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue