From 5c8b11b0be738666ec00f02fb679c9ff8fef947d Mon Sep 17 00:00:00 2001 From: Michael Lumish Date: Mon, 11 Sep 2023 15:39:19 -0700 Subject: [PATCH] Trace parsed unvalidated resources --- .../src/xds-resource-type/cluster-resource-type.ts | 1 + .../src/xds-resource-type/endpoint-resource-type.ts | 1 + .../src/xds-resource-type/listener-resource-type.ts | 1 + .../src/xds-resource-type/route-config-resource-type.ts | 7 +++++++ 4 files changed, 10 insertions(+) diff --git a/packages/grpc-js-xds/src/xds-resource-type/cluster-resource-type.ts b/packages/grpc-js-xds/src/xds-resource-type/cluster-resource-type.ts index c13a91d7e..0038fe912 100644 --- a/packages/grpc-js-xds/src/xds-resource-type/cluster-resource-type.ts +++ b/packages/grpc-js-xds/src/xds-resource-type/cluster-resource-type.ts @@ -285,6 +285,7 @@ export class ClusterResourceType extends XdsResourceType { ); } const message = decodeSingleResource(CDS_TYPE_URL, resource.value); + trace('Decoded raw resource of type ' + CDS_TYPE_URL + ': ' + JSON.stringify(message)); const validatedMessage = this.validateResource(context, message); if (validatedMessage) { return { diff --git a/packages/grpc-js-xds/src/xds-resource-type/endpoint-resource-type.ts b/packages/grpc-js-xds/src/xds-resource-type/endpoint-resource-type.ts index 6ffd7788d..10d8cc3c7 100644 --- a/packages/grpc-js-xds/src/xds-resource-type/endpoint-resource-type.ts +++ b/packages/grpc-js-xds/src/xds-resource-type/endpoint-resource-type.ts @@ -101,6 +101,7 @@ export class EndpointResourceType extends XdsResourceType { ); } const message = decodeSingleResource(EDS_TYPE_URL, resource.value); + trace('Decoded raw resource of type ' + EDS_TYPE_URL + ': ' + JSON.stringify(message)); const validatedMessage = this.validateResource(message); if (validatedMessage) { return { diff --git a/packages/grpc-js-xds/src/xds-resource-type/listener-resource-type.ts b/packages/grpc-js-xds/src/xds-resource-type/listener-resource-type.ts index 20e243b86..73782c380 100644 --- a/packages/grpc-js-xds/src/xds-resource-type/listener-resource-type.ts +++ b/packages/grpc-js-xds/src/xds-resource-type/listener-resource-type.ts @@ -106,6 +106,7 @@ export class ListenerResourceType extends XdsResourceType { ); } const message = decodeSingleResource(LDS_TYPE_URL, resource.value); + trace('Decoded raw resource of type ' + LDS_TYPE_URL + ': ' + JSON.stringify(message)); const validatedMessage = this.validateResource(message); if (validatedMessage) { return { diff --git a/packages/grpc-js-xds/src/xds-resource-type/route-config-resource-type.ts b/packages/grpc-js-xds/src/xds-resource-type/route-config-resource-type.ts index cdc2e3196..6c0bc93e9 100644 --- a/packages/grpc-js-xds/src/xds-resource-type/route-config-resource-type.ts +++ b/packages/grpc-js-xds/src/xds-resource-type/route-config-resource-type.ts @@ -15,6 +15,7 @@ * */ +import { experimental, logVerbosity } from "@grpc/grpc-js"; import { EXPERIMENTAL_FAULT_INJECTION, EXPERIMENTAL_RETRY } from "../environment"; import { RetryPolicy__Output } from "../generated/envoy/config/route/v3/RetryPolicy"; import { RouteConfiguration__Output } from "../generated/envoy/config/route/v3/RouteConfiguration"; @@ -24,6 +25,11 @@ import { validateOverrideFilter } from "../http-filter"; import { RDS_TYPE_URL, decodeSingleResource } from "../resources"; import { Watcher, XdsClient } from "../xds-client"; import { XdsDecodeContext, XdsDecodeResult, XdsResourceType } from "./xds-resource-type"; +const TRACER_NAME = 'xds_client'; + +function trace(text: string): void { + experimental.trace(logVerbosity.DEBUG, TRACER_NAME, text); +} const SUPPORTED_PATH_SPECIFIERS = ['prefix', 'path', 'safe_regex']; const SUPPPORTED_HEADER_MATCH_SPECIFIERS = [ @@ -169,6 +175,7 @@ export class RouteConfigurationResourceType extends XdsResourceType { ); } const message = decodeSingleResource(RDS_TYPE_URL, resource.value); + trace('Decoded raw resource of type ' + RDS_TYPE_URL + ': ' + JSON.stringify(message)); const validatedMessage = this.validateResource(message); if (validatedMessage) { return {