Skip to content

Commit 6dd6687

Browse files
authored
Merge branch 'main' into replace-image
2 parents 5e98aa5 + 5799696 commit 6dd6687

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

aws-distro-opentelemetry-node-autoinstrumentation/src/aws-opentelemetry-configurator.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -256,14 +256,13 @@ export class AwsOpentelemetryConfigurator {
256256

257257
// Register BatchUnsampledSpanProcessor to export unsampled traces in Lambda
258258
// when Application Signals enabled
259-
if (isLambdaEnvironment()) {
259+
if (isLambdaEnvironment() && !hasCustomOtlpTraceEndpoint()) {
260+
const udpSpanExporter = new OTLPUdpSpanExporter(getXrayDaemonEndpoint(), FORMAT_OTEL_UNSAMPLED_TRACES_BINARY_PREFIX);
261+
const configuredExporter = AwsMetricAttributesSpanExporterBuilder.create(udpSpanExporter, resource).build();
260262
spanProcessors.push(
261-
new AwsBatchUnsampledSpanProcessor(
262-
new OTLPUdpSpanExporter(getXrayDaemonEndpoint(), FORMAT_OTEL_UNSAMPLED_TRACES_BINARY_PREFIX),
263-
{
264-
maxExportBatchSize: getSpanExportBatchSize(),
265-
}
266-
)
263+
new AwsBatchUnsampledSpanProcessor(configuredExporter, {
264+
maxExportBatchSize: getSpanExportBatchSize(),
265+
})
267266
);
268267
diag.info('Enabled batch unsampled span processor for Lambda environment.');
269268
}

aws-distro-opentelemetry-node-autoinstrumentation/test/aws-batch-unsampled-span-processor.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ describe('AwsBatchUnsampledSpanProcessor', () => {
457457
const processor = new AwsBatchUnsampledSpanProcessor(exporter, {
458458
maxExportBatchSize: 5,
459459
maxQueueSize: 6,
460+
exportTimeoutMillis: 1000,
460461
});
461462
const totalSpans = 50;
462463
for (let i = 0; i < totalSpans; i++) {

aws-distro-opentelemetry-node-autoinstrumentation/test/sampler/aws-xray-remote-sampler.test.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ describe('AwsXrayRemoteSampler', () => {
8888
).toEqual(SamplingDecision.NOT_RECORD);
8989

9090
setTimeout(() => {
91+
// restore function
92+
(_AwsXRayRemoteSampler.prototype as any).getDefaultTargetPollingInterval = tmp;
93+
9194
expect(
9295
sampler.shouldSample(context.active(), '1234', 'name', SpanKind.CLIENT, { abc: '1234' }, []).decision
9396
).toEqual(SamplingDecision.RECORD_AND_SAMPLED);
@@ -98,8 +101,6 @@ describe('AwsXrayRemoteSampler', () => {
98101
sampler.shouldSample(context.active(), '1234', 'name', SpanKind.CLIENT, { abc: '1234' }, []).decision
99102
).toEqual(SamplingDecision.RECORD_AND_SAMPLED);
100103

101-
// reset function
102-
(_AwsXRayRemoteSampler.prototype as any).getDefaultTargetPollingInterval = tmp;
103104
done();
104105
}, 300);
105106
}, 10);
@@ -139,10 +140,12 @@ describe('AwsXrayRemoteSampler', () => {
139140
sampled++;
140141
}
141142
}
143+
144+
// restore function
145+
(_AwsXRayRemoteSampler.prototype as any).getDefaultTargetPollingInterval = tmp;
146+
142147
expect((sampler as any)._root._root.ruleCache.ruleAppliers[0].reservoirSampler.quota).toEqual(100000);
143148
expect(sampled).toEqual(100000);
144-
// reset function
145-
(_AwsXRayRemoteSampler.prototype as any).getDefaultTargetPollingInterval = tmp;
146149
done();
147150
}, 2000);
148151
}, 100);
@@ -184,13 +187,13 @@ describe('AwsXrayRemoteSampler', () => {
184187
sampled++;
185188
}
186189
}
187-
expect(sampled).toEqual(100);
188-
// reset function
189-
(_AwsXRayRemoteSampler.prototype as any).getDefaultTargetPollingInterval = tmp;
190190
clock.restore();
191+
// restore function
192+
(_AwsXRayRemoteSampler.prototype as any).getDefaultTargetPollingInterval = tmp;
193+
expect(sampled).toEqual(100);
191194
done();
192195
}, 2000);
193-
}, 100);
196+
}, 300);
194197
});
195198

196199
it('generates valid ClientId', () => {

0 commit comments

Comments
 (0)