GL Observability
gl-observability is a comprehensive SDK for implementing observability in Python applications. It provides easy-to-use wrappers for OpenTelemetry, Sentry, and custom logging handlers with PII redaction capabilities.
Key Features
- 📊 OpenTelemetry Integration: simplified initialization for tracing.
- 🛡️ Sentry Support: easy setup for error tracking and performance monitoring.
- 🕵️ PII Redaction: custom logging handlers to redact PII using Regex or NER (Named Entity Recognition).
- 🔌 Framework Support: built-in support for FastAPI, Langchain, HTTPX, Requests, OpenAI, Anthropic, Bedrock, and Google Generative AI instrumentation.
Installation
Prerequisites
- Python 3.11-3.13 - Install here
- Pip (if using pip) - Install here
- Poetry 2.1.3+ (if using Poetry) - Install here
- uv (if using uv) - Install here
- Git (if using Git) - Install here
- For git installation, access to the GDP Labs SDK github repository
1. Installation from Pypi
Choose one of the following methods to install the package:
Using pip
pip install gl-observability-binary[all]
Using Poetry
poetry add gl-observability-binary[all]
Using uv
uv add gl-observability-binary[all]
2. Development Installation (Git)
For development purposes, you can install directly from the Git repository:
poetry add "git+ssh://git@github.com/GDP-ADMIN/gl-sdk.git#subdirectory=libs/gl-observability" --extras all
Optional Dependencies
The OTel instrumentor packages for FastAPI, Langchain, HTTPX, Requests, OpenAI, Anthropic, Bedrock, and Google Generative AI are bundled in core. HTTPX, Requests, and all LLM providers (OpenAI, Anthropic, Bedrock, Google Generative AI) are enabled by default — use_httpx and use_requests default to True, and use_llm (which covers all four LLM providers together) defaults to True. Set any flag to False to disable that integration. Langchain and FastAPI follow the same use_* pattern (use_langchain defaults to False; FastAPI runs when fastapi_config is set).
Each instrumentor must run against a compatible version of the library it traces. If you hit a DependencyConflictError at startup, it means your installed library version falls outside the range the bundled instrumentor supports.
The optional extras solve this by pulling in the instrumented library at a version that is known to be compatible with the bundled instrumentor. Use them as a version resolver, not as a feature flag.
| Extra | Installs |
|---|---|
fastapi |
fastapi at a compatible version |
langchain |
langchain at a compatible version |
httpx |
httpx at a compatible version |
requests |
requests at a compatible version |
llm |
openai, anthropic, boto3, google-generativeai at compatible versions |
all |
All libraries above |
Install a specific extra via gl-observability-binary:
# pip
pip install "gl-observability-binary[langchain]"
# Poetry
poetry add "gl-observability-binary[langchain]"
# uv
uv add "gl-observability-binary[langchain]"
Usage
1. Telemetry Initialization
The library uses a unified init_telemetry function that takes a TelemetryConfig object. You can configure it to send traces to OpenTelemetry (OTLP) or Sentry backend. Multiple backend configuration is supported.
OpenTelemetry Configuration
This setup sends traces to an external OTLP collector (e.g., Jaeger, Tempo).
from fastapi import FastAPI
from gl_observability import init_telemetry, TelemetryConfig, OpenTelemetryBackendConfig, FastAPIConfig
# 1. Setup FastAPI Config (optional, if using FastAPI)
app = FastAPI()
fastapi_config = FastAPIConfig(app=app)
# 2. Configure OpenTelemetryBackendConfig
otel_backend_config = OpenTelemetryBackendConfig(
endpoint="localhost:4318", # OTLP endpoint
use_grpc=False, # Use gRPC or HTTP
headers={"Authorization": "Bearer ..."}, # Optional headers
)
# 3. Configure TelemetryConfig
otel_config = TelemetryConfig(
attributes={"service.name": "..."}, # Resource attributes
backend_config=otel_backend_config, # Backend configuration
fastapi_config=fastapi_config, # FastAPI Instrumentation
use_langchain=True, # Enable Langchain instrumentation (default: False)
# use_httpx, use_requests, and use_llm default to True; set to False to disable.
)
# 4. Initialize Telemetry
init_telemetry(otel_config)
Sentry Configuration
This setup sends errors and traces to Sentry.
from fastapi import FastAPI
from gl_observability import init_telemetry, TelemetryConfig, SentryBackendConfig, FastAPIConfig
# 1. Setup FastAPI Config (optional, if using FastAPI)
app = FastAPI()
fastapi_config = FastAPIConfig(app=app)
# 2. Configure SentryBackendConfig
sentry_backend_config = SentryBackendConfig(
dsn="https://...",
environment="...",
release="...",
send_default_pii=True,
disable_sentry_distributed_tracing=False
)
# 3. Configure TelemetryConfig
otel_config = TelemetryConfig(
attributes={"service.name": "..."}, # Resource attributes
backend_config=sentry_backend_config, # Backend configuration
fastapi_config=fastapi_config, # FastAPI Instrumentation
use_langchain=True, # Enable Langchain instrumentation (default: False)
# use_httpx, use_requests, and use_llm default to True; set to False to disable.
)
# 4. Initialize Telemetry
init_telemetry(otel_config)
Multiple Backend Configuration
This setup the OpenTelemetry SDK used for tracing.
from fastapi import FastAPI
from gl_observability import init_telemetry, TelemetryConfig, OpenTelemetryBackendConfig, SentryBackendConfig
jaeger_backend = OpenTelemetryBackendConfig(endpoint="jager...", ...)
init_telemetry(
TelemetryConfig(
attributes={"service.name": "..."},
backend_config=jaeger_backend,
fastapi_config=fastapi_config,
use_langchain=True,
use_httpx=True,
use_requests=True,
use_llm=True,
)
)
langfuse_backend = OpenTelemetryBackendConfig(endpoint="langfuse...", ...)
init_telemetry(
TelemetryConfig(
backend_config=langfuse_backend
)
)
sentry_backend = SentryBackendConfig(dsn="https://...", ...)
init_telemetry(
TelemetryConfig(
backend_config=sentry_backend
)
)
2. Logging Handlers
The library provides logging handlers to automatically redact Personally Identifiable Information (PII) from logs.
Regex-based PII Redaction
Uses regular expressions to mask common PII patterns like KTP, NPWP, Phone Numbers, and Email.
import logging
from gl_observability.logs.regex_pii_logger_handler import init_regex_pii_logging_handler
# Initialize the handler for a specific logger
init_regex_pii_logging_handler(
logger_name="my_application_logger",
pii_regex_process_enabled=True
)
logger = logging.getLogger("my_application_logger")
logger.info("User email is john.doe@example.com and phone is 08123456789")
# Output: User email is jo******om and phone is 0812******6789
NER-based PII Redaction (Named Entity Recognition)
Uses an external API to perform Named Entity Recognition for more advanced PII detection and redaction.
import logging
from gl_observability.logs.ner_pii_logger_handler import init_ner_pii_logging_handler
# Initialize the handler
init_ner_pii_logging_handler(
logger_name="my_application_logger",
api_url="https://your-ner-api.com/anonymize",
api_field="text", # The field name in API response containing the redacted text
pii_ner_process_enabled=True
)
logger = logging.getLogger("my_application_logger")
logger.info("My KTP is 3525011212941001")
# Output will be redacted based on API response
Metadata
Release files for gl-observability-binary 0.2.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 3.4 MB
Release files / gl_observability_binary-0.2.5-cp313-cp313-win_amd64.whl
| Download URL | gl_observability_binary-0.2.5-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 287.6 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
ecbd3be5bb99f77cae16fec55529908bfa4fdf7a4afbc1d264eeb1a32f25d5d7
|
|
BLAKE2b-256 checksum How to use checksums |
db13bc67b6aa650d45f5263c595579e47b08d21a6034f4ca868b82334e7cc7af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.
Transparency logRelease files / gl_observability_binary-0.2.5-cp313-cp313-manylinux_2_31_x86_64.whl
| Download URL | gl_observability_binary-0.2.5-cp313-cp313-manylinux_2_31_x86_64.whl |
|---|---|
| Size | 531.7 kB |
| Tags | CPython 3.13 Linux glibc 2.31+ x86-64 |
|
SHA-256 checksum How to use checksums |
4fa27be2e26453f9055b8891534a910f8aea9eb6728c16d65019ffe60f568b9a
|
|
BLAKE2b-256 checksum How to use checksums |
70f50113a19641377c06716b972697911dfbb5a4a6f9c1a9e5f4737f7a2de203
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.8.24
|
Release files / gl_observability_binary-0.2.5-cp313-cp313-macosx_13_0_arm64.whl
| Download URL | gl_observability_binary-0.2.5-cp313-cp313-macosx_13_0_arm64.whl |
|---|---|
| Size | 326.5 kB |
| Tags | CPython 3.13 macOS 13.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
94c5a688eef59b8880d87eb96ea66660a8f2528c1d1c0adf7919d984f1458281
|
|
BLAKE2b-256 checksum How to use checksums |
cca44d2727533414420ebed227774966910b64e72ed8fa4f4dd86d0de3fe1bf0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.
Transparency logRelease files / gl_observability_binary-0.2.5-cp312-cp312-win_amd64.whl
| Download URL | gl_observability_binary-0.2.5-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 290.2 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
024c5019db75d132d272c2cefc5393e24555284d6023e5fc49f0ec4825d19c79
|
|
BLAKE2b-256 checksum How to use checksums |
7f63f3b93e2307653b679a293022315a9e8b113a3a244d8e12ccc116444b558f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.
Transparency logRelease files / gl_observability_binary-0.2.5-cp312-cp312-manylinux_2_31_x86_64.whl
| Download URL | gl_observability_binary-0.2.5-cp312-cp312-manylinux_2_31_x86_64.whl |
|---|---|
| Size | 532.5 kB |
| Tags | CPython 3.12 Linux glibc 2.31+ x86-64 |
|
SHA-256 checksum How to use checksums |
af49b4d01ac614893acaada896d9720629f379843c7ca053ddaf0fef917387f6
|
|
BLAKE2b-256 checksum How to use checksums |
fccc34fc386a393058adb846c0043af2fcdd15df1d183b026b73087b7d470a49
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.8.24
|
Release files / gl_observability_binary-0.2.5-cp312-cp312-macosx_13_0_arm64.whl
| Download URL | gl_observability_binary-0.2.5-cp312-cp312-macosx_13_0_arm64.whl |
|---|---|
| Size | 325.9 kB |
| Tags | CPython 3.12 macOS 13.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
ccf2e6cb0e566b51cfc05a6aa3c1c58f4b5b8134553252c977c77af35feff885
|
|
BLAKE2b-256 checksum How to use checksums |
6f39b7841cbfb9874fe0bdc8cd9a74c897fc21095f8801cf7a7c2a994ee948f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.
Transparency logRelease files / gl_observability_binary-0.2.5-cp311-cp311-win_amd64.whl
| Download URL | gl_observability_binary-0.2.5-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 299.2 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
09272ebf324f9df8f8af5b8c66bcaf2aef7986731512480929d9d261146167d9
|
|
BLAKE2b-256 checksum How to use checksums |
b28bf4a5f9c3631da2e66a8c597e4de15f012df2ab5ed5bb44b739afb1c3cc63
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.
Transparency logRelease files / gl_observability_binary-0.2.5-cp311-cp311-manylinux_2_31_x86_64.whl
| Download URL | gl_observability_binary-0.2.5-cp311-cp311-manylinux_2_31_x86_64.whl |
|---|---|
| Size | 483.8 kB |
| Tags | CPython 3.11 Linux glibc 2.31+ x86-64 |
|
SHA-256 checksum How to use checksums |
28c35cb524143739014bf1023dfa7f4a874e610a484f699d8f091e1041a08405
|
|
BLAKE2b-256 checksum How to use checksums |
7f284dcff189895bf15099f5ae3f00d61f1e852c9c4cd96b5b25f53ccd3699af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.8.24
|
Release files / gl_observability_binary-0.2.5-cp311-cp311-macosx_13_0_arm64.whl
| Download URL | gl_observability_binary-0.2.5-cp311-cp311-macosx_13_0_arm64.whl |
|---|---|
| Size | 323.1 kB |
| Tags | CPython 3.11 macOS 13.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
c719b34b0689a3d0aea60a5e0c751b577169311c6a099eb240e32c585da5a520
|
|
BLAKE2b-256 checksum How to use checksums |
d45f63ee20e7396dfe4cb5ba46cb8a4b40f16a9386c5e8f46c7a27d5211f0f20
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.
Transparency log