add attribute namespaces, change to snake_case · googleapis/java-bigquery@0ebaa92 · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

Commit 0ebaa92

Browse files
committed
add attribute namespaces, change to snake_case
1 parent a963641 commit 0ebaa92

File tree

14 files changed

+49
-91
lines changed

14 files changed

+49
-91
lines changed

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
@@ -445,7 +445,6 @@ && getOptions().getOpenTelemetryTracer() != null) {
445445
.getOpenTelemetryTracer()
446446
.spanBuilder("com.google.cloud.bigquery.BigQuery.createJob")
447447
.setAllAttributes(jobInfo.getJobId().getOtelAttributes())
448-
.setAttribute("status", getFieldAsString(jobInfo.getStatus()))
449448
.setAllAttributes(otelAttributesFromOptions(options))
450449
.startSpan();
451450
}
@@ -616,7 +615,7 @@ && getOptions().getOpenTelemetryTracer() != null) {
616615
getOptions()
617616
.getOpenTelemetryTracer()
618617
.spanBuilder("com.google.cloud.bigquery.BigQuery.listDatasets")
619-
.setAttribute("projectId", projectId)
618+
.setAttribute("bq.dataset.project_id", projectId)
620619
.setAllAttributes(otelAttributesFromOptions(options))
621620
.startSpan();
622621
}
@@ -1638,7 +1637,6 @@ && getOptions().getOpenTelemetryTracer() != null) {
16381637
.getOpenTelemetryTracer()
16391638
.spanBuilder("com.google.cloud.bigquery.BigQuery.listTableData")
16401639
.setAllAttributes(tableId.getOtelAttributes())
1641-
.setAllAttributes(schema.getOtelAttributes())
16421640
.setAllAttributes(otelAttributesFromOptions(options))
16431641
.startSpan();
16441642
}
@@ -1735,7 +1733,7 @@ && getOptions().getOpenTelemetryTracer() != null) {
17351733
getOptions()
17361734
.getOpenTelemetryTracer()
17371735
.spanBuilder("com.google.cloud.bigquery.BigQuery.getJob")
1738-
.setAllAttributes(jobId.getOtelAttributes())
1736+
.setAllAttributes(completeJobId.getOtelAttributes())
17391737
.setAllAttributes(otelAttributesFromOptions(options))
17401738
.startSpan();
17411739
}
@@ -1848,7 +1846,7 @@ && getOptions().getOpenTelemetryTracer() != null) {
18481846
getOptions()
18491847
.getOpenTelemetryTracer()
18501848
.spanBuilder("com.google.cloud.bigquery.BigQuery.cancelJob")
1851-
.setAllAttributes(jobId.getOtelAttributes())
1849+
.setAllAttributes(completeJobId.getOtelAttributes())
18521850
.startSpan();
18531851
}
18541852
try (Scope jobCancelScope = jobCancel != null ? jobCancel.makeCurrent() : null) {
@@ -1895,7 +1893,6 @@ && getOptions().getOpenTelemetryTracer() != null) {
18951893
getOptions()
18961894
.getOpenTelemetryTracer()
18971895
.spanBuilder("com.google.cloud.bigquery.BigQuery.query")
1898-
.setAllAttributes(configuration.getOtelAttributes())
18991896
.setAllAttributes(otelAttributesFromOptions(options))
19001897
.startSpan();
19011898
}
@@ -1933,7 +1930,7 @@ && getOptions().getOpenTelemetryTracer() != null) {
19331930
getOptions()
19341931
.getOpenTelemetryTracer()
19351932
.spanBuilder("com.google.cloud.bigquery.BigQuery.queryRpc")
1936-
.setAttribute("projectId", projectId)
1933+
.setAttribute("bq.query.project_id", projectId)
19371934
.setAllAttributes(otelAttributesFromQueryRequest(content))
19381935
.setAllAttributes(otelAttributesFromOptions(options))
19391936
.startSpan();
@@ -2034,7 +2031,6 @@ && getOptions().getOpenTelemetryTracer() != null) {
20342031
getOptions()
20352032
.getOpenTelemetryTracer()
20362033
.spanBuilder("com.google.cloud.bigquery.BigQuery.query")
2037-
.setAllAttributes(configuration.getOtelAttributes())
20382034
.setAllAttributes(jobId.getOtelAttributes())
20392035
.setAllAttributes(otelAttributesFromOptions(options))
20402036
.startSpan();
@@ -2267,7 +2263,7 @@ && getOptions().getOpenTelemetryTracer() != null) {
22672263
.getOpenTelemetryTracer()
22682264
.spanBuilder("com.google.cloud.bigquery.BigQuery.testIamPermissions")
22692265
.setAllAttributes(tableId.getOtelAttributes())
2270-
.setAttribute("permissions", permissions.toString())
2266+
.setAttribute("bq.iam.permissions", permissions.toString())
22712267
.setAllAttributes(otelAttributesFromOptions(options))
22722268
.startSpan();
22732269
}
@@ -2318,27 +2314,27 @@ private static Attributes otelAttributesFromOptions(Option... options) {
23182314
for (Option option : options) {
23192315
attributes =
23202316
attributes.toBuilder()
2321-
.put(option.getRpcOption().toString(), option.getValue().toString())
2317+
.put("bq.option." + option.getRpcOption().toString(), option.getValue().toString())
23222318
.build();
23232319
}
23242320
return attributes;
23252321
}
23262322

23272323
private static Attributes otelAttributesFromQueryRequest(QueryRequest request) {
23282324
return Attributes.builder()
2329-
.put("dryRun", getFieldAsString(request.getDryRun()))
2330-
.put("jobCreationMode", getFieldAsString(request.getJobCreationMode()))
2331-
.put("kind", getFieldAsString(request.getKind()))
2332-
.put("location", getFieldAsString(request.getLocation()))
2333-
.put("requestId", getFieldAsString(request.getRequestId()))
2334-
.put("useQueryCache", getFieldAsString(request.getUseQueryCache()))
2325+
.put("bq.query.dry_run", getFieldAsString(request.getDryRun()))
2326+
.put("bq.query.job_creation_mode", getFieldAsString(request.getJobCreationMode()))
2327+
.put("bq.query.kind", getFieldAsString(request.getKind()))
2328+
.put("bq.query.location", getFieldAsString(request.getLocation()))
2329+
.put("bq.query.request_id", getFieldAsString(request.getRequestId()))
2330+
.put("bq.query.use_query_cache", getFieldAsString(request.getUseQueryCache()))
23352331
.build();
23362332
}
23372333

23382334
private static Attributes otelAttributesFromPolicy(Policy policy) {
23392335
return Attributes.builder()
2340-
.put("version", getFieldAsString(policy.getVersion()))
2341-
.put("bindings", getFieldAsString(policy.getBindings()))
2336+
.put("bq.policy.version", getFieldAsString(policy.getVersion()))
2337+
.put("bq.policy.bindings", getFieldAsString(policy.getBindings()))
23422338
.build();
23432339
}
23442340

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
}

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import com.google.api.services.bigquery.model.TableSchema;
2323
import com.google.common.base.Function;
2424
import com.google.common.base.MoreObjects;
25-
import io.opentelemetry.api.common.Attributes;
2625
import java.io.Serializable;
2726
import java.util.Collections;
2827
import java.util.List;
@@ -100,13 +99,4 @@ static Schema fromPb(com.google.api.services.bigquery.model.TableSchema tableSch
10099
}
101100
return Schema.of(FieldList.fromPb(fields));
102101
}
103-
104-
public Attributes getOtelAttributes() {
105-
Attributes attributes = Attributes.builder().build();
106-
for (Field field : this.getFields()) {
107-
attributes =
108-
attributes.toBuilder().put("Field: " + field.getName(), field.toString()).build();
109-
}
110-
return attributes;
111-
}
112102
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ static TableId fromPb(TableReference tableRef) {
118118

119119
protected Attributes getOtelAttributes() {
120120
return Attributes.builder()
121-
.put("project", this.getProject())
122-
.put("dataset", this.getDataset())
123-
.put("table", this.getTable())
121+
.put("bq.table.project", this.getProject())
122+
.put("bq.table.dataset", this.getDataset())
123+
.put("bq.table.id", this.getTable())
124124
.build();
125125
}
126126
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -772,11 +772,11 @@ private static String getFieldAsString(Object field) {
772772
protected Attributes getOtelAttributes() {
773773
return Attributes.builder()
774774
.putAll(this.getTableId().getOtelAttributes())
775-
.put("creationTime", getFieldAsString(this.getCreationTime()))
776-
.put("expirationTime", getFieldAsString(this.getExpirationTime()))
777-
.put("lastModifiedTime", getFieldAsString(this.getLastModifiedTime()))
778-
.put("numBytes", getFieldAsString(this.getNumBytes()))
779-
.put("numRows", getFieldAsString(this.getNumRows()))
775+
.put("bq.table.creation_time", getFieldAsString(this.getCreationTime()))
776+
.put("bq.table.expiration_time", getFieldAsString(this.getExpirationTime()))
777+
.put("bq.table.last_modified_time", getFieldAsString(this.getLastModifiedTime()))
778+
.put("bq.table.num_bytes", getFieldAsString(this.getNumBytes()))
779+
.put("bq.table.num_rows", getFieldAsString(this.getNumRows()))
780780
.build();
781781
}
782782
}

google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7587,19 +7587,19 @@ public void testOpenTelemetryTracingDatasets() {
75877587
parentSpan.end();
75887588
Map<AttributeKey<?>, Object> createMap =
75897589
OTEL_ATTRIBUTES.get("com.google.cloud.bigquery.BigQuery.createDataset");
7590-
assertEquals(createMap.get(AttributeKey.stringKey("location")), "null");
7590+
assertEquals(createMap.get(AttributeKey.stringKey("bq.dataset.location")), "null");
75917591

75927592
Map<AttributeKey<?>, Object> getMap =
75937593
OTEL_ATTRIBUTES.get("com.google.cloud.bigquery.BigQuery.getDataset");
7594-
assertEquals(getMap.get(AttributeKey.stringKey("dataset")), billingModelDataset);
7594+
assertEquals(getMap.get(AttributeKey.stringKey("bq.dataset.id")), billingModelDataset);
75957595

75967596
Map<AttributeKey<?>, Object> updateMap =
75977597
OTEL_ATTRIBUTES.get("com.google.cloud.bigquery.BigQuery.updateDataset");
7598-
assertEquals(updateMap.get(AttributeKey.stringKey("ACCESS_POLICY_VERSION")), "2");
7598+
assertEquals(updateMap.get(AttributeKey.stringKey("bq.option.ACCESS_POLICY_VERSION")), "2");
75997599

76007600
Map<AttributeKey<?>, Object> deleteMap =
76017601
OTEL_ATTRIBUTES.get("com.google.cloud.bigquery.BigQuery.deleteDataset");
7602-
assertEquals(deleteMap.get(AttributeKey.stringKey("dataset")), billingModelDataset);
7602+
assertEquals(deleteMap.get(AttributeKey.stringKey("bq.dataset.id")), billingModelDataset);
76037603

76047604
// All should be children spans of parentSpan
76057605
assertEquals(
@@ -7644,12 +7644,12 @@ public void testOpenTelemetryTracingTables() {
76447644
assertEquals(
76457645
OTEL_ATTRIBUTES
76467646
.get("com.google.cloud.bigquery.BigQuery.createTable")
7647-
.get(AttributeKey.stringKey("table")),
7647+
.get(AttributeKey.stringKey("bq.table.id")),
76487648
tableName);
76497649
assertEquals(
76507650
OTEL_ATTRIBUTES
76517651
.get("com.google.cloud.bigquery.BigQuery.createTable")
7652-
.get(AttributeKey.stringKey("creationTime")),
7652+
.get(AttributeKey.stringKey("bq.table.creation_time")),
76537653
"null");
76547654

76557655
Table updatedTable =

0 commit comments

Comments
 (0)

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.