Skip to content

Commit

Permalink
Organize the documentation (#483)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kludex authored Oct 9, 2024
1 parent 9e47aa7 commit b204ba4
Show file tree
Hide file tree
Showing 21 changed files with 44 additions and 36 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ First release from new repo!
[v0.53.0]: https://github.com/pydantic/logfire/compare/v0.52.0...v0.53.0
[v0.52.0]: https://github.com/pydantic/logfire/compare/v0.51.0...v0.52.0
[v0.51.0]: https://github.com/pydantic/logfire/compare/v0.50.1...v0.51.0
[v0.50.1]: https://github.com/pydantic/logfire/compare/v0.50.0...v0.50.1
[v0.50.0]: https://github.com/pydantic/logfire/compare/v0.49.1...v0.50.0
[v0.49.1]: https://github.com/pydantic/logfire/compare/v0.49.0...v0.49.1
[v0.49.0]: https://github.com/pydantic/logfire/compare/v0.48.1...v0.49.0
Expand Down
1 change: 0 additions & 1 deletion docs/api/integrations/logging.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/api/integrations/structlog.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/help.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The [usage documentation](index.md) is the most complete guide on how to get sta

## :material-api: SDK API Documentation

The [SDK API documentation](api/logfire.md) give reference docs for the **Logfire** SDK.
The [SDK API documentation](reference/api/logfire.md) give reference docs for the **Logfire** SDK.

## :material-email: Email

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 4 additions & 8 deletions docs/examples.md → docs/reference/examples.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
---
hide:
- navigation
---
# Examples

These are working, stand-alone apps and projects that you can clone, spin up locally and play around with to get a feel for the different capabilities of Logfire.

**Got a suggestion?**

If you want to see an example of a particular language or library, [get in touch](help.md).
If you want to see an example of a particular language or library, [get in touch](../help.md).

## Python

### Flask and SQLAlchemy example

This example is a simple Python financial calculator app using Flask and SQLAlchemy which is instrumented using the appropriate integrations as well as [auto-tracing](guides/onboarding-checklist/add-auto-tracing.md). If you spin up the server locally and interact with the calculator app, you'll be able to see traces come in automatically:
This example is a simple Python financial calculator app using Flask and SQLAlchemy which is instrumented using the appropriate integrations as well as [auto-tracing](../guides/onboarding-checklist/add-auto-tracing.md). If you spin up the server locally and interact with the calculator app, you'll be able to see traces come in automatically:

![Flask and SQLAlchemy example](images/logfire-screenshot-examples-flask-sqlalchemy.png)
![Flask and SQLAlchemy example](../images/logfire-screenshot-examples-flask-sqlalchemy.png)

[See it on GitHub :material-open-in-new:](https://github.com/pydantic/logfire/tree/main/examples/python/flask-sqlalchemy/){:target="_blank"}

## 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](../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:

### Cloudflare worker example

Expand Down
6 changes: 0 additions & 6 deletions docs/reference/index.md

This file was deleted.

3 changes: 3 additions & 0 deletions docs/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ 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
you can send data to Logfire from other languages.

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

### Automatic anomaly detection
Expand Down
7 changes: 4 additions & 3 deletions logfire-api/logfire_api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from __future__ import annotations

from contextlib import contextmanager
import importlib
import sys
from typing import TYPE_CHECKING, ContextManager, Literal
from contextlib import nullcontext
from contextlib import contextmanager, nullcontext
from typing import Any, ContextManager, Literal, TYPE_CHECKING
from unittest.mock import MagicMock

try:
Expand Down Expand Up @@ -166,6 +165,8 @@ def shutdown(self, *args, **kwargs) -> None: ...
instrument_system_metrics = DEFAULT_LOGFIRE_INSTANCE.instrument_system_metrics
shutdown = DEFAULT_LOGFIRE_INSTANCE.shutdown

def loguru_handler() -> dict[str, Any]: ...

def no_auto_trace(x):
return x

Expand Down
10 changes: 9 additions & 1 deletion logfire-api/logfire_api/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ from .integrations.logging import LogfireLoggingHandler as LogfireLoggingHandler
from .integrations.structlog import LogfireProcessor as StructlogProcessor
from .version import VERSION as VERSION
from logfire.sampling import SamplingOptions as SamplingOptions
from typing import Any

__all__ = ['Logfire', 'LogfireSpan', 'LevelName', 'AdvancedOptions', 'ConsoleOptions', 'CodeSource', 'PydanticPlugin', 'configure', 'span', 'instrument', 'log', 'trace', 'debug', 'notice', 'info', 'warn', 'error', 'exception', 'fatal', 'force_flush', 'log_slow_async_callbacks', 'install_auto_tracing', 'instrument_pydantic', 'instrument_fastapi', 'instrument_openai', 'instrument_anthropic', 'instrument_asyncpg', 'instrument_httpx', 'instrument_celery', 'instrument_requests', 'instrument_psycopg', 'instrument_django', 'instrument_flask', 'instrument_starlette', 'instrument_aiohttp_client', 'instrument_sqlalchemy', 'instrument_redis', 'instrument_pymongo', 'instrument_mysql', 'instrument_system_metrics', 'AutoTraceModule', 'with_tags', 'with_settings', 'shutdown', 'load_spans_from_file', 'no_auto_trace', 'ScrubMatch', 'ScrubbingOptions', 'VERSION', 'suppress_instrumentation', 'StructlogProcessor', 'LogfireLoggingHandler', 'SamplingOptions', 'MetricsOptions']
__all__ = ['Logfire', 'LogfireSpan', 'LevelName', 'AdvancedOptions', 'ConsoleOptions', 'CodeSource', 'PydanticPlugin', 'configure', 'span', 'instrument', 'log', 'trace', 'debug', 'notice', 'info', 'warn', 'error', 'exception', 'fatal', 'force_flush', 'log_slow_async_callbacks', 'install_auto_tracing', 'instrument_pydantic', 'instrument_fastapi', 'instrument_openai', 'instrument_anthropic', 'instrument_asyncpg', 'instrument_httpx', 'instrument_celery', 'instrument_requests', 'instrument_psycopg', 'instrument_django', 'instrument_flask', 'instrument_starlette', 'instrument_aiohttp_client', 'instrument_sqlalchemy', 'instrument_redis', 'instrument_pymongo', 'instrument_mysql', 'instrument_system_metrics', 'AutoTraceModule', 'with_tags', 'with_settings', 'shutdown', 'load_spans_from_file', 'no_auto_trace', 'ScrubMatch', 'ScrubbingOptions', 'VERSION', 'suppress_instrumentation', 'StructlogProcessor', 'LogfireLoggingHandler', 'loguru_handler', 'SamplingOptions', 'MetricsOptions']

DEFAULT_LOGFIRE_INSTANCE = Logfire()
span = DEFAULT_LOGFIRE_INSTANCE.span
Expand Down Expand Up @@ -49,4 +50,11 @@ warn = DEFAULT_LOGFIRE_INSTANCE.warn
error = DEFAULT_LOGFIRE_INSTANCE.error
fatal = DEFAULT_LOGFIRE_INSTANCE.fatal
exception = DEFAULT_LOGFIRE_INSTANCE.exception

def loguru_handler() -> dict[str, Any]:
"""Create a **Logfire** handler for Loguru.
Returns:
A dictionary with the handler and format for Loguru.
"""
__version__ = VERSION
8 changes: 7 additions & 1 deletion logfire-api/logfire_api/_internal/config.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ class MetricsOptions:

@dataclass
class CodeSource:
"""Settings for the source code of the project."""
"""Settings for the source code of the project.
!!! Warning
This setting is experimental, and may change in the future!
"""
repository: str
revision: str
root_path: str
Expand Down Expand Up @@ -111,6 +115,8 @@ def configure(*, send_to_logfire: bool | Literal['if-token-present'] | None = No
Defaults to `True` if and only if the Python version is at least 3.11.
sampling: Sampling options. See the [sampling guide](https://logfire.pydantic.dev/docs/guides/advanced/sampling/).
code_source: Settings for the source code of the project.
!!! Warning
This setting is experimental, and may change in the future!
advanced: Advanced options primarily used for testing by Logfire developers.
"""

Expand Down
1 change: 1 addition & 0 deletions logfire/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def loguru_handler() -> dict[str, Any]:
'suppress_instrumentation',
'StructlogProcessor',
'LogfireLoggingHandler',
'loguru_handler',
'SamplingOptions',
'MetricsOptions',
)
2 changes: 1 addition & 1 deletion logfire/integrations/loguru.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Integration with Loguru."""
"""Integration with [Loguru](https://github.com/Delgan/loguru)."""

from __future__ import annotations

Expand Down
2 changes: 1 addition & 1 deletion logfire/integrations/structlog.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Logfire processor for structlog."""
"""Logfire processor for [structlog](https://www.structlog.org/en/stable/)."""

from __future__ import annotations

Expand Down
20 changes: 8 additions & 12 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,21 +138,17 @@ nav:
- Use Cases:
- Web Frameworks: integrations/use-cases/web-frameworks.md
- Reference:
- Reference: reference/index.md
- Examples: reference/examples.md
- Configuration: reference/configuration.md
- Organization Structure: reference/organization-structure.md
- SDK CLI: reference/cli.md
- SDK API:
- Logfire: api/logfire.md
- Testing: api/testing.md
- Sampling: api/sampling.md
- Propagate: api/propagate.md
- Exceptions: api/exceptions.md
- Integrations:
- api/integrations/pydantic.md
- api/integrations/logging.md
- api/integrations/structlog.md
- Examples: examples.md
- SDK API:
- Logfire: reference/api/logfire.md
- Testing: reference/api/testing.md
- Sampling: reference/api/sampling.md
- Propagate: reference/api/propagate.md
- Exceptions: reference/api/exceptions.md
- Pydantic: reference/api/pydantic.md
- Help: help.md
- Roadmap: roadmap.md
- Legal:
Expand Down
4 changes: 4 additions & 0 deletions tests/test_logfire_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ def func() -> None: ...
logfire_api.LogfireLoggingHandler()
logfire__all__.remove('LogfireLoggingHandler')

assert hasattr(logfire_api, 'loguru_handler')
logfire_api.loguru_handler()
logfire__all__.remove('loguru_handler')

assert hasattr(logfire_api, 'StructlogProcessor')
logfire_api.StructlogProcessor()
logfire__all__.remove('StructlogProcessor')
Expand Down

0 comments on commit b204ba4

Please sign in to comment.