question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hi guys, Are there plans to create an example for this using Spring AOP for cross-cutting concerns like X-Ray? Currently we are trying to avoid many responsibilities in the code that don’t belong to the class, and for that we are using AOP. This is an example of what we are doing, but it is not working in the case of errors.

@Aspect
public class XRayAspect {

    private Logger logger = LoggerFactory.getLogger(XRayAspect.class);

    @Pointcut("@annotation(com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand) && execution(* *(..))")
    public void annotationHystrixPointCut() {

    }

    @Before("annotationHystrixPointCut()")
    public void createSubsegment(JoinPoint joinPoint) {
        logger.info("---------------------- it executed before " + joinPoint);
        AWSXRay.getThreadLocal().addSubsegment(AWSXRay.beginSubsegment(joinPoint.getSignature().getName()));

    }

    @AfterThrowing(pointcut = "annotationHystrixPointCut()", throwing = "ex")
    public void addExceptiontoSubSegment(Exception ex) {
        logger.error("---------------------- it happened an error ", ex);
        AWSXRay.getCurrentSubsegment().addException(ex);
    }

    @After("annotationHystrixPointCut()")
    public void finalizeSubsegment() {

        logger.info("---------------------- it happened after ");
        AWSXRay.endSubsegment();
    }
}

I would appreciate any feedback you could provide.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
mwunderlcommented, Sep 20, 2017
0reactions
paolocarrascocommented, Sep 20, 2017

Hi @mwunderl, thanks! I finally found that the best approach to register the exceptions is by using an around aspect; before and after are useful only on annotations and metadata.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Aspect-Oriented Programming for AWS X-Ray Using Spring
An aspect-oriented approach is a perfect way to implement AWS X-Ray because it keeps the underlying code clean and provides non-invasive, ...
Read more >
Aspect Ratios in Underwater Imaging | X-Ray Mag
In simple words, aspect ratios are about image proportions. The right proportion can give the final kick to an image. Aspect ratio is...
Read more >
X-ray Radiographic Patient Positioning - StatPearls - NCBI - NIH
The lateral aspect of the ankle is generally placed against the receptor with an X-ray beam directed from medial to lateral.
Read more >
Practical Aspects of X-ray Measurement, with Special ...
We should seek a unit of quantity which is fundamental, determined by a property of the rays themselves, and measurable to an exact...
Read more >
Knowing right from left on X-rays: A way to minimize errors ...
Errors in laterality identification on radiographic images can lead to unnecessary repeat radiographic exposures or even errors in therapeutic or surgical ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found