Skip to content

Commit

Permalink
feat(telemetry): Use kork-proto as source of proto library, remove so…
Browse files Browse the repository at this point in the history
…me GRPC

cruft.
  • Loading branch information
Travis Tomsu committed Sep 11, 2019
1 parent 16b5ab4 commit 5e46d04
Show file tree
Hide file tree
Showing 12 changed files with 322 additions and 251 deletions.
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ buildscript {
// this override is needed to omit compileOnly dependencies from generated pom.xml
classpath "com.netflix.nebula:nebula-publishing-plugin:12.0.1"
}
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.8'
}
}

Expand Down
47 changes: 0 additions & 47 deletions echo-proto/echo-proto.gradle

This file was deleted.

83 changes: 0 additions & 83 deletions echo-proto/src/main/proto/event.proto

This file was deleted.

7 changes: 4 additions & 3 deletions echo-telemetry/echo-telemetry.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
dependencies {
implementation project(':echo-model')
implementation project(':echo-notifications')
implementation project(':echo-proto')
implementation 'com.google.guava:guava'
implementation 'com.google.protobuf:protobuf-java-util'
implementation "com.netflix.spinnaker.kork:kork-proto"
implementation 'com.netflix.spinnaker.kork:kork-web'
implementation 'com.squareup.retrofit:retrofit'
implementation 'com.squareup.retrofit:converter-jackson'
implementation 'com.netflix.spinnaker.kork:kork-web'
implementation 'com.google.protobuf:protobuf-java-util:3.7.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,50 +16,65 @@

package com.netflix.spinnaker.echo.config;

import static retrofit.Endpoints.newFixedEndpoint;

import com.netflix.spinnaker.echo.telemetry.TelemetryService;
import com.netflix.spinnaker.retrofit.RetrofitConfigurationProperties;
import com.netflix.spinnaker.retrofit.Slf4jRetrofitLogger;
import groovy.transform.CompileStatic;
import com.squareup.okhttp.OkHttpClient;
import java.util.concurrent.TimeUnit;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import retrofit.Endpoint;
import retrofit.RestAdapter;
import retrofit.client.Client;
import retrofit.client.OkClient;
import retrofit.converter.JacksonConverter;

@Slf4j
@Configuration
@ConditionalOnProperty("telemetry.enabled")
@CompileStatic
class TelemetryConfig {

@Value("${telemetry.endpoint}")
String endpoint;

@Bean
Endpoint telemetryEndpoint() {
return newFixedEndpoint(endpoint);
}
@EnableConfigurationProperties(TelemetryConfig.TelemetryConfigProps.class)
public class TelemetryConfig {

@Bean
public TelemetryService telemetryService(
Endpoint telemetryEndpoint, Client retrofitClient, RestAdapter.LogLevel retrofitLogLevel) {
RetrofitConfigurationProperties retrofitConfigurationProperties,
TelemetryConfigProps configProps) {
log.info("Telemetry service loaded");

TelemetryService client =
new RestAdapter.Builder()
.setEndpoint(telemetryEndpoint)
.setEndpoint(configProps.endpoint)
.setConverter(new JacksonConverter())
.setClient(retrofitClient)
.setLogLevel(RestAdapter.LogLevel.FULL)
.setClient(telemetryOkClient(configProps))
.setLogLevel(retrofitConfigurationProperties.getLogLevel())
.setLog(new Slf4jRetrofitLogger(TelemetryService.class))
.build()
.create(TelemetryService.class);

return client;
}

private OkClient telemetryOkClient(TelemetryConfigProps configProps) {
OkHttpClient httpClient = new OkHttpClient();
httpClient.setConnectTimeout(configProps.connectionTimeoutMillis, TimeUnit.MILLISECONDS);
httpClient.setReadTimeout(configProps.readTimeoutMillis, TimeUnit.MILLISECONDS);
return new OkClient(httpClient);
}

@Data
@ConfigurationProperties(prefix = "telemetry")
public static class TelemetryConfigProps {

public static final String DEFAULT_TELEMETRY_ENDPOINT = "https://stats.spinnaker.io/log";

boolean enabled = false;
String endpoint = DEFAULT_TELEMETRY_ENDPOINT;
String instanceId;
String spinnakerVersion = "unknown";
int connectionTimeoutMillis = 3000;
int readTimeoutMillis = 5000;
}
}
Loading

0 comments on commit 5e46d04

Please sign in to comment.