-
Notifications
You must be signed in to change notification settings - Fork 90
@Logging annotation with logEvent = true does not play nice with @Tracing annotation in RequestStreamHandler #277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi, @allenada Thanks for opening an issue with detailed information. I will have a look at it sometime this week. |
I did have some time to take a deeper look into this myself. Looks like if you change LambdaLoggingAspect.java#L78 to the following then the issue is resolved (at least in my local unit test):
|
I did managed to replicate the issue and also understand the problem, which exists only if you are using input stream version of handler together with tracing and logging together. I haven't find a proper solution yet, but I will check the solution which you mentioned as well and also dive a bit more deeper this week. In the meantime(while we fix this) I am sure there must be reasons on using stream handler version, but if it helps, you may also switch the lambda function handler to the request handler implementation. |
I am planning to revisit this issue sometime this week. |
I am using Lambda Powertools Java to capture logs, metrics, and traces for my REST service running in Lambda. I am using RequestStreamHandler to forward ApiGateway request to a JerseyLambdaContainerHandler containing handling for my various endpoints proxied by ApiGateway.
Using
@Logging(logEvent = true)
and@Tracing
together causes theJerseyLambdaContainerHandler
to not process the request as the InputStream has been read from already due to the(logEvent = true)
specification on the@Logging
annotation. I do not see these errors using@Logging
and@Tracing
together, just@Logging(logEvent = true)
alone, or just@Tracing
alone.How has this issue affected you? What are you trying to accomplish?
I attempted to use both
@Tracing
and@Logging(logEvent = true)
on the same handler method implementing RequestStreamHandlerThe handler method is unable to process the request due to:
I am able to work around it by resetting the
InputStream
on the first line of the handler. My method:What were you trying to accomplish?
To use the powertools annotations on my RequestStreamHandler without needing to reset
inputStream
Expected Behavior
The inputStream should not be exhausted after the powertools aspects run before my method
Current Behavior
The inputStream is exhausted by the powertools aspects run before my method
Possible Solution
I believe this post details the issue but I'm not an expert in AspectJ (just consuming it here). That post and answer implies that LambdaLoggingAspect.java#L174 is not actually working so when
LambdaTracingAspect
runs after theLambdaLoggingAspect
, it is not actually getting the updated parameters. However, it does not throw this error if I use the@Logging(logEvent = true)
annotation without the@Tracing
annotation which I do not understand in the context of the above hypothesis so I'm doubtful of my own hypothesis for that reason.Steps to Reproduce (for bugs)
@Logging(logEvent=true)
and@Tracing
InputStream
Environment
The text was updated successfully, but these errors were encountered: