SDK for Observability tools
Project description
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, and Requests 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
Using Poetry
poetry add gl-observability-binary
Using uv
uv add gl-observability-binary
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"
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
use_httpx=True, # Enable HTTPX instrumentation
use_requests=True, # Enable Requests instrumentation
)
# 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
use_httpx=True, # Enable HTTPX instrumentation
use_requests=True, # Enable Requests instrumentation
)
# 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,
)
)
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.
[!WARNING] The NER logging handler makes synchronous API calls for each log record, which may impact performance.
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gl_observability_binary-0.1.4-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: gl_observability_binary-0.1.4-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 293.1 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
232eacc32d904748f29270718e5c4475e311a8b0aa53460d43d17e45b0091e65
|
|
| MD5 |
f74998af1183d21aa5e3148773a387dc
|
|
| BLAKE2b-256 |
79bac3120a1d4d80a6446b65f4b954a201b58bab92c1f47a8119116d9ef56996
|
Provenance
The following attestation bundles were made for gl_observability_binary-0.1.4-cp313-cp313-win_amd64.whl:
Publisher:
build-binary.yml on GDP-ADMIN/gl-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gl_observability_binary-0.1.4-cp313-cp313-win_amd64.whl -
Subject digest:
232eacc32d904748f29270718e5c4475e311a8b0aa53460d43d17e45b0091e65 - Sigstore transparency entry: 936197923
- Sigstore integration time:
-
Permalink:
GDP-ADMIN/gl-sdk@1078f092307112ed56328b351abca33ca5fa16a5 -
Branch / Tag:
refs/tags/gl_observability-v0.1.4 - Owner: https://github.com/GDP-ADMIN
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-binary.yml@1078f092307112ed56328b351abca33ca5fa16a5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file gl_observability_binary-0.1.4-cp313-cp313-manylinux_2_31_x86_64.whl.
File metadata
- Download URL: gl_observability_binary-0.1.4-cp313-cp313-manylinux_2_31_x86_64.whl
- Upload date:
- Size: 451.2 kB
- Tags: CPython 3.13, manylinux: glibc 2.31+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.24
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5029667c9a284f06477261050e06f9f0b5aa3fdcb6c6edb71a33abbca20c65e6
|
|
| MD5 |
5e4ceb0d6f038b4dd16b294f83e550bb
|
|
| BLAKE2b-256 |
3ac47f37f37d24d5de53a001f334bee03bc40d02a9c51520d7c41c9973db136f
|
File details
Details for the file gl_observability_binary-0.1.4-cp313-cp313-macosx_13_0_arm64.whl.
File metadata
- Download URL: gl_observability_binary-0.1.4-cp313-cp313-macosx_13_0_arm64.whl
- Upload date:
- Size: 246.5 kB
- Tags: CPython 3.13, macOS 13.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b3d78e6754d448948acd1c43a004355f06f251d854654642e52902adf37596a5
|
|
| MD5 |
2c72d2dc6fe314b753fc603feb59b34a
|
|
| BLAKE2b-256 |
826323e6ec41affde42785feba02676c16ba17b856ef25f5ac7fcd00d87e1f7a
|
Provenance
The following attestation bundles were made for gl_observability_binary-0.1.4-cp313-cp313-macosx_13_0_arm64.whl:
Publisher:
build-binary.yml on GDP-ADMIN/gl-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gl_observability_binary-0.1.4-cp313-cp313-macosx_13_0_arm64.whl -
Subject digest:
b3d78e6754d448948acd1c43a004355f06f251d854654642e52902adf37596a5 - Sigstore transparency entry: 936197913
- Sigstore integration time:
-
Permalink:
GDP-ADMIN/gl-sdk@1078f092307112ed56328b351abca33ca5fa16a5 -
Branch / Tag:
refs/tags/gl_observability-v0.1.4 - Owner: https://github.com/GDP-ADMIN
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-binary.yml@1078f092307112ed56328b351abca33ca5fa16a5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file gl_observability_binary-0.1.4-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: gl_observability_binary-0.1.4-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 295.2 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd0e5dd77ff755ed9b3c8010926f229ad950fcd039537ff87fdc451cc14400f7
|
|
| MD5 |
e352eab2c1295701fdde56129b4f7410
|
|
| BLAKE2b-256 |
5b2a2eb9512817dbe438f21dbc8f789046d2f230497fed861e139c524dc612c3
|
Provenance
The following attestation bundles were made for gl_observability_binary-0.1.4-cp312-cp312-win_amd64.whl:
Publisher:
build-binary.yml on GDP-ADMIN/gl-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gl_observability_binary-0.1.4-cp312-cp312-win_amd64.whl -
Subject digest:
dd0e5dd77ff755ed9b3c8010926f229ad950fcd039537ff87fdc451cc14400f7 - Sigstore transparency entry: 936197917
- Sigstore integration time:
-
Permalink:
GDP-ADMIN/gl-sdk@1078f092307112ed56328b351abca33ca5fa16a5 -
Branch / Tag:
refs/tags/gl_observability-v0.1.4 - Owner: https://github.com/GDP-ADMIN
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-binary.yml@1078f092307112ed56328b351abca33ca5fa16a5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file gl_observability_binary-0.1.4-cp312-cp312-manylinux_2_31_x86_64.whl.
File metadata
- Download URL: gl_observability_binary-0.1.4-cp312-cp312-manylinux_2_31_x86_64.whl
- Upload date:
- Size: 453.3 kB
- Tags: CPython 3.12, manylinux: glibc 2.31+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.24
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2adf5e1ce4bba28b48c08b2799701d52e120646c27988692a69a3abe4c570a35
|
|
| MD5 |
89719f98e9c5b8c03b6636153b09f78f
|
|
| BLAKE2b-256 |
0b09062df4c4c86e1e0901f7da37f3f0aafe62a39bfb788bcb0e8594134fbe7a
|
File details
Details for the file gl_observability_binary-0.1.4-cp312-cp312-macosx_13_0_arm64.whl.
File metadata
- Download URL: gl_observability_binary-0.1.4-cp312-cp312-macosx_13_0_arm64.whl
- Upload date:
- Size: 247.0 kB
- Tags: CPython 3.12, macOS 13.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
357135cefd9e40c86a79014ba6572f5691e9e1115c22d30c416a639f9a050029
|
|
| MD5 |
a84a8a0c081e5921fa1766cc15420f86
|
|
| BLAKE2b-256 |
e9a13842fefa0b4ace70fe4eb6d46d45a3a488a22fe19b998329a006f285b57b
|
Provenance
The following attestation bundles were made for gl_observability_binary-0.1.4-cp312-cp312-macosx_13_0_arm64.whl:
Publisher:
build-binary.yml on GDP-ADMIN/gl-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gl_observability_binary-0.1.4-cp312-cp312-macosx_13_0_arm64.whl -
Subject digest:
357135cefd9e40c86a79014ba6572f5691e9e1115c22d30c416a639f9a050029 - Sigstore transparency entry: 936197911
- Sigstore integration time:
-
Permalink:
GDP-ADMIN/gl-sdk@1078f092307112ed56328b351abca33ca5fa16a5 -
Branch / Tag:
refs/tags/gl_observability-v0.1.4 - Owner: https://github.com/GDP-ADMIN
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-binary.yml@1078f092307112ed56328b351abca33ca5fa16a5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file gl_observability_binary-0.1.4-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: gl_observability_binary-0.1.4-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 298.1 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dbe2deeb65fca38bfba4dc3d24e5b9159a250229c4a108f86b07cede5f0af225
|
|
| MD5 |
d2085d23b149756fabc09eb35b49b791
|
|
| BLAKE2b-256 |
ec1d2a086178b956e76b064fc90111eebc4fefc3232123faf9386eeeca0a13de
|
Provenance
The following attestation bundles were made for gl_observability_binary-0.1.4-cp311-cp311-win_amd64.whl:
Publisher:
build-binary.yml on GDP-ADMIN/gl-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gl_observability_binary-0.1.4-cp311-cp311-win_amd64.whl -
Subject digest:
dbe2deeb65fca38bfba4dc3d24e5b9159a250229c4a108f86b07cede5f0af225 - Sigstore transparency entry: 936197936
- Sigstore integration time:
-
Permalink:
GDP-ADMIN/gl-sdk@1078f092307112ed56328b351abca33ca5fa16a5 -
Branch / Tag:
refs/tags/gl_observability-v0.1.4 - Owner: https://github.com/GDP-ADMIN
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-binary.yml@1078f092307112ed56328b351abca33ca5fa16a5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file gl_observability_binary-0.1.4-cp311-cp311-manylinux_2_31_x86_64.whl.
File metadata
- Download URL: gl_observability_binary-0.1.4-cp311-cp311-manylinux_2_31_x86_64.whl
- Upload date:
- Size: 412.4 kB
- Tags: CPython 3.11, manylinux: glibc 2.31+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.24
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
757aec1bbf5c82095db2ce40acfe47bd46219bd5901ba76e461066f22321d7e4
|
|
| MD5 |
51797114557d1c41c981c9f4a1b1f979
|
|
| BLAKE2b-256 |
778991c9572a3a716755d1a15bd715225861b493839fc6cd2dbf084246f98556
|
File details
Details for the file gl_observability_binary-0.1.4-cp311-cp311-macosx_13_0_arm64.whl.
File metadata
- Download URL: gl_observability_binary-0.1.4-cp311-cp311-macosx_13_0_arm64.whl
- Upload date:
- Size: 243.4 kB
- Tags: CPython 3.11, macOS 13.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
466155a63e66de451385a938dce64e00234df3361eed3c15dbb24ce532af830e
|
|
| MD5 |
7a07a1e884a6b99adc8e220705ea2cc2
|
|
| BLAKE2b-256 |
8da1d0d7c1e990fe8664d499b18240c46dca4d6776942e6e74a2b7a0d5725279
|
Provenance
The following attestation bundles were made for gl_observability_binary-0.1.4-cp311-cp311-macosx_13_0_arm64.whl:
Publisher:
build-binary.yml on GDP-ADMIN/gl-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gl_observability_binary-0.1.4-cp311-cp311-macosx_13_0_arm64.whl -
Subject digest:
466155a63e66de451385a938dce64e00234df3361eed3c15dbb24ce532af830e - Sigstore transparency entry: 936197893
- Sigstore integration time:
-
Permalink:
GDP-ADMIN/gl-sdk@1078f092307112ed56328b351abca33ca5fa16a5 -
Branch / Tag:
refs/tags/gl_observability-v0.1.4 - Owner: https://github.com/GDP-ADMIN
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-binary.yml@1078f092307112ed56328b351abca33ca5fa16a5 -
Trigger Event:
push
-
Statement type: