@@ -9,6 +9,12 @@ class DataStreamsCheckpointer {
9
9
this . dsmProcessor = tracer . _dataStreamsProcessor
10
10
}
11
11
12
+ /**
13
+ * @param {string } type - The type of the checkpoint, usually the streaming technology being used.
14
+ * Examples include kafka, kinesis, sns etc.
15
+ * @param {string } target - The target of data. This can be a topic, exchange or stream name.
16
+ * @param {Object } carrier - The carrier object to inject context into.
17
+ */
12
18
setProduceCheckpoint ( type , target , carrier ) {
13
19
if ( ! this . config . dsmEnabled ) return
14
20
@@ -23,14 +29,29 @@ class DataStreamsCheckpointer {
23
29
this . tracer . inject ( ctx , 'text_map_dsm' , carrier )
24
30
}
25
31
26
- setConsumeCheckpoint ( type , source , carrier ) {
32
+ /**
33
+ * @param {string } type - The type of the checkpoint, usually the streaming technology being used.
34
+ * Examples include kafka, kinesis, sns etc.
35
+ * @param {string } source - The source of data. This can be a topic, exchange or stream name.
36
+ * @param {Object } carrier - The carrier object to extract context from.
37
+ * @param {boolean } [manualCheckpoint=true] - Whether this checkpoint was manually set. Keep true if manually
38
+ * instrumenting. Manual instrumentation always overrides automatic
39
+ * instrumentation in the case a call is both manually and automatically
40
+ * instrumented.
41
+ */
42
+ setConsumeCheckpoint ( type , source , carrier , manualCheckpoint = true ) {
27
43
if ( ! this . config . dsmEnabled ) return
28
44
29
45
const parentCtx = this . tracer . extract ( 'text_map_dsm' , carrier )
30
46
DataStreamsContext . setDataStreamsContext ( parentCtx )
31
47
48
+ const tags = [ 'type:' + type , 'topic:' + source , 'direction:in' ]
49
+ if ( manualCheckpoint ) {
50
+ tags . push ( 'manual_checkpoint:true' )
51
+ }
52
+
32
53
const ctx = this . dsmProcessor . setCheckpoint (
33
- [ 'type:' + type , 'topic:' + source , 'direction:in' , 'manual_checkpoint:true' ] ,
54
+ tags ,
34
55
null ,
35
56
parentCtx ,
36
57
null
0 commit comments