Skip to content

Commit 16b16c5

Browse files
authored
Merge branch 'main' into renovate/opentelemetry-go-contrib-monorepo
2 parents 1413775 + a2f0b67 commit 16b16c5

File tree

343 files changed

+15928
-6620
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

343 files changed

+15928
-6620
lines changed

.github/CODEOWNERS

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,27 @@
2727
/storagetransfer/ @GoogleCloudPlatform/go-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/gcs-sdk-team
2828

2929
# DEE Infra
30-
/batch/ @GoogleCloudPlatform/go-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/dee-infra
31-
/compute/ @GoogleCloudPlatform/go-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/dee-infra
32-
/iam/ @GoogleCloudPlatform/go-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/dee-infra
33-
/iap/ @GoogleCloudPlatform/go-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/dee-infra
34-
/kms/ @GoogleCloudPlatform/go-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/dee-infra
35-
/privateca/ @GoogleCloudPlatform/go-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/dee-infra
36-
/mediacdn/ @GoogleCloudPlatform/go-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/dee-infra
30+
/batch/ @GoogleCloudPlatform/go-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
31+
/compute/ @GoogleCloudPlatform/go-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
32+
/iam/ @GoogleCloudPlatform/go-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
33+
/iap/ @GoogleCloudPlatform/go-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
34+
/kms/ @GoogleCloudPlatform/go-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
35+
/privateca/ @GoogleCloudPlatform/go-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
36+
/mediacdn/ @GoogleCloudPlatform/go-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
3737

3838
# Other Owners
3939
/auth/ @GoogleCloudPlatform/go-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/googleapis-auth
4040
/asset/ @GoogleCloudPlatform/go-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/cloud-asset-analysis-team
4141
/billing/ @GoogleCloudPlatform/go-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/billing-samples-maintainers
4242
/dlp/ @GoogleCloudPlatform/go-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/googleapis-dlp
43+
/modelarmor/ @GoogleCloudPlatform/go-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/cloud-modelarmor-team
4344
/healthcare/ @GoogleCloudPlatform/go-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/healthcare-life-sciences
4445
/media/ @GoogleCloudPlatform/go-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/cloud-media-team
4546
/parametermanager/ @GoogleCloudPlatform/go-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/cloud-secrets-team @GoogleCloudPlatform/cloud-parameters-team
4647
/secretmanager/ @GoogleCloudPlatform/go-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/cloud-secrets-team
4748
/securitycenter/ @GoogleCloudPlatform/go-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/gcp-security-command-center
4849
/translate/ @GoogleCloudPlatform/go-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/cloud-ml-translate-dev
50+
/connectgateway/ @GoogleCloudPlatform/go-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/connectgateway
4951

5052
# Does not have owner
5153
/cdn/ @GoogleCloudPlatform/go-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers

.github/blunderbuss.yml

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,14 @@ assign_issues_by:
5252
- 'api: dlp'
5353
to:
5454
- GoogleCloudPlatform/googleapis-dlp
55-
- labels:
56-
- "api: batch"
57-
- "api: compute"
58-
- "api: cloudkms"
59-
- "api: iam"
60-
- "api: kms"
61-
- "api: privateca"
62-
to:
63-
- GoogleCloudPlatform/dee-infra
6455
- labels:
6556
- "api: parametermanager"
6657
to:
6758
- GoogleCloudPlatform/cloud-parameters-team
59+
- labels:
60+
- "api: modelarmor"
61+
to:
62+
- GoogleCloudPlatform/cloud-modelarmor-team
6863
- labels:
6964
- "api: secretmanager"
7065
to:
@@ -93,15 +88,6 @@ assign_prs_by:
9388
- 'api: dlp'
9489
to:
9590
- GoogleCloudPlatform/googleapis-dlp
96-
- labels:
97-
- "api: batch"
98-
- "api: compute"
99-
- "api: cloudkms"
100-
- "api: iam"
101-
- "api: kms"
102-
- "api: privateca"
103-
to:
104-
- GoogleCloudPlatform/dee-infra
10591
- labels:
10692
- "api: secretmanager"
10793
to:
@@ -110,7 +96,15 @@ assign_prs_by:
11096
- "api: parametermanager"
11197
to:
11298
- GoogleCloudPlatform/cloud-parameters-team
99+
- labels:
100+
- "api: modelarmor"
101+
to:
102+
- GoogleCloudPlatform/cloud-modelarmor-team
113103
- labels:
114104
- "api: securitycenter"
115105
to:
116106
- GoogleCloudPlatform/gcp-security-command-center
107+
- labels:
108+
- "api: connectgateway"
109+
to:
110+
- GoogleCloudPlatform/connectgateway

aiplatform/snippets/embeddings.go

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ import (
2828
"google.golang.org/protobuf/types/known/structpb"
2929
)
3030

31-
// embedTexts shows how embeddings are set for text-embedding-005 model
31+
// embedTexts shows how embeddings are set for gemini-embedding-001 model
3232
func embedTexts(w io.Writer, project, location string) error {
3333
// location := "us-central1"
3434
ctx := context.Background()
3535

3636
apiEndpoint := fmt.Sprintf("%s-aiplatform.googleapis.com:443", location)
37-
dimensionality := 5
38-
model := "text-embedding-005"
37+
dimensionality := 3072
38+
model := "gemini-embedding-001"
3939
texts := []string{"banana muffins? ", "banana bread? banana muffins?"}
4040

4141
client, err := aiplatform.NewPredictionClient(ctx, option.WithEndpoint(apiEndpoint))
@@ -45,41 +45,54 @@ func embedTexts(w io.Writer, project, location string) error {
4545
defer client.Close()
4646

4747
endpoint := fmt.Sprintf("projects/%s/locations/%s/publishers/google/models/%s", project, location, model)
48-
instances := make([]*structpb.Value, len(texts))
49-
for i, text := range texts {
50-
instances[i] = structpb.NewStructValue(&structpb.Struct{
48+
allEmbeddings := make([][]float32, 0, len(texts))
49+
// gemini-embedding-001 takes 1 input at a time
50+
for _, text := range texts {
51+
instances := make([]*structpb.Value, 1)
52+
instances[0] = structpb.NewStructValue(&structpb.Struct{
5153
Fields: map[string]*structpb.Value{
5254
"content": structpb.NewStringValue(text),
5355
"task_type": structpb.NewStringValue("QUESTION_ANSWERING"),
5456
},
5557
})
56-
}
5758

58-
params := structpb.NewStructValue(&structpb.Struct{
59-
Fields: map[string]*structpb.Value{
60-
"outputDimensionality": structpb.NewNumberValue(float64(dimensionality)),
61-
},
62-
})
59+
params := structpb.NewStructValue(&structpb.Struct{
60+
Fields: map[string]*structpb.Value{
61+
"outputDimensionality": structpb.NewNumberValue(float64(dimensionality)),
62+
},
63+
})
6364

64-
req := &aiplatformpb.PredictRequest{
65-
Endpoint: endpoint,
66-
Instances: instances,
67-
Parameters: params,
68-
}
69-
resp, err := client.Predict(ctx, req)
70-
if err != nil {
71-
return err
72-
}
73-
embeddings := make([][]float32, len(resp.Predictions))
74-
for i, prediction := range resp.Predictions {
75-
values := prediction.GetStructValue().Fields["embeddings"].GetStructValue().Fields["values"].GetListValue().Values
76-
embeddings[i] = make([]float32, len(values))
77-
for j, value := range values {
78-
embeddings[i][j] = float32(value.GetNumberValue())
65+
req := &aiplatformpb.PredictRequest{
66+
Endpoint: endpoint,
67+
Instances: instances,
68+
Parameters: params,
7969
}
70+
resp, err := client.Predict(ctx, req)
71+
if err != nil {
72+
return err
73+
}
74+
75+
// Process the prediction for the single text
76+
// The response will contain one prediction because we sent one instance.
77+
if len(resp.Predictions) == 0 {
78+
return fmt.Errorf("no predictions returned for text \"%s\"", text)
79+
}
80+
81+
prediction := resp.Predictions[0]
82+
embeddingValues := prediction.GetStructValue().Fields["embeddings"].GetStructValue().Fields["values"].GetListValue().Values
83+
84+
currentEmbedding := make([]float32, len(embeddingValues))
85+
for j, value := range embeddingValues {
86+
currentEmbedding[j] = float32(value.GetNumberValue())
87+
}
88+
allEmbeddings = append(allEmbeddings, currentEmbedding)
8089
}
8190

82-
fmt.Fprintf(w, "Dimensionality: %d. Embeddings length: %d", len(embeddings[0]), len(embeddings))
91+
if len(allEmbeddings) > 0 {
92+
fmt.Fprintf(w, "Dimensionality: %d. Embeddings length: %d", len(allEmbeddings[0]), len(allEmbeddings))
93+
} else {
94+
fmt.Fprintln(w, "No texts were processed.")
95+
}
8396
return nil
8497
}
8598

aiplatform/snippets/embeddings_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
func TestGenerateEmbeddings(t *testing.T) {
2626
tc := testutil.SystemTest(t)
2727
texts := []string{"banana muffins? ", "banana bread? banana muffins?"}
28-
dimensionality := 5
28+
dimensionality := 3072
2929
location := "us-central1"
3030
var buf bytes.Buffer
3131

badfiles_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ var allowList = []string{
130130
// document ai sample pdfs
131131
"documentai/**/*.pdf",
132132

133+
// Model Armor sample pdfs
134+
"modelarmor/test_sample.pdf",
135+
133136
// Speech-to-Text audio/video files
134137
"speech/resources/commercial_mono.wav",
135138

bigquery/go.mod

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,77 +3,80 @@ module github.com/GoogleCloudPlatform/golang-samples/bigquery
33
go 1.23.0
44

55
require (
6-
cloud.google.com/go v0.118.0
7-
cloud.google.com/go/bigquery v1.65.0
8-
cloud.google.com/go/iam v1.3.1
9-
cloud.google.com/go/storage v1.50.0
6+
cloud.google.com/go v0.121.0
7+
cloud.google.com/go/bigquery v1.69.0
8+
cloud.google.com/go/iam v1.5.2
9+
cloud.google.com/go/storage v1.53.0
1010
github.com/GoogleCloudPlatform/golang-samples v0.0.0-20240724083556-7f760db013b7
1111
github.com/apache/arrow/go/v10 v10.0.1
1212
github.com/gofrs/uuid v4.4.0+incompatible
1313
github.com/google/uuid v1.6.0
1414
github.com/googleapis/gax-go/v2 v2.14.1
1515
github.com/linkedin/goavro/v2 v2.13.0
16-
google.golang.org/api v0.217.0
17-
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f
18-
google.golang.org/grpc v1.69.4
19-
google.golang.org/protobuf v1.36.3
16+
google.golang.org/api v0.232.0
17+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250505200425-f936aa4a68b2
18+
google.golang.org/grpc v1.72.0
19+
google.golang.org/protobuf v1.36.6
2020
)
2121

2222
require (
23-
cel.dev/expr v0.19.1 // indirect
24-
cloud.google.com/go/auth v0.14.0 // indirect
25-
cloud.google.com/go/auth/oauth2adapt v0.2.7 // indirect
23+
cel.dev/expr v0.20.0 // indirect
24+
cloud.google.com/go/auth v0.16.1 // indirect
25+
cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect
2626
cloud.google.com/go/compute/metadata v0.6.0 // indirect
27-
cloud.google.com/go/longrunning v0.6.4 // indirect
28-
cloud.google.com/go/monitoring v1.23.0 // indirect
29-
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.25.0 // indirect
30-
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.49.0 // indirect
31-
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.49.0 // indirect
27+
cloud.google.com/go/longrunning v0.6.7 // indirect
28+
cloud.google.com/go/monitoring v1.24.0 // indirect
29+
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.27.0 // indirect
30+
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.51.0 // indirect
31+
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.51.0 // indirect
3232
github.com/andybalholm/brotli v1.0.5 // indirect
3333
github.com/apache/arrow/go/v15 v15.0.2 // indirect
3434
github.com/apache/thrift v0.17.0 // indirect
3535
github.com/cespare/xxhash/v2 v2.3.0 // indirect
3636
github.com/cncf/xds/go v0.0.0-20250121191232-2f005788dc42 // indirect
37-
github.com/envoyproxy/go-control-plane/envoy v1.32.3 // indirect
38-
github.com/envoyproxy/protoc-gen-validate v1.1.0 // indirect
37+
github.com/envoyproxy/go-control-plane/envoy v1.32.4 // indirect
38+
github.com/envoyproxy/protoc-gen-validate v1.2.1 // indirect
3939
github.com/felixge/httpsnoop v1.0.4 // indirect
40+
github.com/go-jose/go-jose/v4 v4.0.4 // indirect
4041
github.com/go-logr/logr v1.4.2 // indirect
4142
github.com/go-logr/stdr v1.2.2 // indirect
4243
github.com/goccy/go-json v0.10.3 // indirect
4344
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
4445
github.com/golang/snappy v0.0.4 // indirect
4546
github.com/google/flatbuffers v23.5.26+incompatible // indirect
4647
github.com/google/s2a-go v0.1.9 // indirect
47-
github.com/googleapis/enterprise-certificate-proxy v0.3.4 // indirect
48+
github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect
4849
github.com/klauspost/asmfmt v1.3.2 // indirect
4950
github.com/klauspost/compress v1.17.11 // indirect
5051
github.com/klauspost/cpuid/v2 v2.2.6 // indirect
5152
github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8 // indirect
5253
github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3 // indirect
5354
github.com/pierrec/lz4/v4 v4.1.18 // indirect
5455
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
56+
github.com/spiffe/go-spiffe/v2 v2.5.0 // indirect
57+
github.com/zeebo/errs v1.4.0 // indirect
5558
github.com/zeebo/xxh3 v1.0.2 // indirect
5659
go.opencensus.io v0.24.0 // indirect
5760
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
58-
go.opentelemetry.io/contrib/detectors/gcp v1.34.0 // indirect
59-
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.59.0 // indirect
60-
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.59.0 // indirect
61-
go.opentelemetry.io/otel v1.34.0 // indirect
62-
go.opentelemetry.io/otel/metric v1.34.0 // indirect
63-
go.opentelemetry.io/otel/sdk v1.34.0 // indirect
64-
go.opentelemetry.io/otel/sdk/metric v1.34.0 // indirect
65-
go.opentelemetry.io/otel/trace v1.34.0 // indirect
66-
golang.org/x/crypto v0.32.0 // indirect
67-
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
68-
golang.org/x/mod v0.20.0 // indirect
69-
golang.org/x/net v0.34.0 // indirect
70-
golang.org/x/oauth2 v0.25.0 // indirect
71-
golang.org/x/sync v0.10.0 // indirect
72-
golang.org/x/sys v0.29.0 // indirect
73-
golang.org/x/text v0.21.0 // indirect
74-
golang.org/x/time v0.9.0 // indirect
75-
golang.org/x/tools v0.24.0 // indirect
61+
go.opentelemetry.io/contrib/detectors/gcp v1.35.0 // indirect
62+
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.60.0 // indirect
63+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0 // indirect
64+
go.opentelemetry.io/otel v1.35.0 // indirect
65+
go.opentelemetry.io/otel/metric v1.35.0 // indirect
66+
go.opentelemetry.io/otel/sdk v1.35.0 // indirect
67+
go.opentelemetry.io/otel/sdk/metric v1.35.0 // indirect
68+
go.opentelemetry.io/otel/trace v1.35.0 // indirect
69+
golang.org/x/crypto v0.37.0 // indirect
70+
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
71+
golang.org/x/mod v0.23.0 // indirect
72+
golang.org/x/net v0.39.0 // indirect
73+
golang.org/x/oauth2 v0.30.0 // indirect
74+
golang.org/x/sync v0.14.0 // indirect
75+
golang.org/x/sys v0.32.0 // indirect
76+
golang.org/x/text v0.24.0 // indirect
77+
golang.org/x/time v0.11.0 // indirect
78+
golang.org/x/tools v0.30.0 // indirect
7679
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect
77-
google.golang.org/genproto v0.0.0-20250115164207-1a7da9e5054f // indirect
78-
google.golang.org/genproto/googleapis/api v0.0.0-20250115164207-1a7da9e5054f // indirect
80+
google.golang.org/genproto v0.0.0-20250303144028-a0af3efb3deb // indirect
81+
google.golang.org/genproto/googleapis/api v0.0.0-20250505200425-f936aa4a68b2 // indirect
7982
)

0 commit comments

Comments
 (0)