mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add option for exporting traces to a provided Honeycomb team (#4816)
This commit is contained in:
@@ -289,10 +289,18 @@ func newConfig() *codersdk.DeploymentConfig {
|
||||
Default: "tls12",
|
||||
},
|
||||
},
|
||||
TraceEnable: &codersdk.DeploymentConfigField[bool]{
|
||||
Name: "Trace Enable",
|
||||
Usage: "Whether application tracing data is collected.",
|
||||
Flag: "trace",
|
||||
Trace: &codersdk.TraceConfig{
|
||||
Enable: &codersdk.DeploymentConfigField[bool]{
|
||||
Name: "Trace Enable",
|
||||
Usage: "Whether application tracing data is collected. It exports to a backend configured by environment variables. See: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md",
|
||||
Flag: "trace",
|
||||
},
|
||||
HoneycombAPIKey: &codersdk.DeploymentConfigField[string]{
|
||||
Name: "Trace Honeycomb API Key",
|
||||
Usage: "Enables trace exporting to Honeycomb.io using the provided API Key.",
|
||||
Flag: "trace-honeycomb-api-key",
|
||||
Secret: true,
|
||||
},
|
||||
},
|
||||
SecureAuthCookie: &codersdk.DeploymentConfigField[bool]{
|
||||
Name: "Secure Auth Cookie",
|
||||
|
||||
@@ -114,6 +114,16 @@ func TestConfig(t *testing.T) {
|
||||
require.Equal(t, config.TLS.Enable.Value, true)
|
||||
require.Equal(t, config.TLS.MinVersion.Value, "tls10")
|
||||
},
|
||||
}, {
|
||||
Name: "Trace",
|
||||
Env: map[string]string{
|
||||
"CODER_TRACE_ENABLE": "true",
|
||||
"CODER_TRACE_HONEYCOMB_API_KEY": "my-honeycomb-key",
|
||||
},
|
||||
Valid: func(config *codersdk.DeploymentConfig) {
|
||||
require.Equal(t, config.Trace.Enable.Value, true)
|
||||
require.Equal(t, config.Trace.HoneycombAPIKey.Value, "my-honeycomb-key")
|
||||
},
|
||||
}, {
|
||||
Name: "OIDC",
|
||||
Env: map[string]string{
|
||||
@@ -192,6 +202,7 @@ func TestConfig(t *testing.T) {
|
||||
}} {
|
||||
tc := tc
|
||||
t.Run(tc.Name, func(t *testing.T) {
|
||||
t.Helper()
|
||||
for key, value := range tc.Env {
|
||||
t.Setenv(key, value)
|
||||
}
|
||||
|
||||
+2
-2
@@ -125,9 +125,9 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
|
||||
shouldCoderTrace = cfg.Telemetry.Trace.Value
|
||||
}
|
||||
|
||||
if cfg.TraceEnable.Value || shouldCoderTrace {
|
||||
if cfg.Trace.Enable.Value || shouldCoderTrace {
|
||||
sdkTracerProvider, closeTracing, err := tracing.TracerProvider(ctx, "coderd", tracing.TracerOpts{
|
||||
Default: cfg.TraceEnable.Value,
|
||||
Default: cfg.Trace.Enable.Value,
|
||||
Coder: shouldCoderTrace,
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user