Skip to content

Commit

Permalink
Document Code Source links (#505)
Browse files Browse the repository at this point in the history
Co-authored-by: Sydney Runkle <54324534+sydney-runkle@users.noreply.github.com>
  • Loading branch information
Kludex and sydney-runkle authored Oct 18, 2024
1 parent 0428370 commit fa559ad
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 9 deletions.
44 changes: 44 additions & 0 deletions docs/guides/advanced/link-to-code-source.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
!!! warning "Experimental"
This feature is experimental and may change in the future.

If you have any feedback or suggestions, please [let us know][help].

We support linking to the source code on GitHub, GitLab, and any other VCS provider that uses the same URL format.

![Link to GitHub](../../images/guide/link-to-github.gif)

## Usage

Here's an example:

```python
import logfire

logfire.configure(
code_source=logfire.CodeSource(
repository='https://github.com/pydantic/logfire', #(1)!
revision='<hash of commit used on release>', #(2)!
root_path='.', #(3)!
)
)
```

1. The URL of the repository e.g. `https://github.com/pydantic/logfire`.
2. The specific branch, tag, or commit hash to link to e.g. `main`.
3. The path to the root of the repository. If your code is in a subdirectory, you can specify it here.

You can learn more in our [`logfire.CodeSource`][logfire.CodeSource] API reference.

## Alternative Configuration

For other OpenTelemetry SDKs, you can configure these settings using resource attributes, e.g. by setting the
[`OTEL_RESOURCE_ATTRIBUTES`][otel-resource-attributes] environment variable:

```
OTEL_RESOURCE_ATTRIBUTES=vcs.repository.url.full=https://github.com/pydantic/platform
OTEL_RESOURCE_ATTRIBUTES=${OTEL_RESOURCE_ATTRIBUTES},vcs.repository.ref.revision=main
OTEL_RESOURCE_ATTRIBUTES=${OTEL_RESOURCE_ATTRIBUTES},vcs.root.path=.
```

[help]: ../../help.md
[otel-resource-attributes]: https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/#general-sdk-configuration
Binary file added docs/images/guide/link-to-github.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 0 additions & 7 deletions docs/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@ new event has occurred.

See [this GitHub issue][alerts-email-gh-issue] for more information.

### Links to GitHub code source

You'll be able to go to your GitHub repository directly from the Logfire UI, and see
the code of a logfire call or exception.

See [this GitHub issue][gh-code-source-gh-issue] for more information.

### Cross-Project Dashboards

You'll be able to create dashboards with information from multiple projects.
Expand Down
5 changes: 3 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,11 @@ nav:
- Sampling: guides/advanced/sampling.md
- Scrubbing: guides/advanced/scrubbing.md
- Generators: guides/advanced/generators.md
- Testing: guides/advanced/testing.md
- Backfill: guides/advanced/backfill.md
- Creating Write Tokens: guides/advanced/creating-write-tokens.md
- Query API: guides/advanced/query-api.md
- Link to Code Source: guides/advanced/link-to-code-source.md
- Testing: guides/advanced/testing.md
- Backfill: guides/advanced/backfill.md
- Integrations:
- Integrations: integrations/index.md
- OpenTelemetry:
Expand Down

0 comments on commit fa559ad

Please sign in to comment.