Skip to content

Commit 72d6736

Browse files
authored
Add spans to azappconfig (Azure#21919)
1 parent e1cf912 commit 72d6736

File tree

6 files changed

+40
-9
lines changed

6 files changed

+40
-9
lines changed

sdk/data/azappconfig/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
### Bugs Fixed
1010

1111
### Other Changes
12+
* Updated to latest version of `azcore`.
13+
* Enabled spans for distributed tracing.
1214

1315
## 1.0.0 (2023-10-11)
1416

sdk/data/azappconfig/client.go

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,11 @@ func newClient(endpoint string, authPolicy policy.Policy, options *ClientOptions
6161
}
6262

6363
cache := synctoken.NewCache()
64-
client, err := azcore.NewClient(moduleName+".Client", moduleVersion, runtime.PipelineOptions{
64+
client, err := azcore.NewClient(moduleName, moduleVersion, runtime.PipelineOptions{
6565
PerRetry: []policy.Policy{authPolicy, synctoken.NewPolicy(cache)},
66+
Tracing: runtime.TracingOptions{
67+
Namespace: "Microsoft.AppConfig",
68+
},
6669
}, &options.ClientOptions)
6770
if err != nil {
6871
return nil, err
@@ -87,6 +90,10 @@ func (c *Client) SetSyncToken(syncToken SyncToken) error {
8790
// - value is the value for the setting. pass nil if the setting doesn't have a value
8891
// - options contains the optional values. can be nil
8992
func (c *Client) AddSetting(ctx context.Context, key string, value *string, options *AddSettingOptions) (AddSettingResponse, error) {
93+
var err error
94+
ctx, endSpan := runtime.StartSpan(ctx, "Client.AddSetting", c.appConfigClient.Tracer(), nil)
95+
defer func() { endSpan(err) }()
96+
9097
if options == nil {
9198
options = &AddSettingOptions{}
9299
}
@@ -108,6 +115,10 @@ func (c *Client) AddSetting(ctx context.Context, key string, value *string, opti
108115

109116
// DeleteSetting deletes a configuration setting from the configuration store.
110117
func (c *Client) DeleteSetting(ctx context.Context, key string, options *DeleteSettingOptions) (DeleteSettingResponse, error) {
118+
var err error
119+
ctx, endSpan := runtime.StartSpan(ctx, "Client.DeleteSetting", c.appConfigClient.Tracer(), nil)
120+
defer func() { endSpan(err) }()
121+
111122
if options == nil {
112123
options = &DeleteSettingOptions{}
113124
}
@@ -127,6 +138,10 @@ func (c *Client) DeleteSetting(ctx context.Context, key string, options *DeleteS
127138

128139
// GetSetting retrieves an existing configuration setting from the configuration store.
129140
func (c *Client) GetSetting(ctx context.Context, key string, options *GetSettingOptions) (GetSettingResponse, error) {
141+
var err error
142+
ctx, endSpan := runtime.StartSpan(ctx, "Client.GetSetting", c.appConfigClient.Tracer(), nil)
143+
defer func() { endSpan(err) }()
144+
130145
if options == nil {
131146
options = &GetSettingOptions{}
132147
}
@@ -147,13 +162,16 @@ func (c *Client) GetSetting(ctx context.Context, key string, options *GetSetting
147162

148163
// SetReadOnly sets an existing configuration setting to read only or read write state in the configuration store.
149164
func (c *Client) SetReadOnly(ctx context.Context, key string, isReadOnly bool, options *SetReadOnlyOptions) (SetReadOnlyResponse, error) {
165+
var err error
166+
ctx, endSpan := runtime.StartSpan(ctx, "Client.SetReadOnly", c.appConfigClient.Tracer(), nil)
167+
defer func() { endSpan(err) }()
168+
150169
if options == nil {
151170
options = &SetReadOnlyOptions{}
152171
}
153172

154173
setting := Setting{Key: &key, Label: options.Label}
155174

156-
var err error
157175
if isReadOnly {
158176
var resp generated.AzureAppConfigurationClientPutLockResponse
159177
resp, err = c.appConfigClient.PutLock(ctx, *setting.Key, setting.toGeneratedPutLockOptions(options.OnlyIfUnchanged))
@@ -183,6 +201,10 @@ func (c *Client) SetReadOnly(ctx context.Context, key string, isReadOnly bool, o
183201
// - value is the value for the setting. pass nil if the setting doesn't have a value
184202
// - options contains the optional values. can be nil
185203
func (c *Client) SetSetting(ctx context.Context, key string, value *string, options *SetSettingOptions) (SetSettingResponse, error) {
204+
var err error
205+
ctx, endSpan := runtime.StartSpan(ctx, "Client.SetSetting", c.appConfigClient.Tracer(), nil)
206+
defer func() { endSpan(err) }()
207+
186208
if options == nil {
187209
options = &SetSettingOptions{}
188210
}
@@ -226,6 +248,7 @@ func (c *Client) NewListRevisionsPager(selector SettingSelector, options *ListRe
226248
SyncToken: SyncToken(*page.SyncToken),
227249
}, nil
228250
},
251+
Tracer: c.appConfigClient.Tracer(),
229252
})
230253
}
231254

@@ -253,5 +276,6 @@ func (c *Client) NewListSettingsPager(selector SettingSelector, options *ListSet
253276
SyncToken: SyncToken(*page.SyncToken),
254277
}, nil
255278
},
279+
Tracer: c.appConfigClient.Tracer(),
256280
})
257281
}

sdk/data/azappconfig/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ module github.com/Azure/azure-sdk-for-go/sdk/data/azappconfig
33
go 1.18
44

55
require (
6-
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.8.0
6+
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0
77
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0
8-
github.com/Azure/azure-sdk-for-go/sdk/internal v1.4.0
8+
github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0
99
github.com/stretchr/testify v1.8.4
1010
)
1111

sdk/data/azappconfig/go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.8.0 h1:9kDVnTz3vbfweTqAUmk/a/pH5pWFCHtvRpHYC0G/dcA=
2-
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.8.0/go.mod h1:3Ug6Qzto9anB6mGlEdgYMDF5zHQ+wwhEaYR4s17PHMw=
1+
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 h1:fb8kj/Dh4CSwgsOzHeZY4Xh68cFVbzXx+ONXGMY//4w=
2+
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0/go.mod h1:uReU2sSxZExRPBAg3qKzmAucSi51+SP1OhohieR821Q=
33
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 h1:BMAjVKJM0U/CYF27gA0ZMmXGkOcvfFtD0oHVZ1TIPRI=
44
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0/go.mod h1:1fXstnBMas5kzG+S3q8UoJcmyU6nUeunJcMDHcRYHhs=
5-
github.com/Azure/azure-sdk-for-go/sdk/internal v1.4.0 h1:TuEMD+E+1aTjjLICGQOW6vLe8UWES7kopac9mUXL56Y=
6-
github.com/Azure/azure-sdk-for-go/sdk/internal v1.4.0/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI=
5+
github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 h1:d81/ng9rET2YqdVkVwkb6EXeRrLJIwyGnJcAlAWKwhs=
6+
github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI=
77
github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 h1:WpB/QDNLpMw72xHJc34BNNykqSOeEJDAWkhf0u12/Jk=
88
github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI=
99
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=

sdk/data/azappconfig/internal/generated/custom_client.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package generated
88

99
import (
1010
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
11+
"github.com/Azure/azure-sdk-for-go/sdk/azcore/tracing"
1112
)
1213

1314
func NewAzureAppConfigurationClient(endpoint string, client *azcore.Client) *AzureAppConfigurationClient {
@@ -16,3 +17,7 @@ func NewAzureAppConfigurationClient(endpoint string, client *azcore.Client) *Azu
1617
endpoint: endpoint,
1718
}
1819
}
20+
21+
func (a *AzureAppConfigurationClient) Tracer() tracing.Tracer {
22+
return a.internal.Tracer()
23+
}

sdk/data/azappconfig/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
package azappconfig
88

99
const (
10-
moduleName = "azappconfig"
10+
moduleName = "github.com/Azure/azure-sdk-for-go/sdk/data/azappconfig"
1111
moduleVersion = "v1.0.1"
1212
)

0 commit comments

Comments
 (0)