Skip to content

[Usage Counters] enhancements#187664

Merged
gsoldevila merged 6 commits intoelastic:mainfrom
gsoldevila:kbn-dashboards-plus-plus-enhancements
Jul 5, 2024
Merged

[Usage Counters] enhancements#187664
gsoldevila merged 6 commits intoelastic:mainfrom
gsoldevila:kbn-dashboards-plus-plus-enhancements

Conversation

@gsoldevila
Copy link
Contributor

Summary

Follow up to #187064

  • Improves the rollups.test.ts integration test.
  • Adds the count field to the mappings, so that it can be aggregated.

@gsoldevila gsoldevila added Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// Feature:Telemetry release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting v8.16.0 labels Jul 5, 2024
@gsoldevila gsoldevila requested a review from a team as a code owner July 5, 2024 11:55
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-core (Team:Core)

@gsoldevila gsoldevila enabled auto-merge (squash) July 5, 2024 12:12
await createTestCounters(internalRepository);
});

it('deletes documents older that the retention period, from all namespaces', async () => {
Copy link
Member

Choose a reason for hiding this comment

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

FMI: how are we testing the from all namespaces here?

EDIT: Oh! gotcha! createTestCounters creates some counters in other spaces.

}

// domainId, counterName, counterType, source, count, namespace?
type CounterAttributes = [string, string, string, 'ui' | 'server', number, string?];
Copy link
Member

Choose a reason for hiding this comment

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

nit... how about we define this as an object? When I was reading the usage, I was only guessing what each value meant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I kinda like the compact form of the array, it's much easier to read when defining multiple counters. Example from another test I'm working on:

const FIRST_DAY_COUNTERS: CounterAttributes[] = [
  // domainId, counterName, counterType, source, count, namespace?
  ['dashboards', 'aDashboardId', 'viewed', 'server', 10, 'first'],
  ['dashboards', 'aDashboardId', 'edited', 'server', 5, 'first'],
  ['dashboards', 'aDashboardId', 'viewed', 'server', 100, 'second'],
  ['dashboards', 'aDashboardId', 'edited', 'server', 50, 'second'],
  ['dashboards', 'aDashboardId', 'consoleErrors', 'ui', 3, 'first'],
  ['dashboards', 'aDashboardId', 'consoleErrors', 'ui', 9, 'second'],
  ['dashboards', 'list', 'viewed', 'ui', 256, 'default'],
  ['someDomain', 'someCounterName', 'someCounter', 'server', 13, 'first'],
];

I can add a comment on top of the definition call, as a quick visual reference.

id,
...(namespace && { namespaces: [namespace] }),
updated_at: date.format(), // illustrative purpose only, overriden by SOR
// updated_at: date // illustrative purpose only, overriden by SOR
Copy link
Member

Choose a reason for hiding this comment

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

if not needed, should we remove it?

counterName: { type: 'keyword' },
counterType: { type: 'keyword' },
source: { type: 'keyword' },
count: { type: 'integer' },
Copy link
Member

Choose a reason for hiding this comment

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

👌

@gsoldevila gsoldevila merged commit 0f43e8a into elastic:main Jul 5, 2024
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting Feature:Telemetry release_note:skip Skip the PR/issue when compiling release notes Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// v8.16.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants