Skip to content

Commit 3a50104

Browse files
taherkltaherkl
andauthored
OTEL integration (#87)
* OTEL Implementation Co-authored-by: taherkl <[email protected]>
1 parent c8f27ea commit 3a50104

File tree

12 files changed

+1510
-154
lines changed

12 files changed

+1510
-154
lines changed

api/v1/db.go

Lines changed: 260 additions & 89 deletions
Large diffs are not rendered by default.

config.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,43 @@ spanner:
44
database_name: ${DATABASE_ID}
55
query_limit: ${QUERY_LIMIT}
66
dynamo_query_limit: ${DYNAMODB_QUERY_LIMIT}
7+
Session:
8+
# Minimum number of sessions that Spanner pool will always maintain by the session pool.
9+
# Defaults to 100.
10+
min: 100
11+
# Maximum number of sessions that Spanner pool will have.
12+
# Defaults to 400.
13+
max: 200
14+
# Number of channels utilized by the Spanner client.
15+
# Defaults to 4.
16+
grpcChannels: 4
17+
otel:
18+
# Set enabled to true or false for OTEL metrics and traces
19+
enabled: True
20+
# Whether or not to enable client side metrics (such as sessions, gfe latency etc.)
21+
enabledClientSideMetrics: False
22+
# Name of the collector service to be setup as a sidecar
23+
serviceName: YOUR_OTEL_COLLECTOR_SERVICE_NAME
24+
healthcheck:
25+
# Enable the health check in this proxy application config only if the
26+
# "health_check" extension is added to the OTEL collector service configuration.
27+
#
28+
# Recommendation:
29+
# Enable the OTEL health check if you need to verify the collector's availability
30+
# at the start of the application. For development or testing environments, it can
31+
# be safely disabled to reduce complexity.
32+
33+
# Enable/Disable Health Check for OTEL, Default 'False'.
34+
enabled: False
35+
# Health check endpoint for the OTEL collector service
36+
endpoint: YOUR_OTEL_COLLECTOR_HEALTHCHECK_ENDPOINT
37+
metrics:
38+
# Collector service endpoint
39+
enabled: False
40+
endpoint: YOUR_OTEL_COLLECTOR_SERVICE_ENDPOINT
41+
traces:
42+
# Collector service endpoint
43+
enabled: False
44+
endpoint: YOUR_OTEL_COLLECTOR_SERVICE_ENDPOINT
45+
#Sampling ratio should be between 0 and 1. Here 0.05 means 5/100 Sampling ratio.
46+
samplingRatio: YOUR_SAMPLING_RATIO

config/config.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,18 @@ package config
1818

1919
import (
2020
"fmt"
21+
22+
"gopkg.in/yaml.v3"
23+
2124
"log"
2225
"os"
2326

2427
"github.com/cloudspannerecosystem/dynamodb-adapter/models"
2528
"github.com/cloudspannerecosystem/dynamodb-adapter/pkg/errors"
26-
"gopkg.in/yaml.v2"
29+
)
30+
31+
const (
32+
proxyReleaseVersion = "v1.0.0"
2733
)
2834

2935
// Configuration struct
@@ -47,6 +53,7 @@ func InitConfig(filepath string) {
4753
if err != nil {
4854
log.Printf("failed to read config file: %v", err)
4955
}
56+
GlobalConfig.UserAgent = "dynamodb-adapter/" + proxyReleaseVersion
5057
models.GlobalConfig = GlobalConfig
5158
}
5259

@@ -60,7 +67,6 @@ func loadConfig(filename string) (*models.Config, error) {
6067
if err := yaml.Unmarshal(data, &config); err != nil {
6168
return nil, fmt.Errorf("failed to unmarshal config: %w", err)
6269
}
63-
6470
return &config, nil
6571
}
6672

go.mod

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ require (
1818
github.com/gin-gonic/gin v1.7.4
1919
github.com/gorilla/websocket v1.4.2 // indirect
2020
github.com/imkira/go-interpol v1.1.0 // indirect
21-
github.com/opentracing/opentracing-go v1.2.0
2221
github.com/robfig/cron v1.2.0
2322
github.com/satori/go.uuid v1.2.0
2423
github.com/stretchr/testify v1.10.0
@@ -27,19 +26,19 @@ require (
2726
github.com/valyala/fasthttp v1.15.1 // indirect
2827
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
2928
go.uber.org/zap v1.19.1
30-
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
29+
golang.org/x/tools v0.22.0 // indirect
3130
google.golang.org/api v0.218.0
3231
google.golang.org/genproto v0.0.0-20250122153221-138b5a5a4fd4 // indirect
3332
gopkg.in/go-playground/assert.v1 v1.2.1
3433
)
3534

3635
require (
36+
cloud.google.com/go v0.118.1 // indirect
3737
github.com/antlr4-go/antlr/v4 v4.13.1
3838
github.com/tj/assert v0.0.3
3939
)
4040

4141
require (
42-
cloud.google.com/go v0.118.1 // indirect
4342
github.com/KyleBanks/depth v1.2.1 // indirect
4443
github.com/PuerkitoBio/purell v1.1.1 // indirect
4544
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
@@ -88,24 +87,23 @@ require (
8887
golang.org/x/sync v0.10.0 // indirect
8988
golang.org/x/sys v0.29.0 // indirect
9089
golang.org/x/text v0.21.0 // indirect
91-
google.golang.org/grpc v1.70.0 // indirect
90+
google.golang.org/grpc v1.70.0
9291
google.golang.org/protobuf v1.36.4 // indirect
9392
gopkg.in/yaml.v2 v2.4.0
9493
gopkg.in/yaml.v3 v3.0.1
9594
moul.io/http2curl v1.0.1-0.20190925090545-5cd742060b0e // indirect
9695
)
9796

9897
require (
99-
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.37.1
100-
github.com/aws/smithy-go v1.22.1 // indirect
101-
)
102-
103-
require (
104-
github.com/aws/aws-sdk-go-v2/config v1.28.5
105-
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.24 // indirect
106-
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.24 // indirect
107-
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1 // indirect
108-
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.10.5 // indirect
98+
github.com/google/uuid v1.6.0
99+
go.opentelemetry.io/contrib/detectors/gcp v1.33.0
100+
go.opentelemetry.io/otel v1.34.0
101+
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.33.0
102+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.33.0
103+
go.opentelemetry.io/otel/metric v1.34.0
104+
go.opentelemetry.io/otel/sdk v1.34.0
105+
go.opentelemetry.io/otel/sdk/metric v1.33.0
106+
go.opentelemetry.io/otel/trace v1.34.0
109107
)
110108

111109
require (
@@ -115,37 +113,47 @@ require (
115113
cloud.google.com/go/compute/metadata v0.6.0 // indirect
116114
cloud.google.com/go/iam v1.3.1 // indirect
117115
cloud.google.com/go/longrunning v0.6.4 // indirect
118-
cloud.google.com/go/monitoring v1.23.0 // indirect
119116
github.com/GoogleCloudPlatform/grpc-gcp-go/grpcgcp v1.5.2 // indirect
120117
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.25.0 // indirect
121-
github.com/aws/aws-sdk-go-v2/credentials v1.17.46 // indirect
122-
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.20 // indirect
123-
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect
124-
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.5 // indirect
125-
github.com/aws/aws-sdk-go-v2/service/sso v1.24.6 // indirect
126-
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.5 // indirect
127-
github.com/aws/aws-sdk-go-v2/service/sts v1.33.1 // indirect
118+
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.37.1
119+
github.com/aws/smithy-go v1.22.1 // indirect
120+
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
128121
github.com/cespare/xxhash/v2 v2.3.0 // indirect
129122
github.com/cncf/xds/go v0.0.0-20240905190251-b4127c9b8d78 // indirect
130-
github.com/envoyproxy/go-control-plane/envoy v1.32.4 // indirect
131123
github.com/envoyproxy/protoc-gen-validate v1.2.1 // indirect
132124
github.com/felixge/httpsnoop v1.0.4 // indirect
133125
github.com/go-logr/logr v1.4.2 // indirect
134126
github.com/go-logr/stdr v1.2.2 // indirect
135127
github.com/google/s2a-go v0.1.9 // indirect
136-
github.com/google/uuid v1.6.0 // indirect
137128
github.com/googleapis/enterprise-certificate-proxy v0.3.4 // indirect
129+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.24.0 // indirect
138130
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
139131
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
140-
go.opentelemetry.io/contrib/detectors/gcp v1.33.0 // indirect
141132
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.58.0 // indirect
142133
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.58.0 // indirect
143-
go.opentelemetry.io/otel v1.34.0 // indirect
144-
go.opentelemetry.io/otel/metric v1.34.0 // indirect
145-
go.opentelemetry.io/otel/sdk v1.34.0 // indirect
146-
go.opentelemetry.io/otel/sdk/metric v1.32.0 // indirect
147-
go.opentelemetry.io/otel/trace v1.34.0 // indirect
134+
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.33.0 // indirect
135+
go.opentelemetry.io/proto/otlp v1.4.0 // indirect
148136
golang.org/x/time v0.9.0 // indirect
149137
google.golang.org/genproto/googleapis/api v0.0.0-20250124145028-65684f501c47 // indirect
150138
google.golang.org/genproto/googleapis/rpc v0.0.0-20250124145028-65684f501c47 // indirect
151139
)
140+
141+
require (
142+
github.com/aws/aws-sdk-go-v2/config v1.28.5
143+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.24 // indirect
144+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.24 // indirect
145+
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1 // indirect
146+
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.10.5 // indirect
147+
)
148+
149+
require (
150+
cloud.google.com/go/monitoring v1.23.0 // indirect
151+
github.com/aws/aws-sdk-go-v2/credentials v1.17.46 // indirect
152+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.20 // indirect
153+
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect
154+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.5 // indirect
155+
github.com/aws/aws-sdk-go-v2/service/sso v1.24.6 // indirect
156+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.5 // indirect
157+
github.com/aws/aws-sdk-go-v2/service/sts v1.33.1 // indirect
158+
github.com/envoyproxy/go-control-plane/envoy v1.32.4 // indirect
159+
)

go.sum

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,8 @@ github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLj
694694
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
695695
github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
696696
github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
697+
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
698+
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
697699
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
698700
github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
699701
github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw=
@@ -949,6 +951,8 @@ github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad
949951
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
950952
github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4ZsPv9hVvWI6+ch50m39Pf2Ks=
951953
github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3/go.mod h1:o//XUCC/F+yRGJoPO/VU0GSB0f8Nhgmxx0VIRUvaC0w=
954+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.24.0 h1:TmHmbvxPmaegwhDubVz0lICL0J5Ka2vwTzhoePEXsGE=
955+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.24.0/go.mod h1:qztMSjm835F2bXf+5HKAPIS5qsmQDqZna/PgVt4rWtI=
952956
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
953957
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
954958
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
@@ -1034,8 +1038,6 @@ github.com/onsi/ginkgo v1.10.1 h1:q/mM8GF/n0shIN8SaAZ0V+jnLPzen6WIVZdiwrRlMlo=
10341038
github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
10351039
github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME=
10361040
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
1037-
github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs=
1038-
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
10391041
github.com/phpdave11/gofpdf v1.4.2/go.mod h1:zpO6xFn9yxo3YLyMvW8HcKWVdbNqgIfOOp2dXMnm1mY=
10401042
github.com/phpdave11/gofpdi v1.0.12/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI=
10411043
github.com/phpdave11/gofpdi v1.0.13/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI=
@@ -1167,22 +1169,31 @@ go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.58.0 h1:yd02MEj
11671169
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.58.0/go.mod h1:umTcuxiv1n/s/S6/c2AT/g2CQ7u5C59sHDNmfSwgz7Q=
11681170
go.opentelemetry.io/otel v1.34.0 h1:zRLXxLCgL1WyKsPVrgbSdMN4c0FMkDAskSTQP+0hdUY=
11691171
go.opentelemetry.io/otel v1.34.0/go.mod h1:OWFPOQ+h4G8xpyjgqo4SxJYdDQ/qmRH+wivy7zzx9oI=
1172+
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.33.0 h1:7F29RDmnlqk6B5d+sUqemt8TBfDqxryYW5gX6L74RFA=
1173+
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.33.0/go.mod h1:ZiGDq7xwDMKmWDrN1XsXAj0iC7hns+2DhxBFSncNHSE=
1174+
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.33.0 h1:Vh5HayB/0HHfOQA7Ctx69E/Y/DcQSMPpKANYVMQ7fBA=
1175+
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.33.0/go.mod h1:cpgtDBaqD/6ok/UG0jT15/uKjAY8mRA53diogHBg3UI=
1176+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.33.0 h1:5pojmb1U1AogINhN3SurB+zm/nIcusopeBNp42f45QM=
1177+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.33.0/go.mod h1:57gTHJSE5S1tqg+EKsLPlTWhpHMsWlVmer+LA926XiA=
11701178
go.opentelemetry.io/otel/metric v1.34.0 h1:+eTR3U0MyfWjRDhmFMxe2SsW64QrZ84AOhvqS7Y+PoQ=
11711179
go.opentelemetry.io/otel/metric v1.34.0/go.mod h1:CEDrp0fy2D0MvkXE+dPV7cMi8tWZwX3dmaIhwPOaqHE=
11721180
go.opentelemetry.io/otel/sdk v1.34.0 h1:95zS4k/2GOy069d321O8jWgYsW3MzVV+KuSPKp7Wr1A=
11731181
go.opentelemetry.io/otel/sdk v1.34.0/go.mod h1:0e/pNiaMAqaykJGKbi+tSjWfNNHMTxoC9qANsCzbyxU=
1174-
go.opentelemetry.io/otel/sdk/metric v1.32.0 h1:rZvFnvmvawYb0alrYkjraqJq0Z4ZUJAiyYCU9snn1CU=
1175-
go.opentelemetry.io/otel/sdk/metric v1.32.0/go.mod h1:PWeZlq0zt9YkYAp3gjKZ0eicRYvOh1Gd+X99x6GHpCQ=
1182+
go.opentelemetry.io/otel/sdk/metric v1.33.0 h1:Gs5VK9/WUJhNXZgn8MR6ITatvAmKeIuCtNbsP3JkNqU=
1183+
go.opentelemetry.io/otel/sdk/metric v1.33.0/go.mod h1:dL5ykHZmm1B1nVRk9dDjChwDmt81MjVp3gLkQRwKf/Q=
11761184
go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC8mh/k=
11771185
go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE=
11781186
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
11791187
go.opentelemetry.io/proto/otlp v0.15.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U=
11801188
go.opentelemetry.io/proto/otlp v0.19.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U=
1189+
go.opentelemetry.io/proto/otlp v1.4.0 h1:TA9WRvW6zMwP+Ssb6fLoUIuirti1gGbP28GcKG1jgeg=
1190+
go.opentelemetry.io/proto/otlp v1.4.0/go.mod h1:PPBWZIP98o2ElSqI35IHfu7hIhSwvc5N38Jw8pXuGFY=
11811191
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
11821192
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
11831193
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
1184-
go.uber.org/goleak v1.1.11-0.20210813005559-691160354723 h1:sHOAIxRGBp443oHZIPB+HsUGaksVCXVQENPxwTfQdH4=
11851194
go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
1195+
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
1196+
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
11861197
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
11871198
go.uber.org/multierr v1.7.0 h1:zaiO/rmgFjbmCXdSYJWQcdvOCsthmdaHfr3Gm2Kx4Ec=
11881199
go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
@@ -1259,8 +1270,8 @@ golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91
12591270
golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
12601271
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
12611272
golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
1262-
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
1263-
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
1273+
golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0=
1274+
golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
12641275
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
12651276
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
12661277
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -1559,8 +1570,8 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc
15591570
golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k=
15601571
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
15611572
golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s=
1562-
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
1563-
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
1573+
golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA=
1574+
golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c=
15641575
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
15651576
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
15661577
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

initializer/initializer.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
package initializer
1818

1919
import (
20+
"context"
21+
2022
"github.com/cloudspannerecosystem/dynamodb-adapter/config"
2123
"github.com/cloudspannerecosystem/dynamodb-adapter/service/services"
2224
"github.com/cloudspannerecosystem/dynamodb-adapter/service/spanner"
@@ -27,12 +29,14 @@ import (
2729
// Config, storage and all other global objects are initialize
2830
func InitAll(filepath string) error {
2931
config.InitConfig(filepath)
30-
storage.InitializeDriver()
31-
err := spanner.ParseDDL(true)
32+
err := storage.InitializeDriver(context.Background())
33+
if err != nil {
34+
return err
35+
}
36+
err = spanner.ParseDDL(true)
3237
if err != nil {
3338
return err
3439
}
3540
services.StartConfigManager()
36-
services.InitStream()
3741
return nil
3842
}

models/model.go

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,69 @@
1616
package models
1717

1818
import (
19+
"context"
1920
"sync"
2021

2122
"github.com/antonmedv/expr/vm"
2223
"github.com/aws/aws-sdk-go/service/dynamodb"
24+
otelgo "github.com/cloudspannerecosystem/dynamodb-adapter/otel"
2325
)
2426

2527
type SpannerConfig struct {
26-
ProjectID string `yaml:"project_id"`
27-
InstanceID string `yaml:"instance_id"`
28-
DatabaseName string `yaml:"database_name"`
29-
QueryLimit int64 `yaml:"query_limit"`
30-
DynamoQueryLimit int32 `yaml:"dynamo_query_limit"` //dynamo_query_limit
28+
ProjectID string `yaml:"project_id"`
29+
InstanceID string `yaml:"instance_id"`
30+
DatabaseName string `yaml:"database_name"`
31+
QueryLimit int64 `yaml:"query_limit"`
32+
DynamoQueryLimit int32 `yaml:"dynamo_query_limit"` //dynamo_query_limit
33+
Session Session `yaml:"Session"`
34+
}
35+
36+
type Session struct {
37+
Min uint64 `yaml:"min"`
38+
Max uint64 `yaml:"max"`
39+
GrpcChannels int `yaml:"grpcChannels"`
40+
}
41+
42+
// Spanner read/write operation settings.
43+
type Operation struct {
44+
MaxCommitDelay uint64 `yaml:"maxCommitDelay"`
45+
ReplayProtection bool `yaml:"replayProtection"`
46+
}
47+
48+
// OtelConfig defines the structure of the YAML configuration
49+
type OtelConfig struct {
50+
Enabled bool `yaml:"enabled"`
51+
EnabledClientSideMetrics bool `yaml:"enabledClientSideMetrics"`
52+
ServiceName string `yaml:"serviceName"`
53+
HealthCheck struct {
54+
Enabled bool `yaml:"enabled"`
55+
Endpoint string `yaml:"endpoint"`
56+
} `yaml:"healthcheck"`
57+
Metrics struct {
58+
Enabled bool `yaml:"enabled"`
59+
Endpoint string `yaml:"endpoint"`
60+
} `yaml:"metrics"`
61+
Traces struct {
62+
Enabled bool `yaml:"enabled"`
63+
Endpoint string `yaml:"endpoint"`
64+
SamplingRatio float64 `yaml:"samplingRatio"`
65+
} `yaml:"traces"`
3166
}
3267

3368
type Config struct {
34-
Spanner SpannerConfig `yaml:"spanner"`
69+
Spanner SpannerConfig `yaml:"spanner"`
70+
Otel *OtelConfig `yaml:"otel"`
71+
UserAgent string
72+
}
73+
74+
type Proxy struct {
75+
Context context.Context
76+
OtelInst *otelgo.OpenTelemetry // Exported field (starts with uppercase)
77+
OtelShutdown func(context.Context) error
3578
}
3679

80+
var GlobalProxy *Proxy
81+
3782
var GlobalConfig *Config
3883

3984
// Meta struct

0 commit comments

Comments
 (0)