mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: create tracing.SlogSink for storing logs as span events (#4962)
This commit is contained in:
@@ -295,6 +295,11 @@ func newConfig() *codersdk.DeploymentConfig {
|
||||
Flag: "trace-honeycomb-api-key",
|
||||
Secret: true,
|
||||
},
|
||||
CaptureLogs: &codersdk.DeploymentConfigField[bool]{
|
||||
Name: "Capture Logs in Traces",
|
||||
Usage: "Enables capturing of logs as events in traces. This is useful for debugging, but may result in a very large amount of events being sent to the tracing backend which may incur significant costs. If the verbose flag was supplied, debug-level logs will be included.",
|
||||
Flag: "trace-logs",
|
||||
},
|
||||
},
|
||||
SecureAuthCookie: &codersdk.DeploymentConfigField[bool]{
|
||||
Name: "Secure Auth Cookie",
|
||||
|
||||
+4
-1
@@ -88,6 +88,9 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
|
||||
if ok, _ := cmd.Flags().GetBool(varVerbose); ok {
|
||||
logger = logger.Leveled(slog.LevelDebug)
|
||||
}
|
||||
if cfg.Trace.CaptureLogs.Value {
|
||||
logger = logger.AppendSinks(tracing.SlogSink{})
|
||||
}
|
||||
|
||||
// Main command context for managing cancellation
|
||||
// of running services.
|
||||
@@ -126,7 +129,7 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
|
||||
shouldCoderTrace = cfg.Telemetry.Trace.Value
|
||||
}
|
||||
|
||||
if cfg.Trace.Enable.Value || shouldCoderTrace {
|
||||
if cfg.Trace.Enable.Value || shouldCoderTrace || cfg.Trace.HoneycombAPIKey.Value != "" {
|
||||
sdkTracerProvider, closeTracing, err := tracing.TracerProvider(ctx, "coderd", tracing.TracerOpts{
|
||||
Default: cfg.Trace.Enable.Value,
|
||||
Coder: shouldCoderTrace,
|
||||
|
||||
+8
@@ -188,6 +188,14 @@ Flags:
|
||||
--trace-honeycomb-api-key string Enables trace exporting to Honeycomb.io
|
||||
using the provided API Key.
|
||||
Consumes $CODER_TRACE_HONEYCOMB_API_KEY
|
||||
--trace-logs Enables capturing of logs as events in
|
||||
traces. This is useful for debugging, but
|
||||
may result in a very large amount of
|
||||
events being sent to the tracing backend
|
||||
which may incur significant costs. If the
|
||||
verbose flag was supplied, debug-level
|
||||
logs will be included.
|
||||
Consumes $CODER_TRACE_CAPTURE_LOGS
|
||||
--wildcard-access-url string Specifies the wildcard hostname to use
|
||||
for workspace applications in the form
|
||||
"*.example.com".
|
||||
|
||||
Reference in New Issue
Block a user