Commit Graph

13 Commits

Author SHA1 Message Date
Camden Cheek
db7a268c34
Chore: remove search console (#63322)
The search console page is broken, is not used or maintained, and is
only referenced by a series of blog posts years ago. We have product
support to remove it.
2024-06-19 11:05:03 -06:00
Petri-Johan Last
0b5e7fd490
Replace all traditional for-loops (#60988) 2024-03-11 16:05:47 +02:00
Camden Cheek
f3f8151c51
Search: respect the search.contextLines setting in the backend (#58943)
Currently, we do not respect the search.contextLines setting in the backend. Specifically, the search backend currently always yields results with zero lines of context.

One effect of this is in order to display matches with context lines, any client needs to make a followup request to fetch the full contents of the file. This makes the UI feel laggy because results filter in slowly as you scroll. This is exacerbated by the fact that we load the highlighted code, and highlighting can be unpredictable, sometimes taking a couple seconds to return.

We already stream the matched chunk back to the client, so this just updates the backend so that the streamed results include the number of context lines a user requested. Zoekt already supports this, so it was just a matter of taking advantage of that setting and updating searcher to do the same.
2023-12-15 16:32:25 -07:00
Erik Seliger
7cdadb80ab
Remove unused settings and env vars (#58580)
Found while cleaning up sourcegraph.com
2023-11-27 10:08:12 +01:00
Camden Cheek
539a5e2b38
Chore: construct logger inside dbtest.NewDB (#57549)
construct logger inside dbtest.NewDB
2023-10-11 20:41:11 -05:00
Camden Cheek
084a10ba3b
Tracing: final cleanups (#54694)
This will be my last PR related to the backend tracing work I've been
doing. This is a set of small cleanups to the `trace` package that I've
collecting as I have worked on tracing and used tracing. Following this
PR, the `trace` package is just a very lightweight wrapper around the
standard OpenTelemetry APIs. I think it's best to keep the package
around rather than using opentelemetry directly because it easy to add
convenience methods (which I would be sad to lose).

Each commit is self-contained and has a descriptive message.

If anyone wants to pick up where I'm leaving off, here are a few things
left undone:
- Convert Zoekt to use OpenTelemetry rather than OpenTracing
- Add OpenTelemetry support to other services like syntect-server
- Merge the `internal/trace` and `internal/tracer` packages
- Consider adding a type that conforms to the OpenTelemetry `Span`
interface but also writes to `x/net/trace` that can be enabled when
tracing is not available.
- Remove unrelated code from the `trace` and `tracer` package (see
[here](https://sourcegraph.com/github.com/sourcegraph/sourcegraph@a6759b95dbd8e5e3a604f7fd452b0b85f37091d9/-/blob/internal/tracer/tracer.go?L75-83)
and
[here](https://sourcegraph.com/github.com/sourcegraph/sourcegraph@769fbbf5008e8decc63967dbff53f26333620265/-/blob/internal/trace/buckets.go?L3-7))
- Noodle on a `Traceable` interface (one that impls `Attr()` or
`Attrs()`) so types can be easily added with `SetAttributes()`
- Experiment with sampling
- Experiment with replacing `policy.ShouldTrace` with native
opentelemetry tools

## Test plan

Tested manually that tracing still looks good locally. Will test on
other instances when it rolls out.

<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->
2023-07-13 10:16:11 +02:00
Camden Cheek
cf037e2ee4
Tracing: replace family and title with name (#54563)
This removes the "title" argument to `trace.New()`. This was previously
only displayed as an attribute on the span, which is confusing since
people would often use a span name for this argument since it is called
"title." OpenTelemetry does not have the concept of a family and title
(these are from `x/net/trace`, which is no longer used), so this is
another step towards reconciling our tracing package with OpenTelemetry.

Basically, I went through all uses of `trace.New()` and either named the
span `family.title`, removed the title in the case it was an empty
string, or converted the title to a set of more structured attributes.

Now, `trace.New()` only takes a context, a span name, and an optional
set of attributes.
2023-07-05 23:14:18 +00:00
Camden Cheek
640a338cf4
Settings: make DB calls sequentially (#53803)
We're getting a [concurrent transaction
error](https://sourcegraph.sentry.io/issues/4263654659/?project=6583153&referrer=slack)
from settings because somewhere we're passing a transaction as the
`database.DB` then using it concurrently in this method.

This updates the DB calls to run sequentially. This comes with a perf
penalty, but I'd prefer a small perf impact to
erroring/crashing/silently doing the wrong thing. As a followup, I will
add a DB method that allows you to request settings for multiple
subjects at once. That might not come until after 5.1 though, so I'd at
least like to get this merged and backported.
2023-06-20 21:14:29 +00:00
Milan Freml
c31e079b5b
[chore] Refactored to use common pointers helper functions (#53441)
Originally I started working on this because of
[comment on another
PR](https://github.com/sourcegraph/sourcegraph/pull/53373#discussion_r1228058455).
I quickly wrote an implementation of Ptr and NonZeroPtr. Then I started
refactoring existing code only to find out that @efritz already beat me
to it. But Erics implementation was hidden in
internal/codeintel/resolvers/utils.go

Moved all of the Ptr functions to `pointers` package instead and
refactored all existing code that I could find to use it instead of
redefining the same functions all the time.

Usage is mostly in tests, so hopefully the impact is not as huge as the
diff size might suggest.



## Test plan

A whole lot of unit tests.
2023-06-14 16:48:44 +02:00
Keegan Carruthers-Smith
4b7fde7a2c
settings: introduce Service interface (#53157)
We introduce a service interface for calculating user (and other subjects) settings.

The intention is to make this another service we can inject.

Test Plan: CI
2023-06-09 13:18:57 +00:00
Keegan Carruthers-Smith
99b829a3ac
settings: unexport Latest (#53158)
This is unused outside of the package and the docstring already warns
against using it directly.

Test Plan: CI
2023-06-09 09:28:57 +02:00
Jean-Hadrien Chabran
3d36d34b3d
ci: re-enable race detection (#52776)
The previous approach to enable race detection was too radical and
accidently led to build our binaries with the race flage enabled, which
caused issues when building images down the line.

This happened because putting a `test --something` in bazelrc also sets
it on `build` which is absolutely not what we wanted. Usually folks get
this one working by having a `--stamp` config setting that fixes this
when releasing binaries, which we don't at this stage, as we're still
learning Bazel.

Luckily, this was caught swiftly. The current approach insteads takes a
more granular approach, which makes the `go_test` rule uses our own
variant, which injects the `race = "on"` attribute, but only on
`go_test`.


## Test plan

<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->

CI, being a main-dry-run, this will cover the container building jobs,
which were the ones failing.

---------

Co-authored-by: Alex Ostrikov <alex.ostrikov@sourcegraph.com>
2023-06-05 20:41:47 +02:00
Camden Cheek
016c64742f
Backend: mint settings package (#52476)
This creates a new `internal/settings` package that handles the settings
cascade logic. This allows us to get a user's settings without a
dependency on the `graphqlbackend` settings resolvers.
2023-05-25 18:59:12 -06:00