Skip to content

Handle panic in handle code? #165

Open
@epot

Description

@epot

Expected Behavior

I am sorry I am not sure if it's a bug report, something I misunderstood or...

Basically, I noticed that since I migrated my lambda to this library to leverage APM/logs/metrics in Datadog (which is pretty awesome), I am not able to monitor panics anymore. I have the following code:

func main() {
	lambda.Start(ddlambda.WrapFunction(handle, nil))
}

and the handle method returns (string, error) as expected. But if the code panics instead of returning an error, then I do not see any trace in APM and I have an INFO log that is not correctly parsed that looks like this:

{"errorMessage":"interface conversion: interface {} is nil, not string","errorType":"TypeAssertionError","stackTrace":[{"path":"github.com/aws/[email protected]/lambda/errors.go","line":39,"label":"lambdaPanicResponse"},{"path":"github.com/aws/[email protected]/lambda/invoke_loop.go","line":122,"label":"callBytesHandlerFunc.func1"},{"path":"runtime/panic.go","line":914,"label":"gopanic"},{"path":"runtime/iface.go","line":263,"label":"panicdottypeE"},{"path":"work/warpstream/warpstream/scripts/lambdas/signups/signups.go","line":114,"label":"CheckRecentSignups"},{"path":"work/warpstream/warpstream/scripts/lambdas/signups/signups.go","line":62,"label":"RunLamdba"},{"path":"common/main.go","line":71,"label":"handle"},{"path":"reflect/value.go","line":596,"label":"Value.call"},{"path":"reflect/value.go","line":380,"label":"Value.Call"},{"path":"github.com/!data!dog/[email protected]/internal/wrapper/wrap_handler.go","line":161,"label":"callHandler"},{"path":"github.com/!data!dog/[email protected]/internal/wrapper/wrap_handler.go","line":61,"label":"WrapHandlerWithListeners.func1"},{"path":"reflect/value.go","line":596,"label":"Value.call"},{"path":"reflect/value.go","line":380,"label":"Value.Call"},{"path":"github.com/aws/[email protected]/lambda/handler.go","line":355,"label":"reflectHandler.func2"},{"path":"github.com/aws/[email protected]/lambda/invoke_loop.go","line":125,"label":"callBytesHandlerFunc"},{"path":"github.com/aws/[email protected]/lambda/invoke_loop.go","line":75,"label":"handleInvoke"},{"path":"github.com/aws/[email protected]/lambda/invoke_loop.go","line":39,"label":"startRuntimeAPILoop"},{"path":"github.com/aws/[email protected]/lambda/entry.go","line":106,"label":"start"},{"path":"github.com/aws/[email protected]/lambda/entry.go","line":69,"label":"StartWithOptions"},{"path":"github.com/aws/[email protected]/lambda/entry.go","line":45,"label":"Start"},{"path":"common/main.go","line":90,"label":"main"},{"path":"runtime/proc.go","line":267,"label":"main"},{"path":"runtime/asm_amd64.s","line":1650,"label":"goexit"}]}

Actual Behavior

I was hoping to get a failing trace in APM and an error log attached to it.

Specifications

  • Datadog Go Lambda package version: v1.13.0
  • Go version: 1.22

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions