{"version":3,"file":"logging-response-handler.mjs","names":[],"sources":["../src/logging-response-handler.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { diag } from '@opentelemetry/api';\nimport type { IOtlpResponseHandler } from './response-handler';\n\nfunction isPartialSuccessResponse(\n  response: unknown\n): response is { partialSuccess: never } {\n  return Object.prototype.hasOwnProperty.call(response, 'partialSuccess');\n}\n\n/**\n * Default response handler that logs a partial success to the console.\n */\nexport function createLoggingPartialSuccessResponseHandler<\n  T,\n>(): IOtlpResponseHandler<T> {\n  return {\n    handleResponse(response: T) {\n      // Partial success MUST never be an empty object according the specification\n      // see https://opentelemetry.io/docs/specs/otlp/#partial-success\n      if (\n        response == null ||\n        !isPartialSuccessResponse(response) ||\n        response.partialSuccess == null ||\n        Object.keys(response.partialSuccess).length === 0\n      ) {\n        return;\n      }\n      diag.warn(\n        'Received Partial Success response:',\n        JSON.stringify(response.partialSuccess)\n      );\n    },\n  };\n}\n"],"mappings":";;AAOA,SAAS,yBACP,UACuC;CACvC,OAAO,OAAO,UAAU,eAAe,KAAK,UAAU,gBAAgB;AACxE;;;;AAKA,SAAgB,6CAEa;CAC3B,OAAO,EACL,eAAe,UAAa;EAG1B,IACE,YAAY,QACZ,CAAC,yBAAyB,QAAQ,KAClC,SAAS,kBAAkB,QAC3B,OAAO,KAAK,SAAS,cAAc,CAAC,CAAC,WAAW,GAEhD;EAEF,KAAK,KACH,sCACA,KAAK,UAAU,SAAS,cAAc,CACxC;CACF,EACF;AACF"}