Categorygithub.com/runpod/rplog
repositorypackage
0.1.1
Repository: https://github.com/runpod/rplog.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author

# README

rplog

rplog is runpod's logging and tracing package. It provides a uniform logging implementation across all 3 of Runpod's major languages: Python, JavaScript, and Go.

LanguageSubdirectory
Python./py
JavaScript./js
Go./go

The following documentation covers language-independent aspects of rplog. For language-specific documentation, see the README in the appropriate subdirectory.

Overview: Logs

Logs are written to stderr in JSON format. All logs contain a "metadata" field that is a JSON object containing at least the following fields:

FieldDescriptionExample
commitThe (shortened) git commit hash of the code that is running, as though with git rev-parse --short HEAD86b4b04
envThe environment in which the code is running.prod
language_versionThe language (python, javascript, go) and version of the code that is running.go 1.14.2
repo_pathThe path to the git repository that the code is running from.runpod/rplog
instance_idA unique identifier for the instance of the code that is running.fac72470-068a-44a3-be0d-a43fd9c7fffd
service_startThe time at which rplog was initialized.2020-06-01T00:00:00Z
service_versionThe version of the code that is running. This should line up with the git tag.v0.0.1
service_nameThe name of the service that is running.ai-api

Log Levels

We provide 4 log levels:

LevelDescriptionExample
DEBUGVerbose messages, disabled by default in both dev and prod."GET /api/v1/health" OK"
INFOIndications of normal operation, enabled by default in dev, disabled by default in prod."Starting server on port 8080"
WARNIndications of possible issues, missing but not critical data, etc. Enabled by default in both dev and prod."network storage cache disabled"
ERRORIndications of critical issues, missing critical data, etc. Enabled by default in both dev and prod."failed to connect to database"

Generally speaking, WARN is to be avoided. If you're logging a warning, you should probably be logging an ERROR instead. DEBUG should be used sparingly, and INFO should be used for anything that is not an error.

Populating your logs with metadata via the buildmeta tool

We provide a command-line tool, buildmeta, to populate your logs with metadata. The releases page will contain pre-built binaries ready for use: pick the appropriate binary for your platform and put it in your PATH.

OSARCHBinaryNotes
Linux or WSLamd64buildmeta_amd64_linuxyou probably want this
macOSamd64buildmeta_amd64_darwinolder intel macs
macOSarm64buildmeta_arm64_darwinnewer apple silicon macs
Windows (not WSL)amd64buildmeta_amd64_windows.exeyou probably don't want this

See the buildmeta README for information on how to populate your logs with metadata. In short, you should run buildmeta as part of your deployment process to inject the build-time metadata into your application, either by generating a .py or .js file at 'compile time', or by writing a JSON or environment file to disk that's read at runtime.

Logs: Environment Variables

VariableDescriptionDefault
RUNPOD_LOG_LEVELThe minimum log level to display.INFO
ENVThe environment in which the code is running.unknown
RUNPOD_SERVICE_NAMEThe name of the service that is running.unknown
RUNPOD_SERVICE_VERSIONThe version of the service that is running.unknown
RUNPOD_SERVICE_COMMIT_HASHThe git commit hash of the code that is running.unknown

Timestamps:

All timestamps should be RFC3339 in UTC, a subset of ISO8601. For example: 2020-06-01T00:00:00Z.

Tracing

Traces consist of a request_id, a trace_id, and the trace_start timestamp. A trace_id should begin when an "event" starts in our system (i.e, a customer request comes in, a cron job starts, etc) and travels across services. A request_id is a unique identifier for a single request: i.e, within the bounds of a single service. A trace may outlive a request, but a request will always be part of a trace.