Skip to content

Commit

Permalink
apply changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kludex committed Oct 18, 2024
1 parent a9dd756 commit ed45090
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions docs/guides/advanced/link-to-code-source.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,44 @@
!!! warning "Experimental"
This feature is experimental and may change in the future.

Please give us feedback on [Slack][slack].
If you have any feedback or suggestions, please [let us know][help].

We support linking to the source code on GitHub, or any other VCS provider.
We support linking to the source code on GitHub or any other VCS provider.

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

## Usage

To enable source code linking with Logfire, you need to configure your project. Here's how:
Here's an example:

```python
import logfire

logfire.configure(
code_source=logfire.CodeSource(
repository='https://github.com/pydantic/logfire',
revision='main',
root_path='.',
repository='https://github.com/pydantic/logfire', #(1)!
revision='main', #(2)!
root_path='.', #(3)!
)
)
```

You can check more about it on the [`logfire.CodeSource`][logfire.CodeSource] on our API reference.
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.

| Parameter | Description |
| --- | --- |
| `repository` | The URL of the repository e.g. `https://github.com/pydantic/logfire` |
| `revision` | The specific branch, tag, or commit hash to link to e.g. `main` |
| `root_path` | 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

Alternatively, you can configure these settings using the [`OTEL_RESOURCE_ATTRIBUTES`][otel-resource-attributes] environment variable:
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=.
```

[slack]: https://join.slack.com/t/pydanticlogfire/shared_invite/zt-2b57ljub4-936siSpHANKxoY4dna7qng
[help]: ../../help.md
[otel-resource-attributes]: https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/#general-sdk-configuration

0 comments on commit ed45090

Please sign in to comment.