Skip to content

Commit

Permalink
feat: add enums, consts, and icon functions
Browse files Browse the repository at this point in the history
  • Loading branch information
BenElferink committed Jan 30, 2025
1 parent 2a6b6a5 commit a9be77c
Show file tree
Hide file tree
Showing 8 changed files with 231 additions and 3 deletions.
61 changes: 61 additions & 0 deletions src/@types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,69 @@ export enum NOTIFICATION_TYPE {
DEFAULT = 'default',
}

export enum PLATFORM_TYPE {
K8S = 'k8s',
VM = 'vm',
}

export enum PROGRAMMING_LANGUAGES {
GO = 'go',
JAVASCRIPT = 'javascript',
PYTHON = 'python',
JAVA = 'java',
DOTNET = 'dotnet',
MYSQL = 'mysql',
NGINX = 'nginx',

IGNORED = 'ignored',
UNKNOWN = 'unknown', // language detection completed but could not find a supported language
PROCESSING = 'processing', // language detection is not yet complotted, data is not available
NO_CONTAINERS = 'no containers', // language detection completed but no containers found or they are ignored
NO_RUNNING_PODS = 'no running pods', // no running pods are available for language detection
}

export enum SIGNAL_TYPE {
LOGS = 'logs',
METRICS = 'metrics',
TRACES = 'traces',
}

export enum ENTITY_TYPES {
SOURCE = 'source',
DESTINATION = 'destination',
ACTION = 'action',
INSTRUMENTATION_RULE = 'rule',
}

export enum ACTION_TYPE {
ADD_CLUSTER_INFO = 'AddClusterInfo',
DELETE_ATTRIBUTES = 'DeleteAttribute',
RENAME_ATTRIBUTES = 'RenameAttribute',
ERROR_SAMPLER = 'ErrorSampler',
PROBABILISTIC_SAMPLER = 'ProbabilisticSampler',
LATENCY_SAMPLER = 'LatencySampler',
PII_MASKING = 'PiiMasking',
}

export enum INSTRUMENTATION_RULE_TYPE {
PAYLOAD_COLLECTION = 'PayloadCollection',
CODE_ATTRIBUTES = 'CodeAttributes',
UNKNOWN_TYPE = 'UnknownType',
}

export interface MonitorsOption {
id: SIGNAL_TYPE
value: string
}

export interface ActionOption {
id: string
type?: ACTION_TYPE
icon?: SVG
label: string
description?: string
allowedSignals?: SIGNAL_TYPE[]
docsEndpoint?: string
docsDescription?: string
items?: ActionOption[]
}
2 changes: 1 addition & 1 deletion src/components/monitors-icons/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { Tooltip } from '../tooltip'
import { FlexRow } from '../../styled'
import { SIGNAL_TYPE } from '../../@types'
import { useTheme } from 'styled-components'
import { getMonitorIcon } from '../../functions'
import { MONITORS_OPTIONS } from '../../constants'
import { getMonitorIcon } from '../../functions/get-monitor-icon'

interface MonitorsIconsProps {
monitors?: SIGNAL_TYPE[]
Expand Down
96 changes: 94 additions & 2 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { SIGNAL_TYPE } from '../@types'
import { getActionIcon } from '../functions'
import { ACTION_TYPE, type ActionOption, type MonitorsOption, SIGNAL_TYPE } from '../@types'

export const MONITORS_OPTIONS = [
export const MONITORS_OPTIONS: MonitorsOption[] = [
{
id: SIGNAL_TYPE.LOGS,
value: 'Logs',
Expand All @@ -14,3 +15,94 @@ export const MONITORS_OPTIONS = [
value: 'Traces',
},
]

export const ACTION_OPTIONS: ActionOption[] = [
{
id: 'attributes',
label: 'Attributes',
icon: getActionIcon('attributes'),
items: [
{
id: 'add_cluster_info',
type: ACTION_TYPE.ADD_CLUSTER_INFO,
icon: getActionIcon(ACTION_TYPE.ADD_CLUSTER_INFO),
label: 'Add Cluster Info',
description: 'Add static cluster-scoped attributes to your data.',
allowedSignals: [SIGNAL_TYPE.TRACES, SIGNAL_TYPE.METRICS, SIGNAL_TYPE.LOGS],
docsEndpoint: '/pipeline/actions/attributes/addclusterinfo',
docsDescription:
'The “Add Cluster Info” Odigos Action can be used to add resource attributes to telemetry signals originated from the k8s cluster where the Odigos is running.',
},
{
id: 'delete_attribute',
type: ACTION_TYPE.DELETE_ATTRIBUTES,
icon: getActionIcon(ACTION_TYPE.DELETE_ATTRIBUTES),
label: 'Delete Attribute',
description: 'Delete attributes from logs, metrics, and traces.',
allowedSignals: [SIGNAL_TYPE.TRACES, SIGNAL_TYPE.METRICS, SIGNAL_TYPE.LOGS],
docsEndpoint: '/pipeline/actions/attributes/deleteattribute',
docsDescription: 'The “Delete Attribute” Odigos Action can be used to delete attributes from logs, metrics, and traces.',
},
{
id: 'rename_attribute',
type: ACTION_TYPE.RENAME_ATTRIBUTES,
icon: getActionIcon(ACTION_TYPE.RENAME_ATTRIBUTES),
label: 'Rename Attribute',
description: 'Rename attributes in logs, metrics, and traces.',
allowedSignals: [SIGNAL_TYPE.TRACES, SIGNAL_TYPE.METRICS, SIGNAL_TYPE.LOGS],
docsEndpoint: '/pipeline/actions/attributes/renameattribute',
docsDescription:
'The “Rename Attribute” Odigos Action can be used to rename attributes from logs, metrics, and traces. Different instrumentations might use different attribute names for similar information. This action let’s you to consolidate the names across your cluster.',
},
{
id: 'pii-masking',
type: ACTION_TYPE.PII_MASKING,
icon: getActionIcon(ACTION_TYPE.PII_MASKING),
label: 'PII Masking',
description: 'Mask PII data in your traces.',
allowedSignals: [SIGNAL_TYPE.TRACES],
docsEndpoint: '/pipeline/actions/attributes/piimasking',
docsDescription: 'The “PII Masking” Odigos Action can be used to mask PII data from span attribute values.',
},
],
},
{
id: 'sampler',
label: 'Samplers',
icon: getActionIcon('sampler'),
items: [
{
id: 'error-sampler',
type: ACTION_TYPE.ERROR_SAMPLER,
icon: getActionIcon('sampler'),
label: 'Error Sampler',
description: 'Sample errors based on percentage.',
allowedSignals: [SIGNAL_TYPE.TRACES],
docsEndpoint: '/pipeline/actions/sampling/errorsampler',
docsDescription: 'The “Error Sampler” Odigos Action is a Global Action that supports error sampling by filtering out non-error traces.',
},
{
id: 'latency-action',
type: ACTION_TYPE.LATENCY_SAMPLER,
icon: getActionIcon('sampler'),
label: 'Latency Sampler',
description: 'Add latency to your traces.',
allowedSignals: [SIGNAL_TYPE.TRACES],
docsEndpoint: '/pipeline/actions/sampling/latencysampler',
docsDescription:
'The “Latency Sampler” Odigos Action is an Endpoint Action that samples traces based on their duration for a specific service and endpoint (HTTP route) filter.',
},
{
id: 'probabilistic-sampler',
type: ACTION_TYPE.PROBABILISTIC_SAMPLER,
icon: getActionIcon('sampler'),
label: 'Probabilistic Sampler',
description: 'Sample traces based on percentage.',
allowedSignals: [SIGNAL_TYPE.TRACES],
docsEndpoint: '/pipeline/actions/sampling/probabilisticsampler',
docsDescription:
'The “Probabilistic Sampler” Odigos Action supports probabilistic sampling based on a configured sampling percentage applied to the TraceID.',
},
],
},
]
23 changes: 23 additions & 0 deletions src/functions/get-action-icon/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ACTION_TYPE, type SVG } from '../../@types'
import { AddClusterInfoIcon, DeleteAttributeIcon, PiiMaskingIcon, RenameAttributeIcon, SamplerIcon } from '../../icons'

export const getActionIcon = (type: ACTION_TYPE | 'sampler' | 'attributes') => {
const typeLowerCased = type?.toLowerCase()
const isSamplerCategory = typeLowerCased?.includes('sampler')
const isAttributesCategory = typeLowerCased === 'attributes'

if (isSamplerCategory) return SamplerIcon
if (isAttributesCategory) return PiiMaskingIcon

const LOGOS: Record<ACTION_TYPE, SVG> = {
[ACTION_TYPE.ADD_CLUSTER_INFO]: AddClusterInfoIcon,
[ACTION_TYPE.DELETE_ATTRIBUTES]: DeleteAttributeIcon,
[ACTION_TYPE.PII_MASKING]: PiiMaskingIcon,
[ACTION_TYPE.RENAME_ATTRIBUTES]: RenameAttributeIcon,
[ACTION_TYPE.ERROR_SAMPLER]: SamplerIcon,
[ACTION_TYPE.PROBABILISTIC_SAMPLER]: SamplerIcon,
[ACTION_TYPE.LATENCY_SAMPLER]: SamplerIcon,
}

return LOGOS[type as ACTION_TYPE]
}
13 changes: 13 additions & 0 deletions src/functions/get-entity-icon/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { ENTITY_TYPES, type SVG } from '../../@types'
import { ActionsIcon, DestinationsIcon, RulesIcon, SourcesIcon } from '../../icons'

export const getEntityIcon = (type: ENTITY_TYPES) => {
const LOGOS: Record<ENTITY_TYPES, SVG> = {
[ENTITY_TYPES.SOURCE]: SourcesIcon,
[ENTITY_TYPES.DESTINATION]: DestinationsIcon,
[ENTITY_TYPES.ACTION]: ActionsIcon,
[ENTITY_TYPES.INSTRUMENTATION_RULE]: RulesIcon,
}

return LOGOS[type]
}
12 changes: 12 additions & 0 deletions src/functions/get-instrumentation-rule-icon/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { INSTRUMENTATION_RULE_TYPE, type SVG } from '../../@types'
import { CodeAttributesIcon, OdigosLogo, PayloadCollectionIcon } from '../../icons'

export const getInstrumentationRuleIcon = (type: INSTRUMENTATION_RULE_TYPE) => {
const LOGOS: Record<INSTRUMENTATION_RULE_TYPE, SVG> = {
[INSTRUMENTATION_RULE_TYPE.PAYLOAD_COLLECTION]: PayloadCollectionIcon,
[INSTRUMENTATION_RULE_TYPE.CODE_ATTRIBUTES]: CodeAttributesIcon,
[INSTRUMENTATION_RULE_TYPE.UNKNOWN_TYPE]: OdigosLogo,
}

return LOGOS[type]
}
22 changes: 22 additions & 0 deletions src/functions/get-programming-language-icon/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { PROGRAMMING_LANGUAGES } from '../../@types'

export const getProgrammingLanguageIcon = (language: PROGRAMMING_LANGUAGES) => {
const BASE_URL = 'https://d1n7d4xz7fr8b4.cloudfront.net/'

const LOGOS: Record<PROGRAMMING_LANGUAGES, string> = {
[PROGRAMMING_LANGUAGES.JAVA]: `${BASE_URL}java.svg`,
[PROGRAMMING_LANGUAGES.GO]: `${BASE_URL}go.svg`,
[PROGRAMMING_LANGUAGES.JAVASCRIPT]: `${BASE_URL}nodejs.svg`,
[PROGRAMMING_LANGUAGES.PYTHON]: `${BASE_URL}python.svg`,
[PROGRAMMING_LANGUAGES.DOTNET]: `${BASE_URL}dotnet.svg`,
[PROGRAMMING_LANGUAGES.MYSQL]: `${BASE_URL}mysql.svg`,
[PROGRAMMING_LANGUAGES.NGINX]: `${BASE_URL}nginx.svg`,
[PROGRAMMING_LANGUAGES.IGNORED]: '', // TODO: good icon
[PROGRAMMING_LANGUAGES.UNKNOWN]: '', // TODO: good icon
[PROGRAMMING_LANGUAGES.PROCESSING]: '', // TODO: good icon
[PROGRAMMING_LANGUAGES.NO_CONTAINERS]: '', // TODO: good icon
[PROGRAMMING_LANGUAGES.NO_RUNNING_PODS]: '', // TODO: good icon
}

return LOGOS[language]
}
5 changes: 5 additions & 0 deletions src/functions/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
export * from './get-action-icon'
export * from './get-entity-icon'
export * from './get-instrumentation-rule-icon'
export * from './get-monitor-icon'
export * from './get-programming-language-icon'
export * from './get-status-icon'
export * from './is-emtpy'

0 comments on commit a9be77c

Please sign in to comment.