1
1
import { getSpanPointerAttributes } from "./span-pointers" ;
2
2
import { eventTypes } from "../trace/trigger" ;
3
- import { SPAN_LINK_POINTER_KIND , S3_PTR_KIND , SPAN_POINTER_DIRECTION } from "dd-trace/packages/dd-trace/src/span_pointers" ;
3
+ import { S3_PTR_KIND , SPAN_POINTER_DIRECTION } from "dd-trace/packages/dd-trace/src/span_pointers" ;
4
4
import * as spanPointers from "dd-trace/packages/dd-trace/src/span_pointers" ;
5
5
6
6
// Mock the external dependencies
7
7
jest . mock ( "./log" , ( ) => ( {
8
8
logDebug : jest . fn ( ) ,
9
9
} ) ) ;
10
10
11
+ interface SpanPointerAttributes {
12
+ pointerKind : string ;
13
+ pointerDirection : string ;
14
+ pointerHash : string ;
15
+ }
16
+
11
17
describe ( "span-pointers utils" , ( ) => {
12
- const mockS3PointerHash = "mock-hash-123" ;
18
+ const mockPointerHash = "mock-hash-123" ;
13
19
14
20
beforeEach ( ( ) => {
15
- // Mock the generateS3PointerHash function
16
- jest . spyOn ( spanPointers , "generateS3PointerHash" ) . mockReturnValue ( mockS3PointerHash ) ;
21
+ jest . spyOn ( spanPointers , "generatePointerHash" ) . mockReturnValue ( mockPointerHash ) ;
17
22
} ) ;
18
23
19
24
afterEach ( ( ) => {
@@ -47,18 +52,17 @@ describe("span-pointers utils", () => {
47
52
] ,
48
53
} ;
49
54
50
- const expected = [
55
+ const expected : SpanPointerAttributes [ ] = [
51
56
{
52
- "ptr.kind" : S3_PTR_KIND ,
53
- "ptr.dir" : SPAN_POINTER_DIRECTION . UPSTREAM ,
54
- "ptr.hash" : mockS3PointerHash ,
55
- "link.kind" : SPAN_LINK_POINTER_KIND ,
57
+ pointerKind : S3_PTR_KIND ,
58
+ pointerDirection : SPAN_POINTER_DIRECTION . UPSTREAM ,
59
+ pointerHash : mockPointerHash ,
56
60
} ,
57
61
] ;
58
62
59
63
const result = getSpanPointerAttributes ( eventTypes . s3 , event ) ;
60
64
expect ( result ) . toEqual ( expected ) ;
61
- expect ( spanPointers . generateS3PointerHash ) . toHaveBeenCalledWith ( "test-bucket" , "test-key" , "test-etag" ) ;
65
+ expect ( spanPointers . generatePointerHash ) . toHaveBeenCalledWith ( [ "test-bucket" , "test-key" , "test-etag" ] ) ;
62
66
} ) ;
63
67
64
68
it ( "processes multiple S3 records correctly" , ( ) => {
@@ -85,18 +89,16 @@ describe("span-pointers utils", () => {
85
89
] ,
86
90
} ;
87
91
88
- const expected = [
92
+ const expected : SpanPointerAttributes [ ] = [
89
93
{
90
- "ptr.kind" : S3_PTR_KIND ,
91
- "ptr.dir" : SPAN_POINTER_DIRECTION . UPSTREAM ,
92
- "ptr.hash" : mockS3PointerHash ,
93
- "link.kind" : SPAN_LINK_POINTER_KIND ,
94
+ pointerKind : S3_PTR_KIND ,
95
+ pointerDirection : SPAN_POINTER_DIRECTION . UPSTREAM ,
96
+ pointerHash : mockPointerHash ,
94
97
} ,
95
98
{
96
- "ptr.kind" : S3_PTR_KIND ,
97
- "ptr.dir" : SPAN_POINTER_DIRECTION . UPSTREAM ,
98
- "ptr.hash" : mockS3PointerHash ,
99
- "link.kind" : SPAN_LINK_POINTER_KIND ,
99
+ pointerKind : S3_PTR_KIND ,
100
+ pointerDirection : SPAN_POINTER_DIRECTION . UPSTREAM ,
101
+ pointerHash : mockPointerHash ,
100
102
} ,
101
103
] ;
102
104
@@ -134,12 +136,11 @@ describe("span-pointers utils", () => {
134
136
] ,
135
137
} ;
136
138
137
- const expected = [
139
+ const expected : SpanPointerAttributes [ ] = [
138
140
{
139
- "ptr.kind" : S3_PTR_KIND ,
140
- "ptr.dir" : SPAN_POINTER_DIRECTION . UPSTREAM ,
141
- "ptr.hash" : mockS3PointerHash ,
142
- "link.kind" : SPAN_LINK_POINTER_KIND ,
141
+ pointerKind : S3_PTR_KIND ,
142
+ pointerDirection : SPAN_POINTER_DIRECTION . UPSTREAM ,
143
+ pointerHash : mockPointerHash ,
143
144
} ,
144
145
] ;
145
146
0 commit comments