Skip to content

Commit a2bdfc0

Browse files
authored
feat: add X-Ray tracing configuration to CLI and Plugin struct (#24)
- 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
1 parent a38d7a7 commit a2bdfc0

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,11 @@ func main() {
174174
Usage: "A description of the function.",
175175
EnvVars: []string{"PLUGIN_DESCRIPTION", "DESCRIPTION", "INPUT_DESCRIPTION"},
176176
},
177+
&cli.StringFlag{
178+
Name: "tracing-mode",
179+
Usage: "The function's X-Ray tracing configuration.",
180+
EnvVars: []string{"PLUGIN_TRACING_MODE", "TRACING_MODE", "INPUT_TRACING_MODE"},
181+
},
177182
}
178183

179184
if err := app.Run(os.Args); err != nil {
@@ -210,6 +215,7 @@ func run(c *cli.Context) error {
210215
SecurityGroups: c.StringSlice("securitygroups"),
211216
Description: c.String("description"),
212217
SessionToken: c.String("session-token"),
218+
TracingMode: c.String("tracing-mode"),
213219
},
214220
Commit: Commit{
215221
Sha: c.String("commit.sha"),

plugin.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ type (
4545
Description string
4646
Layers []string
4747
SessionToken string
48+
TracingMode string
4849
}
4950

5051
// Commit information.
@@ -213,6 +214,13 @@ func (p Plugin) Exec() error {
213214
})
214215
}
215216

217+
if p.Config.TracingMode != "" {
218+
isUpdateConfig = true
219+
cfg.SetTracingConfig(&lambda.TracingConfig{
220+
Mode: aws.String(p.Config.TracingMode),
221+
})
222+
}
223+
216224
svc := lambda.New(sess, config)
217225

218226
if isUpdateConfig {

0 commit comments

Comments
 (0)