@opentelemetry/exporter-trace-otlp-http 0.27.0 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/README.md +3 -9
  2. package/build/esm/index.d.ts +0 -2
  3. package/build/esm/index.js +0 -2
  4. package/build/esm/index.js.map +1 -1
  5. package/build/esm/platform/browser/OTLPTraceExporter.d.ts +2 -2
  6. package/build/esm/platform/browser/OTLPTraceExporter.js +2 -3
  7. package/build/esm/platform/browser/OTLPTraceExporter.js.map +1 -1
  8. package/build/esm/platform/browser/index.d.ts +0 -1
  9. package/build/esm/platform/browser/index.js +0 -1
  10. package/build/esm/platform/browser/index.js.map +1 -1
  11. package/build/esm/platform/index.d.ts +0 -1
  12. package/build/esm/platform/index.js +0 -1
  13. package/build/esm/platform/index.js.map +1 -1
  14. package/build/esm/platform/node/OTLPTraceExporter.d.ts +2 -2
  15. package/build/esm/platform/node/OTLPTraceExporter.js +3 -3
  16. package/build/esm/platform/node/OTLPTraceExporter.js.map +1 -1
  17. package/build/esm/platform/node/index.d.ts +0 -3
  18. package/build/esm/platform/node/index.js +0 -3
  19. package/build/esm/platform/node/index.js.map +1 -1
  20. package/build/esm/transform.d.ts +2 -2
  21. package/build/esm/transform.js +18 -2
  22. package/build/esm/transform.js.map +1 -1
  23. package/build/esm/types.d.ts +1 -33
  24. package/build/esm/types.js +0 -30
  25. package/build/esm/types.js.map +1 -1
  26. package/build/esm/version.d.ts +1 -1
  27. package/build/esm/version.js +1 -1
  28. package/build/esm/version.js.map +1 -1
  29. package/build/esnext/index.d.ts +4 -0
  30. package/build/esnext/index.js +19 -0
  31. package/build/esnext/index.js.map +1 -0
  32. package/build/esnext/platform/browser/OTLPTraceExporter.d.ts +13 -0
  33. package/build/esnext/platform/browser/OTLPTraceExporter.js +42 -0
  34. package/build/esnext/platform/browser/OTLPTraceExporter.js.map +1 -0
  35. package/build/esnext/platform/browser/index.d.ts +2 -0
  36. package/build/esnext/platform/browser/index.js +17 -0
  37. package/build/esnext/platform/browser/index.js.map +1 -0
  38. package/build/esnext/platform/index.d.ts +2 -0
  39. package/build/esnext/platform/index.js +17 -0
  40. package/build/esnext/platform/index.js.map +1 -0
  41. package/build/esnext/platform/node/OTLPTraceExporter.d.ts +13 -0
  42. package/build/esnext/platform/node/OTLPTraceExporter.js +43 -0
  43. package/build/esnext/platform/node/OTLPTraceExporter.js.map +1 -0
  44. package/build/esnext/platform/node/index.d.ts +2 -0
  45. package/build/esnext/platform/node/index.js +17 -0
  46. package/build/esnext/platform/node/index.js.map +1 -0
  47. package/build/esnext/transform.d.ts +80 -0
  48. package/build/esnext/transform.js +266 -0
  49. package/build/esnext/transform.js.map +1 -0
  50. package/build/esnext/types.d.ts +209 -0
  51. package/build/esnext/types.js +145 -0
  52. package/build/esnext/types.js.map +1 -0
  53. package/build/esnext/version.d.ts +2 -0
  54. package/build/esnext/version.js +18 -0
  55. package/build/esnext/version.js.map +1 -0
  56. package/build/src/index.d.ts +0 -2
  57. package/build/src/index.js +1 -4
  58. package/build/src/index.js.map +1 -1
  59. package/build/src/platform/browser/OTLPTraceExporter.d.ts +2 -2
  60. package/build/src/platform/browser/OTLPTraceExporter.js +9 -10
  61. package/build/src/platform/browser/OTLPTraceExporter.js.map +1 -1
  62. package/build/src/platform/browser/index.d.ts +0 -1
  63. package/build/src/platform/browser/index.js +0 -1
  64. package/build/src/platform/browser/index.js.map +1 -1
  65. package/build/src/platform/index.d.ts +0 -1
  66. package/build/src/platform/index.js +0 -3
  67. package/build/src/platform/index.js.map +1 -1
  68. package/build/src/platform/node/OTLPTraceExporter.d.ts +2 -2
  69. package/build/src/platform/node/OTLPTraceExporter.js +10 -10
  70. package/build/src/platform/node/OTLPTraceExporter.js.map +1 -1
  71. package/build/src/platform/node/index.d.ts +0 -3
  72. package/build/src/platform/node/index.js +0 -3
  73. package/build/src/platform/node/index.js.map +1 -1
  74. package/build/src/transform.d.ts +2 -2
  75. package/build/src/transform.js.map +1 -1
  76. package/build/src/types.d.ts +1 -33
  77. package/build/src/types.js +1 -13
  78. package/build/src/types.js.map +1 -1
  79. package/build/src/version.d.ts +1 -1
  80. package/build/src/version.js +1 -1
  81. package/build/src/version.js.map +1 -1
  82. package/package.json +30 -21
  83. package/build/esm/OTLPExporterBase.d.ts +0 -36
  84. package/build/esm/OTLPExporterBase.js +0 -114
  85. package/build/esm/OTLPExporterBase.js.map +0 -1
  86. package/build/esm/platform/browser/OTLPExporterBrowserBase.d.ts +0 -18
  87. package/build/esm/platform/browser/OTLPExporterBrowserBase.js +0 -91
  88. package/build/esm/platform/browser/OTLPExporterBrowserBase.js.map +0 -1
  89. package/build/esm/platform/browser/util.d.ts +0 -17
  90. package/build/esm/platform/browser/util.js +0 -77
  91. package/build/esm/platform/browser/util.js.map +0 -1
  92. package/build/esm/platform/node/OTLPExporterNodeBase.d.ts +0 -20
  93. package/build/esm/platform/node/OTLPExporterNodeBase.js +0 -82
  94. package/build/esm/platform/node/OTLPExporterNodeBase.js.map +0 -1
  95. package/build/esm/platform/node/types.d.ts +0 -17
  96. package/build/esm/platform/node/types.js +0 -6
  97. package/build/esm/platform/node/types.js.map +0 -1
  98. package/build/esm/platform/node/util.d.ts +0 -17
  99. package/build/esm/platform/node/util.js +0 -113
  100. package/build/esm/platform/node/util.js.map +0 -1
  101. package/build/esm/util.d.ts +0 -7
  102. package/build/esm/util.js +0 -40
  103. package/build/esm/util.js.map +0 -1
  104. package/build/src/OTLPExporterBase.d.ts +0 -36
  105. package/build/src/OTLPExporterBase.js +0 -113
  106. package/build/src/OTLPExporterBase.js.map +0 -1
  107. package/build/src/platform/browser/OTLPExporterBrowserBase.d.ts +0 -18
  108. package/build/src/platform/browser/OTLPExporterBrowserBase.js +0 -74
  109. package/build/src/platform/browser/OTLPExporterBrowserBase.js.map +0 -1
  110. package/build/src/platform/browser/util.d.ts +0 -17
  111. package/build/src/platform/browser/util.js +0 -70
  112. package/build/src/platform/browser/util.js.map +0 -1
  113. package/build/src/platform/node/OTLPExporterNodeBase.d.ts +0 -20
  114. package/build/src/platform/node/OTLPExporterNodeBase.js +0 -65
  115. package/build/src/platform/node/OTLPExporterNodeBase.js.map +0 -1
  116. package/build/src/platform/node/types.d.ts +0 -17
  117. package/build/src/platform/node/types.js +0 -9
  118. package/build/src/platform/node/types.js.map +0 -1
  119. package/build/src/platform/node/util.d.ts +0 -17
  120. package/build/src/platform/node/util.js +0 -107
  121. package/build/src/platform/node/util.js.map +0 -1
  122. package/build/src/util.d.ts +0 -7
  123. package/build/src/util.js +0 -43
  124. package/build/src/util.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"OTLPTraceExporter.js","sourceRoot":"","sources":["../../../../src/platform/node/OTLPTraceExporter.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAGH,iEAA8D;AAG9D,+CAAkE;AAClE,8CAA2D;AAC3D,qCAAiE;AAEjE,MAAM,+BAA+B,GAAG,YAAY,CAAC;AACrD,MAAM,qBAAqB,GAAC,yBAAyB,+BAA+B,EAAE,CAAC;AAEvF;;GAEG;AACH,MAAa,iBACX,SAAQ,2CAGP;IAED,YAAY,SAAqC,EAAE;QACjD,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAC1B,IAAI,CAAC,OAAO,EACZ,mBAAY,CAAC,uBAAuB,CAClC,aAAM,EAAE,CAAC,iCAAiC,CAC3C,CACF,CAAC;IACJ,CAAC;IAED,OAAO,CACL,KAAqB;QAErB,OAAO,2CAA+B,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC5D,CAAC;IAED,aAAa,CAAC,MAAkC;QAC9C,OAAO,OAAO,MAAM,CAAC,GAAG,KAAK,QAAQ;YACnC,CAAC,CAAC,MAAM,CAAC,GAAG;YACZ,CAAC,CAAC,aAAM,EAAE,CAAC,kCAAkC,CAAC,MAAM,GAAG,CAAC;gBACxD,CAAC,CAAC,aAAM,EAAE,CAAC,kCAAkC;gBAC7C,CAAC,CAAC,aAAM,EAAE,CAAC,2BAA2B,CAAC,MAAM,GAAG,CAAC;oBACjD,CAAC,CAAC,0CAAmC,CAAC,aAAM,EAAE,CAAC,2BAA2B,EAAE,+BAA+B,CAAC;oBAC5G,CAAC,CAAC,qBAAqB,CAAC;IAC5B,CAAC;CACF;AA/BD,8CA+BC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ReadableSpan, SpanExporter } from '@opentelemetry/sdk-trace-base';\nimport { OTLPExporterNodeBase } from './OTLPExporterNodeBase';\nimport { OTLPExporterNodeConfigBase } from './types';\nimport * as otlpTypes from '../../types';\nimport { toOTLPExportTraceServiceRequest } from '../../transform';\nimport { getEnv, baggageUtils } from '@opentelemetry/core';\nimport { appendResourcePathToUrlIfNotPresent } from '../../util';\n\nconst DEFAULT_COLLECTOR_RESOURCE_PATH = '/v1/traces';\nconst DEFAULT_COLLECTOR_URL=`http://localhost:55681${DEFAULT_COLLECTOR_RESOURCE_PATH}`;\n\n/**\n * Collector Trace Exporter for Node\n */\nexport class OTLPTraceExporter\n extends OTLPExporterNodeBase<\n ReadableSpan,\n otlpTypes.opentelemetryProto.collector.trace.v1.ExportTraceServiceRequest\n >\n implements SpanExporter {\n constructor(config: OTLPExporterNodeConfigBase = {}) {\n super(config);\n this.headers = Object.assign(\n this.headers,\n baggageUtils.parseKeyPairsIntoRecord(\n getEnv().OTEL_EXPORTER_OTLP_TRACES_HEADERS\n )\n );\n }\n\n convert(\n spans: ReadableSpan[]\n ): otlpTypes.opentelemetryProto.collector.trace.v1.ExportTraceServiceRequest {\n return toOTLPExportTraceServiceRequest(spans, this, true);\n }\n\n getDefaultUrl(config: OTLPExporterNodeConfigBase) : string {\n return typeof config.url === 'string'\n ? config.url\n : getEnv().OTEL_EXPORTER_OTLP_TRACES_ENDPOINT.length > 0\n ? getEnv().OTEL_EXPORTER_OTLP_TRACES_ENDPOINT\n : getEnv().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0\n ? appendResourcePathToUrlIfNotPresent(getEnv().OTEL_EXPORTER_OTLP_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)\n : DEFAULT_COLLECTOR_URL;\n }\n}\n"]}
1
+ {"version":3,"file":"OTLPTraceExporter.js","sourceRoot":"","sources":["../../../../src/platform/node/OTLPTraceExporter.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAIH,+CAAkE;AAClE,8CAA2D;AAC3D,0EAAyE;AACzE,0EAG2C;AAE3C,MAAM,+BAA+B,GAAG,YAAY,CAAC;AACrD,MAAM,qBAAqB,GAAG,wBAAwB,+BAA+B,EAAE,CAAC;AAExF;;GAEG;AACH,MAAa,iBACX,SAAQ,yCACoE;IAE5E,YAAY,SAAqC,EAAE;QACjD,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAC1B,IAAI,CAAC,OAAO,EACZ,mBAAY,CAAC,uBAAuB,CAClC,IAAA,aAAM,GAAE,CAAC,iCAAiC,CAC3C,CACF,CAAC;IACJ,CAAC;IAED,OAAO,CACL,KAAqB;QAErB,OAAO,IAAA,2CAA+B,EAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC5D,CAAC;IAED,aAAa,CAAC,MAAkC;QAC9C,OAAO,OAAO,MAAM,CAAC,GAAG,KAAK,QAAQ;YACnC,CAAC,CAAC,MAAM,CAAC,GAAG;YACZ,CAAC,CAAC,IAAA,aAAM,GAAE,CAAC,kCAAkC,CAAC,MAAM,GAAG,CAAC;gBACtD,CAAC,CAAC,IAAA,aAAM,GAAE,CAAC,kCAAkC;gBAC7C,CAAC,CAAC,IAAA,aAAM,GAAE,CAAC,2BAA2B,CAAC,MAAM,GAAG,CAAC;oBAC/C,CAAC,CAAC,IAAA,wDAAmC,EAAC,IAAA,aAAM,GAAE,CAAC,2BAA2B,EAAE,+BAA+B,CAAC;oBAC5G,CAAC,CAAC,qBAAqB,CAAC;IAChC,CAAC;CACF;AA7BD,8CA6BC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ReadableSpan, SpanExporter } from '@opentelemetry/sdk-trace-base';\nimport * as otlpTypes from '../../types';\nimport { toOTLPExportTraceServiceRequest } from '../../transform';\nimport { getEnv, baggageUtils } from '@opentelemetry/core';\nimport { OTLPExporterNodeBase } from '@opentelemetry/otlp-exporter-base';\nimport {\n OTLPExporterNodeConfigBase,\n appendResourcePathToUrlIfNotPresent\n} from '@opentelemetry/otlp-exporter-base';\n\nconst DEFAULT_COLLECTOR_RESOURCE_PATH = '/v1/traces';\nconst DEFAULT_COLLECTOR_URL = `http://localhost:4318${DEFAULT_COLLECTOR_RESOURCE_PATH}`;\n\n/**\n * Collector Trace Exporter for Node\n */\nexport class OTLPTraceExporter\n extends OTLPExporterNodeBase<ReadableSpan,\n otlpTypes.opentelemetryProto.collector.trace.v1.ExportTraceServiceRequest>\n implements SpanExporter {\n constructor(config: OTLPExporterNodeConfigBase = {}) {\n super(config);\n this.headers = Object.assign(\n this.headers,\n baggageUtils.parseKeyPairsIntoRecord(\n getEnv().OTEL_EXPORTER_OTLP_TRACES_HEADERS\n )\n );\n }\n\n convert(\n spans: ReadableSpan[]\n ): otlpTypes.opentelemetryProto.collector.trace.v1.ExportTraceServiceRequest {\n return toOTLPExportTraceServiceRequest(spans, this, true);\n }\n\n getDefaultUrl(config: OTLPExporterNodeConfigBase): string {\n return typeof config.url === 'string'\n ? config.url\n : getEnv().OTEL_EXPORTER_OTLP_TRACES_ENDPOINT.length > 0\n ? getEnv().OTEL_EXPORTER_OTLP_TRACES_ENDPOINT\n : getEnv().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0\n ? appendResourcePathToUrlIfNotPresent(getEnv().OTEL_EXPORTER_OTLP_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)\n : DEFAULT_COLLECTOR_URL;\n }\n}\n"]}
@@ -1,5 +1,2 @@
1
1
  export * from './OTLPTraceExporter';
2
- export * from './OTLPExporterNodeBase';
3
- export * from './util';
4
- export * from './types';
5
2
  //# sourceMappingURL=index.d.ts.map
@@ -26,7 +26,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
26
  };
27
27
  Object.defineProperty(exports, "__esModule", { value: true });
28
28
  __exportStar(require("./OTLPTraceExporter"), exports);
29
- __exportStar(require("./OTLPExporterNodeBase"), exports);
30
- __exportStar(require("./util"), exports);
31
- __exportStar(require("./types"), exports);
32
29
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/platform/node/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;AAEH,sDAAoC;AACpC,yDAAuC;AACvC,yCAAuB;AACvB,0CAAwB","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport * from './OTLPTraceExporter';\nexport * from './OTLPExporterNodeBase';\nexport * from './util';\nexport * from './types';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/platform/node/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;AAEH,sDAAoC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport * from './OTLPTraceExporter';\n"]}
@@ -2,8 +2,8 @@ import { SpanAttributes, SpanKind, SpanStatus, TraceState } from '@opentelemetry
2
2
  import * as core from '@opentelemetry/core';
3
3
  import { Resource } from '@opentelemetry/resources';
4
4
  import { ReadableSpan, TimedEvent } from '@opentelemetry/sdk-trace-base';
5
- import { OTLPExporterBase } from './OTLPExporterBase';
6
- import { opentelemetryProto, OTLPExporterConfigBase } from './types';
5
+ import { opentelemetryProto } from './types';
6
+ import { OTLPExporterBase, OTLPExporterConfigBase } from '@opentelemetry/otlp-exporter-base';
7
7
  /**
8
8
  * Converts attributes to KeyValue array
9
9
  * @param attributes
@@ -1 +1 @@
1
- {"version":3,"file":"transform.js","sourceRoot":"","sources":["../../src/transform.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AASH,4CAA4C;AAI5C,mCAIiB;AAEjB,MAAM,iBAAiB,GAAG,UAAU,CAAC;AACrC,MAAM,iBAAiB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ACpB,OAAO,OAAO,CAAC;IACjB,CAAC,EAAE,IAAI,GAAG,EAA8D,CAAC,CAAC;AAC5E,CAAC;AAnBD,wEAmBC;AAED;;;;;GAKG;AACH,SAAS,sCAAsC,CAC7C,sBAAmD,EACnD,KAAqB,EACrB,MAAgB;IAEhB,OAAO;QACL,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACvD,sBAAsB;KACvB,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAS,wBAAwB,CAC/B,YAA6E,EAC7E,cAA8B,EAC9B,MAAgB;IAEhB,OAAO,KAAK,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,EAAE;QACvD,OAAO;YACL,QAAQ,EAAE,mBAAmB,CAAC,QAAQ,EAAE,cAAc,CAAC;YACvD,2BAA2B,EAAE,KAAK,CAAC,IAAI,CACrC,QAAQ,EACR,CAAC,CAAC,sBAAsB,EAAE,KAAK,CAAC,EAAE,EAAE,CAClC,sCAAsC,CACpC,sBAAsB,EACtB,KAAK,EACL,MAAM,CACP,CACJ;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n SpanAttributes,\n Link,\n SpanKind,\n SpanStatus,\n TraceState,\n} from '@opentelemetry/api';\nimport * as core from '@opentelemetry/core';\nimport { Resource } from '@opentelemetry/resources';\nimport { ReadableSpan, TimedEvent } from '@opentelemetry/sdk-trace-base';\nimport { OTLPExporterBase } from './OTLPExporterBase';\nimport {\n OTLP_SPAN_KIND_MAPPING,\n opentelemetryProto,\n OTLPExporterConfigBase,\n} from './types';\n\nconst MAX_INTEGER_VALUE = 2147483647;\nconst MIN_INTEGER_VALUE = -2147483648;\n\n/**\n * Converts attributes to KeyValue array\n * @param attributes\n */\nexport function toCollectorAttributes(\n attributes: SpanAttributes\n): opentelemetryProto.common.v1.KeyValue[] {\n return Object.keys(attributes).map(key => {\n return toCollectorAttributeKeyValue(key, attributes[key]);\n });\n}\n\n/**\n * Converts array of unknown value to ArrayValue\n * @param values\n */\nexport function toCollectorArrayValue(\n values: unknown[]\n): opentelemetryProto.common.v1.ArrayValue {\n return {\n values: values.map(value => toCollectorAnyValue(value)),\n };\n}\n\n/**\n * Converts attributes to KeyValueList\n * @param attributes\n */\nexport function toCollectorKeyValueList(\n attributes: SpanAttributes\n): opentelemetryProto.common.v1.KeyValueList {\n return {\n values: toCollectorAttributes(attributes),\n };\n}\n\n/**\n * Converts key and unknown value to KeyValue\n * @param value event value\n */\nexport function toCollectorAttributeKeyValue(\n key: string,\n value: unknown\n): opentelemetryProto.common.v1.KeyValue {\n const anyValue = toCollectorAnyValue(value);\n return {\n key,\n value: anyValue,\n };\n}\n\n/**\n * Converts unknown value to AnyValue\n * @param value\n */\nexport function toCollectorAnyValue(\n value: unknown\n): opentelemetryProto.common.v1.AnyValue {\n const anyValue: opentelemetryProto.common.v1.AnyValue = {};\n if (typeof value === 'string') {\n anyValue.stringValue = value;\n } else if (typeof value === 'boolean') {\n anyValue.boolValue = value;\n } else if (\n typeof value === 'number' &&\n value <= MAX_INTEGER_VALUE &&\n value >= MIN_INTEGER_VALUE &&\n Number.isInteger(value)\n ) {\n anyValue.intValue = value;\n } else if (typeof value === 'number') {\n anyValue.doubleValue = value;\n } else if (Array.isArray(value)) {\n anyValue.arrayValue = toCollectorArrayValue(value);\n } else if (value) {\n anyValue.kvlistValue = toCollectorKeyValueList(value as SpanAttributes);\n }\n return anyValue;\n}\n\n/**\n *\n * Converts events\n * @param events array of events\n */\nexport function toCollectorEvents(\n timedEvents: TimedEvent[]\n): opentelemetryProto.trace.v1.Span.Event[] {\n return timedEvents.map(timedEvent => {\n const timeUnixNano = core.hrTimeToNanoseconds(timedEvent.time);\n const name = timedEvent.name;\n const attributes = toCollectorAttributes(timedEvent.attributes || {});\n const droppedAttributesCount = 0;\n\n const protoEvent: opentelemetryProto.trace.v1.Span.Event = {\n timeUnixNano,\n name,\n attributes,\n droppedAttributesCount,\n };\n\n return protoEvent;\n });\n}\n\n/**\n * Converts links\n * @param span\n * @param useHex - if ids should be kept as hex without converting to base64\n */\nfunction toCollectorLinks(\n span: ReadableSpan,\n useHex?: boolean\n): opentelemetryProto.trace.v1.Span.Link[] {\n return span.links.map((link: Link) => {\n const protoLink: opentelemetryProto.trace.v1.Span.Link = {\n traceId: useHex\n ? link.context.traceId\n : core.hexToBase64(link.context.traceId),\n spanId: useHex\n ? link.context.spanId\n : core.hexToBase64(link.context.spanId),\n attributes: toCollectorAttributes(link.attributes || {}),\n droppedAttributesCount: 0,\n };\n return protoLink;\n });\n}\n\n/**\n * Converts span\n * @param span\n * @param useHex - if ids should be kept as hex without converting to base64\n */\nexport function toCollectorSpan(\n span: ReadableSpan,\n useHex?: boolean\n): opentelemetryProto.trace.v1.Span {\n return {\n traceId: useHex\n ? span.spanContext().traceId\n : core.hexToBase64(span.spanContext().traceId),\n spanId: useHex\n ? span.spanContext().spanId\n : core.hexToBase64(span.spanContext().spanId),\n parentSpanId: span.parentSpanId\n ? useHex\n ? span.parentSpanId\n : core.hexToBase64(span.parentSpanId)\n : undefined,\n traceState: toCollectorTraceState(span.spanContext().traceState),\n name: span.name,\n kind: toCollectorKind(span.kind),\n startTimeUnixNano: core.hrTimeToNanoseconds(span.startTime),\n endTimeUnixNano: core.hrTimeToNanoseconds(span.endTime),\n attributes: toCollectorAttributes(span.attributes),\n droppedAttributesCount: 0,\n events: toCollectorEvents(span.events),\n droppedEventsCount: 0,\n status: toCollectorStatus(span.status),\n links: toCollectorLinks(span, useHex),\n droppedLinksCount: 0,\n };\n}\n\n/**\n * Converts status\n * @param status\n */\nexport function toCollectorStatus(\n status: SpanStatus\n): opentelemetryProto.trace.v1.SpanStatus {\n const spanStatus: opentelemetryProto.trace.v1.SpanStatus = {\n code: status.code,\n };\n if (typeof status.message !== 'undefined') {\n spanStatus.message = status.message;\n }\n return spanStatus;\n}\n\n/**\n * Converts resource\n * @param resource\n * @param additionalAttributes\n */\nexport function toCollectorResource(\n resource?: Resource,\n additionalAttributes: { [key: string]: unknown } = {}\n): opentelemetryProto.resource.v1.Resource {\n const attr = Object.assign(\n {},\n additionalAttributes,\n resource ? resource.attributes : {}\n );\n const resourceProto: opentelemetryProto.resource.v1.Resource = {\n attributes: toCollectorAttributes(attr),\n droppedAttributesCount: 0,\n };\n\n return resourceProto;\n}\n\n/**\n * Converts span kind\n * @param kind\n */\nexport function toCollectorKind(\n kind: SpanKind\n): opentelemetryProto.trace.v1.Span.SpanKind {\n const collectorKind = OTLP_SPAN_KIND_MAPPING[kind];\n return typeof collectorKind === 'number'\n ? collectorKind\n : opentelemetryProto.trace.v1.Span.SpanKind.SPAN_KIND_UNSPECIFIED;\n}\n\n/**\n * Converts traceState\n * @param traceState\n */\nexport function toCollectorTraceState(\n traceState?: TraceState\n): opentelemetryProto.trace.v1.Span.TraceState | undefined {\n if (!traceState) return undefined;\n return traceState.serialize();\n}\n\n/**\n * Prepares trace service request to be sent to collector\n * @param spans spans\n * @param collectorExporterBase\n * @param useHex - if ids should be kept as hex without converting to base64\n */\nexport function toOTLPExportTraceServiceRequest<\n T extends OTLPExporterConfigBase\n>(\n spans: ReadableSpan[],\n collectorTraceExporterBase: OTLPExporterBase<\n T,\n ReadableSpan,\n opentelemetryProto.collector.trace.v1.ExportTraceServiceRequest\n >,\n useHex?: boolean\n): opentelemetryProto.collector.trace.v1.ExportTraceServiceRequest {\n const groupedSpans: Map<\n Resource,\n Map<core.InstrumentationLibrary, ReadableSpan[]>\n > = groupSpansByResourceAndLibrary(spans);\n\n const additionalAttributes = Object.assign(\n {},\n collectorTraceExporterBase.attributes\n );\n\n return {\n resourceSpans: toCollectorResourceSpans(\n groupedSpans,\n additionalAttributes,\n useHex\n ),\n };\n}\n\n/**\n * Takes an array of spans and groups them by resource and instrumentation\n * library\n * @param spans spans\n */\nexport function groupSpansByResourceAndLibrary(\n spans: ReadableSpan[]\n): Map<Resource, Map<core.InstrumentationLibrary, ReadableSpan[]>> {\n return spans.reduce((spanMap, span) => {\n //group by resource\n let resourceSpans = spanMap.get(span.resource);\n if (!resourceSpans) {\n resourceSpans = new Map<core.InstrumentationLibrary, ReadableSpan[]>();\n spanMap.set(span.resource, resourceSpans);\n }\n //group by instrumentation library\n let libSpans = resourceSpans.get(span.instrumentationLibrary);\n if (!libSpans) {\n libSpans = new Array<ReadableSpan>();\n resourceSpans.set(span.instrumentationLibrary, libSpans);\n }\n libSpans.push(span);\n return spanMap;\n }, new Map<Resource, Map<core.InstrumentationLibrary, ReadableSpan[]>>());\n}\n\n/**\n * Convert to InstrumentationLibrarySpans\n * @param instrumentationLibrary\n * @param spans\n * @param useHex - if ids should be kept as hex without converting to base64\n */\nfunction toCollectorInstrumentationLibrarySpans(\n instrumentationLibrary: core.InstrumentationLibrary,\n spans: ReadableSpan[],\n useHex?: boolean\n): opentelemetryProto.trace.v1.InstrumentationLibrarySpans {\n return {\n spans: spans.map(span => toCollectorSpan(span, useHex)),\n instrumentationLibrary,\n };\n}\n\n/**\n * Returns a list of resource spans which will be exported to the collector\n * @param groupedSpans\n * @param baseAttributes\n * @param useHex - if ids should be kept as hex without converting to base64\n */\nfunction toCollectorResourceSpans(\n groupedSpans: Map<Resource, Map<core.InstrumentationLibrary, ReadableSpan[]>>,\n baseAttributes: SpanAttributes,\n useHex?: boolean\n): opentelemetryProto.trace.v1.ResourceSpans[] {\n return Array.from(groupedSpans, ([resource, libSpans]) => {\n return {\n resource: toCollectorResource(resource, baseAttributes),\n instrumentationLibrarySpans: Array.from(\n libSpans,\n ([instrumentationLibrary, spans]) =>\n toCollectorInstrumentationLibrarySpans(\n instrumentationLibrary,\n spans,\n useHex\n )\n ),\n };\n });\n}\n"]}
1
+ {"version":3,"file":"transform.js","sourceRoot":"","sources":["../../src/transform.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AASH,4CAA4C;AAG5C,mCAGiB;AAGjB,MAAM,iBAAiB,GAAG,UAAU,CAAC;AACrC,MAAM,iBAAiB,GAAG,CAAC,UAAU,CAAC;AAEtC;;;GAGG;AACH,SAAgB,qBAAqB,CACnC,UAA0B;IAE1B,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;QACvC,OAAO,4BAA4B,CAAC,GAAG,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;AACL,CAAC;AAND,sDAMC;AAED;;;GAGG;AACH,SAAgB,qBAAqB,CACnC,MAAiB;IAEjB,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;KACxD,CAAC;AACJ,CAAC;AAND,sDAMC;AAED;;;GAGG;AACH,SAAgB,uBAAuB,CACrC,UAA0B;IAE1B,OAAO;QACL,MAAM,EAAE,qBAAqB,CAAC,UAAU,CAAC;KAC1C,CAAC;AACJ,CAAC;AAND,0DAMC;AAED;;;GAGG;AACH,SAAgB,4BAA4B,CAC1C,GAAW,EACX,KAAc;IAEd,MAAM,QAAQ,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;IAC5C,OAAO;QACL,GAAG;QACH,KAAK,EAAE,QAAQ;KAChB,CAAC;AACJ,CAAC;AATD,oEASC;AAED;;;GAGG;AACH,SAAgB,mBAAmB,CACjC,KAAc;IAEd,MAAM,QAA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may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n SpanAttributes,\n Link,\n SpanKind,\n SpanStatus,\n TraceState,\n} from '@opentelemetry/api';\nimport * as core from '@opentelemetry/core';\nimport { Resource } from '@opentelemetry/resources';\nimport { ReadableSpan, TimedEvent } from '@opentelemetry/sdk-trace-base';\nimport {\n OTLP_SPAN_KIND_MAPPING,\n opentelemetryProto,\n} from './types';\nimport { OTLPExporterBase, OTLPExporterConfigBase } from '@opentelemetry/otlp-exporter-base';\n\nconst MAX_INTEGER_VALUE = 2147483647;\nconst MIN_INTEGER_VALUE = -2147483648;\n\n/**\n * Converts attributes to KeyValue array\n * @param attributes\n */\nexport function toCollectorAttributes(\n attributes: SpanAttributes\n): opentelemetryProto.common.v1.KeyValue[] {\n return Object.keys(attributes).map(key => {\n return toCollectorAttributeKeyValue(key, attributes[key]);\n });\n}\n\n/**\n * Converts array of unknown value to ArrayValue\n * @param values\n */\nexport function toCollectorArrayValue(\n values: unknown[]\n): opentelemetryProto.common.v1.ArrayValue {\n return {\n values: values.map(value => toCollectorAnyValue(value)),\n };\n}\n\n/**\n * Converts attributes to KeyValueList\n * @param attributes\n */\nexport function toCollectorKeyValueList(\n attributes: SpanAttributes\n): opentelemetryProto.common.v1.KeyValueList {\n return {\n values: toCollectorAttributes(attributes),\n };\n}\n\n/**\n * Converts key and unknown value to KeyValue\n * @param value event value\n */\nexport function toCollectorAttributeKeyValue(\n key: string,\n value: unknown\n): opentelemetryProto.common.v1.KeyValue {\n const anyValue = toCollectorAnyValue(value);\n return {\n key,\n value: anyValue,\n };\n}\n\n/**\n * Converts unknown value to AnyValue\n * @param value\n */\nexport function toCollectorAnyValue(\n value: unknown\n): opentelemetryProto.common.v1.AnyValue {\n const anyValue: opentelemetryProto.common.v1.AnyValue = {};\n if (typeof value === 'string') {\n anyValue.stringValue = value;\n } else if (typeof value === 'boolean') {\n anyValue.boolValue = value;\n } else if (\n typeof value === 'number' &&\n value <= MAX_INTEGER_VALUE &&\n value >= MIN_INTEGER_VALUE &&\n Number.isInteger(value)\n ) {\n anyValue.intValue = value;\n } else if (typeof value === 'number') {\n anyValue.doubleValue = value;\n } else if (Array.isArray(value)) {\n anyValue.arrayValue = toCollectorArrayValue(value);\n } else if (value) {\n anyValue.kvlistValue = toCollectorKeyValueList(value as SpanAttributes);\n }\n return anyValue;\n}\n\n/**\n *\n * Converts events\n * @param events array of events\n */\nexport function toCollectorEvents(\n timedEvents: TimedEvent[]\n): opentelemetryProto.trace.v1.Span.Event[] {\n return timedEvents.map(timedEvent => {\n const timeUnixNano = core.hrTimeToNanoseconds(timedEvent.time);\n const name = timedEvent.name;\n const attributes = toCollectorAttributes(timedEvent.attributes || {});\n const droppedAttributesCount = 0;\n\n const protoEvent: opentelemetryProto.trace.v1.Span.Event = {\n timeUnixNano,\n name,\n attributes,\n droppedAttributesCount,\n };\n\n return protoEvent;\n });\n}\n\n/**\n * Converts links\n * @param span\n * @param useHex - if ids should be kept as hex without converting to base64\n */\nfunction toCollectorLinks(\n span: ReadableSpan,\n useHex?: boolean\n): opentelemetryProto.trace.v1.Span.Link[] {\n return span.links.map((link: Link) => {\n const protoLink: opentelemetryProto.trace.v1.Span.Link = {\n traceId: useHex\n ? link.context.traceId\n : core.hexToBase64(link.context.traceId),\n spanId: useHex\n ? link.context.spanId\n : core.hexToBase64(link.context.spanId),\n attributes: toCollectorAttributes(link.attributes || {}),\n droppedAttributesCount: 0,\n };\n return protoLink;\n });\n}\n\n/**\n * Converts span\n * @param span\n * @param useHex - if ids should be kept as hex without converting to base64\n */\nexport function toCollectorSpan(\n span: ReadableSpan,\n useHex?: boolean\n): opentelemetryProto.trace.v1.Span {\n return {\n traceId: useHex\n ? span.spanContext().traceId\n : core.hexToBase64(span.spanContext().traceId),\n spanId: useHex\n ? span.spanContext().spanId\n : core.hexToBase64(span.spanContext().spanId),\n parentSpanId: span.parentSpanId\n ? useHex\n ? span.parentSpanId\n : core.hexToBase64(span.parentSpanId)\n : undefined,\n traceState: toCollectorTraceState(span.spanContext().traceState),\n name: span.name,\n kind: toCollectorKind(span.kind),\n startTimeUnixNano: core.hrTimeToNanoseconds(span.startTime),\n endTimeUnixNano: core.hrTimeToNanoseconds(span.endTime),\n attributes: toCollectorAttributes(span.attributes),\n droppedAttributesCount: 0,\n events: toCollectorEvents(span.events),\n droppedEventsCount: 0,\n status: toCollectorStatus(span.status),\n links: toCollectorLinks(span, useHex),\n droppedLinksCount: 0,\n };\n}\n\n/**\n * Converts status\n * @param status\n */\nexport function toCollectorStatus(\n status: SpanStatus\n): opentelemetryProto.trace.v1.SpanStatus {\n const spanStatus: opentelemetryProto.trace.v1.SpanStatus = {\n code: status.code,\n };\n if (typeof status.message !== 'undefined') {\n spanStatus.message = status.message;\n }\n return spanStatus;\n}\n\n/**\n * Converts resource\n * @param resource\n * @param additionalAttributes\n */\nexport function toCollectorResource(\n resource?: Resource,\n additionalAttributes: { [key: string]: unknown } = {}\n): opentelemetryProto.resource.v1.Resource {\n const attr = Object.assign(\n {},\n additionalAttributes,\n resource ? resource.attributes : {}\n );\n const resourceProto: opentelemetryProto.resource.v1.Resource = {\n attributes: toCollectorAttributes(attr),\n droppedAttributesCount: 0,\n };\n\n return resourceProto;\n}\n\n/**\n * Converts span kind\n * @param kind\n */\nexport function toCollectorKind(\n kind: SpanKind\n): opentelemetryProto.trace.v1.Span.SpanKind {\n const collectorKind = OTLP_SPAN_KIND_MAPPING[kind];\n return typeof collectorKind === 'number'\n ? collectorKind\n : opentelemetryProto.trace.v1.Span.SpanKind.SPAN_KIND_UNSPECIFIED;\n}\n\n/**\n * Converts traceState\n * @param traceState\n */\nexport function toCollectorTraceState(\n traceState?: TraceState\n): opentelemetryProto.trace.v1.Span.TraceState | undefined {\n if (!traceState) return undefined;\n return traceState.serialize();\n}\n\n/**\n * Prepares trace service request to be sent to collector\n * @param spans spans\n * @param collectorExporterBase\n * @param useHex - if ids should be kept as hex without converting to base64\n */\nexport function toOTLPExportTraceServiceRequest<\n T extends OTLPExporterConfigBase\n>(\n spans: ReadableSpan[],\n collectorTraceExporterBase: OTLPExporterBase<\n T,\n ReadableSpan,\n opentelemetryProto.collector.trace.v1.ExportTraceServiceRequest\n >,\n useHex?: boolean\n): opentelemetryProto.collector.trace.v1.ExportTraceServiceRequest {\n const groupedSpans: Map<\n Resource,\n Map<core.InstrumentationLibrary, ReadableSpan[]>\n > = groupSpansByResourceAndLibrary(spans);\n\n const additionalAttributes = Object.assign(\n {},\n collectorTraceExporterBase.attributes\n );\n\n return {\n resourceSpans: toCollectorResourceSpans(\n groupedSpans,\n additionalAttributes,\n useHex\n ),\n };\n}\n\n/**\n * Takes an array of spans and groups them by resource and instrumentation\n * library\n * @param spans spans\n */\nexport function groupSpansByResourceAndLibrary(\n spans: ReadableSpan[]\n): Map<Resource, Map<core.InstrumentationLibrary, ReadableSpan[]>> {\n return spans.reduce((spanMap, span) => {\n //group by resource\n let resourceSpans = spanMap.get(span.resource);\n if (!resourceSpans) {\n resourceSpans = new Map<core.InstrumentationLibrary, ReadableSpan[]>();\n spanMap.set(span.resource, resourceSpans);\n }\n //group by instrumentation library\n let libSpans = resourceSpans.get(span.instrumentationLibrary);\n if (!libSpans) {\n libSpans = new Array<ReadableSpan>();\n resourceSpans.set(span.instrumentationLibrary, libSpans);\n }\n libSpans.push(span);\n return spanMap;\n }, new Map<Resource, Map<core.InstrumentationLibrary, ReadableSpan[]>>());\n}\n\n/**\n * Convert to InstrumentationLibrarySpans\n * @param instrumentationLibrary\n * @param spans\n * @param useHex - if ids should be kept as hex without converting to base64\n */\nfunction toCollectorInstrumentationLibrarySpans(\n instrumentationLibrary: core.InstrumentationLibrary,\n spans: ReadableSpan[],\n useHex?: boolean\n): opentelemetryProto.trace.v1.InstrumentationLibrarySpans {\n return {\n spans: spans.map(span => toCollectorSpan(span, useHex)),\n instrumentationLibrary,\n };\n}\n\n/**\n * Returns a list of resource spans which will be exported to the collector\n * @param groupedSpans\n * @param baseAttributes\n * @param useHex - if ids should be kept as hex without converting to base64\n */\nfunction toCollectorResourceSpans(\n groupedSpans: Map<Resource, Map<core.InstrumentationLibrary, ReadableSpan[]>>,\n baseAttributes: SpanAttributes,\n useHex?: boolean\n): opentelemetryProto.trace.v1.ResourceSpans[] {\n return Array.from(groupedSpans, ([resource, libSpans]) => {\n return {\n resource: toCollectorResource(resource, baseAttributes),\n instrumentationLibrarySpans: Array.from(\n libSpans,\n ([instrumentationLibrary, spans]) =>\n toCollectorInstrumentationLibrarySpans(\n instrumentationLibrary,\n spans,\n useHex\n )\n ),\n };\n });\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { SpanAttributes, SpanStatusCode } from '@opentelemetry/api';
1
+ import { SpanStatusCode } from '@opentelemetry/api';
2
2
  export declare namespace opentelemetryProto {
3
3
  namespace collector {
4
4
  namespace trace.v1 {
@@ -196,38 +196,6 @@ export declare namespace opentelemetryProto {
196
196
  }
197
197
  }
198
198
  }
199
- /**
200
- * Interface for handling error
201
- */
202
- export declare class OTLPExporterError extends Error {
203
- readonly code?: number;
204
- readonly name: string;
205
- readonly data?: string;
206
- constructor(message?: string, code?: number, data?: string);
207
- }
208
- /**
209
- * Interface for handling export service errors
210
- */
211
- export interface ExportServiceError {
212
- name: string;
213
- code: number;
214
- details: string;
215
- metadata: {
216
- [key: string]: unknown;
217
- };
218
- message: string;
219
- stack: string;
220
- }
221
- /**
222
- * Collector Exporter base config
223
- */
224
- export interface OTLPExporterConfigBase {
225
- headers?: Partial<Record<string, unknown>>;
226
- hostname?: string;
227
- attributes?: SpanAttributes;
228
- url?: string;
229
- concurrencyLimit?: number;
230
- }
231
199
  /**
232
200
  * Mapping between api SpanKind and proto SpanKind
233
201
  */
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.OTLP_SPAN_KIND_MAPPING = exports.OTLPExporterError = exports.opentelemetryProto = void 0;
18
+ exports.OTLP_SPAN_KIND_MAPPING = exports.opentelemetryProto = void 0;
19
19
  const api_1 = require("@opentelemetry/api");
20
20
  /* eslint-disable @typescript-eslint/no-namespace */
21
21
  /* eslint-disable @typescript-eslint/no-unused-vars */
@@ -135,18 +135,6 @@ var opentelemetryProto;
135
135
  })(v1 = common.v1 || (common.v1 = {}));
136
136
  })(common = opentelemetryProto.common || (opentelemetryProto.common = {}));
137
137
  })(opentelemetryProto = exports.opentelemetryProto || (exports.opentelemetryProto = {}));
138
- /**
139
- * Interface for handling error
140
- */
141
- class OTLPExporterError extends Error {
142
- constructor(message, code, data) {
143
- super(message);
144
- this.name = 'OTLPExporterError';
145
- this.data = data;
146
- this.code = code;
147
- }
148
- }
149
- exports.OTLPExporterError = OTLPExporterError;
150
138
  /**
151
139
  * Mapping between api SpanKind and proto SpanKind
152
140
  */
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4CAA8E;AAE9E,oDAAoD;AACpD,sDAAsD;AAEtD,IAAiB,kBAAkB,CAkSlC;AAlSD,WAAiB,kBAAkB;IAyBjC,IAAiB,OAAO,CAqIvB;IArID,WAAiB,OAAO;QAAC,IAAA,EAAE,CAqI1B;QArIwB,WAAA,EAAE;YAkEzB,IAAY,sBAkEX;YAlED,WAAY,sBAAsB;gBAChC,0EAA0E;gBAC1E,iIAAuC,CAAA;gBAEvC,2EAA2E;gBAC3E,4EAA4E;gBAC5E,wDAAwD;gBACxD,EAAE;gBACF,oEAAoE;gBACpE,mEAAmE;gBACnE,iEAAiE;gBACjE,EAAE;gBACF,uEAAuE;gBACvE,sEAAsE;gBACtE,gBAAgB;gBAChB,EAAE;gBAC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ACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAVD,8CAUC;AAyBD;;GAEG;AACU,QAAA,sBAAsB,GAAG;IACpC,CAAC,cAAQ,CAAC,QAAQ,CAAC,EACjB,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,kBAAkB;IAC9D,CAAC,cAAQ,CAAC,MAAM,CAAC,EAAE,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,gBAAgB;IAC7E,CAAC,cAAQ,CAAC,MAAM,CAAC,EAAE,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,gBAAgB;IAC7E,CAAC,cAAQ,CAAC,QAAQ,CAAC,EACjB,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,kBAAkB;IAC9D,CAAC,cAAQ,CAAC,QAAQ,CAAC,EACjB,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,kBAAkB;CAC/D,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { SpanAttributes, SpanKind, SpanStatusCode } from '@opentelemetry/api';\n\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unused-vars */\n\nexport namespace opentelemetryProto {\n export namespace collector {\n export namespace trace.v1 {\n export interface TraceService {\n service: opentelemetryProto.collector.trace.v1.TraceService;\n }\n\n export interface ExportTraceServiceRequest {\n resourceSpans: opentelemetryProto.trace.v1.ResourceSpans[];\n }\n }\n export namespace metrics.v1 {\n export interface ExportMetricsServiceRequest {\n resourceMetrics: opentelemetryProto.metrics.v1.ResourceMetrics[];\n }\n }\n }\n\n export namespace resource.v1 {\n export interface Resource {\n attributes: opentelemetryProto.common.v1.KeyValue[];\n droppedAttributesCount: number;\n }\n }\n\n export namespace metrics.v1 {\n export interface Metric {\n name: string;\n description: string;\n unit: string;\n // data:\n intGauge?: opentelemetryProto.metrics.v1.Gauge;\n doubleGauge?: opentelemetryProto.metrics.v1.Gauge;\n intSum?: opentelemetryProto.metrics.v1.Sum;\n doubleSum?: opentelemetryProto.metrics.v1.Sum;\n intHistogram?: opentelemetryProto.metrics.v1.Histogram;\n doubleHistogram?: opentelemetryProto.metrics.v1.Histogram;\n }\n\n export interface Gauge {\n dataPoints: opentelemetryProto.metrics.v1.DataPoint[];\n }\n\n export interface Sum {\n dataPoints: opentelemetryProto.metrics.v1.DataPoint[];\n aggregationTemporality: opentelemetryProto.metrics.v1.AggregationTemporality;\n isMonotonic: boolean;\n }\n\n export interface Histogram {\n dataPoints: opentelemetryProto.metrics.v1.HistogramDataPoint[];\n aggregationTemporality: opentelemetryProto.metrics.v1.AggregationTemporality;\n }\n\n export interface DataPoint {\n labels: opentelemetryProto.common.v1.StringKeyValue[];\n startTimeUnixNano: number;\n timeUnixNano: number;\n value: number;\n exemplars?: opentelemetryProto.metrics.v1.Exemplar[];\n }\n\n export interface Exemplar {\n filteredLabels: opentelemetryProto.common.v1.StringKeyValue[];\n timeUnixNano: number;\n value: number;\n spanId: Uint8Array;\n traceId: Uint8Array;\n }\n\n export interface HistogramDataPoint {\n labels: opentelemetryProto.common.v1.StringKeyValue[];\n startTimeUnixNano: number;\n timeUnixNano: number;\n count: number;\n sum: number;\n bucketCounts?: number[];\n explicitBounds?: number[];\n exemplars?: opentelemetryProto.metrics.v1.Exemplar[][];\n }\n\n export interface InstrumentationLibraryMetrics {\n instrumentationLibrary?: opentelemetryProto.common.v1.InstrumentationLibrary;\n metrics: opentelemetryProto.metrics.v1.Metric[];\n }\n\n export interface ResourceMetrics {\n resource?: opentelemetryProto.resource.v1.Resource;\n instrumentationLibraryMetrics: opentelemetryProto.metrics.v1.InstrumentationLibraryMetrics[];\n }\n\n export enum AggregationTemporality {\n // UNSPECIFIED is the default AggregationTemporality, it MUST not be used.\n AGGREGATION_TEMPORALITY_UNSPECIFIED = 0,\n\n // DELTA is an AggregationTemporality for a metric aggregator which reports\n // changes since last report time. Successive metrics contain aggregation of\n // values from continuous and non-overlapping intervals.\n //\n // The values for a DELTA metric are based only on the time interval\n // associated with one measurement cycle. There is no dependency on\n // previous measurements like is the case for CUMULATIVE metrics.\n //\n // For example, consider a system measuring the number of requests that\n // it receives and reports the sum of these requests every second as a\n // DELTA metric:\n //\n // 1. The system starts receiving at time=t_0.\n // 2. A request is received, the system measures 1 request.\n // 3. A request is received, the system measures 1 request.\n // 4. A request is received, the system measures 1 request.\n // 5. The 1 second collection cycle ends. A metric is exported for the\n // number of requests received over the interval of time t_0 to\n // t_0+1 with a value of 3.\n // 6. A request is received, the system measures 1 request.\n // 7. A request is received, the system measures 1 request.\n // 8. The 1 second collection cycle ends. A metric is exported for the\n // number of requests received over the interval of time t_0+1 to\n // t_0+2 with a value of 2.\n AGGREGATION_TEMPORALITY_DELTA = 1,\n\n // CUMULATIVE is an AggregationTemporality for a metric aggregator which\n // reports changes since a fixed start time. This means that current values\n // of a CUMULATIVE metric depend on all previous measurements since the\n // start time. Because of this, the sender is required to retain this state\n // in some form. If this state is lost or invalidated, the CUMULATIVE metric\n // values MUST be reset and a new fixed start time following the last\n // reported measurement time sent MUST be used.\n //\n // For example, consider a system measuring the number of requests that\n // it receives and reports the sum of these requests every second as a\n // CUMULATIVE metric:\n //\n // 1. The system starts receiving at time=t_0.\n // 2. A request is received, the system measures 1 request.\n // 3. A request is received, the system measures 1 request.\n // 4. A request is received, the system measures 1 request.\n // 5. The 1 second collection cycle ends. A metric is exported for the\n // number of requests received over the interval of time t_0 to\n // t_0+1 with a value of 3.\n // 6. A request is received, the system measures 1 request.\n // 7. A request is received, the system measures 1 request.\n // 8. The 1 second collection cycle ends. A metric is exported for the\n // number of requests received over the interval of time t_0 to\n // t_0+2 with a value of 5.\n // 9. The system experiences a fault and loses state.\n // 10. The system recovers and resumes receiving at time=t_1.\n // 11. A request is received, the system measures 1 request.\n // 12. The 1 second collection cycle ends. A metric is exported for the\n // number of requests received over the interval of time t_1 to\n // t_0+1 with a value of 1.\n //\n // Note: Even though, when reporting changes since last report time, using\n // CUMULATIVE is valid, it is not recommended. This may cause problems for\n // systems that do not use start_time to determine when the aggregation\n // value was reset (e.g. Prometheus).\n AGGREGATION_TEMPORALITY_CUMULATIVE = 2,\n }\n }\n\n export namespace trace.v1 {\n export namespace ConstantSampler {\n export enum ConstantDecision {\n ALWAYS_OFF = 0,\n ALWAYS_ON = 1,\n ALWAYS_PARENT = 2,\n }\n }\n export namespace Span {\n export interface Event {\n timeUnixNano: number;\n name: string;\n attributes?: opentelemetryProto.common.v1.KeyValue[];\n droppedAttributesCount: number;\n }\n\n export interface Link {\n traceId: string;\n spanId: string;\n traceState?: opentelemetryProto.trace.v1.Span.TraceState;\n attributes?: opentelemetryProto.common.v1.KeyValue[];\n droppedAttributesCount: number;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-shadow\n export enum SpanKind {\n SPAN_KIND_UNSPECIFIED,\n SPAN_KIND_INTERNAL,\n SPAN_KIND_SERVER,\n SPAN_KIND_CLIENT,\n SPAN_KIND_PRODUCER,\n SPAN_KIND_CONSUMER,\n }\n\n export type TraceState = string | undefined;\n }\n\n export interface ConstantSampler {\n decision?: opentelemetryProto.trace.v1.ConstantSampler.ConstantDecision;\n }\n\n export interface InstrumentationLibrarySpans {\n instrumentationLibrary?: opentelemetryProto.common.v1.InstrumentationLibrary;\n spans: opentelemetryProto.trace.v1.Span[];\n }\n\n export interface ProbabilitySampler {\n samplingProbability?: number | null;\n }\n\n export interface RateLimitingSampler {\n qps?: number | null;\n }\n\n export interface ResourceSpans {\n resource?: opentelemetryProto.resource.v1.Resource;\n instrumentationLibrarySpans: opentelemetryProto.trace.v1.InstrumentationLibrarySpans[];\n }\n\n export interface Span {\n traceId: string;\n spanId: string;\n traceState: opentelemetryProto.trace.v1.Span.TraceState;\n parentSpanId?: string;\n name?: string;\n kind?: opentelemetryProto.trace.v1.Span.SpanKind;\n startTimeUnixNano?: number;\n endTimeUnixNano?: number;\n attributes?: opentelemetryProto.common.v1.KeyValue[];\n droppedAttributesCount: number;\n events?: opentelemetryProto.trace.v1.Span.Event[];\n droppedEventsCount: number;\n links?: opentelemetryProto.trace.v1.Span.Link[];\n droppedLinksCount: number;\n status?: SpanStatus;\n }\n\n export interface SpanStatus {\n /** The status code of this message. */\n code: SpanStatusCode;\n /** A developer-facing error message. */\n message?: string;\n }\n\n export interface TraceConfig {\n constantSampler?: ConstantSampler | null;\n probabilitySampler?: ProbabilitySampler | null;\n rateLimitingSampler?: RateLimitingSampler | null;\n }\n }\n export namespace common.v1 {\n export interface KeyValue {\n key: string;\n value: AnyValue;\n }\n\n export type ArrayValue = {\n values: AnyValue[];\n };\n\n export interface KeyValueList {\n values: KeyValue[];\n }\n\n export type AnyValue = {\n stringValue?: string;\n boolValue?: boolean;\n intValue?: number;\n doubleValue?: number;\n arrayValue?: ArrayValue;\n kvlistValue?: KeyValueList;\n };\n\n export interface InstrumentationLibrary {\n name: string;\n version?: string;\n }\n\n export interface StringKeyValue {\n key: string;\n value: string;\n }\n\n export enum ValueType {\n STRING,\n INT,\n DOUBLE,\n BOOL,\n }\n }\n}\n\n/**\n * Interface for handling error\n */\nexport class OTLPExporterError extends Error {\n readonly code?: number;\n override readonly name: string = 'OTLPExporterError';\n readonly data?: string;\n\n constructor(message?: string, code?: number, data?: string) {\n super(message);\n this.data = data;\n this.code = code;\n }\n}\n\n/**\n * Interface for handling export service errors\n */\nexport interface ExportServiceError {\n name: string;\n code: number;\n details: string;\n metadata: { [key: string]: unknown };\n message: string;\n stack: string;\n}\n\n/**\n * Collector Exporter base config\n */\nexport interface OTLPExporterConfigBase {\n headers?: Partial<Record<string, unknown>>;\n hostname?: string;\n attributes?: SpanAttributes;\n url?: string;\n concurrencyLimit?: number;\n}\n\n/**\n * Mapping between api SpanKind and proto SpanKind\n */\nexport const OTLP_SPAN_KIND_MAPPING = {\n [SpanKind.INTERNAL]:\n opentelemetryProto.trace.v1.Span.SpanKind.SPAN_KIND_INTERNAL,\n [SpanKind.SERVER]: opentelemetryProto.trace.v1.Span.SpanKind.SPAN_KIND_SERVER,\n [SpanKind.CLIENT]: opentelemetryProto.trace.v1.Span.SpanKind.SPAN_KIND_CLIENT,\n [SpanKind.PRODUCER]:\n opentelemetryProto.trace.v1.Span.SpanKind.SPAN_KIND_PRODUCER,\n [SpanKind.CONSUMER]:\n opentelemetryProto.trace.v1.Span.SpanKind.SPAN_KIND_CONSUMER,\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4CAA8D;AAE9D,oDAAoD;AACpD,sDAAsD;AAEtD,IAAiB,kBAAkB,CAkSlC;AAlSD,WAAiB,kBAAkB;IAyBjC,IAAiB,OAAO,CAqIvB;IArID,WAAiB,OAAO;QAAC,IAAA,EAAE,CAqI1B;QArIwB,WAAA,EAAE;YAkEzB,IAAY,sBAkEX;YAlED,WAAY,sBAAsB;gBAChC,0EAA0E;gBAC1E,iIAAuC,CAAA;gBAEvC,2EAA2E;gBAC3E,4EAA4E;gBAC5E,wDAAwD;gBACxD,EAAE;gBACF,oEAAoE;gBACpE,mEAAmE;gBACnE,iEAAiE;gBACjE,EAAE;gBACF,uEAAuE;gBACvE,sEAAsE;gBACtE,gBAAgB;gBAChB,EAAE;gBACF,gDAAgD;gBAChD,6DAA6D;gBAC7D,6DAA6D;gBAC7D,6DAA6D;gBAC7D,wEAAwE;gBACxE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AAQ,CAAC,MAAM,CAAC,EAAE,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,gBAAgB;IAC7E,CAAC,cAAQ,CAAC,QAAQ,CAAC,EACjB,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,kBAAkB;IAC9D,CAAC,cAAQ,CAAC,QAAQ,CAAC,EACjB,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,kBAAkB;CAC/D,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { SpanKind, SpanStatusCode } from '@opentelemetry/api';\n\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unused-vars */\n\nexport namespace opentelemetryProto {\n export namespace collector {\n export namespace trace.v1 {\n export interface TraceService {\n service: opentelemetryProto.collector.trace.v1.TraceService;\n }\n\n export interface ExportTraceServiceRequest {\n resourceSpans: opentelemetryProto.trace.v1.ResourceSpans[];\n }\n }\n export namespace metrics.v1 {\n export interface ExportMetricsServiceRequest {\n resourceMetrics: opentelemetryProto.metrics.v1.ResourceMetrics[];\n }\n }\n }\n\n export namespace resource.v1 {\n export interface Resource {\n attributes: opentelemetryProto.common.v1.KeyValue[];\n droppedAttributesCount: number;\n }\n }\n\n export namespace metrics.v1 {\n export interface Metric {\n name: string;\n description: string;\n unit: string;\n // data:\n intGauge?: opentelemetryProto.metrics.v1.Gauge;\n doubleGauge?: opentelemetryProto.metrics.v1.Gauge;\n intSum?: opentelemetryProto.metrics.v1.Sum;\n doubleSum?: opentelemetryProto.metrics.v1.Sum;\n intHistogram?: opentelemetryProto.metrics.v1.Histogram;\n doubleHistogram?: opentelemetryProto.metrics.v1.Histogram;\n }\n\n export interface Gauge {\n dataPoints: opentelemetryProto.metrics.v1.DataPoint[];\n }\n\n export interface Sum {\n dataPoints: opentelemetryProto.metrics.v1.DataPoint[];\n aggregationTemporality: opentelemetryProto.metrics.v1.AggregationTemporality;\n isMonotonic: boolean;\n }\n\n export interface Histogram {\n dataPoints: opentelemetryProto.metrics.v1.HistogramDataPoint[];\n aggregationTemporality: opentelemetryProto.metrics.v1.AggregationTemporality;\n }\n\n export interface DataPoint {\n labels: opentelemetryProto.common.v1.StringKeyValue[];\n startTimeUnixNano: number;\n timeUnixNano: number;\n value: number;\n exemplars?: opentelemetryProto.metrics.v1.Exemplar[];\n }\n\n export interface Exemplar {\n filteredLabels: opentelemetryProto.common.v1.StringKeyValue[];\n timeUnixNano: number;\n value: number;\n spanId: Uint8Array;\n traceId: Uint8Array;\n }\n\n export interface HistogramDataPoint {\n labels: opentelemetryProto.common.v1.StringKeyValue[];\n startTimeUnixNano: number;\n timeUnixNano: number;\n count: number;\n sum: number;\n bucketCounts?: number[];\n explicitBounds?: number[];\n exemplars?: opentelemetryProto.metrics.v1.Exemplar[][];\n }\n\n export interface InstrumentationLibraryMetrics {\n instrumentationLibrary?: opentelemetryProto.common.v1.InstrumentationLibrary;\n metrics: opentelemetryProto.metrics.v1.Metric[];\n }\n\n export interface ResourceMetrics {\n resource?: opentelemetryProto.resource.v1.Resource;\n instrumentationLibraryMetrics: opentelemetryProto.metrics.v1.InstrumentationLibraryMetrics[];\n }\n\n export enum AggregationTemporality {\n // UNSPECIFIED is the default AggregationTemporality, it MUST not be used.\n AGGREGATION_TEMPORALITY_UNSPECIFIED = 0,\n\n // DELTA is an AggregationTemporality for a metric aggregator which reports\n // changes since last report time. Successive metrics contain aggregation of\n // values from continuous and non-overlapping intervals.\n //\n // The values for a DELTA metric are based only on the time interval\n // associated with one measurement cycle. There is no dependency on\n // previous measurements like is the case for CUMULATIVE metrics.\n //\n // For example, consider a system measuring the number of requests that\n // it receives and reports the sum of these requests every second as a\n // DELTA metric:\n //\n // 1. The system starts receiving at time=t_0.\n // 2. A request is received, the system measures 1 request.\n // 3. A request is received, the system measures 1 request.\n // 4. A request is received, the system measures 1 request.\n // 5. The 1 second collection cycle ends. A metric is exported for the\n // number of requests received over the interval of time t_0 to\n // t_0+1 with a value of 3.\n // 6. A request is received, the system measures 1 request.\n // 7. A request is received, the system measures 1 request.\n // 8. The 1 second collection cycle ends. A metric is exported for the\n // number of requests received over the interval of time t_0+1 to\n // t_0+2 with a value of 2.\n AGGREGATION_TEMPORALITY_DELTA = 1,\n\n // CUMULATIVE is an AggregationTemporality for a metric aggregator which\n // reports changes since a fixed start time. This means that current values\n // of a CUMULATIVE metric depend on all previous measurements since the\n // start time. Because of this, the sender is required to retain this state\n // in some form. If this state is lost or invalidated, the CUMULATIVE metric\n // values MUST be reset and a new fixed start time following the last\n // reported measurement time sent MUST be used.\n //\n // For example, consider a system measuring the number of requests that\n // it receives and reports the sum of these requests every second as a\n // CUMULATIVE metric:\n //\n // 1. The system starts receiving at time=t_0.\n // 2. A request is received, the system measures 1 request.\n // 3. A request is received, the system measures 1 request.\n // 4. A request is received, the system measures 1 request.\n // 5. The 1 second collection cycle ends. A metric is exported for the\n // number of requests received over the interval of time t_0 to\n // t_0+1 with a value of 3.\n // 6. A request is received, the system measures 1 request.\n // 7. A request is received, the system measures 1 request.\n // 8. The 1 second collection cycle ends. A metric is exported for the\n // number of requests received over the interval of time t_0 to\n // t_0+2 with a value of 5.\n // 9. The system experiences a fault and loses state.\n // 10. The system recovers and resumes receiving at time=t_1.\n // 11. A request is received, the system measures 1 request.\n // 12. The 1 second collection cycle ends. A metric is exported for the\n // number of requests received over the interval of time t_1 to\n // t_0+1 with a value of 1.\n //\n // Note: Even though, when reporting changes since last report time, using\n // CUMULATIVE is valid, it is not recommended. This may cause problems for\n // systems that do not use start_time to determine when the aggregation\n // value was reset (e.g. Prometheus).\n AGGREGATION_TEMPORALITY_CUMULATIVE = 2,\n }\n }\n\n export namespace trace.v1 {\n export namespace ConstantSampler {\n export enum ConstantDecision {\n ALWAYS_OFF = 0,\n ALWAYS_ON = 1,\n ALWAYS_PARENT = 2,\n }\n }\n export namespace Span {\n export interface Event {\n timeUnixNano: number;\n name: string;\n attributes?: opentelemetryProto.common.v1.KeyValue[];\n droppedAttributesCount: number;\n }\n\n export interface Link {\n traceId: string;\n spanId: string;\n traceState?: opentelemetryProto.trace.v1.Span.TraceState;\n attributes?: opentelemetryProto.common.v1.KeyValue[];\n droppedAttributesCount: number;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-shadow\n export enum SpanKind {\n SPAN_KIND_UNSPECIFIED,\n SPAN_KIND_INTERNAL,\n SPAN_KIND_SERVER,\n SPAN_KIND_CLIENT,\n SPAN_KIND_PRODUCER,\n SPAN_KIND_CONSUMER,\n }\n\n export type TraceState = string | undefined;\n }\n\n export interface ConstantSampler {\n decision?: opentelemetryProto.trace.v1.ConstantSampler.ConstantDecision;\n }\n\n export interface InstrumentationLibrarySpans {\n instrumentationLibrary?: opentelemetryProto.common.v1.InstrumentationLibrary;\n spans: opentelemetryProto.trace.v1.Span[];\n }\n\n export interface ProbabilitySampler {\n samplingProbability?: number | null;\n }\n\n export interface RateLimitingSampler {\n qps?: number | null;\n }\n\n export interface ResourceSpans {\n resource?: opentelemetryProto.resource.v1.Resource;\n instrumentationLibrarySpans: opentelemetryProto.trace.v1.InstrumentationLibrarySpans[];\n }\n\n export interface Span {\n traceId: string;\n spanId: string;\n traceState: opentelemetryProto.trace.v1.Span.TraceState;\n parentSpanId?: string;\n name?: string;\n kind?: opentelemetryProto.trace.v1.Span.SpanKind;\n startTimeUnixNano?: number;\n endTimeUnixNano?: number;\n attributes?: opentelemetryProto.common.v1.KeyValue[];\n droppedAttributesCount: number;\n events?: opentelemetryProto.trace.v1.Span.Event[];\n droppedEventsCount: number;\n links?: opentelemetryProto.trace.v1.Span.Link[];\n droppedLinksCount: number;\n status?: SpanStatus;\n }\n\n export interface SpanStatus {\n /** The status code of this message. */\n code: SpanStatusCode;\n /** A developer-facing error message. */\n message?: string;\n }\n\n export interface TraceConfig {\n constantSampler?: ConstantSampler | null;\n probabilitySampler?: ProbabilitySampler | null;\n rateLimitingSampler?: RateLimitingSampler | null;\n }\n }\n export namespace common.v1 {\n export interface KeyValue {\n key: string;\n value: AnyValue;\n }\n\n export type ArrayValue = {\n values: AnyValue[];\n };\n\n export interface KeyValueList {\n values: KeyValue[];\n }\n\n export type AnyValue = {\n stringValue?: string;\n boolValue?: boolean;\n intValue?: number;\n doubleValue?: number;\n arrayValue?: ArrayValue;\n kvlistValue?: KeyValueList;\n };\n\n export interface InstrumentationLibrary {\n name: string;\n version?: string;\n }\n\n export interface StringKeyValue {\n key: string;\n value: string;\n }\n\n export enum ValueType {\n STRING,\n INT,\n DOUBLE,\n BOOL,\n }\n }\n}\n\n/**\n * Mapping between api SpanKind and proto SpanKind\n */\nexport const OTLP_SPAN_KIND_MAPPING = {\n [SpanKind.INTERNAL]:\n opentelemetryProto.trace.v1.Span.SpanKind.SPAN_KIND_INTERNAL,\n [SpanKind.SERVER]: opentelemetryProto.trace.v1.Span.SpanKind.SPAN_KIND_SERVER,\n [SpanKind.CLIENT]: opentelemetryProto.trace.v1.Span.SpanKind.SPAN_KIND_CLIENT,\n [SpanKind.PRODUCER]:\n opentelemetryProto.trace.v1.Span.SpanKind.SPAN_KIND_PRODUCER,\n [SpanKind.CONSUMER]:\n opentelemetryProto.trace.v1.Span.SpanKind.SPAN_KIND_CONSUMER,\n};\n"]}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.27.0";
1
+ export declare const VERSION = "0.28.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -17,5 +17,5 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.VERSION = void 0;
19
19
  // this is autogenerated file, see scripts/version-update.js
20
- exports.VERSION = '0.27.0';
20
+ exports.VERSION = '0.28.0';
21
21
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.27.0';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.28.0';\n"]}
package/package.json CHANGED
@@ -1,20 +1,23 @@
1
1
  {
2
2
  "name": "@opentelemetry/exporter-trace-otlp-http",
3
- "version": "0.27.0",
3
+ "version": "0.28.0",
4
4
  "description": "OpenTelemetry Collector Trace Exporter allows user to send collected traces to the OpenTelemetry Collector",
5
5
  "main": "build/src/index.js",
6
6
  "module": "build/esm/index.js",
7
+ "esnext": "build/esnext/index.js",
7
8
  "types": "build/src/index.d.ts",
8
9
  "repository": "open-telemetry/opentelemetry-js",
9
10
  "browser": {
10
11
  "./src/platform/index.ts": "./src/platform/browser/index.ts",
11
12
  "./build/esm/platform/index.js": "./build/esm/platform/browser/index.js",
13
+ "./build/esnext/platform/index.js": "./build/esnext/platform/browser/index.js",
12
14
  "./build/src/platform/index.js": "./build/src/platform/browser/index.js"
13
15
  },
14
16
  "scripts": {
15
- "compile": "tsc --build tsconfig.json tsconfig.esm.json",
16
- "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json",
17
- "codecov:browser": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../",
17
+ "prepublishOnly": "npm run compile",
18
+ "compile": "tsc --build tsconfig.all.json",
19
+ "clean": "tsc --build --clean tsconfig.all.json",
20
+ "codecov:browser": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../",
18
21
  "lint": "eslint . --ext .ts",
19
22
  "lint:fix": "eslint . --ext .ts --fix",
20
23
  "tdd": "npm run test -- --watch-extensions ts --watch",
@@ -22,9 +25,11 @@
22
25
  "test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts' --exclude 'test/browser/**/*.ts'",
23
26
  "test:browser": "nyc karma start --single-run",
24
27
  "version": "node ../../../scripts/version-update.js",
25
- "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json",
26
- "precompile": "lerna run version --scope $(npm pkg get name) --include-filtered-dependencies",
27
- "prewatch": "npm run precompile"
28
+ "watch": "tsc --build --watch tsconfig.all.json",
29
+ "precompile": "lerna run version --scope $(npm pkg get name) --include-dependencies",
30
+ "prewatch": "npm run precompile",
31
+ "peer-api-check": "node ../../../scripts/peer-api-check.js",
32
+ "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../"
28
33
  },
29
34
  "keywords": [
30
35
  "opentelemetry",
@@ -38,12 +43,15 @@
38
43
  "author": "OpenTelemetry Authors",
39
44
  "license": "Apache-2.0",
40
45
  "engines": {
41
- "node": ">=8.0.0"
46
+ "node": ">=8.12.0"
42
47
  },
43
48
  "files": [
44
49
  "build/esm/**/*.js",
45
50
  "build/esm/**/*.js.map",
46
51
  "build/esm/**/*.d.ts",
52
+ "build/esnext/**/*.js",
53
+ "build/esnext/**/*.js.map",
54
+ "build/esnext/**/*.d.ts",
47
55
  "build/src/**/*.js",
48
56
  "build/src/**/*.js.map",
49
57
  "build/src/**/*.d.ts",
@@ -55,17 +63,17 @@
55
63
  "access": "public"
56
64
  },
57
65
  "devDependencies": {
58
- "@babel/core": "7.15.0",
59
- "@opentelemetry/api": "^1.0.3",
66
+ "@babel/core": "7.16.0",
67
+ "@opentelemetry/api": "^1.0.0",
60
68
  "@types/mocha": "8.2.3",
61
- "@types/node": "14.17.11",
62
- "@types/sinon": "10.0.2",
63
- "@types/webpack-env": "1.16.2",
64
- "babel-loader": "8.2.2",
69
+ "@types/node": "14.17.33",
70
+ "@types/sinon": "10.0.6",
71
+ "@types/webpack-env": "1.16.3",
72
+ "babel-loader": "8.2.3",
65
73
  "codecov": "3.8.3",
66
74
  "cpx": "1.5.0",
67
75
  "istanbul-instrumenter-loader": "3.0.1",
68
- "karma": "6.3.7",
76
+ "karma": "6.3.16",
69
77
  "karma-chrome-launcher": "3.1.0",
70
78
  "karma-coverage-istanbul-reporter": "3.0.3",
71
79
  "karma-mocha": "2.0.1",
@@ -77,18 +85,19 @@
77
85
  "sinon": "12.0.1",
78
86
  "ts-loader": "8.3.0",
79
87
  "ts-mocha": "8.0.0",
80
- "typescript": "4.3.5",
88
+ "typescript": "4.4.4",
81
89
  "webpack": "4.46.0",
82
- "webpack-cli": "4.8.0",
90
+ "webpack-cli": "4.9.1",
83
91
  "webpack-merge": "5.8.0"
84
92
  },
85
93
  "peerDependencies": {
86
94
  "@opentelemetry/api": "^1.0.0"
87
95
  },
88
96
  "dependencies": {
89
- "@opentelemetry/core": "1.0.1",
90
- "@opentelemetry/resources": "1.0.1",
91
- "@opentelemetry/sdk-trace-base": "1.0.1"
97
+ "@opentelemetry/core": "1.2.0",
98
+ "@opentelemetry/otlp-exporter-base": "0.28.0",
99
+ "@opentelemetry/resources": "1.2.0",
100
+ "@opentelemetry/sdk-trace-base": "1.2.0"
92
101
  },
93
- "gitHead": "f5e227f0cb829df1ca2dc220a3e0e8ae0e607405"
102
+ "gitHead": "a0a670a03fd35b0799bee8cc466f79e93b5b6dd2"
94
103
  }
@@ -1,36 +0,0 @@
1
- import { SpanAttributes } from '@opentelemetry/api';
2
- import { ExportResult } from '@opentelemetry/core';
3
- import { OTLPExporterError, OTLPExporterConfigBase } from './types';
4
- /**
5
- * Collector Exporter abstract base class
6
- */
7
- export declare abstract class OTLPExporterBase<T extends OTLPExporterConfigBase, ExportItem, ServiceRequest> {
8
- readonly url: string;
9
- readonly hostname: string | undefined;
10
- readonly attributes?: SpanAttributes;
11
- protected _concurrencyLimit: number;
12
- protected _isShutdown: boolean;
13
- private _shuttingDownPromise;
14
- protected _sendingPromises: Promise<unknown>[];
15
- /**
16
- * @param config
17
- */
18
- constructor(config?: T);
19
- /**
20
- * Export items.
21
- * @param items
22
- * @param resultCallback
23
- */
24
- export(items: ExportItem[], resultCallback: (result: ExportResult) => void): void;
25
- private _export;
26
- /**
27
- * Shutdown the exporter.
28
- */
29
- shutdown(): Promise<void>;
30
- abstract onShutdown(): void;
31
- abstract onInit(config: T): void;
32
- abstract send(items: ExportItem[], onSuccess: () => void, onError: (error: OTLPExporterError) => void): void;
33
- abstract getDefaultUrl(config: T): string;
34
- abstract convert(objects: ExportItem[]): ServiceRequest;
35
- }
36
- //# sourceMappingURL=OTLPExporterBase.d.ts.map
@@ -1,114 +0,0 @@
1
- /*
2
- * Copyright The OpenTelemetry Authors
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * https://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import { diag } from '@opentelemetry/api';
17
- import { ExportResultCode } from '@opentelemetry/core';
18
- /**
19
- * Collector Exporter abstract base class
20
- */
21
- var OTLPExporterBase = /** @class */ (function () {
22
- /**
23
- * @param config
24
- */
25
- function OTLPExporterBase(config) {
26
- if (config === void 0) { config = {}; }
27
- this._isShutdown = false;
28
- this._shuttingDownPromise = Promise.resolve();
29
- this._sendingPromises = [];
30
- this.url = this.getDefaultUrl(config);
31
- if (typeof config.hostname === 'string') {
32
- this.hostname = config.hostname;
33
- }
34
- this.attributes = config.attributes;
35
- this.shutdown = this.shutdown.bind(this);
36
- this._concurrencyLimit =
37
- typeof config.concurrencyLimit === 'number'
38
- ? config.concurrencyLimit
39
- : Infinity;
40
- // platform dependent
41
- this.onInit(config);
42
- }
43
- /**
44
- * Export items.
45
- * @param items
46
- * @param resultCallback
47
- */
48
- OTLPExporterBase.prototype.export = function (items, resultCallback) {
49
- if (this._isShutdown) {
50
- resultCallback({
51
- code: ExportResultCode.FAILED,
52
- error: new Error('Exporter has been shutdown'),
53
- });
54
- return;
55
- }
56
- if (this._sendingPromises.length >= this._concurrencyLimit) {
57
- resultCallback({
58
- code: ExportResultCode.FAILED,
59
- error: new Error('Concurrent export limit reached'),
60
- });
61
- return;
62
- }
63
- this._export(items)
64
- .then(function () {
65
- resultCallback({ code: ExportResultCode.SUCCESS });
66
- })
67
- .catch(function (error) {
68
- resultCallback({ code: ExportResultCode.FAILED, error: error });
69
- });
70
- };
71
- OTLPExporterBase.prototype._export = function (items) {
72
- var _this = this;
73
- return new Promise(function (resolve, reject) {
74
- try {
75
- diag.debug('items to be sent', items);
76
- _this.send(items, resolve, reject);
77
- }
78
- catch (e) {
79
- reject(e);
80
- }
81
- });
82
- };
83
- /**
84
- * Shutdown the exporter.
85
- */
86
- OTLPExporterBase.prototype.shutdown = function () {
87
- var _this = this;
88
- if (this._isShutdown) {
89
- diag.debug('shutdown already started');
90
- return this._shuttingDownPromise;
91
- }
92
- this._isShutdown = true;
93
- diag.debug('shutdown started');
94
- this._shuttingDownPromise = new Promise(function (resolve, reject) {
95
- Promise.resolve()
96
- .then(function () {
97
- return _this.onShutdown();
98
- })
99
- .then(function () {
100
- return Promise.all(_this._sendingPromises);
101
- })
102
- .then(function () {
103
- resolve();
104
- })
105
- .catch(function (e) {
106
- reject(e);
107
- });
108
- });
109
- return this._shuttingDownPromise;
110
- };
111
- return OTLPExporterBase;
112
- }());
113
- export { OTLPExporterBase };
114
- //# sourceMappingURL=OTLPExporterBase.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OTLPExporterBase.js","sourceRoot":"","sources":["../../src/OTLPExporterBase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAkB,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAgB,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAOrE;;GAEG;AACH;IAaE;;OAEG;IACH,0BAAY,MAAmB;QAAnB,uBAAA,EAAA,SAAY,EAAO;QAPrB,gBAAW,GAAY,KAAK,CAAC;QAC/B,yBAAoB,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAC;QACtD,qBAAgB,GAAuB,EAAE,CAAC;QAMlD,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QACtC,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE;YACvC,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;SACjC;QAED,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QAEpC,IAAI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AC,CAAC;gBACtC,KAAI,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;aACnC;YAAC,OAAO,CAAC,EAAE;gBACV,MAAM,CAAC,CAAC,CAAC,CAAC;aACX;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,mCAAQ,GAAR;QAAA,iBAuBC;QAtBC,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,IAAI,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;YACvC,OAAO,IAAI,CAAC,oBAAoB,CAAC;SAClC;QACD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAC/B,IAAI,CAAC,oBAAoB,GAAG,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;YACtD,OAAO,CAAC,OAAO,EAAE;iBACd,IAAI,CAAC;gBACJ,OAAO,KAAI,CAAC,UAAU,EAAE,CAAC;YAC3B,CAAC,CAAC;iBACD,IAAI,CAAC;gBACJ,OAAO,OAAO,CAAC,GAAG,CAAC,KAAI,CAAC,gBAAgB,CAAC,CAAC;YAC5C,CAAC,CAAC;iBACD,IAAI,CAAC;gBACJ,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC;iBACD,KAAK,CAAC,UAAA,CAAC;gBACN,MAAM,CAAC,CAAC,CAAC,CAAC;YACZ,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACnC,CAAC;IAWH,uBAAC;AAAD,CAAC,AAlHD,IAkHC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { SpanAttributes, diag } from '@opentelemetry/api';\nimport { ExportResult, ExportResultCode } from '@opentelemetry/core';\nimport {\n OTLPExporterError,\n OTLPExporterConfigBase,\n ExportServiceError,\n} from './types';\n\n/**\n * Collector Exporter abstract base class\n */\nexport abstract class OTLPExporterBase<\n T extends OTLPExporterConfigBase,\n ExportItem,\n ServiceRequest\n> {\n public readonly url: string;\n public readonly hostname: string | undefined;\n public readonly attributes?: SpanAttributes;\n protected _concurrencyLimit: number;\n protected _isShutdown: boolean = false;\n private _shuttingDownPromise: Promise<void> = Promise.resolve();\n protected _sendingPromises: Promise<unknown>[] = [];\n\n /**\n * @param config\n */\n constructor(config: T = {} as T) {\n this.url = this.getDefaultUrl(config);\n if (typeof config.hostname === 'string') {\n this.hostname = config.hostname;\n }\n\n this.attributes = config.attributes;\n\n this.shutdown = this.shutdown.bind(this);\n\n this._concurrencyLimit =\n typeof config.concurrencyLimit === 'number'\n ? config.concurrencyLimit\n : Infinity;\n\n // platform dependent\n this.onInit(config);\n }\n\n /**\n * Export items.\n * @param items\n * @param resultCallback\n */\n export(items: ExportItem[], resultCallback: (result: ExportResult) => void): void {\n if (this._isShutdown) {\n resultCallback({\n code: ExportResultCode.FAILED,\n error: new Error('Exporter has been shutdown'),\n });\n return;\n }\n\n if (this._sendingPromises.length >= this._concurrencyLimit) {\n resultCallback({\n code: ExportResultCode.FAILED,\n error: new Error('Concurrent export limit reached'),\n });\n return;\n }\n\n this._export(items)\n .then(() => {\n resultCallback({ code: ExportResultCode.SUCCESS });\n })\n .catch((error: ExportServiceError) => {\n resultCallback({ code: ExportResultCode.FAILED, error });\n });\n }\n\n private _export(items: ExportItem[]): Promise<unknown> {\n return new Promise<void>((resolve, reject) => {\n try {\n diag.debug('items to be sent', items);\n this.send(items, resolve, reject);\n } catch (e) {\n reject(e);\n }\n });\n }\n\n /**\n * Shutdown the exporter.\n */\n shutdown(): Promise<void> {\n if (this._isShutdown) {\n diag.debug('shutdown already started');\n return this._shuttingDownPromise;\n }\n this._isShutdown = true;\n diag.debug('shutdown started');\n this._shuttingDownPromise = new Promise((resolve, reject) => {\n Promise.resolve()\n .then(() => {\n return this.onShutdown();\n })\n .then(() => {\n return Promise.all(this._sendingPromises);\n })\n .then(() => {\n resolve();\n })\n .catch(e => {\n reject(e);\n });\n });\n return this._shuttingDownPromise;\n }\n\n abstract onShutdown(): void;\n abstract onInit(config: T): void;\n abstract send(\n items: ExportItem[],\n onSuccess: () => void,\n onError: (error: OTLPExporterError) => void\n ): void;\n abstract getDefaultUrl(config: T): string;\n abstract convert(objects: ExportItem[]): ServiceRequest;\n}\n"]}
@@ -1,18 +0,0 @@
1
- import { OTLPExporterBase } from '../../OTLPExporterBase';
2
- import { OTLPExporterConfigBase } from '../../types';
3
- import * as otlpTypes from '../../types';
4
- /**
5
- * Collector Metric Exporter abstract base class
6
- */
7
- export declare abstract class OTLPExporterBrowserBase<ExportItem, ServiceRequest> extends OTLPExporterBase<OTLPExporterConfigBase, ExportItem, ServiceRequest> {
8
- protected _headers: Record<string, string>;
9
- private _useXHR;
10
- /**
11
- * @param config
12
- */
13
- constructor(config?: OTLPExporterConfigBase);
14
- onInit(): void;
15
- onShutdown(): void;
16
- send(items: ExportItem[], onSuccess: () => void, onError: (error: otlpTypes.OTLPExporterError) => void): void;
17
- }
18
- //# sourceMappingURL=OTLPExporterBrowserBase.d.ts.map