Skip to content

Commit

Permalink
FFM-7038 - Add SDK info header (#139)
Browse files Browse the repository at this point in the history
FFM-7038 - Add SDK info header

What
Add Harness-SDK-Info header to outbound HTTP connections

Why
Helps with diagnosing issues on the backend

Testing
Manual - tested with a proxy that logs headers
  • Loading branch information
andybharness authored Mar 8, 2023
1 parent e7a1ce1 commit 055d3ac
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
@Slf4j
public class HarnessConnector implements Connector, AutoCloseable {
public static final String REQUEST_ID_KEY = "requestId";
private static final String HARNESS_SDK_INFO =
String.format("Java %s Server", io.harness.cf.Version.VERSION);
private final ClientApi api;
private final MetricsApi metricsApi;
private final String apiKey;
Expand Down Expand Up @@ -66,6 +68,7 @@ ApiClient makeApiClient(int retryBackOfDelay) {
apiClient.setWriteTimeout(options.getWriteTimeout());
apiClient.setDebugging(log.isDebugEnabled());
apiClient.setUserAgent("JavaSDK " + io.harness.cf.Version.VERSION);
apiClient.addDefaultHeader("Harness-SDK-Info", HARNESS_SDK_INFO);

setupTls(apiClient);

Expand Down Expand Up @@ -104,6 +107,7 @@ ApiClient makeMetricsApiClient(int retryBackoffDelay) {
apiClient.setWriteTimeout(maxTimeout);
apiClient.setDebugging(log.isDebugEnabled());
apiClient.setUserAgent("JavaSDK " + io.harness.cf.Version.VERSION);
apiClient.addDefaultHeader("Harness-SDK-Info", HARNESS_SDK_INFO);

setupTls(apiClient);

Expand Down Expand Up @@ -337,6 +341,7 @@ public Service stream(@NonNull final Updater updater) throws ConnectorException
final Map<String, String> map = new HashMap<>();
map.put("Authorization", "Bearer " + token);
map.put("API-Key", apiKey);
map.put("Harness-SDK-Info", HARNESS_SDK_INFO);
log.info("Initialize new EventSource instance");
eventSource =
new EventSource(
Expand Down

0 comments on commit 055d3ac

Please sign in to comment.