Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// SPDX-License-Identifier: Apache-2.0

import * as React from 'react';
import { Dropdown } from 'antd';
import { IoOpenOutline, IoList, IoCopyOutline } from 'react-icons/io5';
import { Dropdown, Tooltip } from 'antd';
import { IoOpenOutline, IoList, IoCopyOutline, IoInformationCircleOutline } from 'react-icons/io5';
import { JsonView, allExpanded, collapseAllNested, defaultStyles } from 'react-json-view-lite';

import CopyIcon from '../../../common/CopyIcon';
Expand All @@ -16,8 +16,6 @@ import './KeyValuesTable.css';
const jsonObjectOrArrayStartRegex = /^(\[|\{)/;

function tryParseJson(value: string) {
// if the value is a string representing actual json object or array, then use json-markup
// otherwise just return as is
try {
return jsonObjectOrArrayStartRegex.test(value) ? JSON.parse(value) : value;
} catch (_) {
Expand Down Expand Up @@ -74,7 +72,6 @@ function formatValue(key: string, value: any) {
content = stringListMarkup(parsed);
} else if (typeof parsed === 'object') {
const shouldJsonTreeExpand = Object.keys(parsed).length <= 10;

content = (
<JsonView
data={parsed}
Expand Down Expand Up @@ -111,20 +108,17 @@ export const LinkValue = (props: { href: string; title?: string; children: React
);

const linkValueList = (links: Link[]) => {
const dropdownItems = links.map(({ text, url }, index) => ({
return links.map(({ text, url }, index) => ({
label: <LinkValue href={url}>{text}</LinkValue>,
key: `${url}-${index}`,
}));
return dropdownItems;
};

type KeyValuesTableProps = {
data: KeyValuePair[];
linksGetter: ((pairs: KeyValuePair[], index: number) => Link[]) | TNil;
};

// KeyValuesTable is displayed as a menu at span level.
// Example: https://github.com/jaegertracing/jaeger-ui/assets/94157520/b518cad9-cb37-4775-a3d6-b667a1235f89
export default function KeyValuesTable(props: KeyValuesTableProps) {
const { data, linksGetter } = props;

Expand Down Expand Up @@ -161,11 +155,24 @@ export default function KeyValuesTable(props: KeyValuesTableProps) {
} else {
valueMarkup = jsonTable;
}
return (
// `i` is necessary in the key because row.key can repeat

const isOtel = row.key.startsWith('otel.');
const keyMarkup = isOtel ? (
<span style={{ color: '#666', fontStyle: 'italic' }} className="is-otel-key">
{row.key}
<Tooltip title="Synthetic Attribute: This tag was generated to map OpenTelemetry semantics to the Jaeger data model. It may not be searchable in the storage directly.">
<IoInformationCircleOutline
style={{ marginLeft: '5px', verticalAlign: 'text-bottom', cursor: 'help' }}
/>
</Tooltip>
</span>
) : (
row.key
);

return (
<tr className="KeyValueTable--row" key={`${row.key}-${i}`}>
<td className="KeyValueTable--keyColumn">{row.key}</td>
<td className="KeyValueTable--keyColumn">{keyMarkup}</td>
<td className="KeyValueTable--valueColumn">
<div className="KeyValueTable--copyContainer">
<CopyIcon
Expand Down