Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

Commit 4d7713d

Browse files
committed
add attribute namespaces, change to snake_case
1 parent e800d8f commit 4d7713d

14 files changed

Lines changed: 49 additions & 91 deletions

File tree

google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryImpl.java

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,6 @@ && getOptions().getOpenTelemetryTracer() != null) {
444444
.getOpenTelemetryTracer()
445445
.spanBuilder("com.google.cloud.bigquery.BigQuery.createJob")
446446
.setAllAttributes(jobInfo.getJobId().getOtelAttributes())
447-
.setAttribute("status", getFieldAsString(jobInfo.getStatus()))
448447
.setAllAttributes(otelAttributesFromOptions(options))
449448
.startSpan();
450449
}
@@ -615,7 +614,7 @@ && getOptions().getOpenTelemetryTracer() != null) {
615614
getOptions()
616615
.getOpenTelemetryTracer()
617616
.spanBuilder("com.google.cloud.bigquery.BigQuery.listDatasets")
618-
.setAttribute("projectId", projectId)
617+
.setAttribute("bq.dataset.project_id", projectId)
619618
.setAllAttributes(otelAttributesFromOptions(options))
620619
.startSpan();
621620
}
@@ -1637,7 +1636,6 @@ && getOptions().getOpenTelemetryTracer() != null) {
16371636
.getOpenTelemetryTracer()
16381637
.spanBuilder("com.google.cloud.bigquery.BigQuery.listTableData")
16391638
.setAllAttributes(tableId.getOtelAttributes())
1640-
.setAllAttributes(schema.getOtelAttributes())
16411639
.setAllAttributes(otelAttributesFromOptions(options))
16421640
.startSpan();
16431641
}
@@ -1734,7 +1732,7 @@ && getOptions().getOpenTelemetryTracer() != null) {
17341732
getOptions()
17351733
.getOpenTelemetryTracer()
17361734
.spanBuilder("com.google.cloud.bigquery.BigQuery.getJob")
1737-
.setAllAttributes(jobId.getOtelAttributes())
1735+
.setAllAttributes(completeJobId.getOtelAttributes())
17381736
.setAllAttributes(otelAttributesFromOptions(options))
17391737
.startSpan();
17401738
}
@@ -1847,7 +1845,7 @@ && getOptions().getOpenTelemetryTracer() != null) {
18471845
getOptions()
18481846
.getOpenTelemetryTracer()
18491847
.spanBuilder("com.google.cloud.bigquery.BigQuery.cancelJob")
1850-
.setAllAttributes(jobId.getOtelAttributes())
1848+
.setAllAttributes(completeJobId.getOtelAttributes())
18511849
.startSpan();
18521850
}
18531851
try (Scope jobCancelScope = jobCancel != null ? jobCancel.makeCurrent() : null) {
@@ -1892,7 +1890,6 @@ && getOptions().getOpenTelemetryTracer() != null) {
18921890
getOptions()
18931891
.getOpenTelemetryTracer()
18941892
.spanBuilder("com.google.cloud.bigquery.BigQuery.query")
1895-
.setAllAttributes(configuration.getOtelAttributes())
18961893
.setAllAttributes(otelAttributesFromOptions(options))
18971894
.startSpan();
18981895
}
@@ -1930,7 +1927,7 @@ && getOptions().getOpenTelemetryTracer() != null) {
19301927
getOptions()
19311928
.getOpenTelemetryTracer()
19321929
.spanBuilder("com.google.cloud.bigquery.BigQuery.queryRpc")
1933-
.setAttribute("projectId", projectId)
1930+
.setAttribute("bq.query.project_id", projectId)
19341931
.setAllAttributes(otelAttributesFromQueryRequest(content))
19351932
.setAllAttributes(otelAttributesFromOptions(options))
19361933
.startSpan();
@@ -2031,7 +2028,6 @@ && getOptions().getOpenTelemetryTracer() != null) {
20312028
getOptions()
20322029
.getOpenTelemetryTracer()
20332030
.spanBuilder("com.google.cloud.bigquery.BigQuery.query")
2034-
.setAllAttributes(configuration.getOtelAttributes())
20352031
.setAllAttributes(jobId.getOtelAttributes())
20362032
.setAllAttributes(otelAttributesFromOptions(options))
20372033
.startSpan();
@@ -2264,7 +2260,7 @@ && getOptions().getOpenTelemetryTracer() != null) {
22642260
.getOpenTelemetryTracer()
22652261
.spanBuilder("com.google.cloud.bigquery.BigQuery.testIamPermissions")
22662262
.setAllAttributes(tableId.getOtelAttributes())
2267-
.setAttribute("permissions", permissions.toString())
2263+
.setAttribute("bq.iam.permissions", permissions.toString())
22682264
.setAllAttributes(otelAttributesFromOptions(options))
22692265
.startSpan();
22702266
}
@@ -2315,27 +2311,27 @@ private static Attributes otelAttributesFromOptions(Option... options) {
23152311
for (Option option : options) {
23162312
attributes =
23172313
attributes.toBuilder()
2318-
.put(option.getRpcOption().toString(), option.getValue().toString())
2314+
.put("bq.option." + option.getRpcOption().toString(), option.getValue().toString())
23192315
.build();
23202316
}
23212317
return attributes;
23222318
}
23232319

23242320
private static Attributes otelAttributesFromQueryRequest(QueryRequest request) {
23252321
return Attributes.builder()
2326-
.put("dryRun", getFieldAsString(request.getDryRun()))
2327-
.put("jobCreationMode", getFieldAsString(request.getJobCreationMode()))
2328-
.put("kind", getFieldAsString(request.getKind()))
2329-
.put("location", getFieldAsString(request.getLocation()))
2330-
.put("requestId", getFieldAsString(request.getRequestId()))
2331-
.put("useQueryCache", getFieldAsString(request.getUseQueryCache()))
2322+
.put("bq.query.dry_run", getFieldAsString(request.getDryRun()))
2323+
.put("bq.query.job_creation_mode", getFieldAsString(request.getJobCreationMode()))
2324+
.put("bq.query.kind", getFieldAsString(request.getKind()))
2325+
.put("bq.query.location", getFieldAsString(request.getLocation()))
2326+
.put("bq.query.request_id", getFieldAsString(request.getRequestId()))
2327+
.put("bq.query.use_query_cache", getFieldAsString(request.getUseQueryCache()))
23322328
.build();
23332329
}
23342330

23352331
private static Attributes otelAttributesFromPolicy(Policy policy) {
23362332
return Attributes.builder()
2337-
.put("version", getFieldAsString(policy.getVersion()))
2338-
.put("bindings", getFieldAsString(policy.getBindings()))
2333+
.put("bq.policy.version", getFieldAsString(policy.getVersion()))
2334+
.put("bq.policy.bindings", getFieldAsString(policy.getBindings()))
23392335
.build();
23402336
}
23412337

google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/DatasetId.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ static DatasetId fromPb(DatasetReference datasetRef) {
8888

8989
protected Attributes getOtelAttributes() {
9090
return Attributes.builder()
91-
.put("project", this.getProject())
92-
.put("dataset", this.getDataset())
91+
.put("bq.dataset.project", this.getProject())
92+
.put("bq.dataset.id", this.getDataset())
9393
.build();
9494
}
9595
}

google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/DatasetInfo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -754,8 +754,8 @@ private static String getFieldAsString(Object field) {
754754
protected Attributes getOtelAttributes() {
755755
return Attributes.builder()
756756
.putAll(this.getDatasetId().getOtelAttributes())
757-
.put("lastModified", getFieldAsString(this.getLastModified()))
758-
.put("location", getFieldAsString(this.getLocation()))
757+
.put("bq.dataset.lastModified", getFieldAsString(this.getLastModified()))
758+
.put("bq.dataset.location", getFieldAsString(this.getLocation()))
759759
.build();
760760
}
761761

google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/JobId.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ private static String getFieldAsString(Object field) {
131131

132132
protected Attributes getOtelAttributes() {
133133
return Attributes.builder()
134-
.put("job", getFieldAsString(this.getJob()))
135-
.put("location", getFieldAsString(this.getLocation()))
136-
.put("project", getFieldAsString(this.getProject()))
134+
.put("bq.job.id", getFieldAsString(this.getJob()))
135+
.put("bq.job.location", getFieldAsString(this.getLocation()))
136+
.put("bq.job.project", getFieldAsString(this.getProject()))
137137
.build();
138138
}
139139
}

google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/JobInfo.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import com.google.api.services.bigquery.model.Job;
2020
import com.google.common.base.Function;
2121
import com.google.common.base.MoreObjects;
22-
import io.opentelemetry.api.common.Attributes;
2322
import java.io.Serializable;
2423
import java.util.Objects;
2524

@@ -376,18 +375,4 @@ public static JobInfo of(JobId jobId, JobConfiguration configuration) {
376375
static JobInfo fromPb(Job jobPb) {
377376
return new BuilderImpl(jobPb).build();
378377
}
379-
380-
private static String getFieldAsString(Object field) {
381-
return field == null ? "null" : field.toString();
382-
}
383-
384-
protected Attributes getOtelAttributes() {
385-
return Attributes.builder()
386-
.putAll(this.getJobId().getOtelAttributes())
387-
.put("creationTime", getFieldAsString(this.getStatistics().getCreationTime()))
388-
.put("startTime", getFieldAsString(this.getStatistics().getStartTime()))
389-
.put("endTime", getFieldAsString(this.getStatistics().getEndTime()))
390-
.put("jobType", getFieldAsString(this.getConfiguration().getType()))
391-
.build();
392-
}
393378
}

google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/ModelId.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ static ModelId fromPb(ModelReference modelRef) {
109109

110110
protected Attributes getOtelAttributes() {
111111
return Attributes.builder()
112-
.put("project", this.getProject())
113-
.put("dataset", this.getDataset())
114-
.put("model", this.getModel())
112+
.put("bq.model.project", this.getProject())
113+
.put("bq.model.dataset", this.getDataset())
114+
.put("bq.model.id", this.getModel())
115115
.build();
116116
}
117117
}

google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/ModelInfo.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -462,11 +462,11 @@ private static String getFieldAsString(Object field) {
462462
protected Attributes getOtelAttributes() {
463463
return Attributes.builder()
464464
.putAll(this.getModelId().getOtelAttributes())
465-
.put("modelType", getFieldAsString(this.getModelType()))
466-
.put("creationTime", getFieldAsString(this.getCreationTime()))
467-
.put("lastModifiedTime", getFieldAsString(this.getLastModifiedTime()))
468-
.put("expirationTime", getFieldAsString(this.getExpirationTime()))
469-
.put("location", getFieldAsString(this.getLocation()))
465+
.put("bq.model.type", getFieldAsString(this.getModelType()))
466+
.put("bq.model.creation_time", getFieldAsString(this.getCreationTime()))
467+
.put("bq.model.last_modified_time", getFieldAsString(this.getLastModifiedTime()))
468+
.put("bq.model.expiration_time", getFieldAsString(this.getExpirationTime()))
469+
.put("bq.model.location", getFieldAsString(this.getLocation()))
470470
.build();
471471
}
472472
}

google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/QueryJobConfiguration.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import com.google.common.collect.Iterables;
3333
import com.google.common.collect.Lists;
3434
import com.google.common.collect.Maps;
35-
import io.opentelemetry.api.common.Attributes;
3635
import java.util.List;
3736
import java.util.Map;
3837
import java.util.Objects;
@@ -1214,16 +1213,4 @@ public QueryParameter apply(Map.Entry<String, QueryParameterValue> entry) {
12141213
return queryParameterPb;
12151214
}
12161215
};
1217-
1218-
private static String getFieldAsString(Object field) {
1219-
return field == null ? "null" : field.toString();
1220-
}
1221-
1222-
public Attributes getOtelAttributes() {
1223-
return Attributes.builder()
1224-
.put("destinationTable", getFieldAsString(this.getDestinationTable()))
1225-
.put("useQueryCache", getFieldAsString(this.useQueryCache()))
1226-
.put("dryRun", getFieldAsString(this.dryRun()))
1227-
.build();
1228-
}
12291216
}

google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/RoutineId.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ static RoutineId fromPb(RoutineReference routineRef) {
112112

113113
protected Attributes getOtelAttributes() {
114114
return Attributes.builder()
115-
.put("project", this.getProject())
116-
.put("dataset", this.getDataset())
117-
.put("routine", this.getRoutine())
115+
.put("bq.routine.project", this.getProject())
116+
.put("bq.routine.dataset", this.getDataset())
117+
.put("bq.routine.id", this.getRoutine())
118118
.build();
119119
}
120120
}

google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/RoutineInfo.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,9 +553,9 @@ private static String getFieldAsString(Object field) {
553553
protected Attributes getOtelAttributes() {
554554
return Attributes.builder()
555555
.putAll(this.getRoutineId().getOtelAttributes())
556-
.put("routineType", getFieldAsString(this.getRoutineType()))
557-
.put("creationTime", getFieldAsString(this.getCreationTime()))
558-
.put("lastModifiedTime", getFieldAsString(this.getLastModifiedTime()))
556+
.put("bq.routine.type", getFieldAsString(this.getRoutineType()))
557+
.put("bq.routine.creation_time", getFieldAsString(this.getCreationTime()))
558+
.put("bq.routine.last_modified_time", getFieldAsString(this.getLastModifiedTime()))
559559
.build();
560560
}
561561
}

0 commit comments

Comments
 (0)