mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 15:31:48 +00:00
worker: actually track error metrics on worker handle error (#39978)
This commit is contained in:
parent
1bc8fedeb8
commit
5b3c5a9697
@ -372,8 +372,15 @@ func (w *Worker) dequeueAndHandle() (dequeued bool, err error) {
|
||||
// handle processes the given record. This method returns an error only if there is an issue updating
|
||||
// the record to a terminal state - no handler errors will bubble up.
|
||||
func (w *Worker) handle(ctx, workerContext context.Context, record Record) (err error) {
|
||||
ctx, handleLog, endOperation := w.options.Metrics.operations.handle.With(ctx, &err, observation.Args{})
|
||||
defer endOperation(1, observation.Args{})
|
||||
var handleErr error
|
||||
ctx, handleLog, endOperation := w.options.Metrics.operations.handle.With(ctx, &handleErr, observation.Args{})
|
||||
defer func() {
|
||||
// prioritize handleErr in `operations.handle.With` without bubbling handleErr up if non-nil
|
||||
if handleErr == nil && err != nil {
|
||||
handleErr = err
|
||||
}
|
||||
endOperation(1, observation.Args{})
|
||||
}()
|
||||
|
||||
// If a maximum runtime is configured, set a deadline on the handle context.
|
||||
if w.options.MaximumRuntimePerJob > 0 {
|
||||
@ -383,7 +390,7 @@ func (w *Worker) handle(ctx, workerContext context.Context, record Record) (err
|
||||
}
|
||||
|
||||
// Open namespace for logger to avoid key collisions on fields
|
||||
handleErr := w.handler.Handle(ctx, handleLog.With(log.Namespace("handle")), record)
|
||||
handleErr = w.handler.Handle(ctx, handleLog.With(log.Namespace("handle")), record)
|
||||
|
||||
if w.options.MaximumRuntimePerJob > 0 && errors.Is(handleErr, context.DeadlineExceeded) {
|
||||
handleErr = errors.Wrap(handleErr, fmt.Sprintf("job exceeded maximum execution time of %s", w.options.MaximumRuntimePerJob))
|
||||
|
||||
@ -432,13 +432,13 @@ commands:
|
||||
cmd: env PATH="${PWD}/.bin:$PATH" .bin/zoekt-webserver -index "$HOME/.sourcegraph/zoekt/index-1" -pprof -rpc -listen "127.0.0.1:3071"
|
||||
|
||||
codeintel-worker:
|
||||
cmd: .bin/precise-code-intel-worker
|
||||
cmd: .bin/codeintel-worker
|
||||
install: |
|
||||
if [ -n "$DELVE" ]; then
|
||||
export GCFLAGS='all=-N -l'
|
||||
fi
|
||||
go build -gcflags="$GCFLAGS" -o .bin/precise-code-intel-worker github.com/sourcegraph/sourcegraph/enterprise/cmd/precise-code-intel-worker
|
||||
checkBinary: .bin/precise-code-intel-worker
|
||||
go build -gcflags="$GCFLAGS" -o .bin/codeintel-worker github.com/sourcegraph/sourcegraph/enterprise/cmd/precise-code-intel-worker
|
||||
checkBinary: .bin/codeintel-worker
|
||||
watch:
|
||||
- lib
|
||||
- internal
|
||||
@ -573,7 +573,7 @@ commands:
|
||||
install: |
|
||||
mkdir -p "${GRAFANA_DISK}"
|
||||
mkdir -p "$(dirname ${GRAFANA_LOG_FILE})"
|
||||
|
||||
export CACHE=true
|
||||
docker inspect $CONTAINER >/dev/null 2>&1 && docker rm -f $CONTAINER
|
||||
./docker-images/grafana/build.sh
|
||||
env:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user