Skip to main content
Change of provenance

The repository or configuration that created this release differ from a previous release. View details.

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

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
    )
)

Masking policy and failure reporting

Import the public masking API from gl_observability:

Purpose Public names
Configure scrubbing MaskingConfig, MaskingRule, BuiltInMaskingRule, DenyFields, MaskingMode
Consume failure reports MaskingReport, MaskingFailureGroup, MaskingPatternSource, OnReportHook
Reuse default reporting masking_config_default_on_report
Disable key-based denial EMPTY_DENY_FIELDS
from gl_observability import (
    EMPTY_DENY_FIELDS,
    BuiltInMaskingRule,
    MaskingConfig,
    MaskingMode,
    MaskingRule,
)

masking_config = MaskingConfig(
    rules=(
        BuiltInMaskingRule.EMAIL,
        MaskingRule(name="CUSTOM_ID", pattern=r"customer-\d+"),
    ),
    deny_fields=EMPTY_DENY_FIELDS,
    mode=MaskingMode.FAIL_CLOSED,
)
# Select only the rules the application needs.
email_only = MaskingConfig(rules=(BuiltInMaskingRule.EMAIL,))
# Pass masking_config to TelemetryConfig(masking_config=masking_config, ...).

BuiltInMaskingRule.PRIVATE_KEY_BLOCK masks from a recognized BEGIN … PRIVATE KEY header through the first END … PRIVATE KEY delimiter, regardless of label. If no closing delimiter exists, it masks the rest of that string, including any trailing text or serialized JSON punctuation. Text after a complete block is preserved.

Trace masking is disabled by default (TelemetryConfig(masking_config=None)). MaskingConfig() also defaults to no value rules and no deny fields. Regex matching adds processing cost on the telemetry export path, so select only the rules or deny fields appropriate for your workload and pass the policy explicitly:

from gl_observability import BuiltInMaskingRule, MaskingConfig, TelemetryConfig

config = TelemetryConfig(
    masking_config=MaskingConfig(rules=(BuiltInMaskingRule.EMAIL,)),
    # Add the desired backend_config and other telemetry options.
)

DEFAULT_RULES and DEFAULT_MASKING_CONFIG have been removed. Applications that used those bundles or relied on automatic masking must now choose individual BuiltInMaskingRule constants or custom MaskingRule instances. Rules run in the supplied order, each seeing the previous rule's output; place specific rules before broader patterns when they overlap.

An empty policy skips compilation and installs no masking wrapper or stage: no masking traversal, reports, or FAIL_OPEN warning occurs. Rule-only and deny-only policies remain active, including a deny pattern of "", which matches every attribute key. A deny-only policy does not enable any value rules. Independent backend SDK scrubbing still follows its own configuration.

OTLP masks span names and span attributes, including string sequences. Sentry masks child-span data, op, and description; root contexts.trace.data, op, and description; root contexts.otel.attributes; the transaction name and its contexts.trace.dynamic_sampling_context.transaction copy; and recursive string leaves in transaction request and user regions. Names, operations, and descriptions use the configured value rules only, without attribute-key denial. SQL and URL text copied into descriptions is masked too. The sampling transaction name is scrubbed before Sentry moves it into the envelope header; other sampling metadata remains unchanged.

Both backends preserve resources. OTLP events, links, status and instrumentation metadata, and Sentry other contexts, tags, extra, breadcrumbs and error events are outside this masking stage. Independent SDK scrubbing and consumer hooks may still change those fields.

Behavior change: Matching text in OTel span names and Sentry operations and transaction names is now redacted; Sentry description masking is retained. For example, both data["db.statement"] and its copied description become SELECT * FROM users WHERE email = '[EMAIL]'. An HTTP description becomes GET api.internal /reset?[GENERIC_CREDENTIAL_KV] when its target contains token=abc123456789. Ordinary operation labels remain unchanged, but matching names/operations may change dashboard grouping. These fields use the same FAIL_CLOSED / FAIL_OPEN behavior as other covered values.

Sentry resources previously masked by this component now pass through unchanged. Applications relying on resource masking can sanitize contexts.otel.resource in a consumer before_send_transaction hook supplied through SentryBackendConfig. The hook runs after this component's masking stage. Regex rules still have false positives and false negatives; this coverage does not guarantee removal of every sensitive value.

Deny fields apply only to attribute keys, before value rules, using Python re.match prefix semantics. Matching is case-sensitive unless flags are supplied: email does not deny user.email, while user\.email$ does. Denied values keep the configured deny mask without value scanning. Request/user keys are never deny-checked.

FAIL_CLOSED replaces a value whose scrubbing raises with [Dropped]. FAIL_OPEN returns that value unmasked and is intended for non-production debugging. Both modes continue scrubbing the other values normally. EMPTY_DENY_FIELDS disables key-based denial; value rules still apply.

on_report receives one MaskingReport per item with masking failures. It defaults to masking_config_default_on_report; a custom hook replaces it, and None disables reporting. Hooks must return promptly. A hook exception is caught and diagnostic logging is attempted; if diagnostic logging raises, that exception may propagate. During context-manager exit, it may replace a traversal exception, which remains in the exception context chain. Nested report delivery on the same thread is skipped while a hook runs; masking still applies and later independent reports can be delivered.

Compiled policies, MaskingSession, MaskingPatternError, DROPPED_VALUE, exporters, and chain/traversal helpers are internal implementation details. The supported masking API consists of the package-root imports listed above; deep imports of implementation details have no compatibility guarantee.

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.4.0.post1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Change of provenance

The repository or configuration that created these release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Built distributions (wheels)

Table of built distributions (wheels) for gl-observability-binary 0.4.0.post1
File Actions
gl_observability_binary-0.4.0.post1-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details for gl_observability_binary-0.4.0.post1-cp313-cp313-win_amd64.whl
gl_observability_binary-0.4.0.post1-cp313-cp313-manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64 Details for gl_observability_binary-0.4.0.post1-cp313-cp313-manylinux_2_28_x86_64.whl
gl_observability_binary-0.4.0.post1-cp313-cp313-macosx_13_0_arm64.whl CPython 3.13 CPython 3.13 macOS 13.0+ ARM64 Details for gl_observability_binary-0.4.0.post1-cp313-cp313-macosx_13_0_arm64.whl
gl_observability_binary-0.4.0.post1-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for gl_observability_binary-0.4.0.post1-cp312-cp312-win_amd64.whl
gl_observability_binary-0.4.0.post1-cp312-cp312-manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64 Details for gl_observability_binary-0.4.0.post1-cp312-cp312-manylinux_2_28_x86_64.whl
gl_observability_binary-0.4.0.post1-cp312-cp312-macosx_13_0_arm64.whl CPython 3.12 CPython 3.12 macOS 13.0+ ARM64 Details for gl_observability_binary-0.4.0.post1-cp312-cp312-macosx_13_0_arm64.whl

Total release size: 4.6 MB

Release files / gl_observability_binary-0.4.0.post1-cp313-cp313-win_amd64.whl

Change of provenance

This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Download URL gl_observability_binary-0.4.0.post1-cp313-cp313-win_amd64.whl
Size 616.5 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
fa08b1120d9ddc0b9f80bc85b2567833d8c6f55540229f908ed5b65039126587
BLAKE2b-256 checksum
How to use checksums
4150f0c9e6188931b767afd7009c0c5dc8ae8c3e48fc16788a823af9e34f7783
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 11, 2026.

Transparency log

Release files / gl_observability_binary-0.4.0.post1-cp313-cp313-manylinux_2_28_x86_64.whl

Change of provenance

This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Download URL gl_observability_binary-0.4.0.post1-cp313-cp313-manylinux_2_28_x86_64.whl
Size 982.9 kB
Tags CPython 3.13 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
6e274be1e28758503788ae0a770a6e6b2a2e90d778ed7f8badd51ba9bb133de7
BLAKE2b-256 checksum
How to use checksums
3d9a340b22b26481f1f430cf1d3619770a742cf6cfbe9bfb00ba3237aeaddac1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.4 {"installer":{"name":"uv","version":"0.13.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"AlmaLinux","version":"8.10","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

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 Google Cloud, verified by PyPI on Nov 11, 2026.

Transparency log

Release files / gl_observability_binary-0.4.0.post1-cp313-cp313-macosx_13_0_arm64.whl

Change of provenance

This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Download URL gl_observability_binary-0.4.0.post1-cp313-cp313-macosx_13_0_arm64.whl
Size 690.7 kB
Tags CPython 3.13 macOS 13.0+ ARM64
SHA-256 checksum
How to use checksums
45c70847f8646e9c00862adde464a31c169ebea9a8898717db9523ffa7a32010
BLAKE2b-256 checksum
How to use checksums
20ea7adaed7c41057a159e2513f0671077c8c7e1aada7642aed26e009315c215
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 11, 2026.

Transparency log

Release files / gl_observability_binary-0.4.0.post1-cp312-cp312-win_amd64.whl

Change of provenance

This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Download URL gl_observability_binary-0.4.0.post1-cp312-cp312-win_amd64.whl
Size 616.1 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
57bb1ff13bc89348d8ddbfe9c2b0f5b82f49bb1eea78ba18da7af42767a869fc
BLAKE2b-256 checksum
How to use checksums
b7ab042b745fe653cf9426bc770cbfa62f1f177e3c5c30c0bc4878f395e1e5f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 11, 2026.

Transparency log

Release files / gl_observability_binary-0.4.0.post1-cp312-cp312-manylinux_2_28_x86_64.whl

Change of provenance

This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Download URL gl_observability_binary-0.4.0.post1-cp312-cp312-manylinux_2_28_x86_64.whl
Size 975.7 kB
Tags CPython 3.12 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
a176410338fa11a61dc56f842dc9203f553ead5ccd996e9c38fa0265369e6aec
BLAKE2b-256 checksum
How to use checksums
b4d412d9916ec6e1d454d2590be02baccbdd8b57790b51f63d54da25ca9c389b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.4 {"installer":{"name":"uv","version":"0.13.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"AlmaLinux","version":"8.10","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

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 Google Cloud, verified by PyPI on Nov 11, 2026.

Transparency log

Release files / gl_observability_binary-0.4.0.post1-cp312-cp312-macosx_13_0_arm64.whl

Change of provenance

This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Download URL gl_observability_binary-0.4.0.post1-cp312-cp312-macosx_13_0_arm64.whl
Size 670.9 kB
Tags CPython 3.12 macOS 13.0+ ARM64
SHA-256 checksum
How to use checksums
eb3f56bb6da6a9db37a6f94b2c71e2df13d44f2d6d62dc9d5eea886ff803387f
BLAKE2b-256 checksum
How to use checksums
34b1ce1d4365f80c2d40b53dc6825808d083a24849b7daf09d5208139132ddc6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 11, 2026.

Transparency log

Security for gl-observability-binary 0.4.0.post1

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.

Change of provenance

The repository and configuration that created this release differ from a previous release.

While this could reflect a routine change by the project maintainers, it may also indicate that the release files have been compromised.

Repository

Select from 6 files

Attestation for gl_observability_binary-0.4.0.post1-cp313-cp313-win_amd64.whl

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 Nov 11, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page