Skip to content

Describe every usage metric and simple metric feature area - #8228

Merged
labkey-jeckels merged 8 commits into
developfrom
fb_metric_descriptions
Oct 28, 2026
Merged

labkey-jeckels merged 8 commits into
developfrom
fb_metric_descriptions

Conversation

@labkey-jeckels

@labkey-jeckels labkey-jeckels commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Rationale

Documents what every usage metric reports to mothership, so each value can be understood without reading the code that produces it.

The provider API changes, so the other fb_metric_descriptions PRs must merge with this one.

GH Issue 1775

Related Pull Requests

Changes

  • Every usage metrics provider reports a description with each value; the separate described-provider interface is merged into the base one.
  • Metrics reported only on some servers can be described without being reported.
  • Simple metric feature areas have fixed names and descriptions, including the client-side areas counted by @labkey/components.
  • Descriptions for the metrics of platform modules.

Every usage metrics provider now reports a description with each value, and simple metric feature areas get descriptions too, including the client-side areas counted by @labkey/components.
@labkey-jeckels
labkey-jeckels requested a review from a team October 25, 2026 22:19
@labkey-jeckels labkey-jeckels self-assigned this Oct 25, 2026
@labkey-jeckels
labkey-jeckels marked this pull request as ready for review October 25, 2026 22:19

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is from the previous change, but since this catch is per-provider, shouldn't the logging highlight the provider that failed?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also, I guess this was intentional, but unfortunate that we have to generate all the metrics just to get the descriptions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Also, I guess this was intentional, but unfortunate that we have to generate all the metrics just to get the descriptions.

Claude kept lamenting on that during its reviews. It didn't seem worth the complexity of decoupling them (and potential drift) since the descriptions will only need to be collected occasionally and every server already recomputes its metric values daily anyway.

It would be easy enough to capture and stash the descriptions during the metric submission process but I wasn't going to bother to automate export/import of them yet.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is from the previous change, but since this catch is per-provider, shouldn't the logging highlight the provider that failed?

The stack trace should contain the class name of the provider. That's often a lambda. I don't know if it's worth a pass to include a name for every provider at registration time.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also, I guess this was intentional, but unfortunate that we have to generate all the metrics just to get the descriptions.

Claude kept lamenting on that during its reviews. It didn't seem worth the complexity of decoupling them (and potential drift) since the descriptions will only need to be collected occasionally and every server already recomputes its metric values daily anyway.

It would be easy enough to capture and stash the descriptions during the metric submission process but I wasn't going to bother to automate export/import of them yet.

My thought: UsageMetrics.put() has the (for now) option of taking a Supplier<Object>. If a supplier is provided, the metrics enumerator will resolve it and the metrics description exporter will not. We can migrate to suppliers over time. Should be an easy change for Claude to implement.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is from the previous change, but since this catch is per-provider, shouldn't the logging highlight the provider that failed?

The stack trace should contain the class name of the provider. That's often a lambda. I don't know if it's worth a pass to include a name for every provider at registration time.

Sure, the name is there. Maybe just update the message to say "a provider in module XXX failed..." since it's not the entire module that failed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK, updated.

@labkey-adam
labkey-adam self-requested a review October 26, 2026 22:14
}

/** Calls the supplier only when values are reported, so a {@code reportedIf(false)} view skips the work. A literal null value resolves here. */
public UsageMetrics put(@NotNull String key, @Nullable Supplier<?> value, @NotNull String description)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh good, so we're already accepting a Supplier

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I converted more, but not all, callers to use a Supplier

return this;
}

/** Calls the supplier only when values are reported, so a {@code reportedIf(false)} view skips the work. A literal null value resolves here. */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's a view? Seems like an odd and overloaded term for us.

@labkey-jeckels labkey-jeckels Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated the comment. It's just a render of the descriptions without grabbing the metrics.

import org.labkey.api.usageMetrics.SimpleMetricsService;

/** Describes the client-side feature areas that @labkey/components counts */
public final class ClientSideMetricDescriptions

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe I missed it, but I didn't see any place where we alert (e.g., log an error or warning, or throw) when we receive a client-side metric that isn't described.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I went back and forth on this.

I pushed an update that logs once per server startup when we get a client-side metric that's not linked to a description. In dev mode, it's ERROR to get caught by automated tests. In prod mode, it's WARN as we get spammed by bots sometimes that make up descriptions.

@labkey-jeckels
labkey-jeckels merged commit f10b78e into develop Oct 28, 2026
10 of 12 checks passed
@labkey-jeckels
labkey-jeckels deleted the fb_metric_descriptions branch October 28, 2026 00:55
labkey-jeckels added a commit to LabKey/commonAssays that referenced this pull request Oct 28, 2026
## Rationale
Describes the Flow and Protein usage metrics, using the API added in the
platform PR.

[GH Issue 1775](LabKey/internal-issues#1775)

## Related Pull Requests
- LabKey/platform#8228
- LabKey/limsModules#2564
- LabKey/premiumModules#821
- LabKey/customModules#289
- LabKey/targetedms#1298
- LabKey/ehrModules#1232

## Changes
- Descriptions for Flow's and Protein's usage metrics.
labkey-jeckels added a commit to LabKey/customModules that referenced this pull request Oct 28, 2026
## Rationale
Describes the Specimen usage metrics, using the API added in the
platform PR.

[GH Issue 1775](LabKey/internal-issues#1775)

## Related Pull Requests
- LabKey/platform#8228
- LabKey/limsModules#2564
- LabKey/premiumModules#821
- LabKey/commonAssays#1094
- LabKey/targetedms#1298
- LabKey/ehrModules#1232

## Changes
- Descriptions for Specimen's usage metrics.
labkey-jeckels added a commit to LabKey/ehrModules that referenced this pull request Oct 28, 2026
## Rationale
Describes the EHR usage metrics, using the API added in the platform PR.

[GH Issue 1775](LabKey/internal-issues#1775)

## Related Pull Requests
- LabKey/platform#8228
- LabKey/limsModules#2564
- LabKey/premiumModules#821
- LabKey/commonAssays#1094
- LabKey/customModules#289
- LabKey/targetedms#1298

## Changes
- Description for the participant history filter's client-side feature
area.
labkey-jeckels added a commit to LabKey/targetedms that referenced this pull request Oct 28, 2026
## Rationale
Describes the TargetedMS usage metrics, using the API added in the
platform PR.

[GH Issue 1775](LabKey/internal-issues#1775)

## Related Pull Requests
- LabKey/platform#8228
- LabKey/limsModules#2564
- LabKey/premiumModules#821
- LabKey/commonAssays#1094
- LabKey/customModules#289
- LabKey/ehrModules#1232

## Changes
- Descriptions for TargetedMS's usage metrics.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants