Skip to content

Support Spring @Cacheable #1800

@Nankh

Description

@Nankh

Hi Team,
First, thank you for the incredible work you've done on this amazing project.

Describe the bug
When using Spring @Cacheable annotation within a redis implementation, I can't see any span reported to zipkin.
Spring Cloud : 2.2.6.RELEASE
Spring-Boot : 2.3.5.RELEASE

Sample
Here a sample and simple code for Cacheable usage
The main controller...

 @RequestMapping(value = "/user/v1/{idUser}",
        produces = { "application/json" }, 
        method = RequestMethod.GET)
public ResponseEntity<String> getUser(Integer idUser) {
        Optional<String> userInformation = myService.getUserName(idUser);
        return userInformation.isEmpty() ? ResponseEntity.noContent().build() : ResponseEntity.ok(userInformation.get());
    }

The service...

 @Cacheable(value = "myCacheNameInRedis")
    public Optional<String> getUserName(Integer idUser) {
        //call repository with idUser;
    }

Dependencies used :

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-sleuth</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-zipkin</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>

Thank you

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions