-
Notifications
You must be signed in to change notification settings - Fork 453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add namespace and placement info to debug endpoint in coordinator #1896
Conversation
@@ -26,7 +26,7 @@ if [[ "$USE_JAEGER" = true ]] ; then | |||
fi | |||
fi | |||
|
|||
docker-compose -f docker-compose.yml up $DOCKER_ARGS m3coordinator01 | |||
docker-compose -f docker-compose.yml up --build -d --renew-anon-volumes m3coordinator01 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove before landing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
be6b355
to
692b3c2
Compare
Codecov Report
@@ Coverage Diff @@
## master #1896 +/- ##
=========================================
- Coverage 61.5% 57.4% -4.1%
=========================================
Files 1100 1039 -61
Lines 104214 91971 -12243
=========================================
- Hits 64136 52873 -11263
+ Misses 35843 35230 -613
+ Partials 4235 3868 -367
Continue to review full report at Codecov.
|
src/query/server/server.go
Outdated
logger.Fatal("unable to get placement opts", zap.Error(err)) | ||
} | ||
|
||
debugWriter, err := xdebug.NewZipWriterWithDefaultSources( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be done inside the if
block; doesn't seem to be used otherwise
src/query/server/server.go
Outdated
mux := http.NewServeMux() | ||
if debugWriter != nil { | ||
if err := debugWriter.RegisterHandler(debugEndpoint, mux); err != nil { | ||
logger.Error("unable to register debug writer endpoint", zap.Error(err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: print the config listen address here?
@@ -94,6 +94,9 @@ type Configuration struct { | |||
// ListenAddress is the server listen address. | |||
ListenAddress *listenaddress.Configuration `yaml:"listenAddress" validate:"nonzero"` | |||
|
|||
// The host and port on which to listen for debug endpoints. | |||
DebugListenAddress string `yaml:"debugListenAddress"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be a good idea to get into the habit of editing annotated config when we add config settings (think it's quite behind unfortunately)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I'm working on restructuring the docs so lemme jot this down.
src/query/api/v1/httpd/handler.go
Outdated
@@ -293,6 +289,20 @@ func (h *Handler) RegisterRoutes() error { | |||
return nil | |||
} | |||
|
|||
// PlacementOpts returns placement opts used in the various placement APIs. | |||
func (h *Handler) PlacementOpts() (placement.HandlerOptions, error) { | |||
placementOpts, err := placement.NewHandlerOptions( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: return placement.NewHandlerOptions(..)
src/query/api/v1/httpd/handler.go
Outdated
@@ -293,6 +289,20 @@ func (h *Handler) RegisterRoutes() error { | |||
return nil | |||
} | |||
|
|||
// PlacementOpts returns placement opts used in the various placement APIs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: placement options
in comment
src/query/api/v1/httpd/handler.go
Outdated
if err != nil { | ||
return err | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is nil
suppose to be returned? If so can you drop a comment about why?
src/query/server/server.go
Outdated
zap.String("address", cfg.DebugListenAddress), zap.Error(err)) | ||
} else { | ||
logger.Info("debug server listening", | ||
zap.String("address", cfg.DebugListenAddress), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: might be better to also include the endpoint, i.e. zap.String("endpoint", fmt.Sprintf("%s%s", cfg.DebugListenAddress, debugEndpoint))
src/x/debug/namespace.go
Outdated
getHandler *namespace.GetHandler | ||
} | ||
|
||
// NewNamespaceInfoSource returns a Source for namespace information |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit; .
at the end of comments
src/x/debug/namespace.go
Outdated
) | ||
|
||
type namespaceInfoSource struct { | ||
getHandler *namespace.GetHandler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: handler
rather than getHandler
9af18f7
to
aa38e73
Compare
@@ -2,6 +2,8 @@ listenAddress: | |||
type: "config" | |||
value: "0.0.0.0:7201" | |||
|
|||
debugListenAddress: "0.0.0.0:7205" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we put this on the main listen address on 7201?
} | ||
|
||
w.Write(jsonData) | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be return w.Write(jsonData)
since Write(...)
can return an error
src/x/debug/namespace.go
Outdated
|
||
marshaler := jsonpb.Marshaler{EmitDefaults: true} | ||
buf := new(bytes.Buffer) | ||
marshaler.Marshal(buf, resp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to check if this returns an error yeah?
src/x/debug/placement.go
Outdated
marshaler := jsonpb.Marshaler{EmitDefaults: true} | ||
marshaler.Marshal(w, resp) | ||
|
||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, here need to check marshaler.Marshal(...)
so maybe just return marshaler.Marshal(w, resp)
src/x/debug/placement.go
Outdated
// Write fetches data about the placement and writes it in the given writer. | ||
// The data is formatted in json. | ||
func (p *placementInfoSource) Write(w io.Writer) error { | ||
placement, _, err := p.getHandler.Get(defaultM3DBServiceName, nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should make the service name be part of the constructor so it can be reused? i.e. NewPlacementInfoSource(serviceName string, ...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also maybe make NewPlacementZipWriterWithDefaultSources(...)
take a serviceNames []string
param and create a new placement info source per service names specified?
src/x/debug/debug.go
Outdated
@@ -68,9 +71,44 @@ func NewZipWriter(iopts instrument.Options) ZipWriter { | |||
} | |||
} | |||
|
|||
// NewPlacementZipWriterWithDefaultSources returns a zipWriter with the following | |||
// debug sources already registered: CPU, heap, host, goroutines, namespace and placement info. | |||
func NewPlacementZipWriterWithDefaultSources( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: NewPlacementAndNamespaceZipWriterWithDefaultSources(...)
so it mentions namespace?
|
||
// Register debug dump handler. | ||
h.router.HandleFunc(xdebug.DebugURL, | ||
wrapped(debugWriter.HTTPHandler()).ServeHTTP) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@robskillington Do I need to include .Methods()
on this?
queryContextOptions models.QueryContextOptions | ||
instrumentOpts instrument.Options | ||
cpuProfileDuration time.Duration | ||
placementServiceNames []string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also create a debugOpts
struct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM other than one nit
"go.uber.org/zap" | ||
) | ||
|
||
const ( | ||
DebugURL = "/debug/dump" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not: need to add comment for exported var
2076fdd
to
1214da8
Compare
What this PR does / why we need it:
This PR adds namespace and placement info the
/debug/dump
endpoint in coordinator.Special notes for your reviewer:
Does this PR introduce a user-facing and/or backwards incompatible change?:
Does this PR require updating code package or user-facing documentation?: