docs: add more hints to observability docs; add database intellij docs (#62183)

* docs: add more hints to observability docs; add database intellij docs

* localize images
This commit is contained in:
Michael Bahr 2024-04-30 10:19:13 +02:00 committed by GitHub
parent 0fb6806f3b
commit 7bc5d6cd9c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 65 additions and 2 deletions

View File

@ -51,11 +51,18 @@ The response headers of the response will now include an `x-trace-url` entry, wh
Note that getting a trace URL requires `urlTemplate` to be configured.
Alternatively you can use the GraphQL API console: Log in to your Sourcegraph instance of choice, navigate
to `/api/console` (e.g. https://sourcegraph.sourcegraph.com/api/console) and add the query parameter `trace=1` to your browser's URL.
Open the developer tools' network tab to inspect your request and find the tracing link in the response headers.
## Tracing backends
Tracing backends can be configured for Sourcegraph to export traces to.
We support exporting traces via [OpenTelemetry](#opentelemetry) (recommended), or directly to [Jaeger](#jaeger).
When you use `sg`, you can run `sg start otel` to start the tracing backend. Requests with `trace=1` or the according
tracing header will then contain a response header with a link to your local tracing backend.
### OpenTelemetry
To learn about exporting traces to various backends using OpenTelemetry, review our [OpenTelemetry documentation](./opentelemetry.md).

View File

@ -1,6 +1,6 @@
# How to debug live code
How to debug a program with Visual Studio Code:
How to debug a program with Visual Studio Code. Instructions for debugging Go code with Goland/IntelliJ [here](#attaching-via-goland)
## Debug TypeScript code
@ -18,7 +18,7 @@ Requires "Debugger for Chrome" extension.
## Debug Go code
Instructions for attaching with Goland [here](#attaching-via-goland)
Instructions for attaching with Goland/IntelliJ [here](#attaching-via-goland).
Install [Delve](https://github.com/derekparker/delve):

View File

@ -28,6 +28,7 @@
- [Set up local development with Zoekt and Sourcegraph](zoekt_local_dev.md)
- [How to debug live code](debug_live_code.md)
- [Ignoring editor config files in Git](ignoring_editor_config_files.md)
- [How to inspect the database from IntelliJ](inspect_postgres_from_intellij.md)
## Testing Sourcegraph & CI

View File

@ -0,0 +1,55 @@
# Inspecting the Postgres database with IntelliJ
This guide teaches you step by step how to use the Database plugin of IntelliJ to set up a connection
to your local sourcegraph database, and how to run SQL queries through it.
If you haven't done so yet, run `sg setup` and `sg start` to make sure your database is up and running.
Below we'll assume the default config for postgres. It is defined in [`sg.config.yaml`](/sg.config.yaml) (or your overrides),
and has `env` keys like `PGPASSWORD` and `PGPORT`.
## 1. Open the database plugin
It's usually on the right edge of your IDE.
![](https://storage.googleapis.com/sourcegraph-assets/docs/images/dev/how-to/intellij-database-database-plugin.png)
## 2. Create a new PostgreSQL connection
Click the `+` sign, then Data Source, and then find PostgreSQL.
![](https://storage.googleapis.com/sourcegraph-assets/docs/images/dev/how-to/intellij-database-create-data-source.png)
## 3. Credentials and Database
Enter the credentials as you see them in the [`sg.config.yaml`](/sg.config.yaml) (or your overrides) mentioned above.
Also enter `sourcegraph` as the database name (or the override that you're using).
![](https://storage.googleapis.com/sourcegraph-assets/docs/images/dev/how-to/intellij-database-config.png)
Below the connection settings you can click on "Test Connection" to make sure that your drivers are working.
IntelliJ may prompt you to download the drivers then.
![](https://storage.googleapis.com/sourcegraph-assets/docs/images/dev/how-to/intellij-database-test-connection.png)
## 4. Select the sourcegraph public schemas
In the `Schema` tab of the connection settings, select the `sourcegraph` database, and its `public` schema. Extend
the `sourcegraph` database if you don't see the `public` schema.
![](https://storage.googleapis.com/sourcegraph-assets/docs/images/dev/how-to/intellij-database-select-schema.png)
Click on Ok to wrap it up.
## Select a table
Open the datasource on the right, and drill down to a table. You can double-click a table to see its content.
![](https://storage.googleapis.com/sourcegraph-assets/docs/images/dev/how-to/intellij-database-select-table.png)
## Query
By click `+` and then Query Console or Shift+CMD+L (on Mac), you can get a regular SQL query editor.
![](https://storage.googleapis.com/sourcegraph-assets/docs/images/dev/how-to/intellij-database-query.png)