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

[baseserver] Emit metrics for logs produced by level ENG-349 #19063

Merged
merged 10 commits into from
Nov 21, 2023

Conversation

easyCZ
Copy link
Member

@easyCZ easyCZ commented Nov 13, 2023

Description

To be able to monitor each cells error logs without having to export them immediately. First we can check volumes. As a side-effect, this also allows us to identify the most offending components in terms of log volume

Summary generated by Copilot

🤖 Generated by Copilot at 1a98bf1

This pull request adds log metrics to the common-go module, which can be used by the base server and other components to report the number of logs by level to prometheus. This enhances the monitoring and debugging capabilities of Gitpod services.

Related Issue(s)

Fixes #

How to test

Documentation

Preview status

Gitpod was successfully deployed to your preview environment.

Build Options

Build
  • /werft with-werft
    Run the build with werft instead of GHA
  • leeway-no-cache
  • /werft no-test
    Run Leeway with --dont-test
Publish
  • /werft publish-to-npm
  • /werft publish-to-jb-marketplace
Installer
  • analytics=segment
  • with-dedicated-emulation
  • workspace-feature-flags
    Add desired feature flags to the end of the line above, space separated
Preview Environment / Integration Tests
  • /werft with-local-preview
    If enabled this will build install/preview
  • /werft with-preview
  • /werft with-large-vm
  • /werft with-gce-vm
    If enabled this will create the environment on GCE infra
  • with-integration-tests=all
    Valid options are all, workspace, webapp, ide, jetbrains, vscode, ssh. If enabled, with-preview and with-large-vm will be enabled.
  • with-monitoring

/hold

@easyCZ easyCZ requested a review from a team as a code owner November 13, 2023 13:32
@easyCZ easyCZ requested a review from a team as a code owner November 13, 2023 13:47
@easyCZ easyCZ changed the title [baseserver] Emit metrics for logs produced by level ENG-349 [baseserver + protocol] Emit metrics for logs produced by level ENG-349 Nov 13, 2023
@easyCZ easyCZ requested a review from a team as a code owner November 14, 2023 10:38
@roboquat roboquat added size/L and removed size/M labels Nov 14, 2023
@easyCZ easyCZ force-pushed the mp/baseserver-log-metrics branch from 8bd046e to 7be67c3 Compare November 14, 2023 14:11
Copy link
Contributor

@mustard-mh mustard-mh left a comment

Choose a reason for hiding this comment

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

Not all components are using baseserver, do we need to register metric manually for them? Or improve it in follow-up PRs? (search github.com/gitpod-io/gitpod/common-go/baseserver in codebase)

Does it make sense to add service name as a label so that we know which components log errors more?

}

func (h *LogHook) Fire(entry *logrus.Entry) error {
h.metrics.ReportLog(entry.Level)
Copy link
Contributor

Choose a reason for hiding this comment

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

log level here is uint32 type Level uint32

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but the method calls

func (m *Metrics) ReportLog(level logrus.Level) {
	m.logEmitedCounter.WithLabelValues(level.String()).Inc()
}

which uses the string version

function doLog(calledViaConsole: boolean, consoleLog: ConsoleLog, severity: GoogleLogSeverity, args: unknown[]): void {
logsCounter.labels(severity).inc();
Copy link
Contributor

Choose a reason for hiding this comment

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

level here is type GoogleLogSeverity = "EMERGENCY" | "ALERT" | "CRITICAL" | "ERROR" | "WARNING" | "INFO" | "DEBUG";

@@ -246,7 +247,16 @@ namespace GoogleLogSeverity {
};
}

const logsCounter = new prometheusClient.Counter({
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 find where we use (expose) this counter

@easyCZ easyCZ force-pushed the mp/baseserver-log-metrics branch from 4484109 to 96ebcd2 Compare November 20, 2023 14:08
@easyCZ easyCZ changed the title [baseserver + protocol] Emit metrics for logs produced by level ENG-349 [baseserver] Emit metrics for logs produced by level ENG-349 Nov 20, 2023
@easyCZ
Copy link
Member Author

easyCZ commented Nov 20, 2023

I've removed TS changes from this PR, I can't figure out how to make it work so will ask EXP

@geropl
Copy link
Member

geropl commented Nov 21, 2023

Testing 👀

Copy link
Member

@geropl geropl left a comment

Choose a reason for hiding this comment

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

Code LGTM, tested on public-api-server, and works ✔️

@geropl
Copy link
Member

geropl commented Nov 21, 2023

TS parts are here; will rebase once this is in.

@roboquat roboquat merged commit f0c8a85 into main Nov 21, 2023
25 of 26 checks passed
@roboquat roboquat deleted the mp/baseserver-log-metrics branch November 21, 2023 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants