Skip to content

Commit 724d34b

Browse files
author
Yogiraj Awati
authored
Merge pull request #67 from rvdwijngaard/master
samplingRule should be an exported type
2 parents 55c3175 + 01519b2 commit 724d34b

File tree

5 files changed

+73
-73
lines changed

5 files changed

+73
-73
lines changed

strategy/sampling/centralized_sampling_rule_manifest.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func (m *CentralizedManifest) createUserRule(svcRule *xraySvc.SamplingRule) *Cen
9292
clock := &utils.DefaultClock{}
9393
rand := &utils.DefaultRand{}
9494

95-
sr := &samplingRule{
95+
sr := &SamplingRule{
9696
ServiceName: *svcRule.ServiceName,
9797
HTTPMethod: *svcRule.HTTPMethod,
9898
URLPath: *svcRule.URLPath,
@@ -114,7 +114,7 @@ func (m *CentralizedManifest) createUserRule(svcRule *xraySvc.SamplingRule) *Cen
114114
ruleName: *svcRule.RuleName,
115115
priority: *svcRule.Priority,
116116
reservoir: cr,
117-
samplingRule: sr,
117+
SamplingRule: sr,
118118
serviceType: *svcRule.ServiceType,
119119
resourceARN: *svcRule.ResourceARN,
120120
attributes: svcRule.Attributes,
@@ -145,7 +145,7 @@ func (m *CentralizedManifest) createUserRule(svcRule *xraySvc.SamplingRule) *Cen
145145
func (m *CentralizedManifest) updateUserRule(r *CentralizedRule, svcRule *xraySvc.SamplingRule) {
146146
// Preemptively dereference xraySvc.SamplingRule fields and panic early on nil pointers.
147147
// A panic in the middle of an update may leave the rule in an inconsistent state.
148-
s := &samplingRule{
148+
s := &SamplingRule{
149149
ServiceName: *svcRule.ServiceName,
150150
HTTPMethod: *svcRule.HTTPMethod,
151151
URLPath: *svcRule.URLPath,
@@ -159,7 +159,7 @@ func (m *CentralizedManifest) updateUserRule(r *CentralizedRule, svcRule *xraySv
159159
r.Lock()
160160
defer r.Unlock()
161161

162-
r.samplingRule = s
162+
r.SamplingRule = s
163163
r.priority = p
164164
r.reservoir.capacity = c
165165
r.serviceType = *svcRule.ServiceType
@@ -174,7 +174,7 @@ func (m *CentralizedManifest) createDefaultRule(svcRule *xraySvc.SamplingRule) *
174174
clock := &utils.DefaultClock{}
175175
rand := &utils.DefaultRand{}
176176

177-
sr := &samplingRule{
177+
sr := &SamplingRule{
178178
FixedTarget: *svcRule.ReservoirSize,
179179
Rate: *svcRule.FixedRate,
180180
}
@@ -191,7 +191,7 @@ func (m *CentralizedManifest) createDefaultRule(svcRule *xraySvc.SamplingRule) *
191191
csr := &CentralizedRule{
192192
ruleName: *svcRule.RuleName,
193193
reservoir: cr,
194-
samplingRule: sr,
194+
SamplingRule: sr,
195195
clock: clock,
196196
rand: rand,
197197
}
@@ -221,7 +221,7 @@ func (m *CentralizedManifest) updateDefaultRule(svcRule *xraySvc.SamplingRule) {
221221

222222
// Preemptively dereference xraySvc.SamplingRule fields and panic early on nil pointers.
223223
// A panic in the middle of an update may leave the rule in an inconsistent state.
224-
s := &samplingRule{
224+
s := &SamplingRule{
225225
FixedTarget: *svcRule.ReservoirSize,
226226
Rate: *svcRule.FixedRate,
227227
}
@@ -231,7 +231,7 @@ func (m *CentralizedManifest) updateDefaultRule(svcRule *xraySvc.SamplingRule) {
231231
r.Lock()
232232
defer r.Unlock()
233233

234-
r.samplingRule = s
234+
r.SamplingRule = s
235235
r.reservoir.capacity = c
236236
}
237237

strategy/sampling/centralized_sampling_rule_manifest_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func TestCreateUserRule(t *testing.T) {
6969
clock := &utils.DefaultClock{}
7070
rand := &utils.DefaultRand{}
7171

72-
sr := &samplingRule{
72+
sr := &SamplingRule{
7373
ServiceName: serviceName,
7474
HTTPMethod: httpMethod,
7575
URLPath: urlPath,
@@ -89,7 +89,7 @@ func TestCreateUserRule(t *testing.T) {
8989
reservoir: cr,
9090
ruleName: ruleName,
9191
priority: priority,
92-
samplingRule: sr,
92+
SamplingRule: sr,
9393
clock: clock,
9494
rand: rand,
9595
serviceType: serviceTye,
@@ -131,7 +131,7 @@ func TestCreateDefaultRule(t *testing.T) {
131131
clock := &utils.DefaultClock{}
132132
rand := &utils.DefaultRand{}
133133

134-
sr := &samplingRule{
134+
sr := &SamplingRule{
135135
FixedTarget: reservoirSize,
136136
Rate: fixedRate,
137137
}
@@ -146,7 +146,7 @@ func TestCreateDefaultRule(t *testing.T) {
146146
exp := &CentralizedRule{
147147
reservoir: cr,
148148
ruleName: ruleName,
149-
samplingRule: sr,
149+
SamplingRule: sr,
150150
clock: clock,
151151
rand: rand,
152152
}
@@ -166,7 +166,7 @@ func TestUpdateDefaultRule(t *testing.T) {
166166
// Original default sampling rule
167167
r := &CentralizedRule{
168168
ruleName: "Default",
169-
samplingRule: &samplingRule{
169+
SamplingRule: &SamplingRule{
170170
FixedTarget: 10,
171171
Rate: 0.05,
172172
},
@@ -194,7 +194,7 @@ func TestUpdateDefaultRule(t *testing.T) {
194194
}
195195

196196
// Expected centralized sampling rule
197-
sr := &samplingRule{
197+
sr := &SamplingRule{
198198
FixedTarget: reservoirSize,
199199
Rate: fixedRate,
200200
}
@@ -208,7 +208,7 @@ func TestUpdateDefaultRule(t *testing.T) {
208208
exp := &CentralizedRule{
209209
reservoir: cr,
210210
ruleName: ruleName,
211-
samplingRule: sr,
211+
SamplingRule: sr,
212212
clock: clock,
213213
rand: rand,
214214
}
@@ -292,7 +292,7 @@ func TestUpdateUserRule(t *testing.T) {
292292
r1 := &CentralizedRule{
293293
ruleName: "r1",
294294
priority: 5,
295-
samplingRule: &samplingRule{
295+
SamplingRule: &SamplingRule{
296296
ServiceName: "*.foo.com",
297297
HTTPMethod: "GET",
298298
URLPath: "/resource/*",
@@ -344,7 +344,7 @@ func TestUpdateUserRule(t *testing.T) {
344344
}
345345

346346
// Expected updated centralized sampling rule
347-
sr := &samplingRule{
347+
sr := &SamplingRule{
348348
ServiceName: serviceName,
349349
HTTPMethod: httpMethod,
350350
URLPath: urlPath,
@@ -363,7 +363,7 @@ func TestUpdateUserRule(t *testing.T) {
363363
reservoir: cr,
364364
ruleName: ruleName,
365365
priority: priority,
366-
samplingRule: sr,
366+
SamplingRule: sr,
367367
resourceARN: resARN,
368368
serviceType: serviceTye,
369369
attributes: attributes,

0 commit comments

Comments
 (0)