Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
4532736
feat(bqjdbc): Per connection logs - Add BigQueryJdbcMdc
Neenu1995 Apr 10, 2026
c3b9b7e
ensure garbage collection
Neenu1995 Apr 10, 2026
8b21ea5
add logs to gitignore
Neenu1995 Apr 10, 2026
0dc67a5
lint
Neenu1995 Apr 10, 2026
a0c2548
fix(java-spanner): use the existing dependency versions (#12746)
suztomo Apr 10, 2026
313bf21
chore: Add AION SDK as code owners for the auth library (#12750)
lqiu96 Apr 10, 2026
a8d88fd
build(sdk-platform-java): Add formatter plugin to the root pom of sdk…
blakeli0 Apr 10, 2026
5cb57d3
fix(hermetic-build): prevent overwrite of Version.java in new librari…
diegomarquezp Apr 10, 2026
2bf9235
ci: fix sdk-platform-java-ci syntax (#12753)
chingor13 Apr 10, 2026
8a32f81
fix(o11y): composite tracer to process url changes (#12754)
diegomarquezp Apr 10, 2026
da5c69e
chore: untangling auth library parent and imported BOM (#12737)
suztomo Apr 10, 2026
da00518
fix(gax): reduce visibility of ApiTracerContext methods (#12738)
blakeli0 Apr 10, 2026
1f65fa5
build: use local clone for release-please (#12757)
chingor13 Apr 10, 2026
f5027f7
chore: Add a library generation skill (#12689)
lqiu96 Apr 10, 2026
8d239f6
fix: normalize indentation in owlbot yamls for new libraries (#12759)
diegomarquezp Apr 10, 2026
8d30e20
chore: Update gapic-generator-java version in WORKSPACE (#12761)
blakeli0 Apr 10, 2026
136d81e
chore(main): release 1.84.0-SNAPSHOT (#12760)
chingor13 Apr 10, 2026
8096f53
chore(bq jdbc): change uber jar bundling rules (#12195)
logachev Apr 10, 2026
3b153be
chore(main): release 1.84.0 (#12764)
diegomarquezp Apr 10, 2026
c5a2b4b
ci: Remove extra compile job (#12763)
lqiu96 Apr 11, 2026
bb67aac
chore: Fix iam policy downgrade (#12767)
blakeli0 Apr 12, 2026
d8383c9
fix(auth): Address ClientSideCredentialAccessBoundary RefreshTask rac…
vverman Apr 13, 2026
4fc7d43
ci: GraalVM CI uses existing Truststore if configured (#1914)
lqiu96 Apr 8, 2026
8cb8e52
test: Fix sonatype complaints in the tests (#1870)
lqiu96 Apr 8, 2026
d16b5b6
fix(gdch): support EC private keys (#1896)
diegomarquezp Apr 8, 2026
0e0fcc3
chore: Refactor x509Provider to create a shared Utils class for Mtls …
vverman Apr 8, 2026
ebbe428
chore: Add licence with year for old TestEnvironmentProvider class
lqiu96 Apr 8, 2026
f76308d
chore: Remove the new .kokoro/build.sh file added from split repo
lqiu96 Apr 8, 2026
dcc8d51
chore(bigquery): remove dev gate flag and beta api for tracing teleme…
ldetmer Apr 13, 2026
2801400
feat: [appoptimize] new module for appoptimize (#12768)
cloud-java-bot Apr 13, 2026
be752b8
fix(bqjdbc): lazily instantiate Statement in BigQueryDatabaseMetaData…
Neenu1995 Apr 13, 2026
d4582b4
chore: Fix GDCH tests referencing obsolete GDCH audience methods (#12…
lqiu96 Apr 13, 2026
c69253a
chore: Update generation configuration at Fri Apr 10 03:01:18 UTC 202…
cloud-java-bot Apr 13, 2026
bd8f287
chore(o11y): remove beta api from observability classes (#12747)
blakeli0 Apr 13, 2026
e1107af
ci: trigger sdk-platform-java CI on google-auth-library-java changes …
blakeli0 Apr 13, 2026
bdec6a4
build(deps): upgrade grpc-gcp to 1.10.0 (#12772)
blakeli0 Apr 13, 2026
f3ab101
fix: update appoptimize version to 0.0.1 to match released repo (#12782)
diegomarquezp Apr 13, 2026
4933999
chore(main): release 1.85.0-SNAPSHOT (#12786)
diegomarquezp Apr 13, 2026
042ec53
ci: replace java-logging with java-pubsub in downstream check (#12783)
blakeli0 Apr 14, 2026
58eec3a
ci: remove redundant sdk-platform-java from split-units (#12784)
blakeli0 Apr 14, 2026
966e8a4
chore(main): release 1.85.0 (#12788)
diegomarquezp Apr 14, 2026
60c8240
ci: trigger split repo tests on auth, gax, and shared-deps changes (#…
lqiu96 Apr 14, 2026
ab9ff2d
fix(bqjdbc): Revert DatabaseMetaData field to be non-static in BigQue…
Neenu1995 Apr 14, 2026
e7cffc1
chore(deps): update upper bound dependencies file (#12706)
renovate-bot Apr 14, 2026
344b82d
fix: correct build directory paths in graalvm cloudbuild.yaml (#12794)
diegomarquezp Apr 14, 2026
6518bba
ci: skip bulk tests for isolated handwritten library changes (#12793)
lqiu96 Apr 14, 2026
9b87f57
fix(datastore): Create a plaintext gRPC transport channel when using …
mw-ship-it Apr 14, 2026
db25973
test(bigquery): Fix flaky ITBigQueryTest#testOpenTelemetryTracingQuer…
jinseopkim0 Apr 14, 2026
123b4e4
chore(main): release 1.86.0-SNAPSHOT (#12799)
diegomarquezp Apr 14, 2026
ff5ff19
Revert "chore(main): release 1.86.0-SNAPSHOT" (#12800)
diegomarquezp Apr 14, 2026
df9be2d
chore: Update generation configuration at Tue Apr 14 03:00:42 UTC 202…
cloud-java-bot Apr 14, 2026
bad2432
build(appoptimize): fix owlbot.py format (#12802)
chingor13 Apr 14, 2026
e659646
fix: bump vectorsearch to 0.13.0 for partial release (#12805)
diegomarquezp Apr 14, 2026
722f19f
chore: Add a Java development skill for the monorepo (#12797)
lqiu96 Apr 15, 2026
2fdb96b
ci: fix library generation presubmit (#12803)
chingor13 Apr 15, 2026
bf54672
ci: restore sdk-platform-java jobs (#12813)
diegomarquezp Apr 15, 2026
fe87622
build: create additional tags on release (#12811)
chingor13 Apr 15, 2026
d0a1e91
ci: fix unmanaged_dependency_check module install (#12812)
chingor13 Apr 15, 2026
eca5736
chore: rm template from issue_tracker in config and repometadata (#12…
zhumin8 Apr 15, 2026
abc4259
build: use local google-auth-library in bazel tests (#12814)
chingor13 Apr 15, 2026
178953f
chore: downgrade gapic-libraries-bom to 1.85.0 (#12808)
blakeli0 Apr 15, 2026
058b80e
test(spanner): add a mock server test using key-aware routing (#12755)
olavloite Apr 16, 2026
ce1a8f7
perf(spanner): use StringBuilder for generating RequestId (#12809)
olavloite Apr 16, 2026
6135fe9
chore: replace non-ASCII characters in api_description (#12795)
zhumin8 Apr 16, 2026
0e1e919
ci: stop using Google's Maven mirror in downstream checks (#12826)
suztomo Apr 16, 2026
aaffa52
change date formatter to DateTimeFormatter
Neenu1995 Apr 17, 2026
40edd07
make id generation cleaner
Neenu1995 Apr 17, 2026
79a5f8b
Merge branch 'main' into ns/mdc-per-conn-logs
Neenu1995 Apr 17, 2026
f206b77
clean up connection class
Neenu1995 Apr 17, 2026
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
@@ -0,0 +1,97 @@
/*
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.cloud.bigquery.jdbc;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;

/**
* Lightweight MDC implementation for the BigQuery JDBC driver using InheritableThreadLocal.
* Allocates a dedicated, independent InheritableThreadLocal object per concrete BigQueryConnection
* instance.
*/
public class BigQueryJdbcMdc {
private static final AtomicLong nextId = new AtomicLong(1);
private static final ConcurrentHashMap<BigQueryConnection, InheritableThreadLocal<String>>
instanceLocals = new ConcurrentHashMap<>();
private static final ConcurrentHashMap<BigQueryConnection, String> instanceIds =
new ConcurrentHashMap<>();
Comment thread
Neenu1995 marked this conversation as resolved.

/** Allocates an exclusive InheritableThreadLocal and registers the connection mapping. */
private static final InheritableThreadLocal<String> currentConnectionId =
new InheritableThreadLocal<>();

public static void registerInstance(BigQueryConnection connection, String id) {
if (connection != null) {
String cleanId =
instanceIds.computeIfAbsent(
connection,
k -> {
String suffix =
(id != null && !id.isEmpty()) ? id : String.valueOf(nextId.getAndIncrement());
return "JdbcConnection-" + suffix;
});

currentConnectionId.set(cleanId);
InheritableThreadLocal<String> threadLocal =
instanceLocals.computeIfAbsent(connection, k -> new InheritableThreadLocal<>());
Comment thread
Neenu1995 marked this conversation as resolved.
threadLocal.set(cleanId);
}
}

/** Retrieves the connection ID mapped to a specific BigQueryConnection instance. */
public static String getConnectionId(BigQueryConnection connection) {
Comment thread
Neenu1995 marked this conversation as resolved.
if (connection != null) {
InheritableThreadLocal<String> local = instanceLocals.get(connection);
if (local != null) {
String val = local.get();
if (val != null) {
return val;
}
}
return instanceIds.get(connection);
}
return null;
}

/**
* Returns the connection ID carried by any registered active connection on the current thread.
*/
public static String getConnectionId() {
return currentConnectionId.get();
}

/** Clears the connection ID context from all active connection contexts on the current thread. */
public static void removeInstance(BigQueryConnection connection) {
if (connection != null) {
InheritableThreadLocal<String> local = instanceLocals.remove(connection);
if (local != null) {
local.remove();
}
instanceIds.remove(connection);
}
}
Comment thread
Neenu1995 marked this conversation as resolved.

public static void clear() {
currentConnectionId.remove();
for (InheritableThreadLocal<String> local : instanceLocals.values()) {
local.remove();
}
instanceLocals.clear();
instanceIds.clear();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Optional;
import java.util.logging.ConsoleHandler;
import java.util.logging.FileHandler;
Expand Down Expand Up @@ -62,7 +63,8 @@ class BigQueryJdbcRootLogger {

public static Formatter getFormatter() {
return new Formatter() {
private static final String PATTERN = "yyyy-MM-dd HH:mm:ss.SSS";
private final DateTimeFormatter dateFormatter =
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS").withZone(ZoneId.systemDefault());
private static final String FORMAT =
"%1$s %2$5s %3$d --- [%4$-7.15s] %5$-50s %6$-20s: %7$s%8$s";
private static final int MAX_THREAD_NAME_LENGTH = 15;
Expand All @@ -81,7 +83,9 @@ Optional<Thread> getThread(long threadId) {

@Override
public String format(LogRecord record) {
String date = new SimpleDateFormat(PATTERN).format(new Date(record.getMillis()));

String date = dateFormatter.format(Instant.ofEpochMilli(record.getMillis()));

String threadName =
getThread(record.getThreadID())
.map(Thread::getName)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.cloud.bigquery.jdbc;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

public class BigQueryJdbcMdcTest {

private BigQueryConnection mockConnection1;
private BigQueryConnection mockConnection2;

@BeforeEach
public void setUp() {
mockConnection1 = Mockito.mock(BigQueryConnection.class);
mockConnection2 = Mockito.mock(BigQueryConnection.class);
}

@AfterEach
public void tearDown() {
BigQueryJdbcMdc.clear();
}

@Test
public void testRegisterAndRetrieveConnectionId() {
BigQueryJdbcMdc.registerInstance(mockConnection1, "123");

assertEquals("JdbcConnection-123", BigQueryJdbcMdc.getConnectionId(mockConnection1));
assertEquals("JdbcConnection-123", BigQueryJdbcMdc.getConnectionId());
}

@Test
public void testClearContext() {
BigQueryJdbcMdc.registerInstance(mockConnection1, "456");
assertEquals("JdbcConnection-456", BigQueryJdbcMdc.getConnectionId(mockConnection1));

BigQueryJdbcMdc.clear();

assertNull(BigQueryJdbcMdc.getConnectionId());
}

@Test
public void testMultipleConnectionsSameThread() {
BigQueryJdbcMdc.registerInstance(mockConnection1, "111");
BigQueryJdbcMdc.registerInstance(mockConnection2, "222");

assertEquals("JdbcConnection-111", BigQueryJdbcMdc.getConnectionId(mockConnection1));
assertEquals("JdbcConnection-222", BigQueryJdbcMdc.getConnectionId(mockConnection2));
}
}
Loading