Skip to content

Commit

Permalink
Merge branch 'main' into anthropic-bedrock
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenhibbert authored Dec 20, 2024
2 parents 4a99039 + 5ef452b commit 29f6eb5
Show file tree
Hide file tree
Showing 47 changed files with 810 additions and 458 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Release Notes

## [v2.9.0] (2024-12-20)

* Capture httpx response JSON bodies by @alexmojaki in [#700](https://github.com/pydantic/logfire/pull/700)
* Use end-at-shutdown and custom `record_exception` logic for all spans by @dmontagu in [#696](https://github.com/pydantic/logfire/pull/696)

## [v2.8.0] (2024-12-18)

* Add `capture_(request|response)_headers` ([#671](https://github.com/pydantic/logfire/pull/671)) and `capture_request_json_body` ([#682](https://github.com/pydantic/logfire/pull/682)) to `instrument_httpx` by @Kludex
Expand Down Expand Up @@ -480,3 +485,4 @@ First release from new repo!
[v2.7.0]: https://github.com/pydantic/logfire/compare/v2.6.2...v2.7.0
[v2.7.1]: https://github.com/pydantic/logfire/compare/v2.7.0...v2.7.1
[v2.8.0]: https://github.com/pydantic/logfire/compare/v2.7.1...v2.8.0
[v2.9.0]: https://github.com/pydantic/logfire/compare/v2.8.0...v2.9.0
4 changes: 2 additions & 2 deletions docs/get-started/traces.md → docs/concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ with logfire.span('counting size of {cwd=}', cwd=cwd):
logfire.info('total size of {cwd} is {size} bytes', cwd=cwd, size=total_size)
```

![Counting size of loaded files screenshot](../images/logfire-screenshot-first-steps-load-files.png)
![Counting size of loaded files screenshot](images/logfire-screenshot-first-steps-load-files.png)

---

Expand All @@ -55,7 +55,7 @@ with logfire.span('Asking the user for their {question}', question='birthday'):
2. Attempt to extract a date from the user input. If any exception is raised, the outer span will include the details of the exception.
3. This will log for example `dob=2000-01-01 age=datetime.timedelta(days=8838)` with `debug` level.

![Logfire hello world screenshot](../images/index/logfire-screenshot-hello-world-age.png)
![Logfire hello world screenshot](images/index/logfire-screenshot-hello-world-age.png)

---

Expand Down
2 changes: 1 addition & 1 deletion docs/guides/onboarding-checklist/add-auto-tracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ main()
```

!!! note
Generator functions will not be traced for reasons explained [here](../advanced/generators.md).
Generator functions will not be traced for reasons explained [here](../../reference/advanced/generators.md).

## Only tracing functions above a minimum duration

Expand Down
2 changes: 1 addition & 1 deletion docs/guides/onboarding-checklist/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fix bugs, analyze user behavior, and make data-driven decisions.
!!! note

If you aren't familiar with traces and spans, start with the
[Tracing with Spans](../../get-started/traces.md) page.
[Tracing with Spans](../../concepts.md) page.

#### Logfire Onboarding Checklist

Expand Down
25 changes: 17 additions & 8 deletions docs/guides/web-ui/live.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ To search the live view, click `Search your spans` (keyboard shortcut `/`), this

### SQL Search

For confident SQL users, write your queries directly here. For devs who want a bit of help, try the new [PydanticAI](https://ai.pydantic.dev/) feature which generates a SQL query based on your prompt. You can also review the fields available and populate your SQL automatically using the `Reference` list, see more on this below.
For confident SQL users, write your queries directly here. For devs who want a bit of help,
try the new [PydanticAI](https://ai.pydantic.dev/) feature which generates a SQL query based on your prompt.
You can also review the fields available and populate your SQL automatically using the `Reference` list, see more on this below.

**WHERE clause**
As the greyed out `SELECT * FROM RECORDS WHERE` implies, you're searching inside the `WHERE` clause of a SQL query. It has auto-complete & schema hints, so try typing something to get a reminder. To run your query click `Run` or keyboard shortcut `cmd+enter` (or `ctrl+enter` on windows/linux).
**WHERE clause**
As the greyed out `SELECT * FROM RECORDS WHERE` implies, you're searching inside the `WHERE` clause of a SQL query.
It has auto-complete & schema hints, so try typing something to get a reminder. To run your query click `Run` or
keyboard shortcut `cmd+enter` (or `ctrl+enter` on Windows/Linux).

Note: you can run more complex queries on the [explore screen](explore.md)

Expand Down Expand Up @@ -62,7 +66,7 @@ If you're not sure where to start, scroll down to the `Start here` for beginner-

### Ask in Language -> Get SQL

Write your question in your native language, and the model will convert that question to a SQL query.
Write your question in your native language, and the model will convert that question to a SQL query.

![Search box natural language](../../images/guide/live-view-natural-language.png)

Expand All @@ -74,18 +78,23 @@ Under the hood this feature uses an LLM running with [PydanticAI](https://github

Reference: A list of pre-populated query clauses. Clicking any of the clauses will populate the SQL editor, and (where applicable) you can choose a value from the autopopulated dropdown.

This list gives you a powerful way to rapidly generate the query you need, while simultaneously learning more about all the ways you can search your data. Clicking multiple clauses will add them to your query with a SQL `AND` statement. If you'd like something other than an `AND` statement, you can replace this with alternative SQL operators like `OR`, or `NOT`.

This list gives you a powerful way to rapidly generate the query you need, while simultaneously
learning more about all the ways you can search your data. Clicking multiple clauses will add them
to your query with a SQL `AND` statement. If you'd like something other than an `AND` statement, you
can replace this with alternative SQL operators like `OR`, or `NOT`.

## Details panel closed

![Logfire live view collapsed](../../images/guide/live-view-collapsed-annotated.png)

This is what you'll see when you come to the live view of a project with some data.

1. **Organization and project labels:** In this example, the organization is `christophergs`, and the project is `docs-app`. You can click the organization name to go to the organization overview page; the project name is a link to this page.
1. **Organization and project labels:** In this example, the organization is `christophergs`, and
the project is `docs-app`. You can click the organization name to go to the organization overview page;
the project name is a link to this page.

2. **Environment:** In the above screenshot, this is set to `all envs`. See the [environments docs](../advanced/environments.md) for details.
2. **Environment:** In the above screenshot, this is set to `all envs`.
See the [environments docs](../../how-to-guides/environments.md) for details.

3. **Timeline:** This shows a histogram of the counts of spans matching your query over time. The blue-highlighted section corresponds to the time range currently visible in the scrollable list of traces below. You can click at points on this line to move to viewing logs from that point in time.

Expand Down
1 change: 0 additions & 1 deletion docs/help.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
hide:
- navigation
- toc
---

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ these [environment variables](https://opentelemetry.io/docs/languages/sdk-config
- `OTEL_EXPORTER_OTLP_ENDPOINT=https://logfire-api.pydantic.dev` for both traces and metrics, or:
- `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://logfire-api.pydantic.dev/v1/traces` for just traces
- `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=https://logfire-api.pydantic.dev/v1/metrics` for just metrics
- `OTEL_EXPORTER_OTLP_HEADERS='Authorization=your-write-token'` - see [Creating Write Tokens](./creating-write-tokens.md)
- `OTEL_EXPORTER_OTLP_HEADERS='Authorization=your-write-token'` - see [Create Write Tokens](./create-write-tokens.md)
to obtain a write token and replace `your-write-token` with it.
- `OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf` to export in Protobuf format over HTTP (not gRPC).
The **Logfire** backend supports both Protobuf and JSON, but only over HTTP for now. Some SDKs (such as Python) already use this value as the default so setting this isn't required, but other SDKs use `grpc` as the default.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
To send data to **Logfire**, you need to create a write token.
A write token is a unique identifier that allows you to send data to a specific **Logfire** project.
If you set up Logfire according to the [getting started guide](../../index.md), you already have a write token locally tied to the project you created.
If you set up Logfire according to the [getting started guide](../index.md), you already have a write token locally tied to the project you created.
But if you want to configure other computers to write to that project, for example in a deployed application, you need to create a new write token.

You can create a write token by following these steps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ If you are using languages other than Python, you can set the environment like t
---

Once set, you will see your environment in the Logfire UI `all envs` dropdown,
which is present on the [Live View](../web-ui/live.md), [Dashboards](../web-ui/dashboards.md) and [Explore](../web-ui/explore.md) pages:
which is present on the [Live View](../guides/web-ui/live.md), [Dashboards](../guides/web-ui/dashboards.md)
and [Explore](../guides/web-ui/explore.md) pages:

![Environments](../../images/guide/environments.png)
![Environments](../images/guide/environments.png)

!!! info
When using an environment for the first time, it may take a **few minutes** for the environment to appear in the UI.
Expand Down Expand Up @@ -55,5 +56,5 @@ environment name.
## Should I use environments or projects?

Environments are more lightweight than projects. Projects give you the ability to assign specific
user groups and permissions levels (see this [organization structure diagram](../../reference/organization-structure.md)
user groups and permissions levels (see this [organization structure diagram](../reference/organization-structure.md)
for details). So if you need to allow different team members to view dev vs. prod traces, then projects would be a better fit.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

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)
![Link to GitHub](../images/guide/link-to-github.gif)

## Usage

Expand Down Expand Up @@ -40,5 +40,5 @@ OTEL_RESOURCE_ATTRIBUTES=${OTEL_RESOURCE_ATTRIBUTES},vcs.repository.ref.revision
OTEL_RESOURCE_ATTRIBUTES=${OTEL_RESOURCE_ATTRIBUTES},vcs.root.path=.
```

[help]: ../../help.md
[help]: ../help.md
[otel-resource-attributes]: https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/#general-sdk-configuration
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ See [here](#additional-configuration) for more details about the available respo

## How to Create a Read Token

If you've set up Logfire following the [getting started guide](../../index.md), you can generate read tokens from
If you've set up Logfire following the [getting started guide](../index.md), you can generate read tokens from
the Logfire web interface, for use accessing the Logfire Query API.

To create a read token:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ User details: User(id=123, password='secret')
This is necessary so that safe messages such as 'Password is correct' are not redacted completely.

Using f-strings (e.g. `logfire.info(f'User details: {user}')`) *is* safe if `inspect_arguments` is enabled (the default in Python 3.11+) and working correctly.
[See here](../onboarding-checklist/add-manual-tracing.md#f-strings) for more information.
[See here](../guides/onboarding-checklist/add-manual-tracing.md#f-strings) for more information.

In short, don't format the message yourself. This is also a good practice in general for [other reasons](../onboarding-checklist/add-manual-tracing.md#messages-and-span-names).
In short, don't format the message yourself. This is also a good practice in general for [other reasons](../guides/onboarding-checklist/add-manual-tracing.md#messages-and-span-names).

### Keep sensitive data out of URLs

Expand Down
15 changes: 8 additions & 7 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ From the team behind **Pydantic**, **Logfire** is a new type of observability pl
the same belief as our open source library — that the most powerful tools can be easy to use.

**Logfire** is built on OpenTelemetry, and supports monitoring your application from any language,
with particularly great support for Python! [Read more](why-logfire/index.md).
with particularly great support for Python! [Read more](why.md).

## Getting Started

Expand Down Expand Up @@ -52,7 +52,8 @@ logfire auth
## Instrument your project {#instrument}
=== ":material-cog-outline: Development"
!!! tip "Development setup"
During development, we recommend using the CLI to configure Logfire. You can also use a [write token](guides/advanced/creating-write-tokens.md).
During development, we recommend using the CLI to configure Logfire.
You can also use a [write token](how-to-guides/create-write-tokens.md).

1. Set your project

Expand All @@ -72,8 +73,8 @@ logfire auth
logfire.info('Hello, {name}!', name='world') # (2)!
```

1. The `configure()` method should be called once before logging to initialize **Logfire**.
2. This will log `Hello world!` with `info` level.
3. The `configure()` method should be called once before logging to initialize **Logfire**.
4. This will log `Hello world!` with `info` level.

!!! info ""
Other [log levels][logfire.Logfire] are also available to use, including `trace`, `debug`, `notice`, `warn`,
Expand All @@ -97,8 +98,8 @@ logfire auth

2. Configure your **Logfire** environment

```bash title="in the terminal:"
LOGFIRE_TOKEN=<your-write-token>
```bash title="In the terminal:"
export LOGFIRE_TOKEN=<your-write-token>
```

!!! info ""
Expand Down Expand Up @@ -130,7 +131,7 @@ logfire auth

Ready to keep going?

- Read about [Tracing with Spans](get-started/traces.md)
- Read about [Concepts](concepts.md)
- Complete the [Onboarding Checklist](guides/onboarding-checklist/index.md)

More topics to explore...
Expand Down
2 changes: 1 addition & 1 deletion docs/integrations/event-streams/airflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,4 @@ otel_task_log_event = True
[OpenTelemetry Collector]: https://opentelemetry.io/docs/collector/
[OpenTelemetry Collector installation]: https://opentelemetry.io/docs/collector/installation/
[OpenTelemetry Collector Receiver]: https://opentelemetry.io/docs/collector/configuration/#receivers
[write-token]: ../../guides/advanced/creating-write-tokens.md
[write-token]: ../../how-to-guides/create-write-tokens.md
2 changes: 1 addition & 1 deletion docs/integrations/llms/anthropic.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ integration: logfire
**Logfire** supports instrumenting calls to [Anthropic](https://github.com/anthropics/anthropic-sdk-python)
with one extra line of code.

```python hl_lines="6"
```python hl_lines="7"
import anthropic
import logfire

Expand Down
2 changes: 1 addition & 1 deletion docs/integrations/llms/mirascope.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Since Mirascope is built on top of [Pydantic][pydantic], you can use the [Pydant

This can be particularly useful when [extracting structured information][mirascope-extracting-structured-information] using LLMs:

```py hl_lines="3 5 8 17"
```py hl_lines="3 5 8 18"
from typing import Literal, Type

import logfire
Expand Down
19 changes: 19 additions & 0 deletions docs/integrations/logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,23 @@ logger.error("Hello %s!", "Fred")
# 10:05:06.855 Hello Fred!
```

## Oh no! Too many logs from...

A common issue with logging is that it can be **too verbose**... Right? :sweat_smile:

Don't worry! We are here to help you.

In those cases, you can set the log level to a higher value to suppress logs that are less important.
Let's see an example with the [`apscheduler`](https://apscheduler.readthedocs.io/en/3.x/) logger:

```py title="main.py"
import logging

logger = logging.getLogger("apscheduler")
logger.setLevel(logging.WARNING)
```

In this example, we set the log level of the `apscheduler` logger to `WARNING`, which means that
only logs with a level of `WARNING` or higher will be emitted.

[logging]: https://docs.python.org/3/library/logging.html
2 changes: 1 addition & 1 deletion docs/integrations/web-frameworks/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ To replace the `Authorization` header value with `[REDACTED]` to avoid leaking u
OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SANITIZE_FIELDS="Authorization"
```

(although usually it's better to rely on **Logfire**'s [scrubbing](../../guides/advanced/scrubbing.md) feature)
(although usually it's better to rely on **Logfire**'s [scrubbing](../../how-to-guides/scrubbing.md) feature)

## Query HTTP requests duration per percentile

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion docs/reference/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This example is a simple Python financial calculator app using Flask and SQLAlch

## JavaScript

Currently we only have a Python SDK, but the Logfire backend and UI support data sent by any OpenTelemetry client. See the [alternative clients guide](../guides/advanced/alternative-clients.md) for details on setting up OpenTelemetry in any language. We're working on a JavaScript SDK, but in the meantime here are some examples of using plain OpenTelemetry in JavaScript:
Currently we only have a Python SDK, but the Logfire backend and UI support data sent by any OpenTelemetry client. See the [alternative clients guide](../how-to-guides/alternative-clients.md) for details on setting up OpenTelemetry in any language. We're working on a JavaScript SDK, but in the meantime here are some examples of using plain OpenTelemetry in JavaScript:

### Cloudflare worker example

Expand Down
5 changes: 0 additions & 5 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
---
hide:
- navigation
---

--8<-- "CHANGELOG.md"
9 changes: 1 addition & 8 deletions docs/roadmap.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
---
hide:
- navigation
---

# Roadmap

Here is the roadmap for **Pydantic Logfire**. This is a living document, and it will be updated as we progress.

If you have any questions, or a feature request, **please join our [Slack][slack]**.
Expand Down Expand Up @@ -72,7 +65,7 @@ Logfire is built on top of OpenTelemetry, which means that it supports all the l
Still, we are planning to create custom SDKs for JavaScript, TypeScript, and Rust, and make sure that the
attributes are displayed in a nice way in the Logfire UI — as they are for Python.

For now, you can check our [Alternative Clients](guides/advanced/alternative-clients.md) section to see how
For now, you can check our [Alternative Clients](how-to-guides/alternative-clients.md) section to see how
you can send data to Logfire from other languages.

See [this GitHub issue][language-support-gh-issue] for more information.
Expand Down
Loading

0 comments on commit 29f6eb5

Please sign in to comment.