Commit 1001b660 authored by Jacob Vosmaer's avatar Jacob Vosmaer Committed by Nick Thomas

Add logging for local LSIF ZIP caching

parent df805fb1
---
title: Add logging for local LSIF ZIP caching
merge_request: 579
author:
type: added
......@@ -2,11 +2,14 @@ package parser
import (
"archive/zip"
"context"
"errors"
"fmt"
"io"
"io/ioutil"
"os"
"gitlab.com/gitlab-org/labkit/log"
)
var (
......@@ -23,7 +26,7 @@ type Config struct {
TempPath string
}
func NewParser(r io.Reader, config Config) (io.ReadCloser, error) {
func NewParser(ctx context.Context, r io.Reader, config Config) (io.ReadCloser, error) {
docs, err := NewDocs(config)
if err != nil {
return nil, err
......@@ -45,6 +48,7 @@ func NewParser(r io.Reader, config Config) (io.ReadCloser, error) {
if err != nil {
return nil, err
}
log.WithContextFields(ctx, log.Fields{"lsif_zip_cache_bytes": size}).Print("cached incoming LSIF zip on disk")
zr, err := zip.NewReader(tempFile, size)
if err != nil {
......
......@@ -3,6 +3,7 @@ package parser
import (
"archive/zip"
"bytes"
"context"
"encoding/json"
"io"
"io/ioutil"
......@@ -42,7 +43,7 @@ func createFiles(t *testing.T, filePath, tmpDir string) {
file, err := os.Open(filePath)
require.NoError(t, err)
parser, err := NewParser(file, Config{})
parser, err := NewParser(context.Background(), file, Config{})
require.NoError(t, err)
zipFileName := tmpDir + ".zip"
......
package parser
import (
"context"
"io"
"io/ioutil"
"os"
......@@ -21,7 +22,7 @@ func BenchmarkGenerate(b *testing.B) {
file, err := os.Open(filePath)
require.NoError(b, err)
parser, err := NewParser(file, Config{})
parser, err := NewParser(context.Background(), file, Config{})
require.NoError(b, err)
_, err = io.Copy(ioutil.Discard, parser)
......
......@@ -187,7 +187,7 @@ func handleLsifUpload(ctx context.Context, reader io.Reader, tempPath, filename
TempPath: tempPath,
}
return parser.NewParser(reader, parserConfig)
return parser.NewParser(ctx, reader, parserConfig)
}
func (rew *rewriter) copyPart(ctx context.Context, name string, p *multipart.Part) error {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment