@azure/monitor-opentelemetry-exporter 1.0.0-beta.32 → 1.0.0-beta.34

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 (193) hide show
  1. package/LICENSE +21 -0
  2. package/dist/commonjs/Declarations/Constants.d.ts +10 -0
  3. package/dist/commonjs/Declarations/Constants.d.ts.map +1 -1
  4. package/dist/commonjs/Declarations/Constants.js +11 -1
  5. package/dist/commonjs/Declarations/Constants.js.map +1 -1
  6. package/dist/commonjs/export/base.js +25 -14
  7. package/dist/commonjs/export/base.js.map +1 -1
  8. package/dist/commonjs/export/log.js +5 -4
  9. package/dist/commonjs/export/log.js.map +1 -1
  10. package/dist/commonjs/export/metric.js +5 -4
  11. package/dist/commonjs/export/metric.js.map +1 -1
  12. package/dist/commonjs/export/statsbeat/customerSDKStats.d.ts +133 -0
  13. package/dist/commonjs/export/statsbeat/customerSDKStats.d.ts.map +1 -0
  14. package/dist/commonjs/export/statsbeat/customerSDKStats.js +528 -0
  15. package/dist/commonjs/export/statsbeat/customerSDKStats.js.map +1 -0
  16. package/dist/commonjs/export/statsbeat/longIntervalStatsbeatMetrics.js +35 -11
  17. package/dist/commonjs/export/statsbeat/longIntervalStatsbeatMetrics.js.map +1 -1
  18. package/dist/commonjs/export/statsbeat/networkStatsbeatMetrics.js +52 -21
  19. package/dist/commonjs/export/statsbeat/networkStatsbeatMetrics.js.map +1 -1
  20. package/dist/commonjs/export/statsbeat/statsbeatExporter.d.ts +7 -0
  21. package/dist/commonjs/export/statsbeat/statsbeatExporter.d.ts.map +1 -1
  22. package/dist/commonjs/export/statsbeat/statsbeatExporter.js +25 -5
  23. package/dist/commonjs/export/statsbeat/statsbeatExporter.js.map +1 -1
  24. package/dist/commonjs/export/statsbeat/statsbeatMetrics.js +6 -8
  25. package/dist/commonjs/export/statsbeat/statsbeatMetrics.js.map +1 -1
  26. package/dist/commonjs/export/statsbeat/types.d.ts +77 -0
  27. package/dist/commonjs/export/statsbeat/types.d.ts.map +1 -1
  28. package/dist/commonjs/export/statsbeat/types.js +105 -1
  29. package/dist/commonjs/export/statsbeat/types.js.map +1 -1
  30. package/dist/commonjs/export/trace.js +6 -5
  31. package/dist/commonjs/export/trace.js.map +1 -1
  32. package/dist/commonjs/generated/applicationInsightsClient.js +9 -4
  33. package/dist/commonjs/generated/applicationInsightsClient.js.map +1 -1
  34. package/dist/commonjs/generated/models/mappers.js +145 -68
  35. package/dist/commonjs/generated/models/mappers.js.map +1 -1
  36. package/dist/commonjs/index.d.ts +2 -1
  37. package/dist/commonjs/index.d.ts.map +1 -1
  38. package/dist/commonjs/index.js +5 -3
  39. package/dist/commonjs/index.js.map +1 -1
  40. package/dist/commonjs/platform/nodejs/baseSender.d.ts +1 -0
  41. package/dist/commonjs/platform/nodejs/baseSender.d.ts.map +1 -1
  42. package/dist/commonjs/platform/nodejs/baseSender.js +92 -31
  43. package/dist/commonjs/platform/nodejs/baseSender.js.map +1 -1
  44. package/dist/commonjs/platform/nodejs/context/context.d.ts +0 -1
  45. package/dist/commonjs/platform/nodejs/context/context.d.ts.map +1 -1
  46. package/dist/commonjs/platform/nodejs/context/context.js +4 -8
  47. package/dist/commonjs/platform/nodejs/context/context.js.map +1 -1
  48. package/dist/commonjs/platform/nodejs/httpSender.js +11 -4
  49. package/dist/commonjs/platform/nodejs/httpSender.js.map +1 -1
  50. package/dist/commonjs/platform/nodejs/index.d.ts +1 -0
  51. package/dist/commonjs/platform/nodejs/index.d.ts.map +1 -1
  52. package/dist/commonjs/platform/nodejs/index.js +1 -0
  53. package/dist/commonjs/platform/nodejs/index.js.map +1 -1
  54. package/dist/commonjs/platform/nodejs/persist/fileAccessControl.js +7 -7
  55. package/dist/commonjs/platform/nodejs/persist/fileAccessControl.js.map +1 -1
  56. package/dist/commonjs/platform/nodejs/persist/fileSystemPersist.d.ts +9 -1
  57. package/dist/commonjs/platform/nodejs/persist/fileSystemPersist.d.ts.map +1 -1
  58. package/dist/commonjs/platform/nodejs/persist/fileSystemPersist.js +37 -16
  59. package/dist/commonjs/platform/nodejs/persist/fileSystemPersist.js.map +1 -1
  60. package/dist/commonjs/{sampling.d.ts → sampling/percentageSampler.d.ts} +2 -3
  61. package/dist/commonjs/sampling/percentageSampler.d.ts.map +1 -0
  62. package/dist/commonjs/{sampling.js → sampling/percentageSampler.js} +6 -39
  63. package/dist/commonjs/sampling/percentageSampler.js.map +1 -0
  64. package/dist/commonjs/sampling/rateLimitedSampler.d.ts +58 -0
  65. package/dist/commonjs/sampling/rateLimitedSampler.d.ts.map +1 -0
  66. package/dist/commonjs/sampling/rateLimitedSampler.js +118 -0
  67. package/dist/commonjs/sampling/rateLimitedSampler.js.map +1 -0
  68. package/dist/commonjs/sampling/samplingUtils.d.ts +17 -0
  69. package/dist/commonjs/sampling/samplingUtils.d.ts.map +1 -0
  70. package/dist/commonjs/sampling/samplingUtils.js +94 -0
  71. package/dist/commonjs/sampling/samplingUtils.js.map +1 -0
  72. package/dist/commonjs/tsdoc-metadata.json +11 -11
  73. package/dist/commonjs/types.d.ts +3 -1
  74. package/dist/commonjs/types.d.ts.map +1 -1
  75. package/dist/commonjs/types.js +4 -0
  76. package/dist/commonjs/types.js.map +1 -1
  77. package/dist/commonjs/utils/common.js +2 -3
  78. package/dist/commonjs/utils/common.js.map +1 -1
  79. package/dist/commonjs/utils/connectionStringParser.js +3 -3
  80. package/dist/commonjs/utils/connectionStringParser.js.map +1 -1
  81. package/dist/commonjs/utils/constants/applicationinsights.d.ts +2 -1
  82. package/dist/commonjs/utils/constants/applicationinsights.d.ts.map +1 -1
  83. package/dist/commonjs/utils/constants/applicationinsights.js +3 -2
  84. package/dist/commonjs/utils/constants/applicationinsights.js.map +1 -1
  85. package/dist/commonjs/utils/eventhub.js +5 -2
  86. package/dist/commonjs/utils/eventhub.js.map +1 -1
  87. package/dist/commonjs/utils/logUtils.d.ts.map +1 -1
  88. package/dist/commonjs/utils/logUtils.js +34 -15
  89. package/dist/commonjs/utils/logUtils.js.map +1 -1
  90. package/dist/commonjs/utils/metricUtils.d.ts.map +1 -1
  91. package/dist/commonjs/utils/metricUtils.js +6 -6
  92. package/dist/commonjs/utils/metricUtils.js.map +1 -1
  93. package/dist/commonjs/utils/spanUtils.d.ts.map +1 -1
  94. package/dist/commonjs/utils/spanUtils.js +29 -14
  95. package/dist/commonjs/utils/spanUtils.js.map +1 -1
  96. package/dist/esm/Declarations/Constants.d.ts +10 -0
  97. package/dist/esm/Declarations/Constants.d.ts.map +1 -1
  98. package/dist/esm/Declarations/Constants.js +10 -0
  99. package/dist/esm/Declarations/Constants.js.map +1 -1
  100. package/dist/esm/export/base.js +25 -14
  101. package/dist/esm/export/base.js.map +1 -1
  102. package/dist/esm/export/log.js +5 -4
  103. package/dist/esm/export/log.js.map +1 -1
  104. package/dist/esm/export/metric.js +5 -4
  105. package/dist/esm/export/metric.js.map +1 -1
  106. package/dist/esm/export/statsbeat/customerSDKStats.d.ts +133 -0
  107. package/dist/esm/export/statsbeat/customerSDKStats.d.ts.map +1 -0
  108. package/dist/esm/export/statsbeat/customerSDKStats.js +523 -0
  109. package/dist/esm/export/statsbeat/customerSDKStats.js.map +1 -0
  110. package/dist/esm/export/statsbeat/longIntervalStatsbeatMetrics.js +35 -11
  111. package/dist/esm/export/statsbeat/longIntervalStatsbeatMetrics.js.map +1 -1
  112. package/dist/esm/export/statsbeat/networkStatsbeatMetrics.js +52 -21
  113. package/dist/esm/export/statsbeat/networkStatsbeatMetrics.js.map +1 -1
  114. package/dist/esm/export/statsbeat/statsbeatExporter.d.ts +7 -0
  115. package/dist/esm/export/statsbeat/statsbeatExporter.d.ts.map +1 -1
  116. package/dist/esm/export/statsbeat/statsbeatExporter.js +25 -5
  117. package/dist/esm/export/statsbeat/statsbeatExporter.js.map +1 -1
  118. package/dist/esm/export/statsbeat/statsbeatMetrics.js +6 -8
  119. package/dist/esm/export/statsbeat/statsbeatMetrics.js.map +1 -1
  120. package/dist/esm/export/statsbeat/types.d.ts +77 -0
  121. package/dist/esm/export/statsbeat/types.d.ts.map +1 -1
  122. package/dist/esm/export/statsbeat/types.js +103 -0
  123. package/dist/esm/export/statsbeat/types.js.map +1 -1
  124. package/dist/esm/export/trace.js +6 -5
  125. package/dist/esm/export/trace.js.map +1 -1
  126. package/dist/esm/generated/applicationInsightsClient.js +9 -4
  127. package/dist/esm/generated/applicationInsightsClient.js.map +1 -1
  128. package/dist/esm/generated/models/mappers.js +145 -68
  129. package/dist/esm/generated/models/mappers.js.map +1 -1
  130. package/dist/esm/index.d.ts +2 -1
  131. package/dist/esm/index.d.ts.map +1 -1
  132. package/dist/esm/index.js +2 -1
  133. package/dist/esm/index.js.map +1 -1
  134. package/dist/esm/platform/nodejs/baseSender.d.ts +1 -0
  135. package/dist/esm/platform/nodejs/baseSender.d.ts.map +1 -1
  136. package/dist/esm/platform/nodejs/baseSender.js +91 -30
  137. package/dist/esm/platform/nodejs/baseSender.js.map +1 -1
  138. package/dist/esm/platform/nodejs/context/context.d.ts +0 -1
  139. package/dist/esm/platform/nodejs/context/context.d.ts.map +1 -1
  140. package/dist/esm/platform/nodejs/context/context.js +4 -8
  141. package/dist/esm/platform/nodejs/context/context.js.map +1 -1
  142. package/dist/esm/platform/nodejs/httpSender.js +11 -4
  143. package/dist/esm/platform/nodejs/httpSender.js.map +1 -1
  144. package/dist/esm/platform/nodejs/index.d.ts +1 -0
  145. package/dist/esm/platform/nodejs/index.d.ts.map +1 -1
  146. package/dist/esm/platform/nodejs/index.js +1 -0
  147. package/dist/esm/platform/nodejs/index.js.map +1 -1
  148. package/dist/esm/platform/nodejs/persist/fileAccessControl.js +7 -7
  149. package/dist/esm/platform/nodejs/persist/fileAccessControl.js.map +1 -1
  150. package/dist/esm/platform/nodejs/persist/fileSystemPersist.d.ts +9 -1
  151. package/dist/esm/platform/nodejs/persist/fileSystemPersist.d.ts.map +1 -1
  152. package/dist/esm/platform/nodejs/persist/fileSystemPersist.js +37 -16
  153. package/dist/esm/platform/nodejs/persist/fileSystemPersist.js.map +1 -1
  154. package/dist/esm/{sampling.d.ts → sampling/percentageSampler.d.ts} +2 -3
  155. package/dist/esm/sampling/percentageSampler.d.ts.map +1 -0
  156. package/dist/esm/{sampling.js → sampling/percentageSampler.js} +6 -39
  157. package/dist/esm/sampling/percentageSampler.js.map +1 -0
  158. package/dist/esm/sampling/rateLimitedSampler.d.ts +58 -0
  159. package/dist/esm/sampling/rateLimitedSampler.d.ts.map +1 -0
  160. package/dist/esm/sampling/rateLimitedSampler.js +114 -0
  161. package/dist/esm/sampling/rateLimitedSampler.js.map +1 -0
  162. package/dist/esm/sampling/samplingUtils.d.ts +17 -0
  163. package/dist/esm/sampling/samplingUtils.d.ts.map +1 -0
  164. package/dist/esm/sampling/samplingUtils.js +89 -0
  165. package/dist/esm/sampling/samplingUtils.js.map +1 -0
  166. package/dist/esm/types.d.ts +3 -1
  167. package/dist/esm/types.d.ts.map +1 -1
  168. package/dist/esm/types.js +4 -0
  169. package/dist/esm/types.js.map +1 -1
  170. package/dist/esm/utils/common.js +2 -3
  171. package/dist/esm/utils/common.js.map +1 -1
  172. package/dist/esm/utils/connectionStringParser.js +3 -3
  173. package/dist/esm/utils/connectionStringParser.js.map +1 -1
  174. package/dist/esm/utils/constants/applicationinsights.d.ts +2 -1
  175. package/dist/esm/utils/constants/applicationinsights.d.ts.map +1 -1
  176. package/dist/esm/utils/constants/applicationinsights.js +2 -1
  177. package/dist/esm/utils/constants/applicationinsights.js.map +1 -1
  178. package/dist/esm/utils/eventhub.js +5 -2
  179. package/dist/esm/utils/eventhub.js.map +1 -1
  180. package/dist/esm/utils/logUtils.d.ts.map +1 -1
  181. package/dist/esm/utils/logUtils.js +31 -12
  182. package/dist/esm/utils/logUtils.js.map +1 -1
  183. package/dist/esm/utils/metricUtils.d.ts.map +1 -1
  184. package/dist/esm/utils/metricUtils.js +6 -6
  185. package/dist/esm/utils/metricUtils.js.map +1 -1
  186. package/dist/esm/utils/spanUtils.d.ts.map +1 -1
  187. package/dist/esm/utils/spanUtils.js +32 -17
  188. package/dist/esm/utils/spanUtils.js.map +1 -1
  189. package/package.json +34 -35
  190. package/dist/commonjs/sampling.d.ts.map +0 -1
  191. package/dist/commonjs/sampling.js.map +0 -1
  192. package/dist/esm/sampling.d.ts.map +0 -1
  193. package/dist/esm/sampling.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"spanUtils.js","sourceRoot":"","sources":["../../../src/utils/spanUtils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,yBAAyB,EACzB,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,0BAA0B,EAC1B,0BAA0B,EAC1B,6BAA6B,EAC7B,uBAAuB,EACvB,uBAAuB,EACvB,oBAAoB,EACpB,yBAAyB,EACzB,iBAAiB,EACjB,wBAAwB,EACxB,oBAAoB,EACpB,6BAA6B,EAC7B,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,EACnB,yBAAyB,EACzB,wBAAwB,EACxB,eAAe,EACf,aAAa,EACb,8BAA8B,EAC9B,oBAAoB,EACpB,eAAe,EACf,oBAAoB,EACpB,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACtB,gBAAgB,EAChB,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,MAAM,EACN,YAAY,EACZ,OAAO,EACP,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,kBAAkB,EAClB,2BAA2B,EAC3B,oBAAoB,EACpB,kBA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AU,CAAC,mBAAmB,CAAC,IAAI,UAAU,CAAC,kBAAkB,CAAC,CAAC;IAC3E,CAAC;IACD,OAAO;AACT,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,UAAsB;IACnD,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,UAAU,CAAC,mBAAmB,CAAC,IAAI,UAAU,CAAC,sBAAsB,CAAC,CAAC;IAC/E,CAAC;IACD,OAAO;AACT,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,UAAsB;IACnD,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,CACL,UAAU,CAAC,gBAAgB,CAAC;YAC5B,UAAU,CAAC,gBAAgB,CAAC;YAC5B,UAAU,CAAC,sBAAsB,CAAC,CACnC,CAAC;IACJ,CAAC;IACD,OAAO;AACT,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ReadableSpan, TimedEvent } from \"@opentelemetry/sdk-trace-base\";\nimport { hrTimeToMilliseconds } from \"@opentelemetry/core\";\nimport type { Link, Attributes, AttributeValue } from \"@opentelemetry/api\";\nimport { diag, SpanKind, SpanStatusCode } from \"@opentelemetry/api\";\nimport {\n DBSYSTEMVALUES_MONGODB,\n DBSYSTEMVALUES_MYSQL,\n DBSYSTEMVALUES_POSTGRESQL,\n DBSYSTEMVALUES_REDIS,\n SEMATTRS_DB_NAME,\n SEMATTRS_DB_OPERATION,\n SEMATTRS_DB_STATEMENT,\n SEMATTRS_DB_SYSTEM,\n SEMATTRS_ENDUSER_ID,\n SEMATTRS_EXCEPTION_ESCAPED,\n SEMATTRS_EXCEPTION_MESSAGE,\n SEMATTRS_EXCEPTION_STACKTRACE,\n SEMATTRS_EXCEPTION_TYPE,\n SEMATTRS_HTTP_CLIENT_IP,\n SEMATTRS_HTTP_METHOD,\n SEMATTRS_HTTP_STATUS_CODE,\n SEMATTRS_HTTP_URL,\n SEMATTRS_HTTP_USER_AGENT,\n SEMATTRS_NET_PEER_IP,\n SEMATTRS_RPC_GRPC_STATUS_CODE,\n SEMATTRS_RPC_SYSTEM,\n ATTR_HTTP_REQUEST_METHOD,\n ATTR_CLIENT_ADDRESS,\n ATTR_NETWORK_PEER_ADDRESS,\n ATTR_USER_AGENT_ORIGINAL,\n ATTR_HTTP_ROUTE,\n ATTR_URL_FULL,\n ATTR_HTTP_RESPONSE_STATUS_CODE,\n SEMATTRS_HTTP_SCHEME,\n ATTR_URL_SCHEME,\n SEMATTRS_HTTP_TARGET,\n ATTR_URL_PATH,\n ATTR_URL_QUERY,\n ATTR_SERVER_ADDRESS,\n SEMATTRS_HTTP_HOST,\n SEMATTRS_NET_PEER_NAME,\n ATTR_CLIENT_PORT,\n ATTR_SERVER_PORT,\n SEMATTRS_NET_PEER_PORT,\n} from \"@opentelemetry/semantic-conventions\";\n\nimport {\n createTagsFromResource,\n getDependencyTarget,\n getUrl,\n hrTimeToDate,\n isSqlDB,\n isSyntheticSource,\n serializeAttribute,\n} from \"./common.js\";\nimport type { Tags, Properties, MSLink, Measurements } from \"../types.js\";\nimport {\n httpSemanticValues,\n internalMicrosoftAttributes,\n legacySemanticValues,\n MaxPropertyLengths,\n} from \"../types.js\";\nimport { parseEventHubSpan } from \"./eventhub.js\";\nimport {\n AzureMonitorSampleRate,\n DependencyTypes,\n MS_LINKS,\n} from \"./constants/applicationinsights.js\";\nimport { AzNamespace, MicrosoftEventHub } from \"./constants/span/azAttributes.js\";\nimport type {\n TelemetryExceptionData,\n MessageData,\n RemoteDependencyData,\n RequestData,\n TelemetryItem as Envelope,\n TelemetryExceptionDetails,\n} from \"../generated/index.js\";\nimport { KnownContextTagKeys } from \"../generated/index.js\";\nimport { msToTimeSpan } from \"./breezeUtils.js\";\n\nfunction createTagsFromSpan(span: ReadableSpan): Tags {\n const tags: Tags = createTagsFromResource(span.resource);\n tags[KnownContextTagKeys.AiOperationId] = span.spanContext().traceId;\n if (span.parentSpanContext?.spanId) {\n tags[KnownContextTagKeys.AiOperationParentId] = span.parentSpanContext.spanId;\n }\n const endUserId = span.attributes[SEMATTRS_ENDUSER_ID];\n if (endUserId) {\n tags[KnownContextTagKeys.AiUserId] = String(endUserId);\n }\n const httpUserAgent = getUserAgent(span.attributes);\n if (httpUserAgent) {\n // TODO: Not exposed in Swagger, need to update def\n tags[\"ai.user.userAgent\"] = String(httpUserAgent);\n }\n if (isSyntheticSource(span.attributes)) {\n tags[KnownContextTagKeys.AiOperationSyntheticSource] = \"True\";\n }\n if (span.kind === SpanKind.SERVER) {\n const httpMethod = getHttpMethod(span.attributes);\n getLocationIp(tags, span.attributes);\n if (httpMethod) {\n const httpRoute = span.attributes[ATTR_HTTP_ROUTE];\n const httpUrl = getHttpUrl(span.attributes);\n tags[KnownContextTagKeys.AiOperationName] = span.name; // Default\n if (httpRoute) {\n // AiOperationName max length is 1024\n // https://github.com/MohanGsk/ApplicationInsights-Home/blob/master/EndpointSpecs/Schemas/Bond/ContextTagKeys.bond\n tags[KnownContextTagKeys.AiOperationName] = String(\n `${httpMethod as string} ${httpRoute as string}`,\n ).substring(0, MaxPropertyLengths.TEN_BIT);\n } else if (httpUrl) {\n try {\n const url = new URL(String(httpUrl));\n tags[KnownContextTagKeys.AiOperationName] = String(\n `${httpMethod} ${url.pathname}`,\n ).substring(0, MaxPropertyLengths.TEN_BIT);\n } catch {\n /* no-op */\n }\n }\n } else {\n tags[KnownContextTagKeys.AiOperationName] = span.name;\n }\n } else {\n if (span.attributes[KnownContextTagKeys.AiOperationName]) {\n tags[KnownContextTagKeys.AiOperationName] = span.attributes[\n KnownContextTagKeys.AiOperationName\n ] as string;\n }\n }\n // TODO: Location IP TBD for non server spans\n\n return tags;\n}\n\nfunction createPropertiesFromSpanAttributes(attributes?: Attributes): {\n [propertyName: string]: string;\n} {\n const properties: { [propertyName: string]: string } = {};\n if (attributes) {\n for (const key of Object.keys(attributes)) {\n // Avoid duplication ignoring fields already mapped.\n if (\n // We need to not ignore the _MS.ProcessedByMetricExtractors key as it's used to identify standard metrics\n !(\n (key.startsWith(\"_MS.\") && !internalMicrosoftAttributes.includes(key as any)) ||\n key.startsWith(\"microsoft.\") ||\n legacySemanticValues.includes(key) ||\n httpSemanticValues.includes(key as any) ||\n key === (KnownContextTagKeys.AiOperationName as string)\n )\n ) {\n properties[key] = serializeAttribute(attributes[key]);\n }\n }\n }\n return properties;\n}\n\nfunction createPropertiesFromSpan(span: ReadableSpan): [Properties, Measurements] {\n const properties: Properties = createPropertiesFromSpanAttributes(span.attributes);\n const measurements: Measurements = {};\n\n const links: MSLink[] = span.links.map((link: Link) => ({\n operation_Id: link.context.traceId,\n id: link.context.spanId,\n }));\n if (links.length > 0) {\n properties[MS_LINKS] = JSON.stringify(links);\n }\n return [properties, measurements];\n}\n\nfunction createDependencyData(span: ReadableSpan): RemoteDependencyData {\n const remoteDependencyData: RemoteDependencyData = {\n name: span.name, // Default\n id: `${span.spanContext().spanId}`,\n success: span.status?.code !== SpanStatusCode.ERROR,\n resultCode: \"0\",\n type: \"Dependency\",\n duration: msToTimeSpan(hrTimeToMilliseconds(span.duration)),\n version: 2,\n };\n if (span.kind === SpanKind.PRODUCER) {\n remoteDependencyData.type = DependencyTypes.QueueMessage;\n }\n if (span.kind === SpanKind.INTERNAL && span.parentSpanContext) {\n remoteDependencyData.type = DependencyTypes.InProc;\n }\n\n const httpMethod = getHttpMethod(span.attributes);\n const dbSystem = span.attributes[SEMATTRS_DB_SYSTEM];\n const rpcSystem = span.attributes[SEMATTRS_RPC_SYSTEM];\n // HTTP Dependency\n if (httpMethod) {\n const httpUrl = getHttpUrl(span.attributes);\n if (httpUrl) {\n try {\n const dependencyUrl = new URL(String(httpUrl));\n remoteDependencyData.name = `${httpMethod} ${dependencyUrl.pathname}`;\n } catch {\n /* no-op */\n }\n }\n remoteDependencyData.type = DependencyTypes.Http;\n remoteDependencyData.data = getUrl(span.attributes);\n const httpStatusCode = getHttpStatusCode(span.attributes);\n if (httpStatusCode) {\n remoteDependencyData.resultCode = String(httpStatusCode);\n }\n let target = getDependencyTarget(span.attributes);\n if (target) {\n try {\n // Remove default port\n const portRegex = new RegExp(/(https?)(:\\/\\/.*)(:\\d+)(\\S*)/);\n const res = portRegex.exec(target);\n if (res !== null) {\n const protocol = res[1];\n const port = res[3];\n if (\n (protocol === \"https\" && port === \":443\") ||\n (protocol === \"http\" && port === \":80\")\n ) {\n // Drop port\n target = res[1] + res[2] + res[4];\n }\n }\n } catch {\n /* no-op */\n }\n remoteDependencyData.target = `${target}`;\n }\n }\n // DB Dependency\n else if (dbSystem) {\n // TODO: Remove special logic when Azure UX supports OpenTelemetry dbSystem\n if (String(dbSystem) === DBSYSTEMVALUES_MYSQL) {\n remoteDependencyData.type = \"mysql\";\n } else if (String(dbSystem) === DBSYSTEMVALUES_POSTGRESQL) {\n remoteDependencyData.type = \"postgresql\";\n } else if (String(dbSystem) === DBSYSTEMVALUES_MONGODB) {\n remoteDependencyData.type = \"mongodb\";\n } else if (String(dbSystem) === DBSYSTEMVALUES_REDIS) {\n remoteDependencyData.type = \"redis\";\n } else if (isSqlDB(String(dbSystem))) {\n remoteDependencyData.type = \"SQL\";\n } else {\n remoteDependencyData.type = String(dbSystem);\n }\n const dbStatement = span.attributes[SEMATTRS_DB_STATEMENT];\n const dbOperation = span.attributes[SEMATTRS_DB_OPERATION];\n if (dbStatement) {\n remoteDependencyData.data = String(dbStatement);\n } else if (dbOperation) {\n remoteDependencyData.data = String(dbOperation);\n }\n const target = getDependencyTarget(span.attributes);\n const dbName = span.attributes[SEMATTRS_DB_NAME];\n if (target) {\n remoteDependencyData.target = dbName ? `${target}|${dbName}` : `${target}`;\n } else {\n remoteDependencyData.target = dbName ? `${dbName}` : `${dbSystem}`;\n }\n }\n // grpc Dependency\n else if (rpcSystem) {\n if (rpcSystem === DependencyTypes.Wcf) {\n remoteDependencyData.type = DependencyTypes.Wcf;\n } else {\n remoteDependencyData.type = DependencyTypes.Grpc;\n }\n const grpcStatusCode = span.attributes[SEMATTRS_RPC_GRPC_STATUS_CODE];\n if (grpcStatusCode) {\n remoteDependencyData.resultCode = String(grpcStatusCode);\n }\n const target = getDependencyTarget(span.attributes);\n if (target) {\n remoteDependencyData.target = `${target}`;\n } else if (rpcSystem) {\n remoteDependencyData.target = String(rpcSystem);\n }\n }\n return remoteDependencyData;\n}\n\nfunction createRequestData(span: ReadableSpan): RequestData {\n const requestData: RequestData = {\n id: `${span.spanContext().spanId}`,\n success:\n span.status.code !== SpanStatusCode.ERROR &&\n (Number(getHttpStatusCode(span.attributes)) || 0) < 400,\n responseCode: \"0\",\n duration: msToTimeSpan(hrTimeToMilliseconds(span.duration)),\n version: 2,\n source: undefined,\n };\n const httpMethod = getHttpMethod(span.attributes);\n const grpcStatusCode = span.attributes[SEMATTRS_RPC_GRPC_STATUS_CODE];\n if (httpMethod) {\n requestData.url = getUrl(span.attributes);\n const httpStatusCode = getHttpStatusCode(span.attributes);\n if (httpStatusCode) {\n requestData.responseCode = String(httpStatusCode);\n }\n } else if (grpcStatusCode) {\n requestData.responseCode = String(grpcStatusCode);\n }\n return requestData;\n}\n\n/**\n * Span to Azure envelope parsing.\n * @internal\n */\nexport function readableSpanToEnvelope(span: ReadableSpan, ikey: string): Envelope {\n let name: string;\n let baseType: \"RemoteDependencyData\" | \"RequestData\";\n let baseData: RemoteDependencyData | RequestData;\n\n const time = hrTimeToDate(span.startTime);\n const instrumentationKey = ikey;\n const tags = createTagsFromSpan(span);\n const [properties, measurements] = createPropertiesFromSpan(span);\n switch (span.kind) {\n case SpanKind.CLIENT:\n case SpanKind.PRODUCER:\n case SpanKind.INTERNAL:\n name = \"Microsoft.ApplicationInsights.RemoteDependency\";\n baseType = \"RemoteDependencyData\";\n baseData = createDependencyData(span);\n break;\n case SpanKind.SERVER:\n case SpanKind.CONSUMER:\n name = \"Microsoft.ApplicationInsights.Request\";\n baseType = \"RequestData\";\n baseData = createRequestData(span);\n baseData.name = tags[KnownContextTagKeys.AiOperationName];\n break;\n default:\n // never\n diag.error(`Unsupported span kind ${span.kind}`);\n throw new Error(`Unsupported span kind ${span.kind}`);\n }\n\n let sampleRate = 100;\n if (span.attributes[AzureMonitorSampleRate]) {\n sampleRate = Number(span.attributes[AzureMonitorSampleRate]);\n }\n\n // Azure SDK\n if (span.attributes[AzNamespace]) {\n if (span.kind === SpanKind.INTERNAL) {\n baseData.type = `${DependencyTypes.InProc} | ${span.attributes[AzNamespace]}`;\n }\n if (span.attributes[AzNamespace] === MicrosoftEventHub) {\n parseEventHubSpan(span, baseData);\n }\n }\n\n // Truncate properties\n if (baseData.id) {\n baseData.id = baseData.id.substring(0, MaxPropertyLengths.NINE_BIT);\n }\n if (baseData.name) {\n baseData.name = baseData.name.substring(0, MaxPropertyLengths.TEN_BIT);\n }\n if (baseData.resultCode) {\n baseData.resultCode = String(baseData.resultCode).substring(0, MaxPropertyLengths.TEN_BIT);\n }\n if (baseData.data) {\n baseData.data = String(baseData.data).substring(0, MaxPropertyLengths.THIRTEEN_BIT);\n }\n if (baseData.type) {\n baseData.type = String(baseData.type).substring(0, MaxPropertyLengths.TEN_BIT);\n }\n if (baseData.target) {\n baseData.target = String(baseData.target).substring(0, MaxPropertyLengths.TEN_BIT);\n }\n if (baseData.properties) {\n for (const key of Object.keys(baseData.properties)) {\n baseData.properties[key] = baseData.properties[key].substring(\n 0,\n MaxPropertyLengths.THIRTEEN_BIT,\n );\n }\n }\n\n return {\n name,\n sampleRate,\n time,\n instrumentationKey,\n tags,\n version: 1,\n data: {\n baseType,\n baseData: {\n ...baseData,\n properties,\n measurements,\n },\n },\n };\n}\n\n/**\n * Span Events to Azure envelopes parsing.\n * @internal\n */\nexport function spanEventsToEnvelopes(span: ReadableSpan, ikey: string): Envelope[] {\n const envelopes: Envelope[] = [];\n if (span.events) {\n span.events.forEach((event: TimedEvent) => {\n let baseType: \"ExceptionData\" | \"MessageData\";\n const time = hrTimeToDate(event.time);\n let name = \"\";\n let baseData: TelemetryExceptionData | MessageData;\n const properties = createPropertiesFromSpanAttributes(event.attributes);\n\n const tags: Tags = createTagsFromResource(span.resource);\n tags[KnownContextTagKeys.AiOperationId] = span.spanContext().traceId;\n const spanId = span.spanContext().spanId;\n if (spanId) {\n tags[KnownContextTagKeys.AiOperationParentId] = spanId;\n }\n\n // Only generate exception telemetry for incoming requests\n if (event.name === \"exception\") {\n name = \"Microsoft.ApplicationInsights.Exception\";\n baseType = \"ExceptionData\";\n let typeName = \"\";\n let message = \"Exception\";\n let stack = \"\";\n let hasFullStack = false;\n if (event.attributes) {\n typeName = String(event.attributes[SEMATTRS_EXCEPTION_TYPE]);\n stack = String(event.attributes[SEMATTRS_EXCEPTION_STACKTRACE]);\n if (stack) {\n hasFullStack = true;\n }\n const exceptionMsg = event.attributes[SEMATTRS_EXCEPTION_MESSAGE];\n if (exceptionMsg) {\n message = String(exceptionMsg);\n }\n const escaped = event.attributes[SEMATTRS_EXCEPTION_ESCAPED];\n if (escaped !== undefined) {\n properties[SEMATTRS_EXCEPTION_ESCAPED] = String(escaped);\n }\n }\n const exceptionDetails: TelemetryExceptionDetails = {\n typeName: typeName,\n message: message,\n stack: stack,\n hasFullStack: hasFullStack,\n };\n const exceptionData: TelemetryExceptionData = {\n exceptions: [exceptionDetails],\n version: 2,\n properties: properties,\n };\n baseData = exceptionData;\n } else {\n name = \"Microsoft.ApplicationInsights.Message\";\n baseType = \"MessageData\";\n const messageData: MessageData = {\n message: event.name,\n version: 2,\n properties: properties,\n };\n baseData = messageData;\n }\n let sampleRate = 100;\n if (span.attributes[AzureMonitorSampleRate]) {\n sampleRate = Number(span.attributes[AzureMonitorSampleRate]);\n }\n // Truncate properties\n if (baseData.message) {\n baseData.message = String(baseData.message).substring(0, MaxPropertyLengths.FIFTEEN_BIT);\n }\n if (baseData.properties) {\n for (const key of Object.keys(baseData.properties)) {\n baseData.properties[key] = baseData.properties[key].substring(\n 0,\n MaxPropertyLengths.THIRTEEN_BIT,\n );\n }\n }\n const env: Envelope = {\n name: name,\n time: time,\n instrumentationKey: ikey,\n version: 1,\n sampleRate: sampleRate,\n data: {\n baseType: baseType,\n baseData: baseData,\n },\n tags: tags,\n };\n envelopes.push(env);\n });\n }\n return envelopes;\n}\n\nexport function getPeerIp(attributes: Attributes): AttributeValue | undefined {\n if (attributes) {\n return attributes[ATTR_NETWORK_PEER_ADDRESS] || attributes[SEMATTRS_NET_PEER_IP];\n }\n return;\n}\n\nexport function getLocationIp(tags: Tags, attributes: Attributes): void {\n if (attributes) {\n const httpClientIp = getHttpClientIp(attributes);\n const netPeerIp = getPeerIp(attributes);\n if (httpClientIp) {\n tags[KnownContextTagKeys.AiLocationIp] = String(httpClientIp);\n } else if (netPeerIp) {\n tags[KnownContextTagKeys.AiLocationIp] = String(netPeerIp);\n }\n }\n}\n\nexport function getHttpClientIp(attributes: Attributes): AttributeValue | undefined {\n if (attributes) {\n return attributes[ATTR_CLIENT_ADDRESS] || attributes[SEMATTRS_HTTP_CLIENT_IP];\n }\n return;\n}\n\nexport function getUserAgent(attributes: Attributes): AttributeValue | undefined {\n if (attributes) {\n return attributes[ATTR_USER_AGENT_ORIGINAL] || attributes[SEMATTRS_HTTP_USER_AGENT];\n }\n return;\n}\n\nexport function getHttpUrl(attributes: Attributes): AttributeValue | undefined {\n // Stable sem conv only supports populating url from `url.full`\n if (attributes) {\n return attributes[ATTR_URL_FULL] || attributes[SEMATTRS_HTTP_URL];\n }\n return;\n}\n\nexport function getHttpMethod(attributes: Attributes): AttributeValue | undefined {\n if (attributes) {\n return attributes[ATTR_HTTP_REQUEST_METHOD] || attributes[SEMATTRS_HTTP_METHOD];\n }\n return;\n}\n\nexport function getHttpStatusCode(attributes: Attributes): AttributeValue | undefined {\n if (attributes) {\n return attributes[ATTR_HTTP_RESPONSE_STATUS_CODE] || attributes[SEMATTRS_HTTP_STATUS_CODE];\n }\n return;\n}\n\nexport function getHttpScheme(attributes: Attributes): AttributeValue | undefined {\n if (attributes) {\n return attributes[ATTR_URL_SCHEME] || attributes[SEMATTRS_HTTP_SCHEME];\n }\n return;\n}\n\nexport function getHttpTarget(attributes: Attributes): AttributeValue | undefined {\n if (attributes) {\n if (attributes[ATTR_URL_PATH]) {\n return attributes[ATTR_URL_PATH];\n }\n if (attributes[ATTR_URL_QUERY]) {\n return attributes[ATTR_URL_QUERY];\n }\n return attributes[SEMATTRS_HTTP_TARGET];\n }\n return;\n}\n\nexport function getHttpHost(attributes: Attributes): AttributeValue | undefined {\n if (attributes) {\n return attributes[ATTR_SERVER_ADDRESS] || attributes[SEMATTRS_HTTP_HOST];\n }\n return;\n}\n\nexport function getNetPeerName(attributes: Attributes): AttributeValue | undefined {\n if (attributes) {\n return attributes[ATTR_CLIENT_ADDRESS] || attributes[SEMATTRS_NET_PEER_NAME];\n }\n return;\n}\n\nexport function getNetPeerPort(attributes: Attributes): AttributeValue | undefined {\n if (attributes) {\n return (\n attributes[ATTR_CLIENT_PORT] ||\n attributes[ATTR_SERVER_PORT] ||\n attributes[SEMATTRS_NET_PEER_PORT]\n );\n }\n return;\n}\n"]}
1
+ {"version":3,"file":"spanUtils.js","sourceRoot":"","sources":["../../../src/utils/spanUtils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,yBAAyB,EACzB,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,0BAA0B,EAC1B,0BAA0B,EAC1B,6BAA6B,EAC7B,uBAAuB,EACvB,uBAAuB,EACvB,oBAAoB,EACpB,yBAAyB,EACzB,iBAAiB,EACjB,wBAAwB,EACxB,oBAAoB,EACpB,6BAA6B,EAC7B,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,EACnB,yBAAyB,EACzB,wBAAwB,EACxB,eAAe,EACf,aAAa,EACb,8BAA8B,EAC9B,oBAAoB,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;AACT,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,UAAsB;IACnD,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,CACL,UAAU,CAAC,gBAAgB,CAAC;YAC5B,UAAU,CAAC,gBAAgB,CAAC;YAC5B,UAAU,CAAC,sBAAsB,CAAC,CACnC,CAAC;IACJ,CAAC;IACD,OAAO;AACT,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ReadableSpan, TimedEvent } from \"@opentelemetry/sdk-trace-base\";\nimport { hrTimeToMilliseconds } from \"@opentelemetry/core\";\nimport type { Link, Attributes, AttributeValue } from \"@opentelemetry/api\";\nimport { diag, SpanKind, SpanStatusCode } from \"@opentelemetry/api\";\nimport {\n DBSYSTEMVALUES_MONGODB,\n DBSYSTEMVALUES_MYSQL,\n DBSYSTEMVALUES_POSTGRESQL,\n DBSYSTEMVALUES_REDIS,\n SEMATTRS_DB_NAME,\n SEMATTRS_DB_OPERATION,\n SEMATTRS_DB_STATEMENT,\n SEMATTRS_DB_SYSTEM,\n SEMATTRS_EXCEPTION_ESCAPED,\n SEMATTRS_EXCEPTION_MESSAGE,\n SEMATTRS_EXCEPTION_STACKTRACE,\n SEMATTRS_EXCEPTION_TYPE,\n SEMATTRS_HTTP_CLIENT_IP,\n SEMATTRS_HTTP_METHOD,\n SEMATTRS_HTTP_STATUS_CODE,\n SEMATTRS_HTTP_URL,\n SEMATTRS_HTTP_USER_AGENT,\n SEMATTRS_NET_PEER_IP,\n SEMATTRS_RPC_GRPC_STATUS_CODE,\n SEMATTRS_RPC_SYSTEM,\n ATTR_HTTP_REQUEST_METHOD,\n ATTR_CLIENT_ADDRESS,\n ATTR_NETWORK_PEER_ADDRESS,\n ATTR_USER_AGENT_ORIGINAL,\n ATTR_HTTP_ROUTE,\n ATTR_URL_FULL,\n ATTR_HTTP_RESPONSE_STATUS_CODE,\n SEMATTRS_HTTP_SCHEME,\n ATTR_URL_SCHEME,\n SEMATTRS_HTTP_TARGET,\n ATTR_URL_PATH,\n ATTR_URL_QUERY,\n ATTR_SERVER_ADDRESS,\n SEMATTRS_HTTP_HOST,\n SEMATTRS_NET_PEER_NAME,\n ATTR_CLIENT_PORT,\n ATTR_SERVER_PORT,\n SEMATTRS_NET_PEER_PORT,\n} from \"@opentelemetry/semantic-conventions\";\n\nimport {\n createTagsFromResource,\n getDependencyTarget,\n getUrl,\n hrTimeToDate,\n isSqlDB,\n isSyntheticSource,\n serializeAttribute,\n} from \"./common.js\";\nimport type { Tags, Properties, MSLink, Measurements } from \"../types.js\";\nimport {\n httpSemanticValues,\n internalMicrosoftAttributes,\n legacySemanticValues,\n MaxPropertyLengths,\n experimentalOpenTelemetryValues,\n} from \"../types.js\";\nimport { parseEventHubSpan } from \"./eventhub.js\";\nimport {\n AzureMonitorSampleRate,\n DependencyTypes,\n MicrosoftClientIp,\n MS_LINKS,\n} from \"./constants/applicationinsights.js\";\nimport { AzNamespace, MicrosoftEventHub } from \"./constants/span/azAttributes.js\";\nimport type {\n TelemetryExceptionData,\n MessageData,\n RemoteDependencyData,\n RequestData,\n TelemetryItem as Envelope,\n TelemetryExceptionDetails,\n} from \"../generated/index.js\";\nimport { KnownContextTagKeys } from \"../generated/index.js\";\nimport { msToTimeSpan } from \"./breezeUtils.js\";\n\nfunction createTagsFromSpan(span: ReadableSpan): Tags {\n const tags: Tags = createTagsFromResource(span.resource);\n tags[KnownContextTagKeys.AiOperationId] = span.spanContext().traceId;\n if (span.parentSpanContext?.spanId) {\n tags[KnownContextTagKeys.AiOperationParentId] = span.parentSpanContext.spanId;\n }\n\n // Map OpenTelemetry enduser attributes to Application Insights user attributes\n const endUserId = span.attributes[experimentalOpenTelemetryValues.ATTR_ENDUSER_ID];\n if (endUserId) {\n tags[KnownContextTagKeys.AiUserAuthUserId] = String(endUserId);\n }\n\n const endUserPseudoId = span.attributes[experimentalOpenTelemetryValues.ATTR_ENDUSER_PSEUDO_ID];\n if (endUserPseudoId) {\n tags[KnownContextTagKeys.AiUserId] = String(endUserPseudoId);\n }\n\n const httpUserAgent = getUserAgent(span.attributes);\n if (httpUserAgent) {\n // TODO: Not exposed in Swagger, need to update def\n tags[\"ai.user.userAgent\"] = String(httpUserAgent);\n }\n if (isSyntheticSource(span.attributes)) {\n tags[KnownContextTagKeys.AiOperationSyntheticSource] = \"True\";\n }\n\n // Check for microsoft.client.ip first - this takes precedence over all other IP logic\n const microsoftClientIp = span.attributes[MicrosoftClientIp];\n if (microsoftClientIp) {\n tags[KnownContextTagKeys.AiLocationIp] = String(microsoftClientIp);\n }\n\n if (span.kind === SpanKind.SERVER) {\n const httpMethod = getHttpMethod(span.attributes);\n // Only use the fallback IP logic for server spans if microsoft.client.ip is not set\n if (!microsoftClientIp) {\n getLocationIp(tags, span.attributes);\n }\n if (httpMethod) {\n const httpRoute = span.attributes[ATTR_HTTP_ROUTE];\n const httpUrl = getHttpUrl(span.attributes);\n tags[KnownContextTagKeys.AiOperationName] = span.name; // Default\n if (httpRoute) {\n // AiOperationName max length is 1024\n // https://github.com/MohanGsk/ApplicationInsights-Home/blob/master/EndpointSpecs/Schemas/Bond/ContextTagKeys.bond\n tags[KnownContextTagKeys.AiOperationName] = String(\n `${httpMethod as string} ${httpRoute as string}`,\n ).substring(0, MaxPropertyLengths.TEN_BIT);\n } else if (httpUrl) {\n try {\n const url = new URL(String(httpUrl));\n tags[KnownContextTagKeys.AiOperationName] = String(\n `${httpMethod} ${url.pathname}`,\n ).substring(0, MaxPropertyLengths.TEN_BIT);\n } catch {\n /* no-op */\n }\n }\n } else {\n tags[KnownContextTagKeys.AiOperationName] = span.name;\n }\n } else {\n if (span.attributes[KnownContextTagKeys.AiOperationName]) {\n tags[KnownContextTagKeys.AiOperationName] = span.attributes[\n KnownContextTagKeys.AiOperationName\n ] as string;\n }\n }\n // TODO: Location IP TBD for non server spans\n\n return tags;\n}\n\nfunction createPropertiesFromSpanAttributes(attributes?: Attributes): {\n [propertyName: string]: string;\n} {\n const properties: { [propertyName: string]: string } = {};\n if (attributes) {\n for (const key of Object.keys(attributes)) {\n // Avoid duplication ignoring fields already mapped.\n if (\n // We need to not ignore the _MS.ProcessedByMetricExtractors key as it's used to identify standard metrics\n !(\n (key.startsWith(\"_MS.\") && !internalMicrosoftAttributes.includes(key as any)) ||\n key.startsWith(\"microsoft.\") ||\n legacySemanticValues.includes(key) ||\n httpSemanticValues.includes(key as any) ||\n key === (KnownContextTagKeys.AiOperationName as string)\n )\n ) {\n properties[key] = serializeAttribute(attributes[key]);\n }\n }\n }\n return properties;\n}\n\nfunction createPropertiesFromSpan(span: ReadableSpan): [Properties, Measurements] {\n const properties: Properties = createPropertiesFromSpanAttributes(span.attributes);\n const measurements: Measurements = {};\n\n const links: MSLink[] = span.links.map((link: Link) => ({\n operation_Id: link.context.traceId,\n id: link.context.spanId,\n }));\n if (links.length > 0) {\n properties[MS_LINKS] = JSON.stringify(links);\n }\n return [properties, measurements];\n}\n\nfunction createDependencyData(span: ReadableSpan): RemoteDependencyData {\n const remoteDependencyData: RemoteDependencyData = {\n name: span.name, // Default\n id: `${span.spanContext().spanId}`,\n success: span.status?.code !== SpanStatusCode.ERROR,\n resultCode: \"0\",\n type: \"Dependency\",\n duration: msToTimeSpan(hrTimeToMilliseconds(span.duration)),\n version: 2,\n };\n if (span.kind === SpanKind.PRODUCER) {\n remoteDependencyData.type = DependencyTypes.QueueMessage;\n }\n if (span.kind === SpanKind.INTERNAL && span.parentSpanContext) {\n remoteDependencyData.type = DependencyTypes.InProc;\n }\n\n const httpMethod = getHttpMethod(span.attributes);\n const dbSystem = span.attributes[SEMATTRS_DB_SYSTEM];\n const rpcSystem = span.attributes[SEMATTRS_RPC_SYSTEM];\n // HTTP Dependency\n if (httpMethod) {\n const httpUrl = getHttpUrl(span.attributes);\n if (httpUrl) {\n try {\n const dependencyUrl = new URL(String(httpUrl));\n remoteDependencyData.name = `${httpMethod} ${dependencyUrl.pathname}`;\n } catch {\n /* no-op */\n }\n }\n remoteDependencyData.type = DependencyTypes.Http;\n remoteDependencyData.data = getUrl(span.attributes);\n const httpStatusCode = getHttpStatusCode(span.attributes);\n if (httpStatusCode) {\n remoteDependencyData.resultCode = String(httpStatusCode);\n }\n let target = getDependencyTarget(span.attributes);\n if (target) {\n try {\n // Remove default port\n const portRegex = new RegExp(/(https?)(:\\/\\/.*)(:\\d+)(\\S*)/);\n const res = portRegex.exec(target);\n if (res !== null) {\n const protocol = res[1];\n const port = res[3];\n if (\n (protocol === \"https\" && port === \":443\") ||\n (protocol === \"http\" && port === \":80\")\n ) {\n // Drop port\n target = res[1] + res[2] + res[4];\n }\n }\n } catch {\n /* no-op */\n }\n remoteDependencyData.target = `${target}`;\n }\n }\n // DB Dependency\n else if (dbSystem) {\n // TODO: Remove special logic when Azure UX supports OpenTelemetry dbSystem\n if (String(dbSystem) === DBSYSTEMVALUES_MYSQL) {\n remoteDependencyData.type = \"mysql\";\n } else if (String(dbSystem) === DBSYSTEMVALUES_POSTGRESQL) {\n remoteDependencyData.type = \"postgresql\";\n } else if (String(dbSystem) === DBSYSTEMVALUES_MONGODB) {\n remoteDependencyData.type = \"mongodb\";\n } else if (String(dbSystem) === DBSYSTEMVALUES_REDIS) {\n remoteDependencyData.type = \"redis\";\n } else if (isSqlDB(String(dbSystem))) {\n remoteDependencyData.type = \"SQL\";\n } else {\n remoteDependencyData.type = String(dbSystem);\n }\n const dbStatement = span.attributes[SEMATTRS_DB_STATEMENT];\n const dbOperation = span.attributes[SEMATTRS_DB_OPERATION];\n if (dbStatement) {\n remoteDependencyData.data = String(dbStatement);\n } else if (dbOperation) {\n remoteDependencyData.data = String(dbOperation);\n }\n const target = getDependencyTarget(span.attributes);\n const dbName = span.attributes[SEMATTRS_DB_NAME];\n if (target) {\n remoteDependencyData.target = dbName ? `${target}|${dbName}` : `${target}`;\n } else {\n remoteDependencyData.target = dbName ? `${dbName}` : `${dbSystem}`;\n }\n }\n // grpc Dependency\n else if (rpcSystem) {\n if (rpcSystem === DependencyTypes.Wcf) {\n remoteDependencyData.type = DependencyTypes.Wcf;\n } else {\n remoteDependencyData.type = DependencyTypes.Grpc;\n }\n const grpcStatusCode = span.attributes[SEMATTRS_RPC_GRPC_STATUS_CODE];\n if (grpcStatusCode) {\n remoteDependencyData.resultCode = String(grpcStatusCode);\n }\n const target = getDependencyTarget(span.attributes);\n if (target) {\n remoteDependencyData.target = `${target}`;\n } else if (rpcSystem) {\n remoteDependencyData.target = String(rpcSystem);\n }\n }\n return remoteDependencyData;\n}\n\nfunction createRequestData(span: ReadableSpan): RequestData {\n const requestData: RequestData = {\n id: `${span.spanContext().spanId}`,\n success:\n span.status.code !== SpanStatusCode.UNSET\n ? span.status.code === SpanStatusCode.OK\n : (Number(getHttpStatusCode(span.attributes)) || 0) < 400,\n responseCode: \"0\",\n duration: msToTimeSpan(hrTimeToMilliseconds(span.duration)),\n version: 2,\n source: undefined,\n };\n const httpMethod = getHttpMethod(span.attributes);\n const grpcStatusCode = span.attributes[SEMATTRS_RPC_GRPC_STATUS_CODE];\n if (httpMethod) {\n requestData.url = getUrl(span.attributes);\n const httpStatusCode = getHttpStatusCode(span.attributes);\n if (httpStatusCode) {\n requestData.responseCode = String(httpStatusCode);\n }\n } else if (grpcStatusCode) {\n requestData.responseCode = String(grpcStatusCode);\n }\n return requestData;\n}\n\n/**\n * Span to Azure envelope parsing.\n * @internal\n */\nexport function readableSpanToEnvelope(span: ReadableSpan, ikey: string): Envelope {\n let name: string;\n let baseType: \"RemoteDependencyData\" | \"RequestData\";\n let baseData: RemoteDependencyData | RequestData;\n\n const time = hrTimeToDate(span.startTime);\n const instrumentationKey = ikey;\n const tags = createTagsFromSpan(span);\n const [properties, measurements] = createPropertiesFromSpan(span);\n switch (span.kind) {\n case SpanKind.CLIENT:\n case SpanKind.PRODUCER:\n case SpanKind.INTERNAL:\n name = \"Microsoft.ApplicationInsights.RemoteDependency\";\n baseType = \"RemoteDependencyData\";\n baseData = createDependencyData(span);\n break;\n case SpanKind.SERVER:\n case SpanKind.CONSUMER:\n name = \"Microsoft.ApplicationInsights.Request\";\n baseType = \"RequestData\";\n baseData = createRequestData(span);\n baseData.name = tags[KnownContextTagKeys.AiOperationName];\n break;\n default:\n // never\n diag.error(`Unsupported span kind ${span.kind}`);\n throw new Error(`Unsupported span kind ${span.kind}`);\n }\n\n let sampleRate = 100;\n if (span.attributes[AzureMonitorSampleRate]) {\n sampleRate = Number(span.attributes[AzureMonitorSampleRate]);\n }\n\n // Azure SDK\n if (span.attributes[AzNamespace]) {\n if (span.kind === SpanKind.INTERNAL) {\n baseData.type = `${DependencyTypes.InProc} | ${span.attributes[AzNamespace]}`;\n }\n if (span.attributes[AzNamespace] === MicrosoftEventHub) {\n parseEventHubSpan(span, baseData);\n }\n }\n\n // Truncate properties\n if (baseData.id) {\n baseData.id = baseData.id.substring(0, MaxPropertyLengths.NINE_BIT);\n }\n if (baseData.name) {\n baseData.name = baseData.name.substring(0, MaxPropertyLengths.TEN_BIT);\n }\n if (baseData.resultCode) {\n baseData.resultCode = String(baseData.resultCode).substring(0, MaxPropertyLengths.TEN_BIT);\n }\n if (baseData.data) {\n baseData.data = String(baseData.data).substring(0, MaxPropertyLengths.THIRTEEN_BIT);\n }\n if (baseData.type) {\n baseData.type = String(baseData.type).substring(0, MaxPropertyLengths.TEN_BIT);\n }\n if (baseData.target) {\n baseData.target = String(baseData.target).substring(0, MaxPropertyLengths.TEN_BIT);\n }\n if (baseData.properties) {\n for (const key of Object.keys(baseData.properties)) {\n baseData.properties[key] = baseData.properties[key].substring(\n 0,\n MaxPropertyLengths.THIRTEEN_BIT,\n );\n }\n }\n\n return {\n name,\n sampleRate,\n time,\n instrumentationKey,\n tags,\n version: 1,\n data: {\n baseType,\n baseData: {\n ...baseData,\n properties,\n measurements,\n },\n },\n };\n}\n\n/**\n * Span Events to Azure envelopes parsing.\n * @internal\n */\nexport function spanEventsToEnvelopes(span: ReadableSpan, ikey: string): Envelope[] {\n const envelopes: Envelope[] = [];\n if (span.events) {\n span.events.forEach((event: TimedEvent) => {\n let baseType: \"ExceptionData\" | \"MessageData\";\n const time = hrTimeToDate(event.time);\n let name = \"\";\n let baseData: TelemetryExceptionData | MessageData;\n const properties = createPropertiesFromSpanAttributes(event.attributes);\n\n const tags: Tags = createTagsFromResource(span.resource);\n tags[KnownContextTagKeys.AiOperationId] = span.spanContext().traceId;\n const spanId = span.spanContext().spanId;\n if (spanId) {\n tags[KnownContextTagKeys.AiOperationParentId] = spanId;\n }\n\n // Only generate exception telemetry for incoming requests\n if (event.name === \"exception\") {\n name = \"Microsoft.ApplicationInsights.Exception\";\n baseType = \"ExceptionData\";\n let typeName = \"\";\n let message = \"Exception\";\n let stack = \"\";\n let hasFullStack = false;\n if (event.attributes) {\n typeName = String(event.attributes[SEMATTRS_EXCEPTION_TYPE]);\n stack = String(event.attributes[SEMATTRS_EXCEPTION_STACKTRACE]);\n if (stack) {\n hasFullStack = true;\n }\n const exceptionMsg = event.attributes[SEMATTRS_EXCEPTION_MESSAGE];\n if (exceptionMsg) {\n message = String(exceptionMsg);\n }\n const escaped = event.attributes[SEMATTRS_EXCEPTION_ESCAPED];\n if (escaped !== undefined) {\n properties[SEMATTRS_EXCEPTION_ESCAPED] = String(escaped);\n }\n }\n const exceptionDetails: TelemetryExceptionDetails = {\n typeName: typeName,\n message: message,\n stack: stack,\n hasFullStack: hasFullStack,\n };\n const exceptionData: TelemetryExceptionData = {\n exceptions: [exceptionDetails],\n version: 2,\n properties: properties,\n };\n baseData = exceptionData;\n } else {\n name = \"Microsoft.ApplicationInsights.Message\";\n baseType = \"MessageData\";\n const messageData: MessageData = {\n message: event.name,\n version: 2,\n properties: properties,\n };\n baseData = messageData;\n }\n let sampleRate = 100;\n if (span.attributes[AzureMonitorSampleRate]) {\n sampleRate = Number(span.attributes[AzureMonitorSampleRate]);\n }\n // Truncate properties\n if (baseData.message) {\n baseData.message = String(baseData.message).substring(0, MaxPropertyLengths.FIFTEEN_BIT);\n }\n if (baseData.properties) {\n for (const key of Object.keys(baseData.properties)) {\n baseData.properties[key] = baseData.properties[key].substring(\n 0,\n MaxPropertyLengths.THIRTEEN_BIT,\n );\n }\n }\n const env: Envelope = {\n name: name,\n time: time,\n instrumentationKey: ikey,\n version: 1,\n sampleRate: sampleRate,\n data: {\n baseType: baseType,\n baseData: baseData,\n },\n tags: tags,\n };\n envelopes.push(env);\n });\n }\n return envelopes;\n}\n\nexport function getPeerIp(attributes: Attributes): AttributeValue | undefined {\n if (attributes) {\n return attributes[ATTR_NETWORK_PEER_ADDRESS] || attributes[SEMATTRS_NET_PEER_IP];\n }\n return;\n}\n\nexport function getLocationIp(tags: Tags, attributes: Attributes): void {\n if (attributes) {\n const httpClientIp = getHttpClientIp(attributes);\n const netPeerIp = getPeerIp(attributes);\n if (httpClientIp) {\n tags[KnownContextTagKeys.AiLocationIp] = String(httpClientIp);\n } else if (netPeerIp) {\n tags[KnownContextTagKeys.AiLocationIp] = String(netPeerIp);\n }\n }\n}\n\nexport function getHttpClientIp(attributes: Attributes): AttributeValue | undefined {\n if (attributes) {\n return attributes[ATTR_CLIENT_ADDRESS] || attributes[SEMATTRS_HTTP_CLIENT_IP];\n }\n return;\n}\n\nexport function getUserAgent(attributes: Attributes): AttributeValue | undefined {\n if (attributes) {\n return attributes[ATTR_USER_AGENT_ORIGINAL] || attributes[SEMATTRS_HTTP_USER_AGENT];\n }\n return;\n}\n\nexport function getHttpUrl(attributes: Attributes): AttributeValue | undefined {\n // Stable sem conv only supports populating url from `url.full`\n if (attributes) {\n return attributes[ATTR_URL_FULL] || attributes[SEMATTRS_HTTP_URL];\n }\n return;\n}\n\nexport function getHttpMethod(attributes: Attributes): AttributeValue | undefined {\n if (attributes) {\n return attributes[ATTR_HTTP_REQUEST_METHOD] || attributes[SEMATTRS_HTTP_METHOD];\n }\n return;\n}\n\nexport function getHttpStatusCode(attributes: Attributes): AttributeValue | undefined {\n if (attributes) {\n return attributes[ATTR_HTTP_RESPONSE_STATUS_CODE] || attributes[SEMATTRS_HTTP_STATUS_CODE];\n }\n return;\n}\n\nexport function getHttpScheme(attributes: Attributes): AttributeValue | undefined {\n if (attributes) {\n return attributes[ATTR_URL_SCHEME] || attributes[SEMATTRS_HTTP_SCHEME];\n }\n return;\n}\n\nexport function getHttpTarget(attributes: Attributes): AttributeValue | undefined {\n if (attributes) {\n if (attributes[ATTR_URL_PATH]) {\n return attributes[ATTR_URL_PATH];\n }\n if (attributes[ATTR_URL_QUERY]) {\n return attributes[ATTR_URL_QUERY];\n }\n return attributes[SEMATTRS_HTTP_TARGET];\n }\n return;\n}\n\nexport function getHttpHost(attributes: Attributes): AttributeValue | undefined {\n if (attributes) {\n return attributes[ATTR_SERVER_ADDRESS] || attributes[SEMATTRS_HTTP_HOST];\n }\n return;\n}\n\nexport function getNetPeerName(attributes: Attributes): AttributeValue | undefined {\n if (attributes) {\n return attributes[ATTR_CLIENT_ADDRESS] || attributes[SEMATTRS_NET_PEER_NAME];\n }\n return;\n}\n\nexport function getNetPeerPort(attributes: Attributes): AttributeValue | undefined {\n if (attributes) {\n return (\n attributes[ATTR_CLIENT_PORT] ||\n attributes[ATTR_SERVER_PORT] ||\n attributes[SEMATTRS_NET_PEER_PORT]\n );\n }\n return;\n}\n"]}
package/package.json CHANGED
@@ -2,34 +2,13 @@
2
2
  "name": "@azure/monitor-opentelemetry-exporter",
3
3
  "author": "Microsoft Corporation",
4
4
  "sdk-type": "client",
5
- "version": "1.0.0-beta.32",
5
+ "version": "1.0.0-beta.34",
6
6
  "description": "Application Insights exporter for the OpenTelemetry JavaScript (Node.js) SDK",
7
7
  "main": "./dist/commonjs/index.js",
8
8
  "module": "./dist/esm/index.js",
9
9
  "types": "./dist/commonjs/index.d.ts",
10
- "scripts": {
11
- "build": "npm run clean && dev-tool run build-package && dev-tool run extract-api",
12
- "build:samples": "echo Obsolete.",
13
- "check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
14
- "clean": "dev-tool run vendored rimraf --glob dist-esm types dist",
15
- "execute:samples": "dev-tool samples run samples-dev",
16
- "extract-api": "dev-tool run build-package && dev-tool run extract-api",
17
- "format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
18
- "generate:client": "autorest --typescript ./swagger/README.md",
19
- "lint": "eslint package.json api-extractor.json src test",
20
- "lint:fix": "eslint package.json api-extractor.json src test --fix --fix-type [problem,suggestion]",
21
- "pack": "npm pack 2>&1",
22
- "report": "nyc report --reporter=json",
23
- "test": "npm run test:node && npm run test:browser",
24
- "test-opentelemetry-versions": "node test-opentelemetry-versions.js 2>&1",
25
- "test:browser": "echo skipped",
26
- "test:node": "dev-tool run test:vitest",
27
- "test:node:esm": "dev-tool run test:vitest --esm",
28
- "test:node:live": "dev-tool run test:vitest --no-test-proxy -- -c vitest.integration.config.ts",
29
- "update-snippets": "dev-tool run update-snippets"
30
- },
31
10
  "engines": {
32
- "node": ">=18.0.0"
11
+ "node": ">=20.0.0"
33
12
  },
34
13
  "files": [
35
14
  "dist/",
@@ -69,23 +48,23 @@
69
48
  }
70
49
  },
71
50
  "devDependencies": {
72
- "@azure-tools/test-utils-vitest": "^1.0.0",
73
- "@azure/core-util": "^1.11.0",
74
- "@azure/dev-tool": "^1.0.0",
75
- "@azure/eslint-plugin-azure-sdk": "^3.0.0",
76
51
  "@azure/logger": "^1.1.4",
77
52
  "@opentelemetry/instrumentation": "^0.200.0",
78
53
  "@opentelemetry/instrumentation-http": "^0.200.0",
79
54
  "@opentelemetry/sdk-trace-node": "^2.0.0",
80
- "@types/node": "^18.0.0",
81
- "@vitest/browser": "^3.0.9",
82
- "@vitest/coverage-istanbul": "^3.0.9",
55
+ "@types/node": "^20.19.0",
56
+ "@vitest/browser": "^3.2.3",
57
+ "@vitest/coverage-istanbul": "^3.2.3",
83
58
  "dotenv": "^16.0.0",
84
- "eslint": "^9.9.0",
59
+ "eslint": "^9.33.0",
85
60
  "nock": "^13.5.4",
86
61
  "playwright": "^1.50.1",
87
- "typescript": "~5.8.2",
88
- "vitest": "^3.0.9"
62
+ "typescript": "~5.8.3",
63
+ "vitest": "^3.2.3",
64
+ "@azure/core-util": "^1.13.1",
65
+ "@azure/dev-tool": "^1.0.0",
66
+ "@azure-tools/test-utils-vitest": "^2.0.1",
67
+ "@azure/eslint-plugin-azure-sdk": "^3.0.0"
89
68
  },
90
69
  "dependencies": {
91
70
  "@azure/core-auth": "^1.9.0",
@@ -114,7 +93,7 @@
114
93
  ],
115
94
  "type": "module",
116
95
  "tshy": {
117
- "project": "./tsconfig.src.json",
96
+ "project": "../../../tsconfig.src.build.json",
118
97
  "exports": {
119
98
  "./package.json": "./package.json",
120
99
  ".": "./src/index.ts"
@@ -137,5 +116,25 @@
137
116
  "default": "./dist/commonjs/index.js"
138
117
  }
139
118
  }
119
+ },
120
+ "scripts": {
121
+ "build": "npm run clean && dev-tool run build-package && dev-tool run extract-api",
122
+ "build:samples": "tsc -p tsconfig.samples.json",
123
+ "check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
124
+ "clean": "dev-tool run vendored rimraf --glob dist-esm types dist",
125
+ "execute:samples": "dev-tool samples run samples-dev",
126
+ "extract-api": "dev-tool run build-package && dev-tool run extract-api",
127
+ "format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
128
+ "generate:client": "autorest --typescript ./swagger/README.md",
129
+ "lint": "eslint package.json src test",
130
+ "lint:fix": "eslint package.json src test --fix --fix-type [problem,suggestion]",
131
+ "pack": "pnpm pack 2>&1",
132
+ "report": "nyc report --reporter=json",
133
+ "test": "npm run test:node && npm run test:browser",
134
+ "test-opentelemetry-versions": "node test-opentelemetry-versions.js 2>&1",
135
+ "test:browser": "echo skipped",
136
+ "test:node": "dev-tool run build-test --no-browser-test && dev-tool run test:vitest",
137
+ "test:node:live": "dev-tool run test:vitest --no-test-proxy -- -c vitest.integration.config.ts",
138
+ "update-snippets": "dev-tool run update-snippets"
140
139
  }
141
- }
140
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"sampling.d.ts","sourceRoot":"","sources":["../../src/sampling.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAI7E;;;;;GAKG;AACH,qBAAa,0BAA2B,YAAW,OAAO;IACxD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IAEvC;;;OAGG;gBACS,aAAa,GAAE,MAAU;IAQrC;;;;;;;;;;;;;OAaG;IACI,YAAY,CAEjB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EAEf,QAAQ,EAAE,MAAM,EAEhB,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,UAAU,EAEtB,KAAK,EAAE,IAAI,EAAE,GACZ,cAAc;IAqBjB;;OAEG;IACI,QAAQ,IAAI,MAAM;IAIzB,OAAO,CAAC,oBAAoB;CAqB7B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"sampling.js","sourceRoot":"","sources":["../../src/sampling.ts"],"names":[],"mappings":";;;AAIA,kEAAiE;AACjE,qFAAkF;AAElF;;;;;GAKG;AACH,MAAa,0BAA0B;IAIrC;;;OAGG;IACH,YAAY,gBAAwB,CAAC;QACnC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,IAAI,CAAC,aAAa,GAAG,C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Q;QACb,OAAO,8BAA8B,IAAI,CAAC,aAAa,GAAG,CAAC;IAC7D,CAAC;IAEO,oBAAoB,CAAC,KAAa;QACxC,MAAM,SAAS,GAAG,CAAC,UAAU,CAAC;QAC9B,MAAM,SAAS,GAAG,UAAU,CAAC;QAC7B,IAAI,IAAI,GAAG,IAAI,CAAC;QAEhB,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,CAAC;QACX,CAAC;QAED,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;QACxB,CAAC;QAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,uGAAuG;YACvG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAChE,CAAC;QAED,IAAI,GAAG,IAAI,IAAI,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACtD,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,GAAG,GAAG,CAAC;IAClC,CAAC;CACF;AA1FD,gEA0FC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { Link, Attributes, SpanKind, Context } from \"@opentelemetry/api\";\nimport type { Sampler, SamplingResult } from \"@opentelemetry/sdk-trace-base\";\nimport { SamplingDecision } from \"@opentelemetry/sdk-trace-base\";\nimport { AzureMonitorSampleRate } from \"./utils/constants/applicationinsights.js\";\n\n/**\n * ApplicationInsightsSampler is responsible for the following:\n * Implements same trace id hashing algorithm so that traces are sampled the same across multiple nodes\n * Adds item count to span attribute if span is sampled (needed for ingestion service)\n * @param samplingRatio - 0 to 1 value.\n */\nexport class ApplicationInsightsSampler implements Sampler {\n private readonly _sampleRate: number;\n private readonly samplingRatio: number;\n\n /**\n * Initializes a new instance of the ApplicationInsightsSampler class.\n * @param samplingRatio - Value in the range [0,1], 1 meaning all data will sampled and 0 all Tracing data will be sampled out.\n */\n constructor(samplingRatio: number = 1) {\n this.samplingRatio = samplingRatio;\n if (this.samplingRatio > 1 || this.samplingRatio < 0 || !Number.isFinite(this.samplingRatio)) {\n throw new Error(\"Wrong sampling rate, data will not be sampled out\");\n }\n this._sampleRate = Math.round(this.samplingRatio * 100);\n }\n\n /**\n * Checks whether span needs to be created and tracked.\n *\n * @param context - Parent Context which may contain a span.\n * @param traceId - traceif of the span to be created. It can be different from the\n * traceId in the {@link SpanContext}. Typically in situations when the\n * span to be created starts a new trace.\n * @param spanName - Name of the span to be created.\n * @param spanKind - Kind of the span to be created.\n * @param attributes - Initial set of SpanAttributes for the Span being constructed.\n * @param links - Collection of links that will be associated with the Span to\n * be created. Typically useful for batch operations.\n * @returns a {@link SamplingResult}.\n */\n public shouldSample(\n // @ts-expect-error unused argument\n context: Context,\n traceId: string,\n // @ts-expect-error unused argument\n spanName: string,\n // @ts-expect-error unused argument\n spanKind: SpanKind,\n attributes: Attributes,\n // @ts-expect-error unused argument\n links: Link[],\n ): SamplingResult {\n let isSampledIn = false;\n if (this._sampleRate === 100) {\n isSampledIn = true;\n } else if (this._sampleRate === 0) {\n isSampledIn = false;\n } else {\n isSampledIn = this._getSamplingHashCode(traceId) < this._sampleRate;\n }\n // Add sample rate as span attribute\n attributes = attributes || {};\n\n // Only send the sample rate if it's not 100\n if (this._sampleRate !== 100) {\n attributes[AzureMonitorSampleRate] = this._sampleRate;\n }\n return isSampledIn\n ? { decision: SamplingDecision.RECORD_AND_SAMPLED, attributes: attributes }\n : { decision: SamplingDecision.NOT_RECORD, attributes: attributes };\n }\n\n /**\n * Return Sampler description\n */\n public toString(): string {\n return `ApplicationInsightsSampler{${this.samplingRatio}}`;\n }\n\n private _getSamplingHashCode(input: string): number {\n const csharpMin = -2147483648;\n const csharpMax = 2147483647;\n let hash = 5381;\n\n if (!input) {\n return 0;\n }\n\n while (input.length < 8) {\n input = input + input;\n }\n\n for (let i = 0; i < input.length; i++) {\n // JS doesn't respond to integer overflow by wrapping around. Simulate it with bitwise operators ( | 0)\n hash = ((((hash << 5) + hash) | 0) + input.charCodeAt(i)) | 0;\n }\n\n hash = hash <= csharpMin ? csharpMax : Math.abs(hash);\n return (hash / csharpMax) * 100;\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"sampling.d.ts","sourceRoot":"","sources":["../../src/sampling.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAI7E;;;;;GAKG;AACH,qBAAa,0BAA2B,YAAW,OAAO;IACxD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IAEvC;;;OAGG;gBACS,aAAa,GAAE,MAAU;IAQrC;;;;;;;;;;;;;OAaG;IACI,YAAY,CAEjB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EAEf,QAAQ,EAAE,MAAM,EAEhB,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,UAAU,EAEtB,KAAK,EAAE,IAAI,EAAE,GACZ,cAAc;IAqBjB;;OAEG;IACI,QAAQ,IAAI,MAAM;IAIzB,OAAO,CAAC,oBAAoB;CAqB7B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"sampling.js","sourceRoot":"","sources":["../../src/sampling.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM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AAgB,CAAC,kBAAkB,EAAE,UAAU,EAAE,UAAU,EAAE;YAC3E,CAAC,CAAC,EAAE,QAAQ,EAAE,gBAAgB,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC;IACxE,CAAC;IAED;;OAEG;IACI,QAAQ;QACb,OAAO,8BAA8B,IAAI,CAAC,aAAa,GAAG,CAAC;IAC7D,CAAC;IAEO,oBAAoB,CAAC,KAAa;QACxC,MAAM,SAAS,GAAG,CAAC,UAAU,CAAC;QAC9B,MAAM,SAAS,GAAG,UAAU,CAAC;QAC7B,IAAI,IAAI,GAAG,IAAI,CAAC;QAEhB,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,CAAC;QACX,CAAC;QAED,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;QACxB,CAAC;QAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,uGAAuG;YACvG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAChE,CAAC;QAED,IAAI,GAAG,IAAI,IAAI,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACtD,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,GAAG,GAAG,CAAC;IAClC,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { Link, Attributes, SpanKind, Context } from \"@opentelemetry/api\";\nimport type { Sampler, SamplingResult } from \"@opentelemetry/sdk-trace-base\";\nimport { SamplingDecision } from \"@opentelemetry/sdk-trace-base\";\nimport { AzureMonitorSampleRate } from \"./utils/constants/applicationinsights.js\";\n\n/**\n * ApplicationInsightsSampler is responsible for the following:\n * Implements same trace id hashing algorithm so that traces are sampled the same across multiple nodes\n * Adds item count to span attribute if span is sampled (needed for ingestion service)\n * @param samplingRatio - 0 to 1 value.\n */\nexport class ApplicationInsightsSampler implements Sampler {\n private readonly _sampleRate: number;\n private readonly samplingRatio: number;\n\n /**\n * Initializes a new instance of the ApplicationInsightsSampler class.\n * @param samplingRatio - Value in the range [0,1], 1 meaning all data will sampled and 0 all Tracing data will be sampled out.\n */\n constructor(samplingRatio: number = 1) {\n this.samplingRatio = samplingRatio;\n if (this.samplingRatio > 1 || this.samplingRatio < 0 || !Number.isFinite(this.samplingRatio)) {\n throw new Error(\"Wrong sampling rate, data will not be sampled out\");\n }\n this._sampleRate = Math.round(this.samplingRatio * 100);\n }\n\n /**\n * Checks whether span needs to be created and tracked.\n *\n * @param context - Parent Context which may contain a span.\n * @param traceId - traceif of the span to be created. It can be different from the\n * traceId in the {@link SpanContext}. Typically in situations when the\n * span to be created starts a new trace.\n * @param spanName - Name of the span to be created.\n * @param spanKind - Kind of the span to be created.\n * @param attributes - Initial set of SpanAttributes for the Span being constructed.\n * @param links - Collection of links that will be associated with the Span to\n * be created. Typically useful for batch operations.\n * @returns a {@link SamplingResult}.\n */\n public shouldSample(\n // @ts-expect-error unused argument\n context: Context,\n traceId: string,\n // @ts-expect-error unused argument\n spanName: string,\n // @ts-expect-error unused argument\n spanKind: SpanKind,\n attributes: Attributes,\n // @ts-expect-error unused argument\n links: Link[],\n ): SamplingResult {\n let isSampledIn = false;\n if (this._sampleRate === 100) {\n isSampledIn = true;\n } else if (this._sampleRate === 0) {\n isSampledIn = false;\n } else {\n isSampledIn = this._getSamplingHashCode(traceId) < this._sampleRate;\n }\n // Add sample rate as span attribute\n attributes = attributes || {};\n\n // Only send the sample rate if it's not 100\n if (this._sampleRate !== 100) {\n attributes[AzureMonitorSampleRate] = this._sampleRate;\n }\n return isSampledIn\n ? { decision: SamplingDecision.RECORD_AND_SAMPLED, attributes: attributes }\n : { decision: SamplingDecision.NOT_RECORD, attributes: attributes };\n }\n\n /**\n * Return Sampler description\n */\n public toString(): string {\n return `ApplicationInsightsSampler{${this.samplingRatio}}`;\n }\n\n private _getSamplingHashCode(input: string): number {\n const csharpMin = -2147483648;\n const csharpMax = 2147483647;\n let hash = 5381;\n\n if (!input) {\n return 0;\n }\n\n while (input.length < 8) {\n input = input + input;\n }\n\n for (let i = 0; i < input.length; i++) {\n // JS doesn't respond to integer overflow by wrapping around. Simulate it with bitwise operators ( | 0)\n hash = ((((hash << 5) + hash) | 0) + input.charCodeAt(i)) | 0;\n }\n\n hash = hash <= csharpMin ? csharpMax : Math.abs(hash);\n return (hash / csharpMax) * 100;\n }\n}\n"]}