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

refactor: Remove unnecessary spanlogger usage #13255

Merged
merged 18 commits into from
Jun 21, 2024
Merged

Conversation

DylanGuedes
Copy link
Contributor

@DylanGuedes DylanGuedes commented Jun 18, 2024

What this PR does / why we need it:
Historically, we've been using spanlogger to enrich our spans. That isn't the right usage for it (as of now), as they'll be emitting log lines. Our current usage is causing:

  • Noisy/important log lines less visible
  • Unnecessary logging volume
  • Spread of the bad practice.
    With this PR I'm moving away from spanlogger all places where the log message is too bad or nonexistent. That's because these cases are indicating we don't care about that log line at all, and only about the data injected in the span.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • Title matches the required conventional commits format, see here
    • Note that Promtail is considered to be feature complete, and future development for logs collection will be in Grafana Alloy. As such, feat PRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/setup/upgrade/_index.md
  • For Helm chart changes bump the Helm chart version in production/helm/loki/Chart.yaml and update production/helm/loki/CHANGELOG.md and production/helm/loki/README.md. Example PR
  • If the change is deprecating or removing a configuration option, update the deprecated-config.yaml and deleted-config.yaml files respectively in the tools/deprecated-config-checker directory. Example PR

@DylanGuedes DylanGuedes marked this pull request as ready for review June 21, 2024 11:57
@DylanGuedes DylanGuedes requested a review from a team as a code owner June 21, 2024 11:57
@@ -265,7 +263,7 @@ func (q *query) Exec(ctx context.Context) (logqlmodel.Result, error) {
queueTime, _ := ctx.Value(httpreq.QueryQueueTimeHTTPHeader).(time.Duration)

statResult := statsCtx.Result(time.Since(start), queueTime, q.resultLength(data))
statResult.Log(level.Debug(spLogger))
statResult.LogWithSpan(sp)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder about a little bit different approach where we leave the original stats.Log() method and use that to print the stats in metrics.go.

But here do: sp.LogKV(statResult.KVList()...)

Copy link
Contributor Author

@DylanGuedes DylanGuedes Jun 21, 2024

Choose a reason for hiding this comment

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

i like your style more but fyi we use LogWithSpan at other places. I'll try using LogKV there too then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

pushed 0c9570a addressing it

Copy link
Collaborator

@slim-bean slim-bean left a comment

Choose a reason for hiding this comment

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

LGTM!

@DylanGuedes DylanGuedes merged commit c1fada9 into main Jun 21, 2024
60 checks passed
@DylanGuedes DylanGuedes deleted the remove-spanlogger branch June 21, 2024 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants