feat: add option for exporting traces to a provided Honeycomb team (#4816)

This commit is contained in:
Colin Adler
2022-11-01 09:15:41 -05:00
committed by GitHub
parent 21e64943ac
commit 4c5bf42355
7 changed files with 67 additions and 9 deletions
+12 -4
View File
@@ -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",
+11
View File
@@ -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
View File
@@ -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 {