@@ -503,10 +503,14 @@ func (w *worker) process(destinationJobs []types.DestinationJobT) {
503
503
if err != nil && waitCtx .Err () == nil {
504
504
w .logger .Errorn ("delivery throttler wait error" , obskit .Error (err ))
505
505
}
506
+ rdlTime := time .Now ()
506
507
if transformerProxy {
507
508
attemptedRequests ++
508
509
attemptedJobs += len (destinationJob .JobMetadataArray )
509
510
resp := w .proxyRequest (ctx , destinationJob , val )
511
+ // Record the new transformer_outgoing_request metrics
512
+ w .recordTransformerOutgoingRequestMetrics (val , destinationJob , resp .ProxyRequestStatusCode , time .Since (rdlTime ))
513
+
510
514
for k , v := range resp .DontBatchDirectives {
511
515
dontBatchDirectives [k ] = v
512
516
}
@@ -524,15 +528,14 @@ func (w *worker) process(destinationJobs []types.DestinationJobT) {
524
528
}
525
529
} else {
526
530
sendCtx , cancel := context .WithTimeout (ctx , w .rt .netClientTimeout )
527
- rdlTime := time .Now ()
528
531
attemptedRequests ++
529
532
attemptedJobs += len (destinationJob .JobMetadataArray )
530
533
resp := w .rt .netHandle .SendPost (sendCtx , val )
531
534
cancel ()
532
535
respStatusCode , respBodyTemp , respContentType = resp .StatusCode , string (resp .ResponseBody ), resp .ResponseContentType
533
536
534
537
// Record the new transformer_outgoing_request metrics
535
- w .recordTransformerOutgoingRequestMetrics (val , destinationJob , resp , time .Since (rdlTime ))
538
+ w .recordTransformerOutgoingRequestMetrics (val , destinationJob , respStatusCode , time .Since (rdlTime ))
536
539
537
540
w .routerDeliveryLatencyStat .SendTiming (time .Since (rdlTime ))
538
541
@@ -1213,7 +1216,7 @@ func (w *worker) countTransformedJobStatuses(transformType string, transformedJo
1213
1216
func (w * worker ) recordTransformerOutgoingRequestMetrics (
1214
1217
postParams integrations.PostParametersT ,
1215
1218
destinationJob types.DestinationJobT ,
1216
- resp * routerutils. SendPostResponse ,
1219
+ respStatus int ,
1217
1220
duration time.Duration ,
1218
1221
) {
1219
1222
// Only emit metrics if EndpointPath is present
@@ -1222,13 +1225,14 @@ func (w *worker) recordTransformerOutgoingRequestMetrics(
1222
1225
}
1223
1226
1224
1227
labels := deliveryMetricLabels {
1225
- DestType : w .rt .destType ,
1226
- EndpointPath : postParams .EndpointPath ,
1227
- StatusCode : strconv .Itoa (resp .StatusCode ),
1228
- RequestMethod : postParams .RequestMethod ,
1229
- Module : "router" ,
1230
- WorkspaceID : destinationJob .Destination .WorkspaceID ,
1231
- DestinationID : destinationJob .Destination .ID ,
1228
+ DestType : w .rt .destType ,
1229
+ TransformerProxy : w .rt .reloadableConfig .transformerProxy .Load (),
1230
+ EndpointPath : postParams .EndpointPath ,
1231
+ StatusCode : respStatus ,
1232
+ RequestMethod : postParams .RequestMethod ,
1233
+ Module : "router" ,
1234
+ WorkspaceID : destinationJob .Destination .WorkspaceID ,
1235
+ DestinationID : destinationJob .Destination .ID ,
1232
1236
}
1233
1237
1234
1238
// Get or create cached stats objects using StatsCache
@@ -1242,24 +1246,26 @@ func (w *worker) recordTransformerOutgoingRequestMetrics(
1242
1246
1243
1247
// deliveryMetricLabels represents a unique key for caching stats based on labels
1244
1248
type deliveryMetricLabels struct {
1245
- DestType string
1246
- EndpointPath string
1247
- StatusCode string
1248
- RequestMethod string
1249
- Module string
1250
- WorkspaceID string
1251
- DestinationID string
1249
+ DestType string
1250
+ TransformerProxy bool
1251
+ EndpointPath string
1252
+ StatusCode int
1253
+ RequestMethod string
1254
+ Module string
1255
+ WorkspaceID string
1256
+ DestinationID string
1252
1257
}
1253
1258
1254
1259
// ToStatTags converts deliveryMetricLabels to stats.Tags for StatsCacheKey interface
1255
1260
func (l deliveryMetricLabels ) ToStatTags () stats.Tags {
1256
1261
return stats.Tags {
1257
- "destType" : l .DestType ,
1258
- "endpointPath" : l .EndpointPath ,
1259
- "statusCode" : l .StatusCode ,
1260
- "requestMethod" : l .RequestMethod ,
1261
- "module" : l .Module ,
1262
- "workspaceId" : l .WorkspaceID ,
1263
- "destinationId" : l .DestinationID ,
1262
+ "destType" : l .DestType ,
1263
+ "endpointPath" : l .EndpointPath ,
1264
+ "transformerProxy" : strconv .FormatBool (l .TransformerProxy ),
1265
+ "statusCode" : strconv .Itoa (l .StatusCode ),
1266
+ "requestMethod" : l .RequestMethod ,
1267
+ "module" : l .Module ,
1268
+ "workspaceId" : l .WorkspaceID ,
1269
+ "destinationId" : l .DestinationID ,
1264
1270
}
1265
1271
}
0 commit comments