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

feat: add telemetry on resolve latency #158

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft

Conversation

nicklasl
Copy link
Member

@nicklasl nicklasl commented Nov 13, 2024

The idea with this PR is to add a header with information about how long each resolve took.
It's defining a proto message and encodes the telemetry data in this message as a Base64 string putting it to the X-CONFIDENCE-TELEMETRY.

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

final class ConfidenceIntegrationTest {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were missing good integration tests for resolving using the Confidence SDK standalone. This class was copied from the Provider tests and just massaged to fit the SDK APIs.

@@ -30,7 +30,8 @@ private static ConfidenceValue from(com.google.protobuf.Value value, FlagSchema
if (intVal != value.getNumberValue()) {
throw new ParseError(
String.format(
"%s %s should be an int, but it is a double/long", mismatchPrefix, value));
"%s %s should be an int, but it is a double/long",
mismatchPrefix, value.getNumberValue()));
Copy link
Member Author

@nicklasl nicklasl Nov 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using value.getNumberValue() here since value actually contained a line break which annoyed me when writing tests :)


public class TelemetryClientInterceptor implements ClientInterceptor {
public static final Metadata.Key<String> HEADER_KEY =
Metadata.Key.of("X-CONFIDENCE-TELEMETRY", Metadata.ASCII_STRING_MARSHALLER);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the header in binary instead and the header with -bin suffix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant