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

fix: remove connection-id from metrics attributes #2384

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ private OpenTelemetry enableOpenTelemetryMetrics() throws IOException {

static Attributes createMetricAttributes(SpannerConfiguration spannerConfiguration) {
AttributesBuilder attributesBuilder = Attributes.builder();
attributesBuilder.put("connection_id", UUID.randomUUID().toString());
attributesBuilder.put("database", spannerConfiguration.getDatabase());
attributesBuilder.put("instance_id", spannerConfiguration.getInstance());
attributesBuilder.put("project_id", spannerConfiguration.getProject());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ public ExtendedQueryProtocolHandler(ConnectionHandler connectionHandler) {
.getServer()
.getTracer(ConnectionHandler.class.getName(), getVersion()),
connectionHandler.getServer().getMetrics(),
createMetricAttributes(
connectionHandler.getDatabaseId(),
connectionHandler.getTraceConnectionId().toString()),
createMetricAttributes(connectionHandler.getDatabaseId()),
connectionHandler.getTraceConnectionId().toString(),
connectionHandler::closeAllPortals,
connectionHandler.getDatabaseId(),
Expand Down Expand Up @@ -97,9 +95,8 @@ public Tracer getTracer() {
}

@VisibleForTesting
static Attributes createMetricAttributes(DatabaseId databaseId, String connectionId) {
static Attributes createMetricAttributes(DatabaseId databaseId) {
AttributesBuilder attributesBuilder = Attributes.builder();
attributesBuilder.put("pgadapter.connection_id", connectionId);
attributesBuilder.put("database", databaseId.getDatabase());
attributesBuilder.put("instance_id", databaseId.getInstanceId().getInstance());
attributesBuilder.put("project_id", databaseId.getInstanceId().getProject());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public class BackendConnectionTest {
private static final Runnable DO_NOTHING = () -> {};
private static final DatabaseId DATABASE_ID = DatabaseId.of("p", "i", "d");
private static final Attributes METRIC_ATTRIBUTES =
ExtendedQueryProtocolHandler.createMetricAttributes(DATABASE_ID, "test-id");
ExtendedQueryProtocolHandler.createMetricAttributes(DATABASE_ID);

@Test
public void testExtractDdlUpdateCounts() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public class StatementTest {
private static final Runnable DO_NOTHING = () -> {};
private static final DatabaseId DATABASE_ID = DatabaseId.of("p", "i", "d");
private static final Attributes METRIC_ATTRIBUTES =
ExtendedQueryProtocolHandler.createMetricAttributes(DATABASE_ID, "test-connection");
ExtendedQueryProtocolHandler.createMetricAttributes(DATABASE_ID);

private static ParsedStatement parse(String sql) {
return PARSER.parse(Statement.of(sql));
Expand Down Expand Up @@ -521,7 +521,7 @@ public void testCopyInvalidBuildMutation() throws Exception {
new BackendConnection(
NOOP_OTEL,
NOOP_OTEL_METER,
ExtendedQueryProtocolHandler.createMetricAttributes(databaseId, "test-connection"),
ExtendedQueryProtocolHandler.createMetricAttributes(databaseId),
UUID.randomUUID().toString(),
DO_NOTHING,
databaseId,
Expand Down Expand Up @@ -629,7 +629,7 @@ public void testCopyBatchSizeLimit() throws Exception {
new BackendConnection(
NOOP_OTEL,
NOOP_OTEL_METER,
ExtendedQueryProtocolHandler.createMetricAttributes(databaseId, "test-connection"),
ExtendedQueryProtocolHandler.createMetricAttributes(databaseId),
UUID.randomUUID().toString(),
DO_NOTHING,
databaseId,
Expand Down Expand Up @@ -688,7 +688,7 @@ public void testCopyDataRowLengthMismatchLimit() throws Exception {
new BackendConnection(
NOOP_OTEL,
NOOP_OTEL_METER,
ExtendedQueryProtocolHandler.createMetricAttributes(databaseId, "test-connection"),
ExtendedQueryProtocolHandler.createMetricAttributes(databaseId),
UUID.randomUUID().toString(),
DO_NOTHING,
databaseId,
Expand Down
Loading