Skip to content

Commit

Permalink
[APM] Hash service name/environment for APM per_service telemetry (#1…
Browse files Browse the repository at this point in the history
…41685) (#141822)

* Hash service name/environment for per_service telemetry

* Fix typing and reorder service name/env

Co-authored-by: Kibana Machine <[email protected]>
(cherry picked from commit 90b9afd)

Co-authored-by: Colton Myers <[email protected]>
  • Loading branch information
kibanamachine and Colton Myers authored Sep 26, 2022
1 parent aac7c34 commit 80fa506
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
import { fromKueryExpression } from '@kbn/es-query';
import { flatten, merge, sortBy, sum, pickBy } from 'lodash';
import { createHash } from 'crypto';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { ProcessorEvent } from '@kbn/observability-plugin/common';
import { asMutableArray } from '../../../../common/utils/as_mutable_array';
Expand Down Expand Up @@ -1247,11 +1248,15 @@ export const tasks: TelemetryTask[] = [
});
const envBuckets = response.aggregations?.environments.buckets ?? [];
const data: APMPerService[] = envBuckets.flatMap((envBucket) => {
const env = envBucket.key;
const envHash = createHash('sha256')
.update(envBucket.key as string)
.digest('hex');
const serviceBuckets = envBucket.service_names?.buckets ?? [];
return serviceBuckets.map((serviceBucket) => {
const name = serviceBucket.key;
const fullServiceName = `${env}~${name}`;
const nameHash = createHash('sha256')
.update(serviceBucket.key as string)
.digest('hex');
const fullServiceName = `${nameHash}~${envHash}`;
return {
service_id: fullServiceName,
timed_out: response.timed_out,
Expand Down

0 comments on commit 80fa506

Please sign in to comment.