Skip to content

Commit

Permalink
Merge pull request #22 from taboola/feature/support-Spring2.7
Browse files Browse the repository at this point in the history
Feature/support spring2.7
  • Loading branch information
Shahar-l-Taboola authored Dec 1, 2024
2 parents 77a4b6b + 06aece5 commit 86b71da
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 47 deletions.
18 changes: 6 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.taboola</groupId>
<artifactId>async-profiler-actuator-endpoint</artifactId>
<version>2.0.7</version>
<version>3.0.0</version>

<name>${project.groupId}:${project.artifactId}</name>
<description>Async Profiler Actuator Endpoint</description>
Expand Down Expand Up @@ -48,8 +48,7 @@

<properties>
<slf4j.version>1.7.13</slf4j.version>
<com.taboola.spring.version>4.3.23.RELEASE</com.taboola.spring.version>
<com.taboola.spring.boot.version>1.5.20.RELEASE</com.taboola.spring.boot.version>
<com.taboola.spring.boot.version>2.7.18</com.taboola.spring.boot.version>
<com.taboola.lombok.version>1.18.10</com.taboola.lombok.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
Expand All @@ -67,14 +66,9 @@
<version>0.13.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${com.taboola.spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${com.taboola.spring.version}</version>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>${com.taboola.spring.boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -172,4 +166,4 @@

</plugins>
</build>
</project>
</project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.taboola.async_profiler.spring;

import org.springframework.boot.actuate.endpoint.Endpoint;
import org.springframework.boot.actuate.endpoint.mvc.MvcEndpoint;
import org.springframework.boot.actuate.endpoint.web.annotation.RestControllerEndpoint;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
Expand All @@ -14,31 +13,15 @@
import com.taboola.async_profiler.api.facade.ProfileRequest;
import com.taboola.async_profiler.api.facade.ProfileResult;

public class AsyncProfilerEndpoint implements MvcEndpoint {
@RestControllerEndpoint(id = "async-profiler")
public class AsyncProfilerEndpoint {

public static final String BINARY_PROFILE_ATTACHMENT_HEADER_VALUE = "attachment; filename=profile.";

private final AsyncProfilerService asyncProfilerService;
private final boolean isSensitive;

public AsyncProfilerEndpoint(AsyncProfilerService asyncProfilerService, boolean isSensitive) {
public AsyncProfilerEndpoint(AsyncProfilerService asyncProfilerService) {
this.asyncProfilerService = asyncProfilerService;
this.isSensitive = isSensitive;
}

@Override
public String getPath() {
return "/async-profiler";
}

@Override
public boolean isSensitive() {
return isSensitive;
}

@Override
public Class<? extends Endpoint> getEndpointType() {
return null;
}

@GetMapping(value = "/profile", produces = MediaType.ALL_VALUE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.taboola.async_profiler.api.LabelsWrapper;
import com.taboola.async_profiler.api.continuous.pyroscope.PyroscopeReporterConfig;
import io.pyroscope.okhttp3.OkHttpClient;
import org.springframework.beans.factory.annotation.Value;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
Expand All @@ -30,7 +30,7 @@
public class AsyncProfilerEndpointConfig {

@Bean
@ConfigurationProperties("com.taboola.asyncProfiler")
@ConfigurationProperties("com.taboola.async-profiler")
public AsyncProfilerServiceConfigurations asyncProfilerServiceConfigurations() {
return new AsyncProfilerServiceConfigurations();
}
Expand Down Expand Up @@ -106,8 +106,7 @@ public AsyncProfilerService asyncProfilerService(AsyncProfilerFacade asyncProfil
}

@Bean
public AsyncProfilerEndpoint asyncProfilerEndpoint(AsyncProfilerService asyncProfilerService,
@Value("${com.taboola.asyncProfilerEndpoint.sensitive:false}") boolean isSensitive) {
return new AsyncProfilerEndpoint(asyncProfilerService, isSensitive);
public AsyncProfilerEndpoint asyncProfilerEndpoint(AsyncProfilerService asyncProfilerService) {
return new AsyncProfilerEndpoint(asyncProfilerService);
}
}
2 changes: 2 additions & 0 deletions src/main/resources/META-INF/spring.factories
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.taboola.async_profiler.spring.AsyncProfilerEndpointConfig
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.taboola.async_profiler.spring;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.same;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
Expand Down Expand Up @@ -39,7 +37,7 @@ public class AsyncProfilerEndpointTest {
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
asyncProfilerEndPoint = new AsyncProfilerEndpoint(asyncProfilerService, false);
asyncProfilerEndPoint = new AsyncProfilerEndpoint(asyncProfilerService);
}

@Test
Expand Down Expand Up @@ -115,10 +113,4 @@ public void testGetVersion() {
when(asyncProfilerService.getProfilerVersion()).thenReturn("1");
assertEquals("1", asyncProfilerEndPoint.getVersion());
}

@Test
public void testIsSensitive() {
assertFalse(new AsyncProfilerEndpoint(asyncProfilerService, false).isSensitive());
assertTrue(new AsyncProfilerEndpoint(asyncProfilerService, true).isSensitive());
}
}

0 comments on commit 86b71da

Please sign in to comment.