Skip to content
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

3528 add monitoring tags #3550

Merged
merged 5 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
dfitchett marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Service;

Expand All @@ -19,6 +20,21 @@ public class MetricLoggerService implements IMetricLoggerService {

private final MetricsApi metricsApi;

@Value("${vro.env}")
public final String env;

@Value("${vro.it-portfolio:benefits-delivery}")
public final String itPortfolio;

@Value("${vro.team:va-abd-rrd}")
public final String team;

@Value("${vro.app.name}")
dfitchett marked this conversation as resolved.
Show resolved Hide resolved
public final String service;

@Value("${vro.app.dependency:")
public final String dependency;
dfitchett marked this conversation as resolved.
Show resolved Hide resolved

public static double getTimestamp() {
return Long.valueOf(OffsetDateTime.now().toInstant().getEpochSecond()).doubleValue();
}
Expand All @@ -43,6 +59,15 @@ public ArrayList<String> getTagsForSubmission(String[] customTags) {
if (customTags != null) {
tags.addAll(Arrays.asList(customTags));
}

tags.add("env:" + env);
tags.add("itportfolio:" + itPortfolio);
tags.add("team:" + team);
tags.add("service:" + service);
if (dependency != null && !dependency.isEmpty()) {
dfitchett marked this conversation as resolved.
Show resolved Hide resolved
tags.add("dependency:" + dependency);
}

return tags;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

public class MetricLoggerServiceTest {

private MetricLoggerService mls = new MetricLoggerService(new MetricsApi());
private MetricLoggerService mls = new MetricLoggerService(new MetricsApi(), "", "", "", "", "");
private static final String METRICS_PREFIX = "vro_short_app_name";

@Test
void testConstructors() {
try {
new MetricLoggerService(new MetricsApi());
new MetricLoggerService(new MetricsApi(), "", "", "", "", "");
} catch (Exception e) {
fail("Constructor failed", e);
}
Expand Down Expand Up @@ -63,13 +63,13 @@ void getTagsForSubmission() {
mls.getTagsForSubmission(new String[] {"source:integration-test", "version:2.1"});
assertTrue(tags.contains("source:integration-test"));
assertTrue(tags.contains("version:2.1"));
assertEquals(tags.size(), 2);
assertEquals(tags.size(), 6);
}

@Test
void getTagsForSubmissionNoCustomTags() {
List<String> tags = mls.getTagsForSubmission(null);
assertEquals(0, tags.size());
assertEquals(4, tags.size());
}

@Test
Expand Down Expand Up @@ -128,7 +128,7 @@ void testCreateDistributionPointsPayload() {
@Test
void testSubmitCountCallsApiWithPayload() {
MetricsApi metricsApi = mock(MetricsApi.class);
MetricLoggerService mls = new MetricLoggerService(metricsApi);
MetricLoggerService mls = new MetricLoggerService(metricsApi, "", "", "", "", "");
mls.submitCount(METRICS_PREFIX, IMetricLoggerService.METRIC.RESPONSE_COMPLETE, null);
mls.submitCount(METRICS_PREFIX, IMetricLoggerService.METRIC.RESPONSE_COMPLETE, 3.0, null);
try {
Expand All @@ -141,7 +141,7 @@ void testSubmitCountCallsApiWithPayload() {
@Test
void testSubmitRequestDurationCallsApiWithPayload() {
MetricsApi metricsApi = mock(MetricsApi.class);
MetricLoggerService mls = new MetricLoggerService(metricsApi);
MetricLoggerService mls = new MetricLoggerService(metricsApi, "", "", "", "", "");
mls.submitRequestDuration("app_name_placeholder", 100, 200, null);
try {
verify(metricsApi, times(1))
Expand Down
6 changes: 6 additions & 0 deletions svc-bie-kafka/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,9 @@ management:
group:
liveness.include: livenessState
readiness.include: readinessState

vro:
env: ${ENV}
app:
name: vro-svc-bie-kafka
dependency: bie
6 changes: 6 additions & 0 deletions svc-bip-api/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,9 @@ management:
truststore: ${BIP_TRUSTSTORE}
keystore: ${BIP_KEYSTORE}
truststore_password: ${BIP_PASSWORD}

vro:
env: ${ENV}
app:
name: vro-svc-bip-api
dependency: bip
dfitchett marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

class RabbitMqApiConfigTest {

private final MetricLoggerService metricLoggerService = new MetricLoggerService(new MetricsApi());
private final MetricLoggerService metricLoggerService =
new MetricLoggerService(new MetricsApi(), "", "", "", "", "");

@Test
@SuppressWarnings({"unchecked", "rawtypes"})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
class BipRequestErrorHandlerTest {
private static final String CLAIM_RESPONSE_404 = "bip-test-data/claim_response_404.json";

private final MetricLoggerService metricLoggerService = new MetricLoggerService(new MetricsApi());
private final MetricLoggerService metricLoggerService =
new MetricLoggerService(new MetricsApi(), "", "", "", "", "");

enum HttpStatusCodeTestCase {
NOT_FOUND(new HttpClientErrorException(HttpStatus.NOT_FOUND)),
Expand Down