Skip to content

Commit

Permalink
feat: add X-Ray tracing configuration to CLI and Plugin struct (#24)
Browse files Browse the repository at this point in the history
- Add a new CLI flag for X-Ray tracing configuration
- Update `Plugin` struct with a new `TracingMode` field
- Set the new `TracingMode` field in `Exec` method if provided in the config
  • Loading branch information
appleboy authored Apr 1, 2023
1 parent a38d7a7 commit a2bdfc0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ func main() {
Usage: "A description of the function.",
EnvVars: []string{"PLUGIN_DESCRIPTION", "DESCRIPTION", "INPUT_DESCRIPTION"},
},
&cli.StringFlag{
Name: "tracing-mode",
Usage: "The function's X-Ray tracing configuration.",
EnvVars: []string{"PLUGIN_TRACING_MODE", "TRACING_MODE", "INPUT_TRACING_MODE"},
},
}

if err := app.Run(os.Args); err != nil {
Expand Down Expand Up @@ -210,6 +215,7 @@ func run(c *cli.Context) error {
SecurityGroups: c.StringSlice("securitygroups"),
Description: c.String("description"),
SessionToken: c.String("session-token"),
TracingMode: c.String("tracing-mode"),
},
Commit: Commit{
Sha: c.String("commit.sha"),
Expand Down
8 changes: 8 additions & 0 deletions plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type (
Description string
Layers []string
SessionToken string
TracingMode string
}

// Commit information.
Expand Down Expand Up @@ -213,6 +214,13 @@ func (p Plugin) Exec() error {
})
}

if p.Config.TracingMode != "" {
isUpdateConfig = true
cfg.SetTracingConfig(&lambda.TracingConfig{
Mode: aws.String(p.Config.TracingMode),
})
}

svc := lambda.New(sess, config)

if isUpdateConfig {
Expand Down

0 comments on commit a2bdfc0

Please sign in to comment.