You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[PubSub instrumentation and logging](#pubsub-instrumentation-and-logging)
44
46
-[Kafka](#kafka)
47
+
-[Cache instrumentation and logging](#cache-instrumentation-and-logging)
48
+
-[Redis](#redis)
45
49
-[Profiling](#profiling)
46
50
-[Custom Metrics](#custom-metrics)
47
51
-[Using the `go-sdk` in isolation](#using-the--go-sdk--in-isolation)
@@ -909,6 +913,76 @@ To authenticate the requests to Kafka, Go SDK provides a configuration set for T
909
913
| Assumable role | This role will be used to establish connection to AWS MSK ignoring the static credentials | `role` | `APP_PUBSUB_KAFKA_SASL_AWS_MSK_IAM_ROLE` | string | AWS ARN string |
910
914
| Session name | Will be passed to AWS STS when assuming the role | `session_name` | `APP_PUBSUB_KAFKA_SASL_AWS_MSK_IAM_SESSION_NAME` | string | application |
911
915
916
+
### Cache
917
+
918
+
`go-sdk`provides a convenient way to create an application Cache configuration.
919
+
920
+
Top-level configuration is split into sections specific for the vendor. Let's look into the sample `cache.yml` file:
921
+
922
+
```yaml
923
+
common: &common
924
+
store: redis
925
+
redis:
926
+
url: ""
927
+
# Set by APP_CACHE_REDIS_ADDRS env variable
928
+
addrs:
929
+
- "localhost:6379"
930
+
# Set by APP_CACHE_REDIS_USERNAME env variable
931
+
username: "username"
932
+
# Set by APP_CACHE_REDIS_PASSWORD env variable
933
+
password: "password"
934
+
```
935
+
936
+
#### Redis specific configuration
937
+
938
+
Redis top-level configuration is based on the official [go-redis UniversalOptions](https://pkg.go.dev/github.com/redis/go-redis/v9#UniversalOptions) library options. The following table describes the configuration options:
939
+
940
+
| Setting | Description | YAML variable | Environment variable (ENV) | Type | Possible Values |
| URL | URL into Redis ClusterOptions that can be used to connect to Redis | `url` | `APP_CACHE_REDIS_URL` | string | redis://:password@localhost:6379/0 |
943
+
| Addrs | Either a single address or a seed list of host:port addresses of cluster/sentinel nodes. | `addrs` | `APP_CACHE_REDIS_ADDRS` | list(string) | localhost:6379 |
944
+
| ClientName | ClientName will execute the `CLIENT SETNAME ClientName` command for each conn. | `client_name` | `APP_CACHE_REDIS_CLIENT_NAME` | string | client-name |
945
+
| DB | Database to be selected after connecting to the server. Only single-node and failover clients. | `db` | `APP_CACHE_REDIS_DB` | int | 0 |
946
+
| Protocol | Protocol 2 or 3. Use the version to negotiate RESP version with redis-server. | `protocol` | `APP_CACHE_REDIS_PROTOCOL` | int | 2, 3 |
| PoolSize | Base number of socket connections. | `pool_size` | `APP_CACHE_REDIS_POOL_SIZE` | int | 10 |
959
+
| PoolTimeout | Amount of time client waits for connection if all connections are busy before returning an error. | `pool_timeout` | `APP_CACHE_REDIS_POOL_TIMEOUT` | time.Duration | 4s |
960
+
| MaxIdleConns | Maximum number of idle connections. | `max_idle_conns` | `APP_CACHE_REDIS_MAX_IDLE_CONNS` | int | 10 |
961
+
| MinIdleConns | Minimum number of idle connections. | `min_idle_conns` | `APP_CACHE_REDIS_MIN_IDLE_CONNS` | int | 5 |
962
+
| MaxActiveConns | Maximum number of connections allocated by the pool at a given time. | `max_active_conns` | `APP_CACHE_REDIS_MAX_ACTIVE_CONNS` | int | 100 |
963
+
| ConnMaxIdleTime | Maximum amount of time a connection may be idle. Should be less than server's timeout. | `conn_max_idle_time` | `APP_CACHE_REDIS_CONN_MAX_IDLE_TIME` | time.Duration | 5m |
964
+
| ConnMaxLifetime | Maximum amount of time a connection may be reused. | `conn_max_lifetime` | `APP_CACHE_REDIS_CONN_MAX_LIFETIME` | time.Duration | 5m |
965
+
| MaxRedirects | The maximum number of retries before giving up. Command is retried on network errors and MOVED/ASK redirects. Only cluster clients. | `max_redirects` | `APP_CACHE_REDIS_MAX_REDIRECTS` | int | 8 |
| Enabled | Whether TLS is enabled or not | `enabled` | `APP_CACHE_REDIS_TLS_ENABLED` | bool | true, false |
980
+
| Root certificate | Ca Root CA certificate | `ca` | `APP_CACHE_REDIS_TLS_CA` | string | Root CA |
981
+
| Cert PEM | Client's public key string (PEM format) used for authentication | `cert_pem` | `APP_CACHE_REDIS_TLS_CERT_PEM` | string | long PEM string |
982
+
| Cert PEM Key | Client's private key string (PEM format) used for authentication | `cert_pem_key` | `APP_CACHE_REDIS_TLS_CERT_PEM_KEY` | string | long PEM key string |
983
+
| Passphrase | Passphrase is used in case the private key needs to be decrypted | `passphrase` | `APP_CACHE_REDIS_TLS_PASSPHRASE` | string | pass phrase |
The `go-sdk` provides an easy way to add application performance monitoring
@@ -1250,6 +1324,49 @@ func main() {
1250
1324
}
1251
1325
```
1252
1326
1327
+
### Cache instrumentation and logging
1328
+
1329
+
#### Redis
1330
+
1331
+
`go-sdk`provides a flexible way to instrument the Redis client with logging and tracing capabilities.
1332
+
1333
+
The [go-redis](https://github.com/redis/go-redis) Redis client library is wrapped by the `go-sdk` using [dd-trace-go](https://github.com/DataDog/dd-trace-go/tree/fda4cc5e15b744b10d378a62e026dc61d35f364a/contrib/redis/go-redis.v9) library and traces calls to Redis.
1334
+
1335
+
For logging, `go-sdk` sets the [go-redis](https://pkg.go.dev/github.com/redis/go-redis/v9#SetLogger) logger to the SDK logger. This logger will print `go-redis` log stubs as error log entries.
0 commit comments