Skip to content

Commit

Permalink
feat: Telemetry ID improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziodemaria committed Jun 3, 2024
1 parent 42cec7f commit 0efcf54
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
10 changes: 9 additions & 1 deletion src/main/java/com/spotify/confidence/Confidence.java
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,18 @@ public Builder flagResolverManagedChannel(ManagedChannel managedChannel) {
return this;
}

Confidence buildForProvider() {
return build(true);
}

public Confidence build() {
return build(false);
}

private Confidence build(Boolean isProvider) {
final FlagResolverClient flagResolverClient =
new FlagResolverClientImpl(
new GrpcFlagResolver(clientSecret, flagResolverManagedChannel));
new GrpcFlagResolver(clientSecret, flagResolverManagedChannel, isProvider));
final EventSenderEngine eventSenderEngine =
new EventSenderEngineImpl(clientSecret, DEFAULT_CHANNEL, Instant::now);
closer.register(flagResolverClient);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ public ConfidenceFeatureProvider(Confidence confidence) {
*/
@Deprecated()
public ConfidenceFeatureProvider(String clientSecret, ManagedChannel managedChannel) {
this(Confidence.builder(clientSecret).flagResolverManagedChannel(managedChannel).build());
this(
Confidence.builder(clientSecret)
.flagResolverManagedChannel(managedChannel)
.buildForProvider());
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/spotify/confidence/GrpcFlagResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ public class GrpcFlagResolver implements FlagResolver {

private final FlagResolverServiceGrpc.FlagResolverServiceFutureStub stub;

public GrpcFlagResolver(String clientSecret, ManagedChannel managedChannel) {
public GrpcFlagResolver(String clientSecret, ManagedChannel managedChannel, Boolean isProvider) {
if (Strings.isNullOrEmpty(clientSecret)) {
throw new IllegalArgumentException("clientSecret must be a non-empty string.");
}
this.clientSecret = clientSecret;
this.sdk =
Sdk.newBuilder()
.setId(SdkId.SDK_ID_JAVA_PROVIDER)
.setId(isProvider ? SdkId.SDK_ID_JAVA_PROVIDER : SdkId.SDK_ID_JAVA_CONFIDENCE)
.setVersion(ConfidenceUtils.getSdkVersion())
.build();
this.managedChannel = managedChannel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void beforeEach() {
final FakeEventSenderEngine fakeEventSender = new FakeEventSenderEngine(new FakeClock());
channel = InProcessChannelBuilder.forName(serverName).directExecutor().build();
final FlagResolverClientImpl flagResolver =
new FlagResolverClientImpl(new GrpcFlagResolver("fake-secret", channel));
new FlagResolverClientImpl(new GrpcFlagResolver("fake-secret", channel, false));
final Confidence confidence = Confidence.create(fakeEventSender, flagResolver);
final FeatureProvider featureProvider = new ConfidenceFeatureProvider(confidence);

Expand Down

0 comments on commit 0efcf54

Please sign in to comment.