import { KoaContext , KoaMiddleware , KoaLayerType , KoaInstrumentationConfig , } from './types' ; import { AttributeNames } from './enums/AttributeNames' ; import { SpanAttributes } from '@opentelemetry/api' ; import { SemanticAttributes } from '@opentelemetry/semantic-conventions' ; export const getMiddlewareMetadata = ( context , layer , isRouter , layerPath ? ) : { attributes : SpanAttributes ; name : string ; } => { if ( isRouter ) { return { attributes : { [ AttributeNames . KOA_NAME ] : layerPath , [ AttributeNames . KOA_TYPE ] : KoaLayerType . ROUTER , [ SemanticAttributes . HTTP_ROUTE ] : layerPath , } , name : `router - ${ layerPath }` , } ; } else { return { attributes : { [ AttributeNames . KOA_NAME ] : layer . name ?? 'middleware' , [ AttributeNames . KOA_TYPE ] : KoaLayerType . MIDDLEWARE , } , name : `middleware - ${ layer . name }` , } ; } } ; param list param onException export const isLayerIgnored = ( type , config ? ) : boolean => { return ! ! ( Array . isArray ( config ?. ignoreLayersType ) && config ?. ignoreLayersType ?. includes ( type ) ) ; } ;