Skip to content

Commit

Permalink
Merge pull request #9 from axiomhq/add-field-for-dataset-detection
Browse files Browse the repository at this point in the history
attach axiom object for automatic dataset detection
  • Loading branch information
lukasmalkmus authored Feb 14, 2023
2 parents aade7fe + c883e67 commit bb6ea95
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (

"github.com/axiomhq/axiom-go/axiom"
"go.uber.org/zap"

"github.com/axiomhq/axiom-lambda-extension/version"
)

type Server struct {
Expand All @@ -30,6 +32,7 @@ var (
AWS_LAMBDA_INITIALIZATION_TYPE = os.Getenv("AWS_LAMBDA_INITIALIZATION_TYPE")
AWS_LAMBDA_FUNCTION_MEMORY_SIZE, _ = strconv.ParseInt(os.Getenv("AWS_LAMBDA_FUNCTION_MEMORY_SIZE"), 10, 32)
lambdaMetaInfo = map[string]any{}
axiomMetaInfo = map[string]string{}
)

func init() {
Expand All @@ -43,6 +46,9 @@ func init() {
"memorySizeMB": AWS_LAMBDA_FUNCTION_MEMORY_SIZE,
"version": AWS_LAMBDA_FUNCTION_VERSION,
}
axiomMetaInfo = map[string]string{
"awsLambdaExtensionVersion": version.Get(),
}
}

func New(port string, axClient *axiom.Client, axDataset string) *Server {
Expand Down Expand Up @@ -78,6 +84,7 @@ func (s *Server) httpHandler(w http.ResponseWriter, r *http.Request) {
for _, e := range events {
// attach the lambda information to the event
e["lambda"] = lambdaMetaInfo
e["axiom"] = axiomMetaInfo
// replace the time field with axiom's _time
e["_time"], e["time"] = e["time"], nil
}
Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package version

// manually set constant version
const version string = "v1"
const version string = "v2"

// Get returns the Go module version of the axiom-go module.
func Get() string {
Expand Down

0 comments on commit bb6ea95

Please sign in to comment.