Skip to content

Commit

Permalink
fix default selection between metrics / traces
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Tackett <[email protected]>
  • Loading branch information
Adam Tackett committed Oct 14, 2024
1 parent cd9f806 commit 2b91663
Showing 1 changed file with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import { getWorkspaceIdFromUrl } from '../../../../../../src/core/public/utils';
const cardOne = 'Logs';
const cardTwo = 'Metrics';
const cardThree = 'Traces';
const OTEL_LOGS_OPTION = { label: 'Open Telemetry', value: 'otelLogs' };

interface CollectAndShipDataProps {
isOpen: boolean;
Expand All @@ -71,9 +70,21 @@ export const CollectAndShipData: React.FC<CollectAndShipDataProps> = ({
const [workflows, setWorkflows] = useState<any[]>([]);

Check warning on line 70 in public/components/getting_started/components/getting_started_collectData.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const [collectorOptions, setCollectorOptions] = useState<CollectorOption[]>([]);
const [patternsContent, setPatternsContent] = useState<any[]>([]);

Check warning on line 72 in public/components/getting_started/components/getting_started_collectData.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type

const getTelemetryOption = (collectionMethodOtel: string) => {
switch (collectionMethodOtel) {
case cardTwo:
return { label: 'Open Telemetry', value: 'otelMetrics' };
case cardThree:
return { label: 'Open Telemetry', value: 'otelTraces' };
default:
return { label: 'Open Telemetry', value: 'otelLogs' };
}
};

const [selectedIntegration, setSelectedIntegration] = useState<
Array<EuiSelectableOption<CollectorOption>>
>([OTEL_LOGS_OPTION]);
>([getTelemetryOption(cardOne)]);

const technologyJsonMap: Record<string, any> = {

Check warning on line 89 in public/components/getting_started/components/getting_started_collectData.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
otelLogs: otelJsonLogs,
Expand Down Expand Up @@ -144,7 +155,8 @@ export const CollectAndShipData: React.FC<CollectAndShipDataProps> = ({
// Auto-select first collector if nothing is selected and a collection method is set
useEffect(() => {
if (collectorOptions.length > 0 && !specificMethod && collectionMethod) {
handleSpecificMethodChange([{ ...OTEL_LOGS_OPTION }]);
const telemetryOption = getTelemetryOption(collectionMethod);
handleSpecificMethodChange([{ ...telemetryOption }]);
}
}, [collectorOptions, specificMethod, collectionMethod]);

Check warning on line 161 in public/components/getting_started/components/getting_started_collectData.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useEffect has a missing dependency: 'handleSpecificMethodChange'. Either include it or remove the dependency array

Expand All @@ -157,17 +169,19 @@ export const CollectAndShipData: React.FC<CollectAndShipDataProps> = ({

if (value === cardOne) {
setCollectorOptions([
{ ...OTEL_LOGS_OPTION },
getTelemetryOption(cardOne),
{ label: 'Nginx', value: 'nginx' },
{ label: 'Java', value: 'java' },
{ label: 'Python', value: 'python' },
{ label: 'Golang', value: 'golang' },
]);
} else if (value === cardTwo) {
setCollectorOptions([{ label: 'Open Telemetry', value: 'otelMetrics' }]);
setCollectorOptions([getTelemetryOption(cardTwo)]);
} else if (value === cardThree) {
setCollectorOptions([{ label: 'Open Telemetry', value: 'otelTraces' }]);
setCollectorOptions([getTelemetryOption(cardThree)]);
}

setSelectedIntegration([getTelemetryOption(value)]);
};

const renderSpecificMethodDropdown = () => {
Expand Down

0 comments on commit 2b91663

Please sign in to comment.