Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APM] Dependencies table for backend inventory/detail views #106995

Merged
merged 11 commits into from
Jul 30, 2021

Conversation

dgieselaar
Copy link
Member

Adds dependencies tables for backend inventory and detail views.

Still needs to happen, preferably in follow-up PRs:

  • take kuery into account (not sure if this is reasonable)
  • some ui tweaks
  • API tests

CleanShot 2021-07-28 at 13 38 40@2x

CleanShot 2021-07-28 at 14 12 34@2x

@dgieselaar dgieselaar added Team:APM - DEPRECATED Use Team:obs-ux-infra_services. release_note:skip Skip the PR/issue when compiling release notes v7.15.0 labels Jul 28, 2021
@dgieselaar dgieselaar requested a review from a team as a code owner July 28, 2021 12:13
@elasticmachine
Copy link
Contributor

Pinging @elastic/apm-ui (Team:apm)

@@ -63,6 +54,15 @@ const apmRoutes = route([
}),
]),
},
{
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this puts the main UI routes after the redirect routes, to ensure those are matched first (they're more specific)


export type Node = ServiceNode | BackendNode;

export interface ConnectionMetricItem {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we really call it Metric? I remember there were a lot of discussions when I implemented the comparison feature that "metric" is already over-utilized.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree, will change to "stats"

metrics: {
latency: {
value: number | null;
timeseries: Array<{ x: number; y: number | null }>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use Coordinate?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure thing

Comment on lines 57 to 59
let to: Node = metricItem.to;

to = destinationMap.get(to.backendName) ?? to;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let to: Node = metricItem.to;
to = destinationMap.get(to.backendName) ?? to;
const to: Node = destinationMap.get(to.backendName) ?? metricItem.to

start,
end,
numBuckets,
filter: [...environmentQuery(environment)],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
filter: [...environmentQuery(environment)],
filter: environmentQuery(environment),

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I don't mind this - I think it's more obviously an array this way, which I think it's a good thing.

return withApmSpan('get_destination_map', async () => {
const { apmEventClient } = setup;

const offsetInMs = getOffsetInMs(start, offset);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you considered returning startWithOffset and endWithOffset in getOffsetInMs? I feel like everywhere we'll use it we'll have to subtract the offset from start and end.

Suggested change
const offsetInMs = getOffsetInMs(start, offset);
const {offsetInMs, startWithOffset, endWithOffset} = getOffsetInMs(start, offset);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 good idea

...filter,
{
bool: {
must_not: [{ term: { [AGENT_NAME]: 'rum-js' } }],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you could add a comment explaining why rum is being filtered out?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good one, I'll probably extract it to some other file as it's used in multiple places.

Comment on lines 204 to 221
let node: Node;
if ('serviceName' in mergedDestination) {
node = {
serviceName: mergedDestination.serviceName,
agentName: mergedDestination.agentName,
environment: mergedDestination.environment,
id: objectHash({ serviceName: mergedDestination.serviceName }),
type: NodeType.service,
};
} else {
node = {
backendName: mergedDestination.backendName,
spanType: mergedDestination.spanType,
spanSubtype: mergedDestination.spanSubtype,
id: objectHash({ backendName: mergedDestination.backendName }),
type: NodeType.backend,
};
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you make node a const and use a ternary to set its value?

Suggested change
let node: Node;
if ('serviceName' in mergedDestination) {
node = {
serviceName: mergedDestination.serviceName,
agentName: mergedDestination.agentName,
environment: mergedDestination.environment,
id: objectHash({ serviceName: mergedDestination.serviceName }),
type: NodeType.service,
};
} else {
node = {
backendName: mergedDestination.backendName,
spanType: mergedDestination.spanType,
spanSubtype: mergedDestination.spanSubtype,
id: objectHash({ backendName: mergedDestination.backendName }),
type: NodeType.backend,
};
}
const node: Node = 'serviceName' in mergedDestination ? {
serviceName: mergedDestination.serviceName,
agentName: mergedDestination.agentName,
environment: mergedDestination.environment,
id: objectHash({ serviceName: mergedDestination.serviceName }),
type: NodeType.service,
} :
{
backendName: mergedDestination.backendName,
spanType: mergedDestination.spanType,
spanSubtype: mergedDestination.spanSubtype,
id: objectHash({ backendName: mergedDestination.backendName }),
type: NodeType.backend,
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the if/else is a little more readable here, due to the size of the object being created.

Comment on lines 50 to 52
const offsetInMs = getOffsetInMs(start, offset);
const startWithOffset = start - offsetInMs;
const endWithOffset = end - offsetInMs;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what I meant.

...rangeQuery(startWithOffset, endWithOffset),
{
bool: {
must_not: [{ term: { [AGENT_NAME]: 'rum-js' } }],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a comment here too?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably want to use RUM_AGENT_NAMES to include legacy and otel names.

connections: {
composite: {
size: 10000,
sources: asMutableArray([
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need to use asMutableArray here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to use as const to create a tuple type, otherwise typescript will create a partial type of all element types, which is not recognised by the ES client's types, and the type of the response will be unknown. For the same reason we wrap it in asMutableArray, as as const will convert an Array type to a ReadonlyArray type.

Copy link
Contributor

@cauemarcondes cauemarcondes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just some nits

export function BackendDetailDependenciesTable() {
const {
urlParams: { start, end, environment, comparisonEnabled, comparisonType },
} = useUrlParams();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we still do magic with useUrlParams and start/end, but can the rest fo them come out of the useApmParams below?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the others have slightly different types/defaults as well. I'm trying to err on the safe side here, and then hopefully we can refactor these separately.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have an issue to refactor this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have #105914

text={name}
content={
<EuiFlexGroup gutterSize="s" responsive={false}>
<EuiFlexItem grow={false}>{icon}</EuiFlexItem>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dgieselaar dgieselaar requested a review from cauemarcondes July 30, 2021 10:54
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
apm 1567 1570 +3

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
apm 4.2MB 4.3MB +3.4KB

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

import { AGENT_NAME } from '../../../common/elasticsearch_fieldnames';
import { RUM_AGENT_NAMES } from '../../../common/agent_name';

// exclude RUM exit spans, as they're high cardinality and don't usually
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

@dgieselaar dgieselaar added the auto-backport Deprecated - use backport:version if exact versions are needed label Jul 30, 2021
@dgieselaar dgieselaar enabled auto-merge (squash) July 30, 2021 13:21
Copy link
Contributor

@cauemarcondes cauemarcondes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Nice work 👏🏻

@dgieselaar dgieselaar merged commit efd2540 into elastic:master Jul 30, 2021
@kibanamachine
Copy link
Contributor

💔 Backport failed

Status Branch Result
7.x Commit could not be cherrypicked due to conflicts

To backport manually run:
node scripts/backport --pr 106995

dgieselaar added a commit to dgieselaar/kibana that referenced this pull request Aug 3, 2021
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Aug 3, 2021
@kibanamachine
Copy link
Contributor

Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync.

dgieselaar added a commit that referenced this pull request Aug 3, 2021
@dgieselaar dgieselaar added backport:skip This commit does not require backporting and removed backport missing Added to PRs automatically when the are determined to be missing a backport. labels Aug 3, 2021
@dgieselaar dgieselaar deleted the backend-ui-apis branch August 3, 2021 14:50
streamich pushed a commit to vadimkibana/kibana that referenced this pull request Aug 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:APM - DEPRECATED Use Team:obs-ux-infra_services. v7.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants