Skip to content
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 @@ -70,8 +70,8 @@ public static void addCommonAttributeToSpan(Span span) {
span.setAttribute(GCP_CLIENT_SERVICE, BQ_GCP_CLIENT_SERVICE)
.setAttribute(GCP_CLIENT_REPO, BQ_GCP_CLIENT_REPO)
.setAttribute(GCP_CLIENT_ARTIFACT, BQ_GCP_CLIENT_ARTIFACT)
.setAttribute(GCP_CLIENT_LANGUAGE, BQ_GCP_CLIENT_LANGUAGE);
// TODO: add version
.setAttribute(GCP_CLIENT_LANGUAGE, BQ_GCP_CLIENT_LANGUAGE)
.setAttribute(GCP_CLIENT_VERSION, Version.VERSION);
}

/**
Expand Down
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be package private as per gax's approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to telemetry package in order to make package private

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* 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.telemetry;

import com.google.api.core.InternalApi;

/**
* Version class defines current google-cloud-bigquery artifact version to be referenced at runtime
* for telemetry purposes.
*/
@InternalApi("For internal use only")
final class Version {
// {x-version-update-start:google-cloud-bigquery:current}
static final String VERSION = "2.63.0-SNAPSHOT";
// {x-version-update-end}
}
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,30 @@ public void testAddExceptionToSpan_NoMessage() {
"CLIENT_UNKNOWN_ERROR", spanData.getAttributes().get(BigQueryTelemetryTracer.ERROR_TYPE));
}

@Test
public void testAddCommonAttributeToSpan() {
BigQueryTelemetryTracer.addCommonAttributeToSpan(span);
span.end();

List<SpanData> spans = spanExporter.getFinishedSpanItems();
SpanData spanData = spans.get(0);

assertEquals(
BigQueryTelemetryTracer.BQ_GCP_CLIENT_SERVICE,
spanData.getAttributes().get(BigQueryTelemetryTracer.GCP_CLIENT_SERVICE));
assertEquals(
BigQueryTelemetryTracer.BQ_GCP_CLIENT_REPO,
spanData.getAttributes().get(BigQueryTelemetryTracer.GCP_CLIENT_REPO));
assertEquals(
BigQueryTelemetryTracer.BQ_GCP_CLIENT_ARTIFACT,
spanData.getAttributes().get(BigQueryTelemetryTracer.GCP_CLIENT_ARTIFACT));
assertEquals(
BigQueryTelemetryTracer.BQ_GCP_CLIENT_LANGUAGE,
spanData.getAttributes().get(BigQueryTelemetryTracer.GCP_CLIENT_LANGUAGE));
assertEquals(
Version.VERSION, spanData.getAttributes().get(BigQueryTelemetryTracer.GCP_CLIENT_VERSION));
}

private GoogleJsonResponseException createException(
String highLevelStatusCode, String errorMessage, String detailedErrorMessage, String reason) {
GoogleJsonError googleJsonError = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ private void closeAndVerifySpanData(
assertEquals(
responseCode,
span.getAttributes().get(HttpTracingRequestInitializer.HTTP_RESPONSE_STATUS_CODE));
assertEquals(
Version.VERSION, span.getAttributes().get(BigQueryTelemetryTracer.GCP_CLIENT_VERSION));
assertEquals(
method, span.getAttributes().get(HttpTracingRequestInitializer.HTTP_REQUEST_METHOD));
if (requestBodySize >= 0) {
Expand Down
Loading