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,EACA,SAAU,SAAS/J,EAAK,cAAe,EAAE,EACzC,KAAMA,EAAK,IACb,EAEA,OAAAA,EAAK,YAAY,QAAS0J,GAAS,CAC7BA,EAAK,MAAM,YACb7I,EAAK6I,EAAK,GAAG,EAAIA,EAAK,MAAM,WAE1BA,EAAK,MAAM,cACb7I,EAAK6I,EAAK,GAAG,EAAIA,EAAK,MAAM,aAE1BA,EAAK,MAAM,WACb7I,EAAK6I,EAAK,GAAG,EAAIA,EAAK,MAAM,UAE1BA,EAAK,MAAM,cACb7I,EAAK6I,EAAK,GAAG,EAAIA,EAAK,MAAM,YAEhC,CAAC,EAEM7I,CACT,CAEA,MAAM8H,EAAyB,CAC7B,KAAM,CACJ,IAAIrE,EAAA,EAAiB,CACnB,OAAQ,CACN,CACE,KAAM,QACN,KAAM,WACN,OAAQ,CAAC,CACX,CACF,EACA,KAAM,CACJ,2BAA4B,QAC5B,OAAQ,CACN,YAAa,MACf,CACF,CACF,CAAC,CACH,CACF,C","sources":["webpack://grafana/./public/app/core/utils/tracing.ts","webpack://grafana/./public/app/plugins/datasource/tempo/graphTransform.ts","webpack://grafana/../../opt/drone/yarncache/@opentelemetry-api-npm-1.3.0-ebd4eb9ded-33d284b67b.zip/node_modules/@opentelemetry/api/build/esm/trace/status.js","webpack://grafana/../../opt/drone/yarncache/@opentelemetry-semantic-conventions-npm-1.8.0-176c000826-df30ad9486.zip/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/SemanticResourceAttributes.js","webpack://grafana/./public/app/plugins/datasource/tempo/resultTransformer.ts"],"sourcesContent":["/**\n * Get non overlapping duration of the ranges as they can overlap or have gaps.\n */\nimport { FieldType, MutableDataFrame, NodeGraphDataFrameFieldNames as Fields } from '@grafana/data';\n\nexport function getNonOverlappingDuration(ranges: Array<[number, number]>): number {\n ranges.sort((a, b) => a[0] - b[0]);\n const mergedRanges = ranges.reduce((acc, range) => {\n if (!acc.length) {\n return [range];\n }\n const tail = acc.slice(-1)[0];\n const [prevStart, prevEnd] = tail;\n const [start, end] = range;\n if (end < prevEnd) {\n // In this case the range is completely inside the prev range so we can just ignore it.\n return acc;\n }\n\n if (start > prevEnd) {\n // There is no overlap so we can just add it to stack\n return [...acc, range];\n }\n\n // We know there is overlap and current range ends later than previous so we can just extend the range\n return [...acc.slice(0, -1), [prevStart, end]] as Array<[number, number]>;\n }, [] as Array<[number, number]>);\n\n return mergedRanges.reduce((acc, range) => {\n return acc + (range[1] - range[0]);\n }, 0);\n}\n\n/**\n * Returns a map of the spans with children array for easier processing. It will also contain empty spans in case\n * span is missing but other spans are its children. This is more generic because it needs to allow iterating over\n * both arrays and dataframe views.\n */\nexport function makeSpanMap(getSpan: (index: number) => { span: T; id: string; parentIds: string[] } | undefined): {\n [id: string]: { span: T; children: string[] };\n} {\n const spanMap: { [id: string]: { span?: T; children: string[] } } = {};\n\n let span;\n for (let index = 0; (span = getSpan(index)), !!span; index++) {\n if (!spanMap[span.id]) {\n spanMap[span.id] = {\n span: span.span,\n children: [],\n };\n } else {\n spanMap[span.id].span = span.span;\n }\n\n for (const parentId of span.parentIds) {\n if (parentId) {\n if (!spanMap[parentId]) {\n spanMap[parentId] = {\n span: undefined,\n children: [span.id],\n };\n } else {\n spanMap[parentId].children.push(span.id);\n }\n }\n }\n }\n return spanMap as { [id: string]: { span: T; children: string[] } };\n}\n\nexport function getStats(duration: number, traceDuration: number, selfDuration: number) {\n return {\n main: `${toFixedNoTrailingZeros(duration)}ms (${toFixedNoTrailingZeros((duration / traceDuration) * 100)}%)`,\n secondary: `${toFixedNoTrailingZeros(selfDuration)}ms (${toFixedNoTrailingZeros(\n (selfDuration / duration) * 100\n )}%)`,\n };\n}\n\nfunction toFixedNoTrailingZeros(n: number) {\n return parseFloat(n.toFixed(2));\n}\n\n/**\n * Create default frames used when returning data for node graph.\n */\nexport function makeFrames() {\n const nodesFrame = new MutableDataFrame({\n fields: [\n { name: Fields.id, type: FieldType.string },\n { name: Fields.title, type: FieldType.string },\n { name: Fields.subTitle, type: FieldType.string },\n { name: Fields.mainStat, type: FieldType.string, config: { displayName: 'Total time (% of trace)' } },\n { name: Fields.secondaryStat, type: FieldType.string, config: { displayName: 'Self time (% of total)' } },\n {\n name: Fields.color,\n type: FieldType.number,\n config: { color: { mode: 'continuous-GrYlRd' }, displayName: 'Self time / Trace duration' },\n },\n ],\n meta: {\n preferredVisualisationType: 'nodeGraph',\n },\n });\n\n const edgesFrame = new MutableDataFrame({\n fields: [\n { name: Fields.id, type: FieldType.string },\n { name: Fields.target, type: FieldType.string },\n { name: Fields.source, type: FieldType.string },\n ],\n meta: {\n preferredVisualisationType: 'nodeGraph',\n },\n });\n\n return [nodesFrame, edgesFrame];\n}\n","import {\n DataFrame,\n DataFrameView,\n DataQueryResponse,\n FieldColorModeId,\n FieldDTO,\n MutableDataFrame,\n NodeGraphDataFrameFieldNames as Fields,\n TimeRange,\n} from '@grafana/data';\n\nimport { getNonOverlappingDuration, getStats, makeFrames, makeSpanMap } from '../../../core/utils/tracing';\n\n/**\n * Row in a trace dataFrame\n */\ninterface Row {\n traceID: string;\n spanID: string;\n parentSpanID: string;\n operationName: string;\n serviceName: string;\n serviceTags: string;\n startTime: number;\n duration: number;\n logs: string;\n tags: string;\n}\n\ninterface Node {\n [Fields.id]: string;\n [Fields.title]: string;\n [Fields.subTitle]: string;\n [Fields.mainStat]: string;\n [Fields.secondaryStat]: string;\n [Fields.color]: number;\n}\n\ninterface Edge {\n [Fields.id]: string;\n [Fields.target]: string;\n [Fields.source]: string;\n}\n\nexport function createGraphFrames(data: DataFrame): DataFrame[] {\n const { nodes, edges } = convertTraceToGraph(data);\n const [nodesFrame, edgesFrame] = makeFrames();\n\n for (const node of nodes) {\n nodesFrame.add(node);\n }\n for (const edge of edges) {\n edgesFrame.add(edge);\n }\n\n return [nodesFrame, edgesFrame];\n}\n\nfunction convertTraceToGraph(data: DataFrame): { nodes: Node[]; edges: Edge[] } {\n const nodes: Node[] = [];\n const edges: Edge[] = [];\n\n const view = new DataFrameView(data);\n\n const traceDuration = findTraceDuration(view);\n const spanMap = makeSpanMap((index) => {\n if (index >= data.length) {\n return undefined;\n }\n const span = view.get(index);\n return {\n span: { ...span },\n id: span.spanID,\n parentIds: span.parentSpanID ? [span.parentSpanID] : [],\n };\n });\n\n for (let i = 0; i < view.length; i++) {\n const row = view.get(i);\n\n const ranges: Array<[number, number]> = spanMap[row.spanID].children.map((c) => {\n const span = spanMap[c].span;\n return [span.startTime, span.startTime + span.duration];\n });\n const childrenDuration = getNonOverlappingDuration(ranges);\n const selfDuration = row.duration - childrenDuration;\n const stats = getStats(row.duration, traceDuration, selfDuration);\n\n nodes.push({\n [Fields.id]: row.spanID,\n [Fields.title]: row.serviceName ?? '',\n [Fields.subTitle]: row.operationName,\n [Fields.mainStat]: stats.main,\n [Fields.secondaryStat]: stats.secondary,\n [Fields.color]: selfDuration / traceDuration,\n });\n\n // Sometimes some span can be missing. Don't add edges for those.\n if (row.parentSpanID && spanMap[row.parentSpanID].span) {\n edges.push({\n [Fields.id]: row.parentSpanID + '--' + row.spanID,\n [Fields.target]: row.spanID,\n [Fields.source]: row.parentSpanID,\n });\n }\n }\n\n return { nodes, edges };\n}\n\n/**\n * Get the duration of the whole trace as it isn't a part of the response data.\n * Note: Seems like this should be the same as just longest span, but this is probably safer.\n */\nfunction findTraceDuration(view: DataFrameView): number {\n let traceEndTime = 0;\n let traceStartTime = Infinity;\n\n for (let i = 0; i < view.length; i++) {\n const row = view.get(i);\n\n if (row.startTime < traceStartTime) {\n traceStartTime = row.startTime;\n }\n\n if (row.startTime + row.duration > traceEndTime) {\n traceEndTime = row.startTime + row.duration;\n }\n }\n\n return traceEndTime - traceStartTime;\n}\n\nexport const secondsMetric = 'traces_service_graph_request_server_seconds_sum';\nexport const totalsMetric = 'traces_service_graph_request_total';\nexport const failedMetric = 'traces_service_graph_request_failed_total';\nexport const histogramMetric = 'traces_service_graph_request_server_seconds_bucket';\n\nexport const rateMetric = {\n expr: 'topk(5, sum(rate(traces_spanmetrics_calls_total{}[$__range])) by (span_name))',\n params: [],\n};\nexport const errorRateMetric = {\n expr: 'topk(5, sum(rate(traces_spanmetrics_calls_total{}[$__range])) by (span_name))',\n params: ['status_code=\"STATUS_CODE_ERROR\"'],\n};\nexport const durationMetric = {\n expr: 'histogram_quantile(.9, sum(rate(traces_spanmetrics_latency_bucket{}[$__range])) by (le))',\n params: [],\n};\nexport const defaultTableFilter = 'span_kind=\"SPAN_KIND_SERVER\"';\n\nexport const serviceMapMetrics = [\n secondsMetric,\n totalsMetric,\n failedMetric,\n histogramMetric,\n // These are used for debugging the tempo collection so probably not useful for service map right now.\n // 'traces_service_graph_unpaired_spans_total',\n // 'traces_service_graph_untagged_spans_total',\n];\n\n/**\n * Map response from multiple prometheus metrics into a node graph data frames with nodes and edges.\n * @param responses\n * @param range\n */\nexport function mapPromMetricsToServiceMap(\n responses: DataQueryResponse[],\n range: TimeRange\n): { nodes: DataFrame; edges: DataFrame } {\n const frames = getMetricFrames(responses);\n\n // First just collect data from the metrics into a map with nodes and edges as keys\n const nodesMap: Record = {};\n const edgesMap: Record = {};\n // At this moment we don't have any error/success or other counts so we just use these 2\n collectMetricData(frames[totalsMetric], 'total', totalsMetric, nodesMap, edgesMap);\n collectMetricData(frames[secondsMetric], 'seconds', secondsMetric, nodesMap, edgesMap);\n collectMetricData(frames[failedMetric], 'failed', failedMetric, nodesMap, edgesMap);\n\n return convertToDataFrames(nodesMap, edgesMap, range);\n}\n\nfunction createServiceMapDataFrames() {\n function createDF(name: string, fields: FieldDTO[]) {\n return new MutableDataFrame({ name, fields, meta: { preferredVisualisationType: 'nodeGraph' } });\n }\n\n const nodes = createDF('Nodes', [\n { name: Fields.id },\n { name: Fields.title, config: { displayName: 'Service name' } },\n { name: Fields.mainStat, config: { unit: 'ms/r', displayName: 'Average response time' } },\n {\n name: Fields.secondaryStat,\n config: { unit: 'r/sec', displayName: 'Requests per second' },\n },\n {\n name: Fields.arc + 'success',\n config: { displayName: 'Success', color: { fixedColor: 'green', mode: FieldColorModeId.Fixed } },\n },\n {\n name: Fields.arc + 'failed',\n config: { displayName: 'Failed', color: { fixedColor: 'red', mode: FieldColorModeId.Fixed } },\n },\n ]);\n const edges = createDF('Edges', [\n { name: Fields.id },\n { name: Fields.source },\n { name: Fields.target },\n { name: Fields.mainStat, config: { unit: 'ms/r', displayName: 'Average response time' } },\n { name: Fields.secondaryStat, config: { unit: 'r/sec', displayName: 'Requests per second' } },\n ]);\n\n return [nodes, edges];\n}\n\n/**\n * Group frames from response based on ref id which is set the same as the metric name so we know which metric is where\n * and also put it into DataFrameView so it's easier to work with.\n * @param responses\n */\nfunction getMetricFrames(responses: DataQueryResponse[]): Record {\n return responses[0].data.reduce>((acc, frame) => {\n acc[frame.refId] = new DataFrameView(frame);\n return acc;\n }, {});\n}\n\ntype ServiceMapStatistics = {\n total?: number;\n seconds?: number;\n failed?: number;\n};\n\ntype EdgeObject = ServiceMapStatistics & {\n source: string;\n target: string;\n};\n\n/**\n * Collect data from a metric into a map of nodes and edges. The metric data is modeled as counts of metric per edge\n * which is a pair of client-server nodes. This means we convert each row of the metric 1-1 to edges and than we assign\n * the metric also to server. We count the stats for server only as we show requests/transactions that particular node\n * processed not those which it generated and other stats like average transaction time then stem from that.\n * @param frame\n * @param stat\n * @param metric\n * @param nodesMap\n * @param edgesMap\n */\nfunction collectMetricData(\n frame: DataFrameView | undefined,\n stat: keyof ServiceMapStatistics,\n metric: string,\n nodesMap: Record,\n edgesMap: Record\n) {\n if (!frame) {\n return;\n }\n\n // The name of the value column is in this format\n // TODO figure out if it can be changed\n const valueName = `Value #${metric}`;\n\n for (let i = 0; i < frame.length; i++) {\n const row = frame.get(i);\n const edgeId = `${row.client}_${row.server}`;\n\n if (!edgesMap[edgeId]) {\n // Create edge as it does not exist yet\n edgesMap[edgeId] = {\n target: row.server,\n source: row.client,\n [stat]: row[valueName],\n };\n } else {\n // Add stat to edge\n // We are adding the values if exists but that should not happen in general as there should be single row for\n // an edge.\n edgesMap[edgeId][stat] = (edgesMap[edgeId][stat] || 0) + row[valueName];\n }\n\n if (!nodesMap[row.server]) {\n // Create node for server\n nodesMap[row.server] = {\n [stat]: row[valueName],\n };\n } else {\n // Add stat to server node. Sum up values if there are multiple edges targeting this server node.\n nodesMap[row.server][stat] = (nodesMap[row.server][stat] || 0) + row[valueName];\n }\n\n if (!nodesMap[row.client]) {\n // Create the client node but don't add the stat as edge stats are attributed to the server node. This means for\n // example that the number of requests in a node show how many requests it handled not how many it generated.\n nodesMap[row.client] = {\n [stat]: 0,\n };\n }\n }\n}\n\nfunction convertToDataFrames(\n nodesMap: Record,\n edgesMap: Record,\n range: TimeRange\n): { nodes: DataFrame; edges: DataFrame } {\n const rangeMs = range.to.valueOf() - range.from.valueOf();\n const [nodes, edges] = createServiceMapDataFrames();\n for (const nodeId of Object.keys(nodesMap)) {\n const node = nodesMap[nodeId];\n nodes.add({\n [Fields.id]: nodeId,\n [Fields.title]: nodeId,\n // NaN will not be shown in the node graph. This happens for a root client node which did not process\n // any requests itself.\n [Fields.mainStat]: node.total ? (node.seconds! / node.total) * 1000 : Number.NaN, // Average response time\n [Fields.secondaryStat]: node.total ? Math.round((node.total / (rangeMs / 1000)) * 100) / 100 : Number.NaN, // Request per second (to 2 decimals)\n [Fields.arc + 'success']: node.total ? (node.total - Math.min(node.failed || 0, node.total)) / node.total : 1,\n [Fields.arc + 'failed']: node.total ? Math.min(node.failed || 0, node.total) / node.total : 0,\n });\n }\n for (const edgeId of Object.keys(edgesMap)) {\n const edge = edgesMap[edgeId];\n edges.add({\n [Fields.id]: edgeId,\n [Fields.source]: edge.source,\n [Fields.target]: edge.target,\n [Fields.mainStat]: edge.total ? (edge.seconds! / edge.total) * 1000 : Number.NaN, // Average response time\n [Fields.secondaryStat]: edge.total ? Math.round((edge.total / (rangeMs / 1000)) * 100) / 100 : Number.NaN, // Request per second (to 2 decimals)\n });\n }\n\n return { nodes, edges };\n}\n","/**\n * An enumeration of status codes.\n */\nexport var SpanStatusCode;\n(function (SpanStatusCode) {\n /**\n * The default status.\n */\n SpanStatusCode[SpanStatusCode[\"UNSET\"] = 0] = \"UNSET\";\n /**\n * The operation has been validated by an Application developer or\n * Operator to have completed successfully.\n */\n SpanStatusCode[SpanStatusCode[\"OK\"] = 1] = \"OK\";\n /**\n * The operation contains an error.\n */\n SpanStatusCode[SpanStatusCode[\"ERROR\"] = 2] = \"ERROR\";\n})(SpanStatusCode || (SpanStatusCode = {}));\n//# sourceMappingURL=status.js.map","/*\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// DO NOT EDIT, this is an Auto-generated file from scripts/semconv/templates//templates/SemanticAttributes.ts.j2\nexport var SemanticResourceAttributes = {\n /**\n * Name of the cloud provider.\n */\n CLOUD_PROVIDER: 'cloud.provider',\n /**\n * The cloud account ID the resource is assigned to.\n */\n CLOUD_ACCOUNT_ID: 'cloud.account.id',\n /**\n * The geographical region the resource is running. Refer to your provider's docs to see the available regions, for example [Alibaba Cloud regions](https://www.alibabacloud.com/help/doc-detail/40654.htm), [AWS regions](https://aws.amazon.com/about-aws/global-infrastructure/regions_az/), [Azure regions](https://azure.microsoft.com/en-us/global-infrastructure/geographies/), or [Google Cloud regions](https://cloud.google.com/about/locations).\n */\n CLOUD_REGION: 'cloud.region',\n /**\n * Cloud regions often have multiple, isolated locations known as zones to increase availability. Availability zone represents the zone where the resource is running.\n *\n * Note: Availability zones are called "zones" on Alibaba Cloud and Google Cloud.\n */\n CLOUD_AVAILABILITY_ZONE: 'cloud.availability_zone',\n /**\n * The cloud platform in use.\n *\n * Note: The prefix of the service SHOULD match the one specified in `cloud.provider`.\n */\n CLOUD_PLATFORM: 'cloud.platform',\n /**\n * The Amazon Resource Name (ARN) of an [ECS container instance](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ECS_instances.html).\n */\n AWS_ECS_CONTAINER_ARN: 'aws.ecs.container.arn',\n /**\n * The ARN of an [ECS cluster](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/clusters.html).\n */\n AWS_ECS_CLUSTER_ARN: 'aws.ecs.cluster.arn',\n /**\n * The [launch type](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/launch_types.html) for an ECS task.\n */\n AWS_ECS_LAUNCHTYPE: 'aws.ecs.launchtype',\n /**\n * The ARN of an [ECS task definition](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definitions.html).\n */\n AWS_ECS_TASK_ARN: 'aws.ecs.task.arn',\n /**\n * The task definition family this task definition is a member of.\n */\n AWS_ECS_TASK_FAMILY: 'aws.ecs.task.family',\n /**\n * The revision for this task definition.\n */\n AWS_ECS_TASK_REVISION: 'aws.ecs.task.revision',\n /**\n * The ARN of an EKS cluster.\n */\n AWS_EKS_CLUSTER_ARN: 'aws.eks.cluster.arn',\n /**\n * The name(s) of the AWS log group(s) an application is writing to.\n *\n * Note: Multiple log groups must be supported for cases like multi-container applications, where a single application has sidecar containers, and each write to their own log group.\n */\n AWS_LOG_GROUP_NAMES: 'aws.log.group.names',\n /**\n * The Amazon Resource Name(s) (ARN) of the AWS log group(s).\n *\n * Note: See the [log group ARN format documentation](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/iam-access-control-overview-cwl.html#CWL_ARN_Format).\n */\n AWS_LOG_GROUP_ARNS: 'aws.log.group.arns',\n /**\n * The name(s) of the AWS log stream(s) an application is writing to.\n */\n AWS_LOG_STREAM_NAMES: 'aws.log.stream.names',\n /**\n * The ARN(s) of the AWS log stream(s).\n *\n * Note: See the [log stream ARN format documentation](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/iam-access-control-overview-cwl.html#CWL_ARN_Format). One log group can contain several log streams, so these ARNs necessarily identify both a log group and a log stream.\n */\n AWS_LOG_STREAM_ARNS: 'aws.log.stream.arns',\n /**\n * Container name.\n */\n CONTAINER_NAME: 'container.name',\n /**\n * Container ID. Usually a UUID, as for example used to [identify Docker containers](https://docs.docker.com/engine/reference/run/#container-identification). The UUID might be abbreviated.\n */\n CONTAINER_ID: 'container.id',\n /**\n * The container runtime managing this container.\n */\n CONTAINER_RUNTIME: 'container.runtime',\n /**\n * Name of the image the container was built on.\n */\n CONTAINER_IMAGE_NAME: 'container.image.name',\n /**\n * Container image tag.\n */\n CONTAINER_IMAGE_TAG: 'container.image.tag',\n /**\n * Name of the [deployment environment](https://en.wikipedia.org/wiki/Deployment_environment) (aka deployment tier).\n */\n DEPLOYMENT_ENVIRONMENT: 'deployment.environment',\n /**\n * A unique identifier representing the device.\n *\n * Note: The device identifier MUST only be defined using the values outlined below. This value is not an advertising identifier and MUST NOT be used as such. On iOS (Swift or Objective-C), this value MUST be equal to the [vendor identifier](https://developer.apple.com/documentation/uikit/uidevice/1620059-identifierforvendor). On Android (Java or Kotlin), this value MUST be equal to the Firebase Installation ID or a globally unique UUID which is persisted across sessions in your application. More information can be found [here](https://developer.android.com/training/articles/user-data-ids) on best practices and exact implementation details. Caution should be taken when storing personal data or anything which can identify a user. GDPR and data protection laws may apply, ensure you do your own due diligence.\n */\n DEVICE_ID: 'device.id',\n /**\n * The model identifier for the device.\n *\n * Note: It's recommended this value represents a machine readable version of the model identifier rather than the market or consumer-friendly name of the device.\n */\n DEVICE_MODEL_IDENTIFIER: 'device.model.identifier',\n /**\n * The marketing name for the device model.\n *\n * Note: It's recommended this value represents a human readable version of the device model rather than a machine readable alternative.\n */\n DEVICE_MODEL_NAME: 'device.model.name',\n /**\n * The name of the single function that this runtime instance executes.\n *\n * Note: This is the name of the function as configured/deployed on the FaaS platform and is usually different from the name of the callback function (which may be stored in the [`code.namespace`/`code.function`](../../trace/semantic_conventions/span-general.md#source-code-attributes) span attributes).\n */\n FAAS_NAME: 'faas.name',\n /**\n * The unique ID of the single function that this runtime instance executes.\n *\n * Note: Depending on the cloud provider, use:\n \n * **AWS Lambda:** The function [ARN](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html).\n Take care not to use the "invoked ARN" directly but replace any\n [alias suffix](https://docs.aws.amazon.com/lambda/latest/dg/configuration-aliases.html) with the resolved function version, as the same runtime instance may be invokable with multiple\n different aliases.\n * **GCP:** The [URI of the resource](https://cloud.google.com/iam/docs/full-resource-names)\n * **Azure:** The [Fully Qualified Resource ID](https://docs.microsoft.com/en-us/rest/api/resources/resources/get-by-id).\n \n On some providers, it may not be possible to determine the full ID at startup,\n which is why this field cannot be made required. For example, on AWS the account ID\n part of the ARN is not available without calling another AWS API\n which may be deemed too slow for a short-running lambda function.\n As an alternative, consider setting `faas.id` as a span attribute instead.\n */\n FAAS_ID: 'faas.id',\n /**\n * The immutable version of the function being executed.\n *\n * Note: Depending on the cloud provider and platform, use:\n \n * **AWS Lambda:** The [function version](https://docs.aws.amazon.com/lambda/latest/dg/configuration-versions.html)\n (an integer represented as a decimal string).\n * **Google Cloud Run:** The [revision](https://cloud.google.com/run/docs/managing/revisions)\n (i.e., the function name plus the revision suffix).\n * **Google Cloud Functions:** The value of the\n [`K_REVISION` environment variable](https://cloud.google.com/functions/docs/env-var#runtime_environment_variables_set_automatically).\n * **Azure Functions:** Not applicable. Do not set this attribute.\n */\n FAAS_VERSION: 'faas.version',\n /**\n * The execution environment ID as a string, that will be potentially reused for other invocations to the same function/function version.\n *\n * Note: * **AWS Lambda:** Use the (full) log stream name.\n */\n FAAS_INSTANCE: 'faas.instance',\n /**\n * The amount of memory available to the serverless function in MiB.\n *\n * Note: It's recommended to set this attribute since e.g. too little memory can easily stop a Java AWS Lambda function from working correctly. On AWS Lambda, the environment variable `AWS_LAMBDA_FUNCTION_MEMORY_SIZE` provides this information.\n */\n FAAS_MAX_MEMORY: 'faas.max_memory',\n /**\n * Unique host ID. For Cloud, this must be the instance_id assigned by the cloud provider.\n */\n HOST_ID: 'host.id',\n /**\n * Name of the host. On Unix systems, it may contain what the hostname command returns, or the fully qualified hostname, or another name specified by the user.\n */\n HOST_NAME: 'host.name',\n /**\n * Type of host. For Cloud, this must be the machine type.\n */\n HOST_TYPE: 'host.type',\n /**\n * The CPU architecture the host system is running on.\n */\n HOST_ARCH: 'host.arch',\n /**\n * Name of the VM image or OS install the host was instantiated from.\n */\n HOST_IMAGE_NAME: 'host.image.name',\n /**\n * VM image ID. For Cloud, this value is from the provider.\n */\n HOST_IMAGE_ID: 'host.image.id',\n /**\n * The version string of the VM image as defined in [Version SpanAttributes](README.md#version-attributes).\n */\n HOST_IMAGE_VERSION: 'host.image.version',\n /**\n * The name of the cluster.\n */\n K8S_CLUSTER_NAME: 'k8s.cluster.name',\n /**\n * The name of the Node.\n */\n K8S_NODE_NAME: 'k8s.node.name',\n /**\n * The UID of the Node.\n */\n K8S_NODE_UID: 'k8s.node.uid',\n /**\n * The name of the namespace that the pod is running in.\n */\n K8S_NAMESPACE_NAME: 'k8s.namespace.name',\n /**\n * The UID of the Pod.\n */\n K8S_POD_UID: 'k8s.pod.uid',\n /**\n * The name of the Pod.\n */\n K8S_POD_NAME: 'k8s.pod.name',\n /**\n * The name of the Container in a Pod template.\n */\n K8S_CONTAINER_NAME: 'k8s.container.name',\n /**\n * The UID of the ReplicaSet.\n */\n K8S_REPLICASET_UID: 'k8s.replicaset.uid',\n /**\n * The name of the ReplicaSet.\n */\n K8S_REPLICASET_NAME: 'k8s.replicaset.name',\n /**\n * The UID of the Deployment.\n */\n K8S_DEPLOYMENT_UID: 'k8s.deployment.uid',\n /**\n * The name of the Deployment.\n */\n K8S_DEPLOYMENT_NAME: 'k8s.deployment.name',\n /**\n * The UID of the StatefulSet.\n */\n K8S_STATEFULSET_UID: 'k8s.statefulset.uid',\n /**\n * The name of the StatefulSet.\n */\n K8S_STATEFULSET_NAME: 'k8s.statefulset.name',\n /**\n * The UID of the DaemonSet.\n */\n K8S_DAEMONSET_UID: 'k8s.daemonset.uid',\n /**\n * The name of the DaemonSet.\n */\n K8S_DAEMONSET_NAME: 'k8s.daemonset.name',\n /**\n * The UID of the Job.\n */\n K8S_JOB_UID: 'k8s.job.uid',\n /**\n * The name of the Job.\n */\n K8S_JOB_NAME: 'k8s.job.name',\n /**\n * The UID of the CronJob.\n */\n K8S_CRONJOB_UID: 'k8s.cronjob.uid',\n /**\n * The name of the CronJob.\n */\n K8S_CRONJOB_NAME: 'k8s.cronjob.name',\n /**\n * The operating system type.\n */\n OS_TYPE: 'os.type',\n /**\n * Human readable (not intended to be parsed) OS version information, like e.g. reported by `ver` or `lsb_release -a` commands.\n */\n OS_DESCRIPTION: 'os.description',\n /**\n * Human readable operating system name.\n */\n OS_NAME: 'os.name',\n /**\n * The version string of the operating system as defined in [Version SpanAttributes](../../resource/semantic_conventions/README.md#version-attributes).\n */\n OS_VERSION: 'os.version',\n /**\n * Process identifier (PID).\n */\n PROCESS_PID: 'process.pid',\n /**\n * The name of the process executable. On Linux based systems, can be set to the `Name` in `proc/[pid]/status`. On Windows, can be set to the base name of `GetProcessImageFileNameW`.\n */\n PROCESS_EXECUTABLE_NAME: 'process.executable.name',\n /**\n * The full path to the process executable. On Linux based systems, can be set to the target of `proc/[pid]/exe`. On Windows, can be set to the result of `GetProcessImageFileNameW`.\n */\n PROCESS_EXECUTABLE_PATH: 'process.executable.path',\n /**\n * The command used to launch the process (i.e. the command name). On Linux based systems, can be set to the zeroth string in `proc/[pid]/cmdline`. On Windows, can be set to the first parameter extracted from `GetCommandLineW`.\n */\n PROCESS_COMMAND: 'process.command',\n /**\n * The full command used to launch the process as a single string representing the full command. On Windows, can be set to the result of `GetCommandLineW`. Do not set this if you have to assemble it just for monitoring; use `process.command_args` instead.\n */\n PROCESS_COMMAND_LINE: 'process.command_line',\n /**\n * All the command arguments (including the command/executable itself) as received by the process. On Linux-based systems (and some other Unixoid systems supporting procfs), can be set according to the list of null-delimited strings extracted from `proc/[pid]/cmdline`. For libc-based executables, this would be the full argv vector passed to `main`.\n */\n PROCESS_COMMAND_ARGS: 'process.command_args',\n /**\n * The username of the user that owns the process.\n */\n PROCESS_OWNER: 'process.owner',\n /**\n * The name of the runtime of this process. For compiled native binaries, this SHOULD be the name of the compiler.\n */\n PROCESS_RUNTIME_NAME: 'process.runtime.name',\n /**\n * The version of the runtime of this process, as returned by the runtime without modification.\n */\n PROCESS_RUNTIME_VERSION: 'process.runtime.version',\n /**\n * An additional description about the runtime of the process, for example a specific vendor customization of the runtime environment.\n */\n PROCESS_RUNTIME_DESCRIPTION: 'process.runtime.description',\n /**\n * Logical name of the service.\n *\n * Note: MUST be the same for all instances of horizontally scaled services. If the value was not specified, SDKs MUST fallback to `unknown_service:` concatenated with [`process.executable.name`](process.md#process), e.g. `unknown_service:bash`. If `process.executable.name` is not available, the value MUST be set to `unknown_service`.\n */\n SERVICE_NAME: 'service.name',\n /**\n * A namespace for `service.name`.\n *\n * Note: A string value having a meaning that helps to distinguish a group of services, for example the team name that owns a group of services. `service.name` is expected to be unique within the same namespace. If `service.namespace` is not specified in the Resource then `service.name` is expected to be unique for all services that have no explicit namespace defined (so the empty/unspecified namespace is simply one more valid namespace). Zero-length namespace string is assumed equal to unspecified namespace.\n */\n SERVICE_NAMESPACE: 'service.namespace',\n /**\n * The string ID of the service instance.\n *\n * Note: MUST be unique for each instance of the same `service.namespace,service.name` pair (in other words `service.namespace,service.name,service.instance.id` triplet MUST be globally unique). The ID helps to distinguish instances of the same service that exist at the same time (e.g. instances of a horizontally scaled service). It is preferable for the ID to be persistent and stay the same for the lifetime of the service instance, however it is acceptable that the ID is ephemeral and changes during important lifetime events for the service (e.g. service restarts). If the service has no inherent unique ID that can be used as the value of this attribute it is recommended to generate a random Version 1 or Version 4 RFC 4122 UUID (services aiming for reproducible UUIDs may also use Version 5, see RFC 4122 for more recommendations).\n */\n SERVICE_INSTANCE_ID: 'service.instance.id',\n /**\n * The version string of the service API or implementation.\n */\n SERVICE_VERSION: 'service.version',\n /**\n * The name of the telemetry SDK as defined above.\n */\n TELEMETRY_SDK_NAME: 'telemetry.sdk.name',\n /**\n * The language of the telemetry SDK.\n */\n TELEMETRY_SDK_LANGUAGE: 'telemetry.sdk.language',\n /**\n * The version string of the telemetry SDK.\n */\n TELEMETRY_SDK_VERSION: 'telemetry.sdk.version',\n /**\n * The version string of the auto instrumentation agent, if used.\n */\n TELEMETRY_AUTO_VERSION: 'telemetry.auto.version',\n /**\n * The name of the web engine.\n */\n WEBENGINE_NAME: 'webengine.name',\n /**\n * The version of the web engine.\n */\n WEBENGINE_VERSION: 'webengine.version',\n /**\n * Additional description of the web engine (e.g. detailed version and edition information).\n */\n WEBENGINE_DESCRIPTION: 'webengine.description',\n};\nexport var CloudProviderValues = {\n /** Alibaba Cloud. */\n ALIBABA_CLOUD: 'alibaba_cloud',\n /** Amazon Web Services. */\n AWS: 'aws',\n /** Microsoft Azure. */\n AZURE: 'azure',\n /** Google Cloud Platform. */\n GCP: 'gcp',\n};\nexport var CloudPlatformValues = {\n /** Alibaba Cloud Elastic Compute Service. */\n ALIBABA_CLOUD_ECS: 'alibaba_cloud_ecs',\n /** Alibaba Cloud Function Compute. */\n ALIBABA_CLOUD_FC: 'alibaba_cloud_fc',\n /** AWS Elastic Compute Cloud. */\n AWS_EC2: 'aws_ec2',\n /** AWS Elastic Container Service. */\n AWS_ECS: 'aws_ecs',\n /** AWS Elastic Kubernetes Service. */\n AWS_EKS: 'aws_eks',\n /** AWS Lambda. */\n AWS_LAMBDA: 'aws_lambda',\n /** AWS Elastic Beanstalk. */\n AWS_ELASTIC_BEANSTALK: 'aws_elastic_beanstalk',\n /** Azure Virtual Machines. */\n AZURE_VM: 'azure_vm',\n /** Azure Container Instances. */\n AZURE_CONTAINER_INSTANCES: 'azure_container_instances',\n /** Azure Kubernetes Service. */\n AZURE_AKS: 'azure_aks',\n /** Azure Functions. */\n AZURE_FUNCTIONS: 'azure_functions',\n /** Azure App Service. */\n AZURE_APP_SERVICE: 'azure_app_service',\n /** Google Cloud Compute Engine (GCE). */\n GCP_COMPUTE_ENGINE: 'gcp_compute_engine',\n /** Google Cloud Run. */\n GCP_CLOUD_RUN: 'gcp_cloud_run',\n /** Google Cloud Kubernetes Engine (GKE). */\n GCP_KUBERNETES_ENGINE: 'gcp_kubernetes_engine',\n /** Google Cloud Functions (GCF). */\n GCP_CLOUD_FUNCTIONS: 'gcp_cloud_functions',\n /** Google Cloud App Engine (GAE). */\n GCP_APP_ENGINE: 'gcp_app_engine',\n};\nexport var AwsEcsLaunchtypeValues = {\n /** ec2. */\n EC2: 'ec2',\n /** fargate. */\n FARGATE: 'fargate',\n};\nexport var HostArchValues = {\n /** AMD64. */\n AMD64: 'amd64',\n /** ARM32. */\n ARM32: 'arm32',\n /** ARM64. */\n ARM64: 'arm64',\n /** Itanium. */\n IA64: 'ia64',\n /** 32-bit PowerPC. */\n PPC32: 'ppc32',\n /** 64-bit PowerPC. */\n PPC64: 'ppc64',\n /** 32-bit x86. */\n X86: 'x86',\n};\nexport var OsTypeValues = {\n /** Microsoft Windows. */\n WINDOWS: 'windows',\n /** Linux. */\n LINUX: 'linux',\n /** Apple Darwin. */\n DARWIN: 'darwin',\n /** FreeBSD. */\n FREEBSD: 'freebsd',\n /** NetBSD. */\n NETBSD: 'netbsd',\n /** OpenBSD. */\n OPENBSD: 'openbsd',\n /** DragonFly BSD. */\n DRAGONFLYBSD: 'dragonflybsd',\n /** HP-UX (Hewlett Packard Unix). */\n HPUX: 'hpux',\n /** AIX (Advanced Interactive eXecutive). */\n AIX: 'aix',\n /** Oracle Solaris. */\n SOLARIS: 'solaris',\n /** IBM z/OS. */\n Z_OS: 'z_os',\n};\nexport var TelemetrySdkLanguageValues = {\n /** cpp. */\n CPP: 'cpp',\n /** dotnet. */\n DOTNET: 'dotnet',\n /** erlang. */\n ERLANG: 'erlang',\n /** go. */\n GO: 'go',\n /** java. */\n JAVA: 'java',\n /** nodejs. */\n NODEJS: 'nodejs',\n /** php. */\n PHP: 'php',\n /** python. */\n PYTHON: 'python',\n /** ruby. */\n RUBY: 'ruby',\n /** webjs. */\n WEBJS: 'webjs',\n};\n//# sourceMappingURL=SemanticResourceAttributes.js.map","import { SpanStatus, SpanStatusCode } from '@opentelemetry/api';\nimport { collectorTypes } from '@opentelemetry/exporter-collector';\nimport { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';\n\nimport {\n DataFrame,\n DataQueryResponse,\n DataSourceInstanceSettings,\n FieldType,\n MutableDataFrame,\n TraceKeyValuePair,\n TraceLog,\n TraceSpanReference,\n TraceSpanRow,\n dateTimeFormat,\n FieldDTO,\n} from '@grafana/data';\n\nimport { createGraphFrames } from './graphTransform';\nimport { Span, TraceSearchMetadata } from './types';\n\nexport function createTableFrame(\n logsFrame: DataFrame,\n datasourceUid: string,\n datasourceName: string,\n traceRegexs: string[]\n): DataFrame {\n const tableFrame = new MutableDataFrame({\n fields: [\n {\n name: 'Time',\n type: FieldType.time,\n config: {\n custom: {\n width: 200,\n },\n },\n },\n {\n name: 'traceID',\n type: FieldType.string,\n config: {\n displayNameFromDS: 'Trace ID',\n custom: { width: 180 },\n links: [\n {\n title: 'Click to open trace ${__value.raw}',\n url: '',\n internal: {\n datasourceUid,\n datasourceName,\n query: {\n query: '${__value.raw}',\n },\n },\n },\n ],\n },\n },\n {\n name: 'Message',\n type: FieldType.string,\n },\n ],\n meta: {\n preferredVisualisationType: 'table',\n },\n });\n\n if (!logsFrame || traceRegexs.length === 0) {\n return tableFrame;\n }\n\n const timeField = logsFrame.fields.find((f) => f.type === FieldType.time);\n\n // Going through all string fields to look for trace IDs\n for (let field of logsFrame.fields) {\n let hasMatch = false;\n if (field.type === FieldType.string) {\n const values = field.values.toArray();\n for (let i = 0; i < values.length; i++) {\n const line = values[i];\n if (line) {\n for (let traceRegex of traceRegexs) {\n const match = (line as string).match(traceRegex);\n if (match) {\n const traceId = match[1];\n const time = timeField ? timeField.values.get(i) : null;\n tableFrame.fields[0].values.add(time);\n tableFrame.fields[1].values.add(traceId);\n tableFrame.fields[2].values.add(line);\n hasMatch = true;\n }\n }\n }\n }\n }\n if (hasMatch) {\n break;\n }\n }\n\n return tableFrame;\n}\n\nexport function transformTraceList(\n response: DataQueryResponse,\n datasourceId: string,\n datasourceName: string,\n traceRegexs: string[]\n): DataQueryResponse {\n response.data.forEach((data, index) => {\n const frame = createTableFrame(data, datasourceId, datasourceName, traceRegexs);\n response.data[index] = frame;\n });\n return response;\n}\n\n// Don't forget to change the backend code when the id representation changed\nfunction transformBase64IDToHexString(base64: string) {\n const raw = atob(base64);\n let result = '';\n for (let i = 0; i < raw.length; i++) {\n const hex = raw.charCodeAt(i).toString(16);\n result += hex.length === 2 ? hex : '0' + hex;\n }\n\n return result.length > 16 ? result.slice(16) : result;\n}\n\nfunction transformHexStringToBase64ID(hex: string) {\n const hexArray = hex.match(/\\w{2}/g) || [];\n return btoa(\n hexArray\n .map(function (a) {\n return String.fromCharCode(parseInt(a, 16));\n })\n .join('')\n );\n}\n\nfunction getAttributeValue(value: collectorTypes.opentelemetryProto.common.v1.AnyValue): any {\n if (value.stringValue) {\n return value.stringValue;\n }\n\n if (value.boolValue !== undefined) {\n return Boolean(value.boolValue);\n }\n\n if (value.intValue !== undefined) {\n return Number.parseInt(value.intValue as any, 10);\n }\n\n if (value.doubleValue) {\n return Number.parseFloat(value.doubleValue as any);\n }\n\n if (value.arrayValue) {\n const arrayValue = [];\n for (const arValue of value.arrayValue.values) {\n arrayValue.push(getAttributeValue(arValue));\n }\n return arrayValue;\n }\n\n return '';\n}\n\nfunction resourceToProcess(resource: collectorTypes.opentelemetryProto.resource.v1.Resource | undefined) {\n const serviceTags: TraceKeyValuePair[] = [];\n let serviceName = 'OTLPResourceNoServiceName';\n if (!resource) {\n return { serviceName, serviceTags };\n }\n\n for (const attribute of resource.attributes) {\n if (attribute.key === SemanticResourceAttributes.SERVICE_NAME) {\n serviceName = attribute.value.stringValue || serviceName;\n }\n serviceTags.push({ key: attribute.key, value: getAttributeValue(attribute.value) });\n }\n\n return { serviceName, serviceTags };\n}\n\nfunction getSpanTags(\n span: collectorTypes.opentelemetryProto.trace.v1.Span,\n instrumentationLibrary?: collectorTypes.opentelemetryProto.common.v1.InstrumentationLibrary\n): TraceKeyValuePair[] {\n const spanTags: TraceKeyValuePair[] = [];\n\n if (instrumentationLibrary) {\n if (instrumentationLibrary.name) {\n spanTags.push({ key: 'otel.library.name', value: instrumentationLibrary.name });\n }\n if (instrumentationLibrary.version) {\n spanTags.push({ key: 'otel.library.version', value: instrumentationLibrary.version });\n }\n }\n\n if (span.attributes) {\n for (const attribute of span.attributes) {\n spanTags.push({ key: attribute.key, value: getAttributeValue(attribute.value) });\n }\n }\n\n if (span.status) {\n if (span.status.code && (span.status.code as any) !== SpanStatusCode.UNSET) {\n spanTags.push({\n key: 'otel.status_code',\n value: SpanStatusCode[span.status.code],\n });\n if (span.status.message) {\n spanTags.push({ key: 'otel.status_description', value: span.status.message });\n }\n }\n if (span.status.code === SpanStatusCode.ERROR) {\n spanTags.push({ key: 'error', value: true });\n }\n }\n\n if (span.kind !== undefined) {\n const split = span.kind.toString().toLowerCase().split('_');\n spanTags.push({\n key: 'span.kind',\n value: split.length ? split[split.length - 1] : span.kind.toString(),\n });\n }\n\n return spanTags;\n}\n\nfunction getReferences(span: collectorTypes.opentelemetryProto.trace.v1.Span) {\n const references: TraceSpanReference[] = [];\n if (span.links) {\n for (const link of span.links) {\n const { traceId, spanId } = link;\n const tags: TraceKeyValuePair[] = [];\n if (link.attributes) {\n for (const attribute of link.attributes) {\n tags.push({ key: attribute.key, value: getAttributeValue(attribute.value) });\n }\n }\n references.push({ traceID: traceId, spanID: spanId, tags });\n }\n }\n\n return references;\n}\n\nfunction getLogs(span: collectorTypes.opentelemetryProto.trace.v1.Span) {\n const logs: TraceLog[] = [];\n if (span.events) {\n for (const event of span.events) {\n const fields: TraceKeyValuePair[] = [];\n if (event.attributes) {\n for (const attribute of event.attributes) {\n fields.push({ key: attribute.key, value: getAttributeValue(attribute.value) });\n }\n }\n logs.push({ fields, timestamp: event.timeUnixNano / 1000000 });\n }\n }\n\n return logs;\n}\n\nexport function transformFromOTLP(\n traceData: collectorTypes.opentelemetryProto.trace.v1.ResourceSpans[],\n nodeGraph = false\n): DataQueryResponse {\n const frame = new MutableDataFrame({\n fields: [\n { name: 'traceID', type: FieldType.string },\n { name: 'spanID', type: FieldType.string },\n { name: 'parentSpanID', type: FieldType.string },\n { name: 'operationName', type: FieldType.string },\n { name: 'serviceName', type: FieldType.string },\n { name: 'serviceTags', type: FieldType.other },\n { name: 'startTime', type: FieldType.number },\n { name: 'duration', type: FieldType.number },\n { name: 'logs', type: FieldType.other },\n { name: 'references', type: FieldType.other },\n { name: 'tags', type: FieldType.other },\n ],\n meta: {\n preferredVisualisationType: 'trace',\n custom: {\n traceFormat: 'otlp',\n },\n },\n });\n try {\n for (const data of traceData) {\n const { serviceName, serviceTags } = resourceToProcess(data.resource);\n for (const librarySpan of data.instrumentationLibrarySpans) {\n for (const span of librarySpan.spans) {\n frame.add({\n traceID: transformBase64IDToHexString(span.traceId),\n spanID: transformBase64IDToHexString(span.spanId),\n parentSpanID: transformBase64IDToHexString(span.parentSpanId || ''),\n operationName: span.name || '',\n serviceName,\n serviceTags,\n startTime: span.startTimeUnixNano! / 1000000,\n duration: (span.endTimeUnixNano! - span.startTimeUnixNano!) / 1000000,\n tags: getSpanTags(span, librarySpan.instrumentationLibrary),\n logs: getLogs(span),\n references: getReferences(span),\n } as TraceSpanRow);\n }\n }\n }\n } catch (error) {\n console.error(error);\n return { error: { message: 'JSON is not valid OpenTelemetry format: ' + error }, data: [] };\n }\n\n let data = [frame];\n if (nodeGraph) {\n data.push(...(createGraphFrames(frame) as MutableDataFrame[]));\n }\n\n return { data };\n}\n\n/**\n * Transforms trace dataframes to the OpenTelemetry format\n */\nexport function transformToOTLP(data: MutableDataFrame): {\n batches: collectorTypes.opentelemetryProto.trace.v1.ResourceSpans[];\n} {\n let result: { batches: collectorTypes.opentelemetryProto.trace.v1.ResourceSpans[] } = {\n batches: [],\n };\n\n // Lookup object to see which batch contains spans for which services\n let services: { [key: string]: number } = {};\n\n for (let i = 0; i < data.length; i++) {\n const span = data.get(i);\n\n // Group spans based on service\n if (!services[span.serviceName]) {\n services[span.serviceName] = result.batches.length;\n result.batches.push({\n resource: {\n attributes: [],\n droppedAttributesCount: 0,\n },\n instrumentationLibrarySpans: [\n {\n spans: [],\n },\n ],\n });\n }\n\n let batchIndex = services[span.serviceName];\n\n // Populate resource attributes from service tags\n if (result.batches[batchIndex].resource!.attributes.length === 0) {\n result.batches[batchIndex].resource!.attributes = tagsToAttributes(span.serviceTags);\n }\n\n // Populate instrumentation library if it exists\n if (!result.batches[batchIndex].instrumentationLibrarySpans[0].instrumentationLibrary) {\n let libraryName = span.tags.find((t: TraceKeyValuePair) => t.key === 'otel.library.name')?.value;\n if (libraryName) {\n result.batches[batchIndex].instrumentationLibrarySpans[0].instrumentationLibrary = {\n name: libraryName,\n version: span.tags.find((t: TraceKeyValuePair) => t.key === 'otel.library.version')?.value,\n };\n }\n }\n\n result.batches[batchIndex].instrumentationLibrarySpans[0].spans.push({\n traceId: transformHexStringToBase64ID(span.traceID.padStart(32, '0')),\n spanId: transformHexStringToBase64ID(span.spanID),\n traceState: '',\n parentSpanId: transformHexStringToBase64ID(span.parentSpanID || ''),\n name: span.operationName,\n kind: getOTLPSpanKind(span.tags) as any,\n startTimeUnixNano: span.startTime * 1000000,\n endTimeUnixNano: (span.startTime + span.duration) * 1000000,\n attributes: tagsToAttributes(span.tags),\n droppedAttributesCount: 0,\n droppedEventsCount: 0,\n droppedLinksCount: 0,\n status: getOTLPStatus(span.tags),\n events: getOTLPEvents(span.logs),\n links: getOTLPReferences(span.references),\n });\n }\n\n return result;\n}\n\nfunction getOTLPSpanKind(tags: TraceKeyValuePair[]): string | undefined {\n let spanKind = undefined;\n const spanKindTagValue = tags.find((t) => t.key === 'span.kind')?.value;\n switch (spanKindTagValue) {\n case 'server':\n spanKind = 'SPAN_KIND_SERVER';\n break;\n case 'client':\n spanKind = 'SPAN_KIND_CLIENT';\n break;\n case 'producer':\n spanKind = 'SPAN_KIND_PRODUCER';\n break;\n case 'consumer':\n spanKind = 'SPAN_KIND_CONSUMER';\n break;\n }\n\n return spanKind;\n}\n\n/**\n * Converts key-value tags to OTLP attributes and removes tags added by Grafana\n */\nfunction tagsToAttributes(tags: TraceKeyValuePair[]): collectorTypes.opentelemetryProto.common.v1.KeyValue[] {\n return tags\n .filter(\n (t) =>\n ![\n 'span.kind',\n 'otel.library.name',\n 'otel.libary.version',\n 'otel.status_description',\n 'otel.status_code',\n ].includes(t.key)\n )\n .reduce(\n (attributes, tag) => [...attributes, { key: tag.key, value: toAttributeValue(tag) }],\n []\n );\n}\n\n/**\n * Returns the correct OTLP AnyValue based on the value of the tag value\n */\nfunction toAttributeValue(tag: TraceKeyValuePair): collectorTypes.opentelemetryProto.common.v1.AnyValue {\n if (typeof tag.value === 'string') {\n return { stringValue: tag.value };\n } else if (typeof tag.value === 'boolean') {\n return { boolValue: tag.value };\n } else if (typeof tag.value === 'number') {\n if (tag.value % 1 === 0) {\n return { intValue: tag.value };\n } else {\n return { doubleValue: tag.value };\n }\n } else if (typeof tag.value === 'object') {\n if (Array.isArray(tag.value)) {\n const values: collectorTypes.opentelemetryProto.common.v1.AnyValue[] = [];\n for (const val of tag.value) {\n values.push(toAttributeValue(val));\n }\n\n return { arrayValue: { values } };\n }\n }\n return { stringValue: tag.value };\n}\n\nfunction getOTLPStatus(tags: TraceKeyValuePair[]): SpanStatus | undefined {\n let status = undefined;\n const statusCodeTag = tags.find((t) => t.key === 'otel.status_code');\n if (statusCodeTag) {\n status = {\n code: statusCodeTag.value,\n message: tags.find((t) => t.key === 'otel_status_description')?.value,\n };\n }\n\n return status;\n}\n\nfunction getOTLPEvents(logs: TraceLog[]): collectorTypes.opentelemetryProto.trace.v1.Span.Event[] | undefined {\n if (!logs || !logs.length) {\n return undefined;\n }\n\n let events: collectorTypes.opentelemetryProto.trace.v1.Span.Event[] = [];\n for (const log of logs) {\n let event: collectorTypes.opentelemetryProto.trace.v1.Span.Event = {\n timeUnixNano: log.timestamp * 1000000,\n attributes: [],\n droppedAttributesCount: 0,\n name: '',\n };\n for (const field of log.fields) {\n event.attributes!.push({\n key: field.key,\n value: toAttributeValue(field),\n });\n }\n events.push(event);\n }\n return events;\n}\n\nfunction getOTLPReferences(\n references: TraceSpanReference[]\n): collectorTypes.opentelemetryProto.trace.v1.Span.Link[] | undefined {\n if (!references || !references.length) {\n return undefined;\n }\n\n let links: collectorTypes.opentelemetryProto.trace.v1.Span.Link[] = [];\n for (const ref of references) {\n let link: collectorTypes.opentelemetryProto.trace.v1.Span.Link = {\n traceId: ref.traceID,\n spanId: ref.spanID,\n attributes: [],\n droppedAttributesCount: 0,\n };\n if (ref.tags?.length) {\n for (const tag of ref.tags) {\n link.attributes?.push({\n key: tag.key,\n value: toAttributeValue(tag),\n });\n }\n }\n links.push(link);\n }\n return links;\n}\n\nexport function transformTrace(response: DataQueryResponse, nodeGraph = false): DataQueryResponse {\n const frame: DataFrame = response.data[0];\n\n if (!frame) {\n return emptyDataQueryResponse;\n }\n\n let data = [...response.data];\n if (nodeGraph) {\n data.push(...createGraphFrames(frame));\n }\n\n return {\n ...response,\n data,\n };\n}\n\nexport function createTableFrameFromSearch(data: TraceSearchMetadata[], instanceSettings: DataSourceInstanceSettings) {\n const frame = new MutableDataFrame({\n fields: [\n {\n name: 'traceID',\n type: FieldType.string,\n config: {\n unit: 'string',\n displayNameFromDS: 'Trace ID',\n links: [\n {\n title: 'Trace: ${__value.raw}',\n url: '',\n internal: {\n datasourceUid: instanceSettings.uid,\n datasourceName: instanceSettings.name,\n query: {\n query: '${__value.raw}',\n queryType: 'traceql',\n },\n },\n },\n ],\n },\n },\n { name: 'traceName', type: FieldType.string, config: { displayNameFromDS: 'Trace name' } },\n { name: 'startTime', type: FieldType.string, config: { displayNameFromDS: 'Start time' } },\n { name: 'traceDuration', type: FieldType.number, config: { displayNameFromDS: 'Duration', unit: 'ms' } },\n ],\n meta: {\n preferredVisualisationType: 'table',\n },\n });\n if (!data?.length) {\n return frame;\n }\n // Show the most recent traces\n const traceData = data\n .sort((a, b) => parseInt(b?.startTimeUnixNano!, 10) / 1000000 - parseInt(a?.startTimeUnixNano!, 10) / 1000000)\n .map(transformToTraceData);\n\n for (const trace of traceData) {\n frame.add(trace);\n }\n\n return frame;\n}\n\nfunction transformToTraceData(data: TraceSearchMetadata) {\n let traceName = '';\n if (data.rootServiceName) {\n traceName += data.rootServiceName + ' ';\n }\n if (data.rootTraceName) {\n traceName += data.rootTraceName;\n }\n\n const traceStartTime = parseInt(data.startTimeUnixNano!, 10) / 1000000;\n\n let startTime = !isNaN(traceStartTime) ? dateTimeFormat(traceStartTime) : '';\n\n return {\n traceID: data.traceID,\n startTime,\n traceDuration: data.durationMs?.toString(),\n traceName,\n };\n}\n\nexport function createTableFrameFromTraceQlQuery(\n data: TraceSearchMetadata[],\n instanceSettings: DataSourceInstanceSettings\n): DataFrame[] {\n const frame = new MutableDataFrame({\n fields: [\n {\n name: 'traceID',\n type: FieldType.string,\n config: {\n unit: 'string',\n displayNameFromDS: 'Trace ID',\n custom: {\n width: 200,\n },\n links: [\n {\n title: 'Trace: ${__value.raw}',\n url: '',\n internal: {\n datasourceUid: instanceSettings.uid,\n datasourceName: instanceSettings.name,\n query: {\n query: '${__value.raw}',\n queryType: 'traceql',\n },\n },\n },\n ],\n },\n },\n {\n name: 'startTime',\n type: FieldType.string,\n config: {\n displayNameFromDS: 'Start time',\n custom: {\n width: 200,\n },\n },\n },\n { name: 'traceName', type: FieldType.string, config: { displayNameFromDS: 'Name' } },\n {\n name: 'traceDuration',\n type: FieldType.number,\n config: {\n displayNameFromDS: 'Duration',\n unit: 'ms',\n custom: {\n width: 120,\n },\n },\n },\n ],\n meta: {\n preferredVisualisationType: 'table',\n },\n });\n\n if (!data?.length) {\n return [frame];\n }\n\n const subDataFrames: DataFrame[] = [];\n const tableRows = data\n // Show the most recent traces\n .sort((a, b) => parseInt(b?.startTimeUnixNano!, 10) / 1000000 - parseInt(a?.startTimeUnixNano!, 10) / 1000000)\n .reduce((rows: TraceTableData[], trace, currentIndex) => {\n const traceData: TraceTableData = transformToTraceData(trace);\n rows.push(traceData);\n subDataFrames.push(traceSubFrame(trace, instanceSettings, currentIndex));\n return rows;\n }, []);\n\n for (const row of tableRows) {\n frame.add(row);\n }\n\n return [frame, ...subDataFrames];\n}\n\nconst traceSubFrame = (\n trace: TraceSearchMetadata,\n instanceSettings: DataSourceInstanceSettings,\n currentIndex: number\n): DataFrame => {\n const spanDynamicAttrs: Record = {};\n let hasNameAttribute = false;\n trace.spanSet?.spans.forEach((span) => {\n if (span.name) {\n hasNameAttribute = true;\n }\n span.attributes?.forEach((attr) => {\n spanDynamicAttrs[attr.key] = {\n name: attr.key,\n type: FieldType.string,\n config: { displayNameFromDS: attr.key },\n };\n });\n });\n const subFrame = new MutableDataFrame({\n fields: [\n {\n name: 'traceIdHidden',\n config: {\n custom: { hidden: true },\n },\n },\n {\n name: 'spanID',\n type: FieldType.string,\n config: {\n unit: 'string',\n displayNameFromDS: 'Span ID',\n custom: {\n width: 200,\n },\n links: [\n {\n title: 'Span: ${__value.raw}',\n url: '',\n internal: {\n datasourceUid: instanceSettings.uid,\n datasourceName: instanceSettings.name,\n query: {\n query: '${__data.fields.traceIdHidden}',\n queryType: 'traceql',\n },\n panelsState: {\n trace: {\n spanId: '${__value.raw}',\n },\n },\n },\n },\n ],\n },\n },\n {\n name: 'spanStartTime',\n type: FieldType.string,\n config: {\n displayNameFromDS: 'Start time',\n custom: {\n width: 200,\n },\n },\n },\n {\n name: 'name',\n type: FieldType.string,\n config: { displayNameFromDS: 'Name', custom: { hidden: !hasNameAttribute } },\n },\n ...Object.values(spanDynamicAttrs),\n {\n name: 'duration',\n type: FieldType.number,\n config: {\n displayNameFromDS: 'Duration',\n unit: 'ns',\n custom: {\n width: 120,\n },\n },\n },\n ],\n meta: {\n preferredVisualisationType: 'table',\n custom: {\n parentRowIndex: currentIndex,\n },\n },\n });\n\n trace.spanSet?.spans.forEach((span) => {\n subFrame.add(transformSpanToTraceData(span, trace.traceID));\n });\n\n return subFrame;\n};\n\ninterface TraceTableData {\n [key: string]: string | number | boolean | undefined; // dynamic attribute name\n traceID?: string;\n spanID?: string;\n startTime?: string;\n name?: string;\n traceDuration?: string;\n}\n\nfunction transformSpanToTraceData(span: Span, traceID: string): TraceTableData {\n const spanStartTimeUnixMs = parseInt(span.startTimeUnixNano, 10) / 1000000;\n let spanStartTime = dateTimeFormat(spanStartTimeUnixMs);\n\n const data: TraceTableData = {\n traceIdHidden: traceID,\n spanID: span.spanID,\n spanStartTime,\n duration: parseInt(span.durationNanos, 10),\n name: span.name,\n };\n\n span.attributes?.forEach((attr) => {\n if (attr.value.boolValue) {\n data[attr.key] = attr.value.boolValue;\n }\n if (attr.value.doubleValue) {\n data[attr.key] = attr.value.doubleValue;\n }\n if (attr.value.intValue) {\n data[attr.key] = attr.value.intValue;\n }\n if (attr.value.stringValue) {\n data[attr.key] = attr.value.stringValue;\n }\n });\n\n return data;\n}\n\nconst emptyDataQueryResponse = {\n data: [\n new MutableDataFrame({\n fields: [\n {\n name: 'trace',\n type: FieldType.trace,\n values: [],\n },\n ],\n meta: {\n preferredVisualisationType: 'trace',\n custom: {\n traceFormat: 'otlp',\n },\n },\n }),\n ],\n};\n"],"names":["getNonOverlappingDuration","ranges","a","b","acc","range","tail","prevStart","prevEnd","start","end","makeSpanMap","getSpan","spanMap","span","index","parentId","getStats","duration","traceDuration","selfDuration","toFixedNoTrailingZeros","n","makeFrames","nodesFrame","edgesFrame","createGraphFrames","data","nodes","edges","convertTraceToGraph","node","edge","view","findTraceDuration","i","row","c","childrenDuration","stats","traceEndTime","traceStartTime","secondsMetric","totalsMetric","failedMetric","histogramMetric","rateMetric","errorRateMetric","durationMetric","defaultTableFilter","serviceMapMetrics","mapPromMetricsToServiceMap","responses","frames","getMetricFrames","nodesMap","edgesMap","collectMetricData","convertToDataFrames","createServiceMapDataFrames","createDF","name","fields","frame","stat","metric","valueName","edgeId","rangeMs","nodeId","SpanStatusCode","SemanticResourceAttributes","CloudProviderValues","CloudPlatformValues","AwsEcsLaunchtypeValues","HostArchValues","OsTypeValues","TelemetrySdkLanguageValues","createTableFrame","logsFrame","datasourceUid","datasourceName","traceRegexs","tableFrame","MutableDataFrame","timeField","f","field","hasMatch","values","line","traceRegex","match","traceId","time","transformTraceList","response","datasourceId","transformBase64IDToHexString","base64","raw","result","hex","transformHexStringToBase64ID","hexArray","getAttributeValue","value","arrayValue","arValue","resourceToProcess","resource","serviceTags","serviceName","attribute","getSpanTags","instrumentationLibrary","spanTags","split","getReferences","references","link","spanId","tags","getLogs","logs","event","transformFromOTLP","traceData","nodeGraph","librarySpan","error","transformToOTLP","services","batchIndex","tagsToAttributes","libraryName","t","getOTLPSpanKind","getOTLPStatus","getOTLPEvents","getOTLPReferences","spanKind","attributes","tag","toAttributeValue","val","status","statusCodeTag","events","log","links","ref","transformTrace","emptyDataQueryResponse","createTableFrameFromSearch","instanceSettings","transformToTraceData","trace","traceName","startTime","createTableFrameFromTraceQlQuery","subDataFrames","tableRows","rows","currentIndex","traceSubFrame","spanDynamicAttrs","hasNameAttribute","attr","subFrame","transformSpanToTraceData","traceID","spanStartTimeUnixMs","spanStartTime"],"sourceRoot":""}