@@ -133,16 +133,14 @@ export async function getTraces(
133133 requestId : string ,
134134) : Promise < DatadogTrace [ ] > {
135135 const now = Date . now ( ) ;
136- const fromTime = now - ( 1 * 60 * 60 * 1000 ) ; // 1 hour ago
136+ const fromTime = now - ( 1 * 60 * 60 * 1000 ) ;
137137 const toTime = now ;
138- // Convert service name to lowercase as Datadog stores it that way
139138 const serviceNameLower = serviceName . toLowerCase ( ) ;
140139 const query = `service:${ serviceNameLower } @request_id:${ requestId } ` ;
141140
142141 try {
143142 console . log ( `Searching for traces: ${ query } ` ) ;
144143
145- // First, find spans matching the request_id to get trace IDs
146144 const initialResponse = await datadogClient . post ( '/api/v2/spans/events/search' , {
147145 data : {
148146 type : 'search_request' ,
@@ -163,7 +161,6 @@ export async function getTraces(
163161 const initialSpans = initialResponse . data . data || [ ] ;
164162 console . log ( `Found ${ initialSpans . length } initial span(s)` ) ;
165163
166- // Extract unique trace IDs
167164 const traceIds = new Set < string > ( ) ;
168165 for ( const spanData of initialSpans ) {
169166 const traceId = spanData . attributes ?. trace_id ;
@@ -174,7 +171,6 @@ export async function getTraces(
174171
175172 console . log ( `Found ${ traceIds . size } unique trace(s)` ) ;
176173
177- // Now fetch all spans for each trace ID
178174 const allSpans : any [ ] = [ ] ;
179175 for ( const traceId of traceIds ) {
180176 const traceResponse = await datadogClient . post ( '/api/v2/spans/events/search' , {
@@ -197,7 +193,6 @@ export async function getTraces(
197193 allSpans . push ( ...traceSpans ) ;
198194 }
199195
200- // Group spans by trace_id to reconstruct traces
201196 const traceMap = new Map < string , DatadogSpan [ ] > ( ) ;
202197
203198 for ( const spanData of allSpans ) {
@@ -216,7 +211,6 @@ export async function getTraces(
216211 }
217212 }
218213
219- // Convert map to array of traces
220214 const traces : DatadogTrace [ ] = [ ] ;
221215 for ( const [ traceId , spans ] of traceMap . entries ( ) ) {
222216 traces . push ( {
@@ -242,7 +236,7 @@ export async function getLogs(
242236 requestId : string ,
243237) : Promise < DatadogLog [ ] > {
244238 const now = Date . now ( ) ;
245- const fromTime = now - ( 2 * 60 * 60 * 1000 ) ; // 2 hours ago
239+ const fromTime = now - ( 2 * 60 * 60 * 1000 ) ;
246240 const toTime = now ;
247241 const query = `service:${ serviceName } @lambda.request_id:${ requestId } ` ;
248242
@@ -263,7 +257,6 @@ export async function getLogs(
263257 const rawLogs = response . data . data || [ ] ;
264258 console . log ( `Found ${ rawLogs . length } log(s)` ) ;
265259
266- // Transform raw logs to DatadogLog format
267260 const logs : DatadogLog [ ] = rawLogs . map ( ( logData : any ) => {
268261 const attrs = logData . attributes || { } ;
269262 return {
@@ -292,7 +285,6 @@ export async function getEnhancedMetrics(
292285) : Promise < EnhancedMetrics > {
293286 const result : Partial < EnhancedMetrics > = { } ;
294287
295- // Fetch all categories in parallel
296288 const categoryPromises = Object . entries ( ENHANCED_METRICS_CONFIG ) . map (
297289 async ( [ category , metricNames ] ) => {
298290 const categoryMetrics = await fetchMetricCategory (
@@ -325,7 +317,6 @@ async function fetchMetricCategory(
325317) : Promise < Record < string , MetricPoint [ ] > > {
326318 const promises = metricNames . map ( async ( metricName ) => {
327319 const points = await getMetrics ( metricName , functionName , fromTime , toTime ) ;
328- // Use short name (last part after the last dot)
329320 const shortName = metricName . split ( '.' ) . pop ( ) ! ;
330321 return { shortName, points } ;
331322 } ) ;
@@ -350,7 +341,6 @@ async function getMetrics(
350341 fromTime : number ,
351342 toTime : number
352343) : Promise < MetricPoint [ ] > {
353- // Strip alias/version from function name - metrics are tagged with base name only
354344 const baseFunctionName = getServiceName ( functionName ) . toLowerCase ( ) ;
355345 const query = `avg:${ metricName } {functionname:${ baseFunctionName } }` ;
356346
@@ -371,7 +361,6 @@ async function getMetrics(
371361 return [ ] ;
372362 }
373363
374- // Return points from first series
375364 return ( series [ 0 ] . pointlist || [ ] ) . map ( ( p : [ number , number ] ) => ( {
376365 timestamp : p [ 0 ] ,
377366 value : p [ 1 ] ,
0 commit comments