Skip to content

Commit fbde983

Browse files
committed
address comments - error handling for rule matching and TODO comment
1 parent a79cfd5 commit fbde983

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

incubator/opentelemetry-sampler-aws-xray/src/remote-sampler.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ export class _AWSXRayRemoteSampler implements Sampler {
125125
? samplerConfig.endpoint
126126
: DEFAULT_AWS_PROXY_ENDPOINT;
127127
this.fallbackSampler = new FallbackSampler();
128+
// TODO: Use clientId for retrieving Sampling Targets
128129
this.clientId = _AWSXRayRemoteSampler.generateClientId();
129130
this.ruleCache = new RuleCache(samplerConfig.resource);
130131

@@ -161,16 +162,23 @@ export class _AWSXRayRemoteSampler implements Sampler {
161162
);
162163
}
163164

164-
const matchedRule: SamplingRuleApplier | undefined =
165-
this.ruleCache.getMatchedRule(attributes);
166-
if (matchedRule) {
167-
return matchedRule.shouldSample(
168-
context,
169-
traceId,
170-
spanName,
171-
spanKind,
172-
attributes,
173-
links
165+
try {
166+
const matchedRule: SamplingRuleApplier | undefined =
167+
this.ruleCache.getMatchedRule(attributes);
168+
if (matchedRule) {
169+
return matchedRule.shouldSample(
170+
context,
171+
traceId,
172+
spanName,
173+
spanKind,
174+
attributes,
175+
links
176+
);
177+
}
178+
} catch (e: unknown) {
179+
this.samplerDiag.debug(
180+
'Unexpected error occurred when trying to match or applying a sampling rule',
181+
e
174182
);
175183
}
176184

0 commit comments

Comments
 (0)