sourcegraph / sourcegraph-public-snapshot

Code AI platform with Code Search & Cody
https://sourcegraph.com
Other
10.1k stars 1.28k forks source link

RFE: Make the date/time output formats consistent for all services #45419

Open mike-r-mclaughlin opened 1 year ago

mike-r-mclaughlin commented 1 year ago

Requested by: https://github.com/sourcegraph/accounts/issues/6716 via Slack

Feature request description

Ensure the timestamp in the logs is consistent across all services. Proper ISO format is preferred as it's easy to read and parse.

Is your feature request related to a problem? If so, please describe.

Examples of log formats in use:

worker formats:

{
    "log": "t=2022-12-07T07:46:12+0000 lvl=eror msg=\"error fetching commits from gitserver repo_id: 1: filtering commits: checking sub-repo permissions: request is unauthenticated\"\n",
    "stream": "stderr",
    "attrs": {
        "service": "worker"
    },
    "time": "2022-12-07T07:46:12.541598508Z"
}

and also:

{
    "log": {
        "SeverityText": "ERROR",
        "Timestamp": 1670443658733017775,
        "InstrumentationScope": "worker.insights-job.background.CommitIndexer.GetCommits",
        "Caller": "compression/worker.go: 242",
        "Function": 
...
}

repo-updater formats

{
    "SeverityText": "ERROR",
    "Timestamp": 1670449088188811191,
    "InstrumentationScope": "service.PermsSyncer.runSync",
    "Caller": "authz/perms_syncer.go:1099",
    "Function": "github.com/sourcegraph/sourcegraph/enterprise/cmd/repo-updater/internal/authz.(*PermsSyncer).syncPerms.func3",
    "Body": "failed to sync permissions",
camdencheek commented 1 year ago

This appears to be due to us using multiple log libraries in the product. Transition to the standardized log library is tracked here.