chore(bqjdbc): switch connection identifier to UUID#12957
chore(bqjdbc): switch connection identifier to UUID#12957keshavdandeva wants to merge 3 commits intomainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the BigQueryJdbcMdc class to use UUIDs instead of a sequential AtomicLong for generating connection IDs. This change ensures more robust unique identification for JDBC connections when a specific ID is not provided. I have no feedback to provide.
| (id != null && !id.isEmpty()) ? id : String.valueOf(nextId.getAndIncrement()); | ||
| return "JdbcConnection-" + suffix; | ||
| String baseId = (id != null && !id.isEmpty()) ? id : UUID.randomUUID().toString(); | ||
| return "BQ-JDBC-" + baseId; |
There was a problem hiding this comment.
nit: don't think we need BQ-JDBC- or any other prefix.. They're internal and only relevant to stitch together telemetry/logs. Can be just a uuid
There was a problem hiding this comment.
The user application many have logs generated from other sources. For the file name I think it is useful if we keep the BQ-JDBC prefix. Same with the connection ID, if the user Application is logging from multiple sources , it will be helpful to identify the logs generated by the JDBC Driver.
There was a problem hiding this comment.
Yes, but that's the internal ID, not the filename
| uuid = id.substring("BQ-JDBC-".length()); | ||
| } | ||
| String timestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")); | ||
| String shortUuid = uuid.length() >= 4 ? uuid.substring(0, 4) : uuid; |
There was a problem hiding this comment.
nit: no need for that check, uuid will never be shorter than 4
b/507856382
Changes
BigQueryConnectionUUID.randomUUID().toString()as theconnectionId.BigQueryJdbcMdcBQ-JDBC-to the fullUUIDfor thread context logging.PerConnectionFileHandlerUUIDfromBQ-JDBC-prefix and constructs log filenames with the format:BQ-JDBC-yyyyMMddHHmmss-<first-4-chars-of-UUID>.log.Tests
BigQueryJdbcMdcTestto match the new prefix.PerConnectionFileHandlerTestto use a helper method for finding dynamic log files, making tests cleaner.