Skip to content

Commit

Permalink
make traceIds and spanIds valid in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jj22ee committed Aug 6, 2024
1 parent e09e3bd commit a538ec6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class AwsOpentelemetryConfigurator {
if (process.env.OTEL_NODE_RESOURCE_DETECTORS != null) {
defaultDetectors = getResourceDetectorsFromEnv();
// Add Env/AWS Resource Detectors if not present
const resourceDetectorsFromEnv = process.env.OTEL_NODE_RESOURCE_DETECTORS.split(',');
const resourceDetectorsFromEnv: string[] = process.env.OTEL_NODE_RESOURCE_DETECTORS.split(',');
if (!resourceDetectorsFromEnv.includes('env')) {
defaultDetectors.push(envDetectorSync);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ let attributesMock: Attributes;
let spanDataMock: ReadableSpan;
let instrumentationScopeInfoMock: InstrumentationLibrary;
let resource: Resource;
let parentSpanContextMock: SpanContext;

/** Unit tests for {@link AwsMetricAttributeGenerator}. */
describe('AwsMetricAttributeGeneratorTest', () => {
Expand All @@ -82,12 +81,13 @@ describe('AwsMetricAttributeGeneratorTest', () => {
kind: SpanKind.SERVER,
spanContext: () => {
const spanContext: SpanContext = {
traceId: 'traceId',
spanId: 'spanId',
traceId: '00000000000000000000000000000008',
spanId: '0000000000000009',
traceFlags: 0,
};
return spanContext;
},
parentSpanId: '0000000000000007',
startTime: [0, 0],
endTime: [0, 1],
status: { code: 0 },
Expand All @@ -102,12 +102,6 @@ describe('AwsMetricAttributeGeneratorTest', () => {
droppedEventsCount: 0,
droppedLinksCount: 0,
};
parentSpanContextMock = {
traceId: 'traceId',
spanId: 'spanId',
traceFlags: 0,
};
parentSpanContextMock.isRemote = false;
// Divergence from Java/Python - set AWS_IS_LOCAL_ROOT as false because parentSpanContext is valid and not remote in this test
attributesMock[AWS_ATTRIBUTE_KEYS.AWS_IS_LOCAL_ROOT] = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ describe('AwsSpanProcessingUtilTest', () => {
kind: SpanKind.SERVER,
spanContext: () => {
const spanContext: SpanContext = {
traceId: 'traceId',
spanId: 'spanId',
traceId: '00000000000000000000000000000008',
spanId: '0000000000000009',
traceFlags: 0,
};
return spanContext;
Expand Down Expand Up @@ -205,8 +205,8 @@ describe('AwsSpanProcessingUtilTest', () => {

it('testShouldGenerateServiceMetricAttributes', () => {
const parentSpanContext: SpanContext = {
traceId: 'traceId',
spanId: 'spanId',
traceId: '00000000000000000000000000000008',
spanId: '0000000000000009',
traceFlags: 0,
};
(parentSpanContext as any).isRemote = false;
Expand Down Expand Up @@ -354,8 +354,8 @@ describe('AwsSpanProcessingUtilTest', () => {

function createMockSpanContext(): SpanContext {
return {
traceId: 'traceId',
spanId: 'spanId',
traceId: '00000000000000000000000000000008',
spanId: '0000000000000009',
traceFlags: 0,
};
}

0 comments on commit a538ec6

Please sign in to comment.