chore: remove coder trace telemetry (#9677)

This commit is contained in:
Colin Adler
2023-09-14 02:20:28 -04:00
committed by GitHub
parent e7b0181519
commit 38560dd922
12 changed files with 3 additions and 84 deletions

View File

@ -105,7 +105,6 @@ func (s *scaletestTracingFlags) provider(ctx context.Context) (trace.TracerProvi
tracerProvider, closeTracing, err := tracing.TracerProvider(ctx, scaletestTracerName, tracing.TracerOpts{ tracerProvider, closeTracing, err := tracing.TracerProvider(ctx, scaletestTracerName, tracing.TracerOpts{
Default: s.traceEnable, Default: s.traceEnable,
Coder: s.traceCoder,
Honeycomb: s.traceHoneycombAPIKey, Honeycomb: s.traceHoneycombAPIKey,
}) })
if err != nil { if err != nil {

View File

@ -7,7 +7,6 @@ import (
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
"errors" "errors"
"flag"
"fmt" "fmt"
"io" "io"
"math/rand" "math/rand"
@ -436,10 +435,6 @@ func LoggerFromContext(ctx context.Context) (slog.Logger, bool) {
return l, ok return l, ok
} }
func isTest() bool {
return flag.Lookup("test.v") != nil
}
// RootCmd contains parameters and helpers useful to all commands. // RootCmd contains parameters and helpers useful to all commands.
type RootCmd struct { type RootCmd struct {
clientURL *url.URL clientURL *url.URL

View File

@ -408,7 +408,7 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
// which is caught by goleaks. // which is caught by goleaks.
defer http.DefaultClient.CloseIdleConnections() defer http.DefaultClient.CloseIdleConnections()
tracerProvider, sqlDriver, closeTracing := ConfigureTraceProvider(ctx, logger, inv, vals) tracerProvider, sqlDriver, closeTracing := ConfigureTraceProvider(ctx, logger, vals)
defer func() { defer func() {
logger.Debug(ctx, "closing tracing") logger.Debug(ctx, "closing tracing")
traceCloseErr := shutdownWithTimeout(closeTracing, 5*time.Second) traceCloseErr := shutdownWithTimeout(closeTracing, 5*time.Second)
@ -2087,7 +2087,6 @@ func (s *HTTPServers) Close() {
func ConfigureTraceProvider( func ConfigureTraceProvider(
ctx context.Context, ctx context.Context,
logger slog.Logger, logger slog.Logger,
inv *clibase.Invocation,
cfg *codersdk.DeploymentValues, cfg *codersdk.DeploymentValues,
) (trace.TracerProvider, string, func(context.Context) error) { ) (trace.TracerProvider, string, func(context.Context) error) {
var ( var (
@ -2095,19 +2094,10 @@ func ConfigureTraceProvider(
closeTracing = func(context.Context) error { return nil } closeTracing = func(context.Context) error { return nil }
sqlDriver = "postgres" sqlDriver = "postgres"
) )
// Coder tracing should be disabled if telemetry is disabled unless
// --telemetry-trace was explicitly provided.
shouldCoderTrace := cfg.Telemetry.Enable.Value() && !isTest()
// Only override if telemetryTraceEnable was specifically set.
// By default we want it to be controlled by telemetryEnable.
if inv.ParsedFlags().Changed("telemetry-trace") {
shouldCoderTrace = cfg.Telemetry.Trace.Value()
}
if cfg.Trace.Enable.Value() || shouldCoderTrace || cfg.Trace.HoneycombAPIKey != "" { if cfg.Trace.Enable.Value() || cfg.Trace.DataDog.Value() || cfg.Trace.HoneycombAPIKey != "" {
sdkTracerProvider, _closeTracing, err := tracing.TracerProvider(ctx, "coderd", tracing.TracerOpts{ sdkTracerProvider, _closeTracing, err := tracing.TracerProvider(ctx, "coderd", tracing.TracerOpts{
Default: cfg.Trace.Enable.Value(), Default: cfg.Trace.Enable.Value(),
Coder: shouldCoderTrace,
DataDog: cfg.Trace.DataDog.Value(), DataDog: cfg.Trace.DataDog.Value(),
Honeycomb: cfg.Trace.HoneycombAPIKey.String(), Honeycomb: cfg.Trace.HoneycombAPIKey.String(),
}) })

View File

@ -415,11 +415,6 @@ telemetrywhen required by your organization's security policy.
Whether telemetry is enabled or not. Coder collects anonymized usage Whether telemetry is enabled or not. Coder collects anonymized usage
data to help improve our product. data to help improve our product.
--telemetry-trace bool, $CODER_TELEMETRY_TRACE (default: false)
Whether Opentelemetry traces are sent to Coder. Coder collects
anonymized application tracing to help improve our product. Disabling
telemetry also disables this option.
USER QUIET HOURS SCHEDULE OPTIONS: USER QUIET HOURS SCHEDULE OPTIONS:
Allow users to set quiet hours schedules each day for workspaces to avoid Allow users to set quiet hours schedules each day for workspaces to avoid
workspaces stopping during the day due to template max TTL. workspaces stopping during the day due to template max TTL.

View File

@ -334,11 +334,6 @@ telemetry:
# help improve our product. # help improve our product.
# (default: false, type: bool) # (default: false, type: bool)
enable: false enable: false
# Whether Opentelemetry traces are sent to Coder. Coder collects anonymized
# application tracing to help improve our product. Disabling telemetry also
# disables this option.
# (default: false, type: bool)
trace: false
# URL to send telemetry. # URL to send telemetry.
# (default: https://telemetry.coder.com, type: url) # (default: https://telemetry.coder.com, type: url)
url: https://telemetry.coder.com url: https://telemetry.coder.com

View File

@ -8,7 +8,6 @@ import (
"go.opentelemetry.io/otel" "go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace" "go.opentelemetry.io/otel/exporters/otlp/otlptrace"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc" "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp"
"go.opentelemetry.io/otel/propagation" "go.opentelemetry.io/otel/propagation"
"go.opentelemetry.io/otel/sdk/resource" "go.opentelemetry.io/otel/sdk/resource"
sdktrace "go.opentelemetry.io/otel/sdk/trace" sdktrace "go.opentelemetry.io/otel/sdk/trace"
@ -26,9 +25,6 @@ type TracerOpts struct {
// Default exports to a backend configured by environment variables. See: // Default exports to a backend configured by environment variables. See:
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md
Default bool Default bool
// Coder exports traces to Coder's public tracing ingest service and is used
// to improve the product. It is disabled when opting out of telemetry.
Coder bool
// DataDog exports traces and profiles to the local DataDog daemon. // DataDog exports traces and profiles to the local DataDog daemon.
DataDog bool DataDog bool
// Exports traces to Honeycomb.io with the provided API key. // Exports traces to Honeycomb.io with the provided API key.
@ -88,14 +84,6 @@ func TracerProvider(ctx context.Context, service string, opts TracerOpts) (*sdkt
closers = append(closers, exporter.Shutdown) closers = append(closers, exporter.Shutdown)
tracerOpts = append(tracerOpts, sdktrace.WithBatcher(exporter)) tracerOpts = append(tracerOpts, sdktrace.WithBatcher(exporter))
} }
if opts.Coder {
exporter, err := CoderExporter(ctx)
if err != nil {
return nil, nil, xerrors.Errorf("coder exporter: %w", err)
}
closers = append(closers, exporter.Shutdown)
tracerOpts = append(tracerOpts, sdktrace.WithBatcher(exporter))
}
if opts.Honeycomb != "" { if opts.Honeycomb != "" {
exporter, err := HoneycombExporter(ctx, opts.Honeycomb) exporter, err := HoneycombExporter(ctx, opts.Honeycomb)
if err != nil { if err != nil {
@ -147,20 +135,6 @@ func DefaultExporter(ctx context.Context) (*otlptrace.Exporter, error) {
return exporter, nil return exporter, nil
} }
func CoderExporter(ctx context.Context) (*otlptrace.Exporter, error) {
opts := []otlptracehttp.Option{
otlptracehttp.WithEndpoint("oss-otel-ingest-http.coder.app:443"),
otlptracehttp.WithCompression(otlptracehttp.GzipCompression),
}
exporter, err := otlptrace.New(ctx, otlptracehttp.NewClient(opts...))
if err != nil {
return nil, xerrors.Errorf("create otlp exporter: %w", err)
}
return exporter, nil
}
func HoneycombExporter(ctx context.Context, apiKey string) (*otlptrace.Exporter, error) { func HoneycombExporter(ctx context.Context, apiKey string) (*otlptrace.Exporter, error) {
opts := []otlptracegrpc.Option{ opts := []otlptracegrpc.Option{
otlptracegrpc.WithEndpoint("api.honeycomb.io:443"), otlptracegrpc.WithEndpoint("api.honeycomb.io:443"),

View File

@ -1190,16 +1190,6 @@ when required by your organization's security policy.`,
Group: &deploymentGroupTelemetry, Group: &deploymentGroupTelemetry,
YAML: "enable", YAML: "enable",
}, },
{
Name: "Telemetry Trace",
Description: "Whether Opentelemetry traces are sent to Coder. Coder collects anonymized application tracing to help improve our product. Disabling telemetry also disables this option.",
Flag: "telemetry-trace",
Env: "CODER_TELEMETRY_TRACE",
Default: strconv.FormatBool(flag.Lookup("test.v") == nil),
Value: &c.Telemetry.Trace,
Group: &deploymentGroupTelemetry,
YAML: "trace",
},
{ {
Name: "Telemetry URL", Name: "Telemetry URL",
Description: "URL to send telemetry.", Description: "URL to send telemetry.",

11
docs/cli/server.md generated
View File

@ -967,17 +967,6 @@ Minimum supported version of TLS. Accepted values are "tls10", "tls11", "tls12"
Whether telemetry is enabled or not. Coder collects anonymized usage data to help improve our product. Whether telemetry is enabled or not. Coder collects anonymized usage data to help improve our product.
### --telemetry-trace
| | |
| ----------- | ----------------------------------- |
| Type | <code>bool</code> |
| Environment | <code>$CODER_TELEMETRY_TRACE</code> |
| YAML | <code>telemetry.trace</code> |
| Default | <code>true</code> |
Whether Opentelemetry traces are sent to Coder. Coder collects anonymized application tracing to help improve our product. Disabling telemetry also disables this option.
### --trace ### --trace
| | | | | |

View File

@ -151,7 +151,7 @@ func (*RootCmd) proxyServer() *clibase.Cmd {
defer http.DefaultClient.CloseIdleConnections() defer http.DefaultClient.CloseIdleConnections()
closers.Add(http.DefaultClient.CloseIdleConnections) closers.Add(http.DefaultClient.CloseIdleConnections)
tracer, _, closeTracing := cli.ConfigureTraceProvider(ctx, logger, inv, cfg) tracer, _, closeTracing := cli.ConfigureTraceProvider(ctx, logger, cfg)
defer func() { defer func() {
logger.Debug(ctx, "closing tracing") logger.Debug(ctx, "closing tracing")
traceCloseErr := shutdownWithTimeout(closeTracing, 5*time.Second) traceCloseErr := shutdownWithTimeout(closeTracing, 5*time.Second)

View File

@ -416,11 +416,6 @@ telemetrywhen required by your organization's security policy.
Whether telemetry is enabled or not. Coder collects anonymized usage Whether telemetry is enabled or not. Coder collects anonymized usage
data to help improve our product. data to help improve our product.
--telemetry-trace bool, $CODER_TELEMETRY_TRACE (default: false)
Whether Opentelemetry traces are sent to Coder. Coder collects
anonymized application tracing to help improve our product. Disabling
telemetry also disables this option.
USER QUIET HOURS SCHEDULE OPTIONS: USER QUIET HOURS SCHEDULE OPTIONS:
Allow users to set quiet hours schedules each day for workspaces to avoid Allow users to set quiet hours schedules each day for workspaces to avoid
workspaces stopping during the day due to template max TTL. workspaces stopping during the day due to template max TTL.

1
go.mod
View File

@ -165,7 +165,6 @@ require (
go.opentelemetry.io/otel v1.17.0 go.opentelemetry.io/otel v1.17.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.17.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.17.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.17.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.17.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.17.0
go.opentelemetry.io/otel/sdk v1.17.0 go.opentelemetry.io/otel/sdk v1.17.0
go.opentelemetry.io/otel/trace v1.17.0 go.opentelemetry.io/otel/trace v1.17.0
go.uber.org/atomic v1.11.0 go.uber.org/atomic v1.11.0

2
go.sum
View File

@ -923,8 +923,6 @@ go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.17.0 h1:U5GYackKpVKlPrd/5gK
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.17.0/go.mod h1:aFsJfCEnLzEu9vRRAcUiB/cpRTbVsNdF3OHSPpdjxZQ= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.17.0/go.mod h1:aFsJfCEnLzEu9vRRAcUiB/cpRTbVsNdF3OHSPpdjxZQ=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.17.0 h1:iGeIsSYwpYSvh5UGzWrJfTDJvPjrXtxl3GUppj6IXQU= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.17.0 h1:iGeIsSYwpYSvh5UGzWrJfTDJvPjrXtxl3GUppj6IXQU=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.17.0/go.mod h1:1j3H3G1SBYpZFti6OI4P0uRQCW20MXkG5v4UWXppLLE= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.17.0/go.mod h1:1j3H3G1SBYpZFti6OI4P0uRQCW20MXkG5v4UWXppLLE=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.17.0 h1:kvWMtSUNVylLVrOE4WLUmBtgziYoCIYUNSpTYtMzVJI=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.17.0/go.mod h1:SExUrRYIXhDgEKG4tkiQovd2HTaELiHUsuK08s5Nqx4=
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.40.0 h1:hf7JSONqAuXT1PDYYlVhKNMPLe4060d+4RFREcv7X2c= go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.40.0 h1:hf7JSONqAuXT1PDYYlVhKNMPLe4060d+4RFREcv7X2c=
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.17.0 h1:Ut6hgtYcASHwCzRHkXEtSsM251cXJPW+Z9DyLwEn6iI= go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.17.0 h1:Ut6hgtYcASHwCzRHkXEtSsM251cXJPW+Z9DyLwEn6iI=
go.opentelemetry.io/otel/metric v1.17.0 h1:iG6LGVz5Gh+IuO0jmgvpTB6YVrCGngi8QGm+pMd8Pdc= go.opentelemetry.io/otel/metric v1.17.0 h1:iG6LGVz5Gh+IuO0jmgvpTB6YVrCGngi8QGm+pMd8Pdc=