Skip to content

Commit

Permalink
[OING-184] chore: MicroMeter Prometheus 구현체 추가 (#136)
Browse files Browse the repository at this point in the history
* chore: Add micrometer prometheus and configs

* chore: Remove metrics endpoints from application.yaml for actuaor

* fix: Fix broken CalendarApiTest by making optimizing query public
  • Loading branch information
Kwon770 authored and CChuYong committed Feb 1, 2024
1 parent e73d260 commit 9bd50d9
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 16 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ subprojects {
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0'
runtimeOnly 'io.micrometer:micrometer-registry-prometheus'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-security'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
@Component
public class OptimizedImageUrlProvider implements OptimizedImageUrlGenerator {

private static final String THUMBNAIL_OPTIMIZER_QUERY_STRING = "type=f&w=96&h=96&quality=70&autorotate=false&faceopt=false";
private static final String KB_IMAGE_OPTIMIZER_QUERY_STRING = "?type=f&w=480&h=480&faceopt=false&quality=50&autorotate=false";
public static final String THUMBNAIL_OPTIMIZER_QUERY_STRING = "type=f&w=96&h=96&quality=70&autorotate=false&faceopt=false";
public static final String KB_IMAGE_OPTIMIZER_QUERY_STRING = "?type=f&w=480&h=480&faceopt=false&quality=50&autorotate=false";

@Value("${cloud.ncp.image-optimizer-cdn}")
private String imageOptimizerCdnUrl;
Expand Down
2 changes: 0 additions & 2 deletions gateway/src/main/resources/application-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,3 @@ cloud:
storage:
bucket: bucket
image-optimizer-cdn: https://cdn.com
thumbnail-optimizer-query: ?type=f&w=96&h=96&quality=70&align=4&faceopt=false&anilimit=1
kb-optimizer-query: ?type=f&w=480&h=480&faceopt=false&quality=50&autorotate=false
6 changes: 6 additions & 0 deletions gateway/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,9 @@ springdoc:
display-request-duration: true
operations-sorter: alpha
tags-sorter: alpha

management:
endpoints:
web:
exposure:
include: health,info,prometheus
11 changes: 5 additions & 6 deletions gateway/src/test/java/com/oing/restapi/CalendarApiTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.oing.restapi;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.oing.config.support.OptimizedImageUrlProvider;
import com.oing.domain.CreateNewUserDTO;
import com.oing.domain.SocialLoginProvider;
import com.oing.dto.request.JoinFamilyRequest;
Expand Down Expand Up @@ -65,8 +66,6 @@ class CalendarApiTest {

@Value("${cloud.ncp.image-optimizer-cdn}")
private String imageOptimizerCdn;
@Value("${cloud.ncp.thumbnail-optimizer-query}")
private String thumbnailOptimizerQuery;


@BeforeEach
Expand Down Expand Up @@ -160,19 +159,19 @@ void setUp() {
.andExpect(status().isOk())
.andExpect(jsonPath("$.results[0].date").value("2023-11-01"))
.andExpect(jsonPath("$.results[0].representativePostId").value("2"))
.andExpect(jsonPath("$.results[0].representativeThumbnailUrl").value(imageOptimizerCdn + "/images/2" + thumbnailOptimizerQuery))
.andExpect(jsonPath("$.results[0].representativeThumbnailUrl").value(imageOptimizerCdn + "/images/2" + OptimizedImageUrlProvider.THUMBNAIL_OPTIMIZER_QUERY_STRING))
.andExpect(jsonPath("$.results[0].allFamilyMembersUploaded").value(true))
.andExpect(jsonPath("$.results[1].date").value("2023-11-02"))
.andExpect(jsonPath("$.results[1].representativePostId").value("4"))
.andExpect(jsonPath("$.results[1].representativeThumbnailUrl").value(imageOptimizerCdn + "/images/4" + thumbnailOptimizerQuery))
.andExpect(jsonPath("$.results[1].representativeThumbnailUrl").value(imageOptimizerCdn + "/images/4" + OptimizedImageUrlProvider.THUMBNAIL_OPTIMIZER_QUERY_STRING))
.andExpect(jsonPath("$.results[1].allFamilyMembersUploaded").value(false))
.andExpect(jsonPath("$.results[2].date").value("2023-11-29"))
.andExpect(jsonPath("$.results[2].representativePostId").value("6"))
.andExpect(jsonPath("$.results[2].representativeThumbnailUrl").value(imageOptimizerCdn + "/images/6" + thumbnailOptimizerQuery))
.andExpect(jsonPath("$.results[2].representativeThumbnailUrl").value(imageOptimizerCdn + "/images/6" + OptimizedImageUrlProvider.THUMBNAIL_OPTIMIZER_QUERY_STRING))
.andExpect(jsonPath("$.results[2].allFamilyMembersUploaded").value(true))
.andExpect(jsonPath("$.results[3].date").value("2023-11-30"))
.andExpect(jsonPath("$.results[3].representativePostId").value("8"))
.andExpect(jsonPath("$.results[3].representativeThumbnailUrl").value(imageOptimizerCdn + "/images/8" + thumbnailOptimizerQuery))
.andExpect(jsonPath("$.results[3].representativeThumbnailUrl").value(imageOptimizerCdn + "/images/8" + OptimizedImageUrlProvider.THUMBNAIL_OPTIMIZER_QUERY_STRING))
.andExpect(jsonPath("$.results[3].allFamilyMembersUploaded").value(false));

}
Expand Down
11 changes: 5 additions & 6 deletions gateway/src/test/java/com/oing/restapi/WidgetApiTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.oing.restapi;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.oing.config.support.OptimizedImageUrlProvider;
import com.oing.domain.CreateNewUserDTO;
import com.oing.domain.Member;
import com.oing.domain.MemberPost;
Expand Down Expand Up @@ -66,8 +67,6 @@ class WidgetApiTest {

@Value("${cloud.ncp.image-optimizer-cdn}")
private String imageOptimizerCdn;
@Value("${cloud.ncp.kb-optimizer-query}")
private String kbOptimizerQuery;


@BeforeEach
Expand Down Expand Up @@ -161,8 +160,8 @@ void setUp() throws Exception {
)
.andExpect(status().isOk())
.andExpect(jsonPath("$.authorName").value(TEST_MEMBER2.getName()))
.andExpect(jsonPath("$.authorProfileImageUrl").value(imageOptimizerCdn + "/images/2" + kbOptimizerQuery))
.andExpect(jsonPath("$.postImageUrl").value(imageOptimizerCdn + "/images/2" + kbOptimizerQuery))
.andExpect(jsonPath("$.authorProfileImageUrl").value(imageOptimizerCdn + "/images/2" + OptimizedImageUrlProvider.KB_IMAGE_OPTIMIZER_QUERY_STRING))
.andExpect(jsonPath("$.postImageUrl").value(imageOptimizerCdn + "/images/2" + OptimizedImageUrlProvider.KB_IMAGE_OPTIMIZER_QUERY_STRING))
.andExpect(jsonPath("$.postContent").value(testPost2.getContent()));

}
Expand Down Expand Up @@ -203,8 +202,8 @@ void setUp() throws Exception {
)
.andExpect(status().isOk())
.andExpect(jsonPath("$.authorName").value(TEST_MEMBER2.getName()))
.andExpect(jsonPath("$.authorProfileImageUrl").value(imageOptimizerCdn + "/images/2" + kbOptimizerQuery))
.andExpect(jsonPath("$.postImageUrl").value(imageOptimizerCdn + "/images/2" + kbOptimizerQuery))
.andExpect(jsonPath("$.authorProfileImageUrl").value(imageOptimizerCdn + "/images/2" + OptimizedImageUrlProvider.KB_IMAGE_OPTIMIZER_QUERY_STRING))
.andExpect(jsonPath("$.postImageUrl").value(imageOptimizerCdn + "/images/2" + OptimizedImageUrlProvider.KB_IMAGE_OPTIMIZER_QUERY_STRING))
.andExpect(jsonPath("$.postContent").value(testPost2.getContent()));

}
Expand Down

0 comments on commit 9bd50d9

Please sign in to comment.