Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions router/core/graph_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1510,6 +1510,7 @@ func (s *graphServer) buildGraphMux(
RouterPublicKey: s.publicKey,
EnableRequestTracing: s.engineExecutionConfiguration.EnableRequestTracing,
DevelopmentMode: s.developmentMode,
EnableArt: s.enableArt,
TracerProvider: s.tracerProvider,
FlushTelemetryAfterResponse: s.awsLambda,
TraceExportVariables: s.traceConfig.ExportGraphQLVariables.Enabled,
Expand Down
7 changes: 7 additions & 0 deletions router/core/graphql_prehandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type PreHandlerOptions struct {
FileUploadEnabled bool
TraceExportVariables bool
DevelopmentMode bool
EnableArt bool
EnableRequestTracing bool
AlwaysIncludeQueryPlan bool
AlwaysSkipLoader bool
Expand Down Expand Up @@ -88,6 +89,7 @@ type PreHandler struct {
operationBlocker *OperationBlocker
headerPropagation *HeaderPropagation
developmentMode bool
enableArt bool
alwaysIncludeQueryPlan bool
alwaysSkipLoader bool
queryPlansEnabled bool // queryPlansEnabled is a flag to enable query plans output in the extensions
Expand Down Expand Up @@ -148,6 +150,7 @@ func NewPreHandler(opts *PreHandlerOptions) *PreHandler {
operationBlocker: opts.OperationBlocker,
routerPublicKey: opts.RouterPublicKey,
developmentMode: opts.DevelopmentMode,
enableArt: opts.EnableArt,
enableRequestTracing: opts.EnableRequestTracing,
flushTelemetryAfterResponse: opts.FlushTelemetryAfterResponse,
tracerProvider: opts.TracerProvider,
Expand Down Expand Up @@ -1258,6 +1261,10 @@ func (h *PreHandler) internalParseRequestOptions(r *http.Request, clientInfo *Cl
if h.developmentMode {
return h.parseRequestExecutionOptions(r), h.parseRequestTraceOptions(r), nil
}
// enable_art allows ART without dev_mode or a controlplane token
if h.enableArt {
return h.parseRequestExecutionOptions(r), h.parseRequestTraceOptions(r), nil
}
// If the client has a valid request token, and we have a public key from the controlplane
if clientInfo.WGRequestToken != "" && h.routerPublicKey != nil {
_, err := jwt.Parse(clientInfo.WGRequestToken, func(token *jwt.Token) (interface{}, error) {
Expand Down
8 changes: 8 additions & 0 deletions router/core/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -2092,6 +2092,14 @@ func WithDevelopmentMode(enabled bool) Option {
}
}

// WithEnableArt enables Advanced Request Tracing (ART) and query plan headers
// without requiring dev_mode or a Cosmo Cloud JWT token.
func WithEnableArt(enabled bool) Option {
return func(r *Router) {
r.enableArt = enabled
}
}

func WithClusterName(name string) Option {
return func(r *Router) {
r.clusterName = name
Expand Down
2 changes: 2 additions & 0 deletions router/core/router_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ type Config struct {
connectRPCServer *connectrpc.Server
processStartTime time.Time
developmentMode bool
enableArt bool
healthcheck health.Checker
accessLogsConfig *AccessLogsConfig
// If connecting to localhost inside Docker fails, fallback to the docker internal address for the host
Expand Down Expand Up @@ -251,6 +252,7 @@ func (c *Config) Usage() map[string]any {
usage["access_controller"] = c.accessController != nil
usage["retry_options"] = c.retryOptions.Enabled
usage["development_mode"] = c.developmentMode
usage["enable_art"] = c.enableArt
usage["access_logs"] = c.accessLogsConfig != nil
usage["localhost_fallback_inside_docker"] = c.localhostFallbackInsideDocker
usage["tls_server"] = c.tlsServerConfig != nil
Expand Down
1 change: 1 addition & 0 deletions router/core/supervisor_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ func optionsFromResources(logger *zap.Logger, config *config.Config, reloadPersi
},
}),
WithDevelopmentMode(config.DevelopmentMode),
WithEnableArt(config.EnableArt),
WithTracing(TraceConfigFromTelemetry(&config.Telemetry)),
WithMetrics(MetricConfigFromTelemetry(&config.Telemetry)),
WithTelemetryAttributes(config.Telemetry.Attributes),
Expand Down
1 change: 1 addition & 0 deletions router/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,7 @@ type Config struct {
LocalhostFallbackInsideDocker bool `yaml:"localhost_fallback_inside_docker" envDefault:"true" env:"LOCALHOST_FALLBACK_INSIDE_DOCKER"`
CDN CDNConfiguration `yaml:"cdn,omitempty"`
DevelopmentMode bool `yaml:"dev_mode" envDefault:"false" env:"DEV_MODE"`
EnableArt bool `yaml:"enable_art" envDefault:"false" env:"ENABLE_ART"`
Events EventsConfiguration `yaml:"events,omitempty"`
CacheWarmup CacheWarmupConfiguration `yaml:"cache_warmup,omitempty"`

Expand Down
5 changes: 5 additions & 0 deletions router/pkg/config/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,11 @@
"default": false,
"description": "Enable the development mode. The development mode is used to enable the development features like ART (Advanced Request Tracing) and pretty logs."
},
"enable_art": {
"type": "boolean",
"default": false,
"description": "Enable Advanced Request Tracing (ART) and query plan headers without requiring dev_mode or a Cosmo Cloud JWT token."
},
"tls": {
"type": "object",
"additionalProperties": false,
Expand Down
1 change: 1 addition & 0 deletions router/pkg/config/testdata/config_defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@
"CacheSize": 100000000
},
"DevelopmentMode": false,
"EnableArt": false,
"Events": {
"Providers": {
"Nats": null,
Expand Down
1 change: 1 addition & 0 deletions router/pkg/config/testdata/config_full.json
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@
"CacheSize": 100000000
},
"DevelopmentMode": false,
"EnableArt": false,
"Events": {
"Providers": {
"Nats": [
Expand Down