Skip to content

Commit b391b18

Browse files
committed
update to reduce volume of debug log messages, and also the display of
passwords etc. in the log data
1 parent 70e616e commit b391b18

8 files changed

Lines changed: 37 additions & 30 deletions

File tree

IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/normalizeddata/timeseriesdb/TimeSeriesDBCredentials.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,14 @@ public class TimeSeriesDBCredentials {
6767
@Property(name = TimeSeriesDBProperties.TIME_SERIES_PROPERTY_OAUTH_DATABASE_NAME)
6868
@JsonProperty(value = "database_name")
6969
private String database_name;
70+
71+
/**
72+
* a to string that does not display confidential info
73+
*
74+
* @return
75+
*/
76+
public String safeToString() {
77+
return "TimeSeriesDBCredentials[username" + username + ", password=XXXXX, tennant_name=XXXXX, database_name="
78+
+ database_name + "]";
79+
}
7080
}

IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/normalizeddata/timeseriesdb/TimeSeriesDBOutputOTLP.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,6 @@ public TimeSeriesDBOutputOTLP(DeviceModelInstancesCache deviceModelInstancesCach
9797
this.sentDataIsCompleted = sentDataIsCompleted;
9898
}
9999

100-
@Property(name = "messagehandler.output.normalizeddata.timeseries.doupload", defaultValue = "true")
101-
private boolean doUpload;
102-
103100
@Override
104101
public int getOrder() {
105102
return order;
@@ -133,15 +130,15 @@ public NormalizedData[] processNormalizedData(NormalizedData normalizedData) thr
133130
log.info(() -> "Uploading url=" + metricsClientUrl + ", path=" + metricsPath + ", queryX=" + queryX
134131
+ ", queryY=" + queryY);
135132

136-
if (doUpload) {
137-
HttpResponse<String> resp = metricsClient.uploadMetrics(queryX, queryY, metricsDataString);
138-
log.info("Upload response is " + resp.getBody().orElse("No response data"));
139-
}
133+
HttpResponse<String> resp = metricsClient.uploadMetrics(queryX, queryY, metricsDataString);
134+
log.info("Upload to time series DB response is " + resp.getStatus().getCode() + "("
135+
+ resp.getStatus().toString() + ") with body " + resp.getBody().orElse("No response data"));
140136
return sentDataIsCompleted ? new NormalizedData[0] : new NormalizedData[] { normalizedData };
141137
}
142138

143139
private void addScopeAttributes(NormalizedDataMetricsDataBuilder builder) {
144-
builder.scopeAttribute("my.scope.attribute", "some scope attribute");
140+
// for now this does nothing
141+
// builder.scopeAttribute("my.scope.attribute", "some scope attribute");
145142
}
146143

147144
private void addResourceAttributes(NormalizedDataMetricsDataBuilder builder, NormalizedData normalizedData) {

IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/normalizeddata/timeseriesdb/endpoints/TimeSeriesEndpointsRetriever.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ private void loadEndpointsQueryParams() throws URISyntaxException, SQLException,
132132
"No rows in the result set, has the DB been configured for the telemetry ?");
133133
}
134134
}
135-
log.info("Build endpoints info is " + endpointsResponse);
135+
log.finer("Build endpoints info is " + endpointsResponse);
136136
// let's try and get the params from these
137137
endpointsQueryParams = TimeSeriesEndpointsQueryParams.builder()
138138
.metricsQueryX(endpointsResponse.getOtlp().getQueryParam("x"))

IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/normalizeddata/timeseriesdb/oauth/TimeSeriesDBOAuthClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Software and the Larger Work(s), and to sublicense the foregoing rights on
5757
public interface TimeSeriesDBOAuthClient {
5858
@Consumes(MediaType.APPLICATION_JSON)
5959
@Produces(MediaType.APPLICATION_JSON)
60-
@Post("${" + TimeSeriesDBProperties.TIME_SERIES_PROPERTY_OAUTH_PATH + "}")
60+
@Post("${" + TimeSeriesDBProperties.TIME_SERIES_PROPERTY_OAUTH_PATH + ":/tel/token}")
6161
public OAuthTokenResponse getOAuthToken(@QueryValue("x") String queryParamX, @QueryValue("y") String queryParamY,
6262
@Body String timeSeriesDBCredentials) throws HttpClientException;
6363

IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/normalizeddata/timeseriesdb/oauth/TimeSeriesDBOAuthTokenRequestFilter.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ public void doFilter(MutableHttpRequest<?> request) {
7474
// need to add a request id, apparently this should be unique
7575
String randomUUID = UUID.randomUUID().toString();
7676
request.getHeaders().add(HEADER_REQUEST_ID, randomUUID);
77-
log.info("Added header " + HEADER_REQUEST_ID + " with id " + randomUUID);
78-
log.info("request uri " + request.getUri().toASCIIString());
79-
log.info("request path " + request.getPath());
80-
log.info("request params = " + request.getParameters().asMap().toString());
81-
log.info("request headers = " + request.getHeaders().asMap().toString());
82-
log.info("Request body " + request.getBody(String.class).orElse("No body set"));
77+
log.finer("Added header " + HEADER_REQUEST_ID + " with id " + randomUUID);
78+
log.finer("request uri " + request.getUri().toASCIIString());
79+
log.finer("request path " + request.getPath());
80+
log.finer("request params = " + request.getParameters().asMap().toString());
81+
log.finer("request headers = " + request.getHeaders().asMap().toString());
82+
log.finer("Request body " + request.getBody(String.class).orElse("No body set"));
8383
}
8484

8585
@EventListener

IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/normalizeddata/timeseriesdb/oauth/TimeSeriesDBOAuthTokenRetriever.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ public synchronized String getToken() throws OAuthTokenRetrievalException {
113113
if ((currentToken == null) || (currentTokenRenewTime == null)
114114
|| LocalDateTime.now().isAfter(currentTokenRenewTime)) {
115115
OAuthTokenResponse atr;
116-
log.info("Retrieveing token from DB");
116+
log.info("Retrieveing oauth token from time series DB");
117117
try {
118118
String credentials = mapper.writeValueAsString(tsDBuserCredentials);
119-
log.info("Setting body to " + credentials);
119+
log.fine("Setting body to " + credentials);
120120
atr = authClient.getOAuthToken(queryX, queryY, credentials);
121121
} catch (HttpClientException e) {
122122
throw new OAuthTokenRetrievalException("Problem getting the OAuth token " + e.getLocalizedMessage(), e);
@@ -130,7 +130,8 @@ public synchronized String getToken() throws OAuthTokenRetrievalException {
130130
// need to, yes we should probably allow for better control or retrieval times
131131
// but this is a demo, and not supposed to be production.
132132
this.currentTokenRenewTime = LocalDateTime.now().plusSeconds(atr.getExpiresIn()).minus(renewalPreempt);
133-
log.info("Got token details " + atr);
133+
log.info("Got token details with type " + atr.getTokenType() + " and expiring in " + atr.getExpiresIn()
134+
+ " seconds");
134135
} else {
135136
log.info("Using existing token");
136137
}
@@ -140,7 +141,7 @@ public synchronized String getToken() throws OAuthTokenRetrievalException {
140141

141142
@EventListener
142143
public void onStartup(StartupEvent event) {
143-
log.info("Startup event received for TimeSeriesDBOAuthTokenRetriever tsDBuserCredentials=" + tsDBuserCredentials
144-
+ ", queryX=" + queryX + ", queryY=" + queryY);
144+
log.info("Startup event received for TimeSeriesDBOAuthTokenRetriever tsDBuserCredentials="
145+
+ tsDBuserCredentials.safeToString() + ", queryX=" + queryX + ", queryY=" + queryY);
145146
}
146147
}

IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/normalizeddata/timeseriesdb/otlp/OtlpMetricsClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
public interface OtlpMetricsClient {
2323
@Consumes(MediaType.APPLICATION_JSON)
2424
@Produces(MediaType.APPLICATION_JSON)
25-
@Post("${" + TimeSeriesDBProperties.TIME_SERIES_PROPERTY_METRICS_PATH + "}")
25+
@Post("${" + TimeSeriesDBProperties.TIME_SERIES_PROPERTY_METRICS_PATH + ":/tel/v1/metrics}")
2626
HttpResponse<String> uploadMetrics(@QueryValue("x") String queryParamX, @QueryValue("y") String queryParamY,
2727
@Body String metricsDataString);
2828
}

IoTDBJDBC/src/main/java/com/oracle/demo/timg/iot/iotdbjdbc/messagehandler/outputs/http/normalizeddata/timeseriesdb/otlp/OtlpMetricsRequestFilter.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,23 @@ public OtlpMetricsRequestFilter(BeanProvider<TimeSeriesDBOAuthTokenRetriever> to
4949

5050
@RequestFilter
5151
public void doFilter(MutableHttpRequest<?> request) {
52-
log.info("Running metrics OTLP filtering");
52+
log.fine("Running metrics OTLP filtering");
5353
try {
5454
String token = tokenRetriever.get().getToken();
5555
String tokenType = tokenRetriever.get().getTokenType();
56-
log.info("Got the token and tokenType");
5756
request.getHeaders().add(AUTHORIZATION, (tokenType == null ? "Bearer" : tokenType) + " " + token);
5857
request.getHeaders().add(TimeSeriesDBOAuthTokenRequestFilter.HEADER_REQUEST_ID,
5958
UUID.randomUUID().toString());
60-
log.info("request uri " + request.getUri().toASCIIString());
61-
log.info("request path " + request.getPath());
62-
log.info("request params = " + request.getParameters().asMap().toString());
63-
log.info("request headers = " + request.getHeaders().asMap().toString());
64-
log.info("Request body " + request.getBody(String.class).orElse("No body set"));
59+
log.finer("request uri " + request.getUri().toASCIIString());
60+
log.finer("request path " + request.getPath());
61+
log.finer("request params = " + request.getParameters().asMap().toString());
62+
log.finer("request headers = " + request.getHeaders().asMap().toString());
63+
log.finer("Request body " + request.getBody(String.class).orElse("No body set"));
6564

6665
} catch (OAuthTokenRetrievalException e) {
6766
throw new IllegalStateException("Unable to retrieve an OAuth token for OTLP metrics upload", e);
6867
}
69-
log.info("Added OAuth authorization headers and uuid for OTLP metrics upload");
68+
log.fine("Added OAuth authorization headers and uuid for OTLP metrics upload");
7069
}
7170

7271
@EventListener

0 commit comments

Comments
 (0)