github.com/newrelic/go-agent@v3.26.0+incompatible/internal/tools/uncompress-serverless/main.go (about) 1 // Copyright 2020 New Relic Corporation. All rights reserved. 2 // SPDX-License-Identifier: Apache-2.0 3 4 package main 5 6 import ( 7 "encoding/json" 8 "fmt" 9 "github.com/newrelic/go-agent/internal" 10 "os" 11 ) 12 13 // This tool will take an encoded, compressed serverless payload and print it out in a human readable format. 14 // To use it on a Mac with Bash, copy the payload to the clipboard (the whole thing - `[2,"NR_LAMBDA_MONITORING",{"metadata_version"...]` 15 // without backticks) and then run the app using pbpaste. Example from the root of the project directory: 16 // 17 // go run internal/tools/uncompress-serverless/main.go $(pbpaste) 18 func main() { 19 20 compressed := []byte(os.Args[1]) 21 metadata, uncompressedData, e := internal.ParseServerlessPayload(compressed) 22 if nil != e { 23 panic(e) 24 } 25 js, _ := json.MarshalIndent(map[string]interface{}{"metadata": metadata, "data": uncompressedData}, "", " ") 26 fmt.Println(string(js)) 27 28 }