Skip to content

Commit

Permalink
[APM] Add telemetry for the cardinality of span.destination.service.r…
Browse files Browse the repository at this point in the history
…esource (#162424)

Add telemetry about the cardinality of
`span.destination.service.resource` within the last day.

The indexer will be updated by
elastic/telemetry#2402.

Closes #161986

---------

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
gbamparop and kibanamachine authored Jul 25, 2023
1 parent 02b04dd commit f1fca32
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 0 deletions.
10 changes: 10 additions & 0 deletions x-pack/plugins/apm/common/__snapshots__/apm_telemetry.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
TRANSACTION_RESULT,
TRANSACTION_TYPE,
USER_AGENT_ORIGINAL,
SPAN_DESTINATION_SERVICE_RESOURCE,
} from '../../../../common/es_fields/apm';
import {
APM_SERVICE_GROUP_SAVED_OBJECT_TYPE,
Expand Down Expand Up @@ -802,6 +803,32 @@ export const tasks: TelemetryTask[] = [
},
});

const spanDestinationServiceResourceCount = (
await telemetryClient.search({
index: indices.transaction,
body: {
track_total_hits: false,
size: 0,
timeout,
query: {
bool: {
filter: [
{ term: { [PROCESSOR_EVENT]: ProcessorEvent.span } },
range1d,
],
},
},
},
aggs: {
span_destination_service_resource: {
cardinality: {
field: SPAN_DESTINATION_SERVICE_RESOURCE,
},
},
},
})
).aggregations?.span_destination_service_resource.value;

return {
counts: {
max_error_groups_per_service: {
Expand All @@ -823,6 +850,9 @@ export const tasks: TelemetryTask[] = [
servicesAndEnvironmentsCount.aggregations?.service_environments
.value || 0,
},
span_destination_service_resource: {
'1d': spanDestinationServiceResourceCount || 0,
},
},
};
},
Expand Down
9 changes: 9 additions & 0 deletions x-pack/plugins/apm/server/lib/apm_telemetry/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,15 @@ export const apmSchema: MakeSchemaFrom<APMUsage> = {
},
},
},
span_destination_service_resource: {
'1d': {
...long,
_meta: {
description:
'Total number of unique values of span.destination.service.resource within the last day',
},
},
},
},
cardinality: {
client: { geo: { country_iso_code: { rum: timeframeMap1dSchema } } },
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/apm/server/lib/apm_telemetry/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export interface APMUsage {
traces: TimeframeMap;
services: TimeframeMap;
environments: TimeframeMap1d;
span_destination_service_resource: TimeframeMap1d;
};
cardinality: {
client: { geo: { country_iso_code: { rum: TimeframeMap1d } } };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4011,6 +4011,16 @@
}
}
}
},
"span_destination_service_resource": {
"properties": {
"1d": {
"type": "long",
"_meta": {
"description": "Total number of unique values of span.destination.service.resource within the last day"
}
}
}
}
}
},
Expand Down

0 comments on commit f1fca32

Please sign in to comment.