gl-observability-binary 0.0.0b1__cp312-cp312-win_amd64.whl → 0.1.1__cp312-cp312-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gl_observability/__init__.pyi +4 -2
- gl_observability/initializer.pyi +54 -12
- gl_observability/traces/backend/opentelemetry.pyi +30 -0
- gl_observability/traces/backend/sentry.pyi +37 -0
- gl_observability/traces/config.pyi +48 -0
- gl_observability/traces/{opentelemetry/instrument → instrument}/functions.pyi +3 -3
- gl_observability/traces/{opentelemetry/instrument → instrument}/http.pyi +1 -1
- gl_observability.cp312-win_amd64.pyd +0 -0
- gl_observability.pyi +16 -16
- {gl_observability_binary-0.0.0b1.dist-info → gl_observability_binary-0.1.1.dist-info}/METADATA +73 -53
- gl_observability_binary-0.1.1.dist-info/RECORD +20 -0
- gl_observability/backend/__init__.pyi +0 -4
- gl_observability/backend/opentelemetry/initializer.pyi +0 -61
- gl_observability/backend/sentry/initializer.pyi +0 -39
- gl_observability/traces/opentelemetry/__init__.pyi +0 -0
- gl_observability/traces/opentelemetry/instrument/__init__.pyi +0 -4
- gl_observability_binary-0.0.0b1.dist-info/RECORD +0 -22
- /gl_observability/{backend/opentelemetry → traces/backend}/__init__.pyi +0 -0
- /gl_observability/{backend/sentry → traces/instrument}/__init__.pyi +0 -0
- {gl_observability_binary-0.0.0b1.dist-info → gl_observability_binary-0.1.1.dist-info}/WHEEL +0 -0
- {gl_observability_binary-0.0.0b1.dist-info → gl_observability_binary-0.1.1.dist-info}/top_level.txt +0 -0
gl_observability/__init__.pyi
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
from gl_observability.backend import OpenTelemetryConfig as OpenTelemetryConfig, SentryConfig as SentryConfig
|
|
2
1
|
from gl_observability.initializer import TelemetryConfig as TelemetryConfig, init_telemetry as init_telemetry
|
|
2
|
+
from gl_observability.traces.backend.opentelemetry import OpenTelemetryBackendConfig as OpenTelemetryBackendConfig
|
|
3
|
+
from gl_observability.traces.backend.sentry import SentryBackendConfig as SentryBackendConfig
|
|
4
|
+
from gl_observability.traces.config import FastAPIConfig as FastAPIConfig
|
|
3
5
|
|
|
4
|
-
__all__ = ['
|
|
6
|
+
__all__ = ['TelemetryConfig', 'init_telemetry', 'FastAPIConfig', 'OpenTelemetryBackendConfig', 'SentryBackendConfig']
|
gl_observability/initializer.pyi
CHANGED
|
@@ -1,24 +1,66 @@
|
|
|
1
1
|
from _typeshed import Incomplete
|
|
2
|
-
from gl_observability.backend.opentelemetry
|
|
3
|
-
from gl_observability.backend.sentry
|
|
2
|
+
from gl_observability.traces.backend.opentelemetry import OpenTelemetryBackendConfig as OpenTelemetryBackendConfig, init_otel_with_external_exporter as init_otel_with_external_exporter
|
|
3
|
+
from gl_observability.traces.backend.sentry import SentryBackendConfig as SentryBackendConfig, init_sentry as init_sentry
|
|
4
|
+
from gl_observability.traces.config import FastAPIConfig as FastAPIConfig, OpenTelemetryTraceConfig as OpenTelemetryTraceConfig, auto_initialize_services as auto_initialize_services, setup_tracer_provider as setup_tracer_provider
|
|
5
|
+
from opentelemetry.sdk.trace.sampling import Sampler
|
|
4
6
|
|
|
5
7
|
class TelemetryConfig:
|
|
6
|
-
"""Configuration
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
"""Configuration for telemetry initialization.
|
|
9
|
+
|
|
10
|
+
All instrumentation is done via OpenTelemetry.
|
|
11
|
+
"""
|
|
12
|
+
trace_sampler: Incomplete
|
|
13
|
+
attributes: Incomplete
|
|
14
|
+
fastapi_config: Incomplete
|
|
15
|
+
use_langchain: Incomplete
|
|
16
|
+
use_httpx: Incomplete
|
|
17
|
+
use_requests: Incomplete
|
|
18
|
+
backend_config: Incomplete
|
|
19
|
+
def __init__(self, *, attributes: dict[str, str] | None = None, trace_sampler: Sampler | None = None, fastapi_config: FastAPIConfig | None = None, use_langchain: bool = False, use_httpx: bool = True, use_requests: bool = True, backend_config: OpenTelemetryBackendConfig | SentryBackendConfig | None = None) -> None:
|
|
20
|
+
"""Initialize the telemetry configuration.
|
|
11
21
|
|
|
12
22
|
Args:
|
|
13
|
-
|
|
14
|
-
|
|
23
|
+
attributes (dict[str, str] | None, optional): Resource attributes. Defaults to None.
|
|
24
|
+
trace_sampler (Sampler | None, optional): The sampler for traces. Defaults to None.
|
|
25
|
+
fastapi_config (FastAPIConfig | None, optional): FastAPI configuration for instrumentation.
|
|
26
|
+
Defaults to None.
|
|
27
|
+
use_langchain (bool, optional): Enable Langchain instrumentation. Defaults to False.
|
|
28
|
+
use_httpx (bool, optional): Enable HTTPX instrumentation. Defaults to True.
|
|
29
|
+
use_requests (bool, optional): Enable Requests instrumentation. Defaults to True.
|
|
30
|
+
backend_config (OpenTelemetryBackendConfig | SentryBackendConfig | None, optional): The telemetry
|
|
31
|
+
backend configuration. Defaults to None. Make sure to set at least one backend configuration,
|
|
32
|
+
if not traces will not be exported.
|
|
15
33
|
"""
|
|
16
34
|
|
|
17
35
|
def init_telemetry(config: TelemetryConfig) -> None:
|
|
18
|
-
|
|
36
|
+
'''Initialize telemetry for tracing.
|
|
37
|
+
|
|
38
|
+
This function initializes OpenTelemetry instrumentation with the specified backend.
|
|
39
|
+
All tracing is done via OpenTelemetry regardless of the backend.
|
|
19
40
|
|
|
20
|
-
|
|
41
|
+
Supported backends:
|
|
42
|
+
- OTLP: Export traces to an OTLP endpoint (Jaeger, Tempo, etc.)
|
|
43
|
+
- Sentry: Export traces to Sentry using OpenTelemetry
|
|
44
|
+
|
|
45
|
+
Examples:
|
|
46
|
+
Basic OTLP setup:
|
|
47
|
+
>>> from gl_observability import TelemetryConfig, init_telemetry, OpenTelemetryBackendConfig
|
|
48
|
+
>>>
|
|
49
|
+
>>> config = TelemetryConfig(
|
|
50
|
+
... attributes={"service.name": "my-service"},
|
|
51
|
+
... backend_config=OpenTelemetryBackendConfig(endpoint="localhost:4317")
|
|
52
|
+
... )
|
|
53
|
+
>>> init_telemetry(config)
|
|
54
|
+
|
|
55
|
+
Sentry setup:
|
|
56
|
+
>>> from gl_observability import TelemetryConfig, init_telemetry, SentryBackendConfig
|
|
57
|
+
>>>
|
|
58
|
+
>>> config = TelemetryConfig(
|
|
59
|
+
... attributes={"service.name": "my-service"},
|
|
60
|
+
... backend_config=SentryBackendConfig(dsn="https://...")
|
|
61
|
+
... )
|
|
62
|
+
>>> init_telemetry(config)
|
|
21
63
|
|
|
22
64
|
Args:
|
|
23
65
|
config (TelemetryConfig): The telemetry configuration.
|
|
24
|
-
|
|
66
|
+
'''
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from _typeshed import Incomplete
|
|
2
|
+
from opentelemetry.sdk.trace import TracerProvider
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
class OpenTelemetryBackendConfig:
|
|
6
|
+
"""Configuration for OpenTelemetry OTLP exporter."""
|
|
7
|
+
endpoint: Incomplete
|
|
8
|
+
headers: Incomplete
|
|
9
|
+
use_grpc: Incomplete
|
|
10
|
+
additional_options: Incomplete
|
|
11
|
+
def __init__(self, *, endpoint: str, headers: dict[str, str] = None, use_grpc: bool = True, **kwargs: Any) -> None:
|
|
12
|
+
'''Initializes the OpenTelemetryBackendConfig configuration object with the specified parameters.
|
|
13
|
+
|
|
14
|
+
Args:
|
|
15
|
+
endpoint (str): The OTLP endpoint e.g. "https://localhost:4318".
|
|
16
|
+
headers (dict[str, str], optional): Headers with key value for connecting to the exporter. Defaults to None.
|
|
17
|
+
use_grpc (bool, optional): Use gRPC for OpenTelemetry exporter. Defaults to True.
|
|
18
|
+
**kwargs: Additional keyword arguments passed to OTLPSpanExporter.
|
|
19
|
+
'''
|
|
20
|
+
|
|
21
|
+
def init_otel_with_external_exporter(config: OpenTelemetryBackendConfig, tracer_provider: TracerProvider) -> None:
|
|
22
|
+
"""Initialize OpenTelemetry with an external OTLP exporter.
|
|
23
|
+
|
|
24
|
+
This method initializes OpenTelemetry with an external exporter (OTLP)
|
|
25
|
+
and instruments FastAPI, Langchain, HTTPX, and Requests if configured.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
config (OpenTelemetryBackendConfig): The OTLP exporter configuration.
|
|
29
|
+
tracer_provider (TracerProvider): The tracer provider to use.
|
|
30
|
+
"""
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from _typeshed import Incomplete
|
|
2
|
+
from opentelemetry.sdk.trace import TracerProvider
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
class SentryBackendConfig:
|
|
6
|
+
"""Configuration object for Sentry initialization."""
|
|
7
|
+
dsn: Incomplete
|
|
8
|
+
environment: Incomplete
|
|
9
|
+
release: Incomplete
|
|
10
|
+
profiles_sample_rate: Incomplete
|
|
11
|
+
send_default_pii: Incomplete
|
|
12
|
+
disable_sentry_distributed_tracing: Incomplete
|
|
13
|
+
additional_options: Incomplete
|
|
14
|
+
def __init__(self, *, dsn: str | None = None, environment: str | None = None, release: str | None = None, profiles_sample_rate: float | None = None, send_default_pii: bool | None = None, disable_sentry_distributed_tracing: bool = False, **kwargs: Any) -> None:
|
|
15
|
+
"""Initializes the Sentry configuration object with the specified parameters.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
dsn (str | None, optional): The Sentry Project DSN. Defaults to None.
|
|
19
|
+
environment (str | None, optional): The environment for the Sentry project. Defaults to None.
|
|
20
|
+
release (str | None, optional): The release version for the Sentry project. Defaults to None.
|
|
21
|
+
profiles_sample_rate (float | None, optional): The sample rate for performance monitoring. Defaults to None.
|
|
22
|
+
send_default_pii (bool | None, optional): Whether to send default Personally Identifiable Information (PII).
|
|
23
|
+
Defaults to None.
|
|
24
|
+
disable_sentry_distributed_tracing (bool, optional): Whether to disable distributed tracing for Sentry.
|
|
25
|
+
Defaults to False.
|
|
26
|
+
**kwargs: Additional keyword arguments to pass to sentry_sdk.init
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
def init_sentry(config: SentryBackendConfig, tracer_provider: TracerProvider) -> None:
|
|
30
|
+
"""Initializes Sentry with OpenTelemetry for error tracking and performance monitoring.
|
|
31
|
+
|
|
32
|
+
Initializes Sentry with the specified parameters.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
config (SentryBackendConfig): The configuration object for Sentry initialization.
|
|
36
|
+
tracer_provider (TracerProvider): The tracer provider to use.
|
|
37
|
+
"""
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
from _typeshed import Incomplete
|
|
2
|
+
from fastapi import FastAPI
|
|
3
|
+
from opentelemetry.sdk.trace import TracerProvider
|
|
4
|
+
from opentelemetry.sdk.trace.sampling import Sampler
|
|
5
|
+
|
|
6
|
+
class FastAPIConfig:
|
|
7
|
+
"""Configuration for FastAPI instrumentation."""
|
|
8
|
+
app: Incomplete
|
|
9
|
+
def __init__(self, app: FastAPI) -> None:
|
|
10
|
+
"""Initialize FastAPI configuration.
|
|
11
|
+
|
|
12
|
+
Args:
|
|
13
|
+
app (FastAPI): The FastAPI application instance.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
class OpenTelemetryTraceConfig:
|
|
17
|
+
"""Configuration for OpenTelemetry Trace initialization."""
|
|
18
|
+
provider: TracerProvider | None
|
|
19
|
+
attributes: Incomplete
|
|
20
|
+
trace_sampler: Incomplete
|
|
21
|
+
fastapi_config: Incomplete
|
|
22
|
+
use_langchain: Incomplete
|
|
23
|
+
use_httpx: Incomplete
|
|
24
|
+
use_requests: Incomplete
|
|
25
|
+
def __init__(self, *, attributes: dict[str, str], trace_sampler: Sampler | None, fastapi_config: FastAPIConfig | None, use_langchain: bool, use_httpx: bool, use_requests: bool) -> None:
|
|
26
|
+
"""Initialize OpenTelemetry configuration.
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
attributes (dict[str, str]): Resource attributes.
|
|
30
|
+
trace_sampler (Sampler): Trace sampler.
|
|
31
|
+
fastapi_config (FastAPIConfig): FastAPI configuration.
|
|
32
|
+
use_langchain (bool): Enable Langchain instrumentation.
|
|
33
|
+
use_httpx (bool): Enable HTTPX instrumentation.
|
|
34
|
+
use_requests (bool): Enable Requests instrumentation.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
def setup_tracer_provider(opentelemetry_config: OpenTelemetryTraceConfig):
|
|
38
|
+
"""Set up the TracerProvider with the given configuration.
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
opentelemetry_config (OpenTelemetryTraceConfig): The configuration for OpenTelemetry.
|
|
42
|
+
"""
|
|
43
|
+
def auto_initialize_services(opentelemetry_config: OpenTelemetryTraceConfig) -> None:
|
|
44
|
+
"""Automatically initialize FastAPI, Langchain, HTTPX, and Requests tracing if applicable.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
opentelemetry_config (OpenTelemetryTraceConfig): The configuration for OpenTelemetry.
|
|
48
|
+
"""
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
|
2
2
|
from typing import Collection
|
|
3
3
|
|
|
4
|
-
class
|
|
4
|
+
class FunctionsInstrumentor(BaseInstrumentor):
|
|
5
5
|
"""OpenTelemetry Generic Function Instrumentor.
|
|
6
6
|
|
|
7
7
|
Supports:
|
|
@@ -61,7 +61,7 @@ class BOSAFunctionsInstrumentor(BaseInstrumentor):
|
|
|
61
61
|
from module.classes.custom_class import CustomClass
|
|
62
62
|
|
|
63
63
|
# Instrument all functions in the module
|
|
64
|
-
|
|
64
|
+
FunctionsInstrumentor().instrument(
|
|
65
65
|
methods=[
|
|
66
66
|
functions.sync_function, functions.async_function,
|
|
67
67
|
CustomClass.method, CustomClass.class_method,
|
|
@@ -85,7 +85,7 @@ class BOSAFunctionsInstrumentor(BaseInstrumentor):
|
|
|
85
85
|
await functions.async_function(...)
|
|
86
86
|
|
|
87
87
|
# Uninstrument all functions in the module
|
|
88
|
-
|
|
88
|
+
FunctionsInstrumentor().uninstrument()
|
|
89
89
|
```
|
|
90
90
|
|
|
91
91
|
Note:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import http.client
|
|
2
2
|
from dataclasses import dataclass
|
|
3
3
|
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
|
4
|
-
from opentelemetry.trace import Span, Tracer
|
|
4
|
+
from opentelemetry.trace import Span, Tracer, TracerProvider
|
|
5
5
|
from typing import Any, Callable
|
|
6
6
|
|
|
7
7
|
METHOD_INDEX: int
|
|
Binary file
|
gl_observability.pyi
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
# This file was generated by Nuitka
|
|
2
2
|
|
|
3
3
|
# Stubs included by default
|
|
4
|
+
from gl_observability.traces.backend.opentelemetry import OpenTelemetryBackendConfig
|
|
5
|
+
from gl_observability.traces.config import FastAPIConfig
|
|
6
|
+
from gl_observability.traces.backend.sentry import SentryBackendConfig
|
|
4
7
|
from gl_observability.initializer import TelemetryConfig, init_telemetry
|
|
5
|
-
from gl_observability.backend import OpenTelemetryConfig, SentryConfig
|
|
6
8
|
|
|
7
9
|
|
|
8
10
|
__name__ = ...
|
|
@@ -11,10 +13,14 @@ __name__ = ...
|
|
|
11
13
|
|
|
12
14
|
# Modules used internally, to allow implicit dependencies to be seen:
|
|
13
15
|
import os
|
|
14
|
-
import gl_observability.backend.OpenTelemetryConfig
|
|
15
|
-
import gl_observability.backend.SentryConfig
|
|
16
|
-
import fastapi
|
|
17
16
|
import opentelemetry
|
|
17
|
+
import opentelemetry.sdk
|
|
18
|
+
import opentelemetry.sdk.trace
|
|
19
|
+
import opentelemetry.sdk.trace.sampling
|
|
20
|
+
import logging
|
|
21
|
+
import typing
|
|
22
|
+
import requests
|
|
23
|
+
import re
|
|
18
24
|
import opentelemetry.exporter
|
|
19
25
|
import opentelemetry.exporter.otlp
|
|
20
26
|
import opentelemetry.exporter.otlp.proto
|
|
@@ -22,24 +28,18 @@ import opentelemetry.exporter.otlp.proto.grpc
|
|
|
22
28
|
import opentelemetry.exporter.otlp.proto.grpc.trace_exporter
|
|
23
29
|
import opentelemetry.exporter.otlp.proto.http
|
|
24
30
|
import opentelemetry.exporter.otlp.proto.http.trace_exporter
|
|
31
|
+
import opentelemetry.sdk.trace.export
|
|
32
|
+
import sentry_sdk
|
|
33
|
+
import opentelemetry.propagate
|
|
34
|
+
import sentry_sdk.integrations
|
|
35
|
+
import sentry_sdk.integrations.opentelemetry
|
|
36
|
+
import fastapi
|
|
25
37
|
import opentelemetry.instrumentation
|
|
26
38
|
import opentelemetry.instrumentation.fastapi
|
|
27
39
|
import opentelemetry.instrumentation.httpx
|
|
28
40
|
import opentelemetry.instrumentation.langchain
|
|
29
41
|
import opentelemetry.instrumentation.requests
|
|
30
|
-
import opentelemetry.propagate
|
|
31
|
-
import opentelemetry.sdk
|
|
32
42
|
import opentelemetry.sdk.resources
|
|
33
|
-
import opentelemetry.sdk.trace
|
|
34
|
-
import opentelemetry.sdk.trace.export
|
|
35
|
-
import opentelemetry.sdk.trace.sampling
|
|
36
|
-
import sentry_sdk
|
|
37
|
-
import sentry_sdk.integrations
|
|
38
|
-
import sentry_sdk.integrations.opentelemetry
|
|
39
|
-
import typing
|
|
40
|
-
import logging
|
|
41
|
-
import requests
|
|
42
|
-
import re
|
|
43
43
|
import importlib
|
|
44
44
|
import inspect
|
|
45
45
|
import wrapt
|
{gl_observability_binary-0.0.0b1.dist-info → gl_observability_binary-0.1.1.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: gl-observability-binary
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.1.1
|
|
4
4
|
Summary: SDK for Observability tools
|
|
5
5
|
Author-email: HansSeanNathanael <hans.s.nathanael@gdplabs.id>
|
|
6
6
|
Requires-Python: <3.14,>=3.11
|
|
@@ -34,7 +34,7 @@ Requires-Dist: ruff<1.0.0,>=0.11.12; extra == "dev"
|
|
|
34
34
|
|
|
35
35
|
## Key Features
|
|
36
36
|
|
|
37
|
-
- 📊 **OpenTelemetry Integration**: simplified initialization for tracing
|
|
37
|
+
- 📊 **OpenTelemetry Integration**: simplified initialization for tracing.
|
|
38
38
|
- 🛡️ **Sentry Support**: easy setup for error tracking and performance monitoring.
|
|
39
39
|
- 🕵️ **PII Redaction**: custom logging handlers to redact PII using Regex or NER (Named Entity Recognition).
|
|
40
40
|
- 🔌 **Framework Support**: built-in support for FastAPI, Langchain, HTTPX, and Requests instrumentation.
|
|
@@ -84,34 +84,39 @@ poetry add "git+ssh://git@github.com/GDP-ADMIN/gl-sdk.git#subdirectory=libs/gl-o
|
|
|
84
84
|
|
|
85
85
|
### 1. Telemetry Initialization
|
|
86
86
|
|
|
87
|
-
The library uses a unified `init_telemetry` function that takes a `TelemetryConfig` object. You can configure it
|
|
87
|
+
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.
|
|
88
88
|
|
|
89
|
-
#### OpenTelemetry Configuration
|
|
89
|
+
#### OpenTelemetry Configuration
|
|
90
90
|
|
|
91
91
|
This setup sends traces to an external OTLP collector (e.g., Jaeger, Tempo).
|
|
92
92
|
|
|
93
93
|
```python
|
|
94
94
|
from fastapi import FastAPI
|
|
95
|
-
from gl_observability
|
|
96
|
-
from gl_observability import TelemetryConfig, init_telemetry
|
|
95
|
+
from gl_observability import init_telemetry, TelemetryConfig, OpenTelemetryBackendConfig, FastAPIConfig
|
|
97
96
|
|
|
98
97
|
# 1. Setup FastAPI Config (optional, if using FastAPI)
|
|
99
98
|
app = FastAPI()
|
|
100
99
|
fastapi_config = FastAPIConfig(app=app)
|
|
101
100
|
|
|
102
|
-
# 2. Configure
|
|
103
|
-
|
|
104
|
-
endpoint="localhost:
|
|
105
|
-
use_grpc=False,
|
|
106
|
-
|
|
107
|
-
use_langchain=True, # Enable Langchain instrumentation
|
|
108
|
-
use_httpx=True, # Enable HTTPX instrumentation
|
|
109
|
-
use_requests=True, # Enable Requests instrumentation
|
|
110
|
-
attributes={"service.name": "my-service", "env": "production"}
|
|
101
|
+
# 2. Configure OpenTelemetryBackendConfig
|
|
102
|
+
otel_backend_config = OpenTelemetryBackendConfig(
|
|
103
|
+
endpoint="localhost:4318", # OTLP endpoint
|
|
104
|
+
use_grpc=False, # Use gRPC or HTTP
|
|
105
|
+
headers={"Authorization": "Bearer ..."}, # Optional headers
|
|
111
106
|
)
|
|
112
107
|
|
|
113
|
-
# 3.
|
|
114
|
-
|
|
108
|
+
# 3. Configure TelemetryConfig
|
|
109
|
+
otel_config = TelemetryConfig(
|
|
110
|
+
attributes={"service.name": "..."}, # Resource attributes
|
|
111
|
+
backend_config=otel_backend_config, # Backend configuration
|
|
112
|
+
fastapi_config=fastapi_config, # FastAPI Instrumentation
|
|
113
|
+
use_langchain=True, # Enable Langchain instrumentation
|
|
114
|
+
use_httpx=True, # Enable HTTPX instrumentation
|
|
115
|
+
use_requests=True, # Enable Requests instrumentation
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
# 4. Initialize Telemetry
|
|
119
|
+
init_telemetry(otel_config)
|
|
115
120
|
```
|
|
116
121
|
|
|
117
122
|
#### Sentry Configuration
|
|
@@ -119,54 +124,69 @@ init_telemetry(TelemetryConfig(otel_config=otel_config))
|
|
|
119
124
|
This setup sends errors and traces to Sentry.
|
|
120
125
|
|
|
121
126
|
```python
|
|
122
|
-
from
|
|
123
|
-
from gl_observability import TelemetryConfig,
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
#
|
|
130
|
-
|
|
131
|
-
dsn="
|
|
132
|
-
environment="
|
|
133
|
-
release="
|
|
134
|
-
|
|
135
|
-
|
|
127
|
+
from fastapi import FastAPI
|
|
128
|
+
from gl_observability import init_telemetry, TelemetryConfig, SentryBackendConfig, FastAPIConfig
|
|
129
|
+
|
|
130
|
+
# 1. Setup FastAPI Config (optional, if using FastAPI)
|
|
131
|
+
app = FastAPI()
|
|
132
|
+
fastapi_config = FastAPIConfig(app=app)
|
|
133
|
+
|
|
134
|
+
# 2. Configure SentryBackendConfig
|
|
135
|
+
sentry_backend_config = SentryBackendConfig(
|
|
136
|
+
dsn="https://...",
|
|
137
|
+
environment="...",
|
|
138
|
+
release="...",
|
|
139
|
+
send_default_pii=True,
|
|
140
|
+
disable_sentry_distributed_tracing=False
|
|
136
141
|
)
|
|
137
142
|
|
|
138
|
-
#
|
|
139
|
-
|
|
143
|
+
# 3. Configure TelemetryConfig
|
|
144
|
+
otel_config = TelemetryConfig(
|
|
145
|
+
attributes={"service.name": "..."}, # Resource attributes
|
|
146
|
+
backend_config=sentry_backend_config, # Backend configuration
|
|
147
|
+
fastapi_config=fastapi_config, # FastAPI Instrumentation
|
|
148
|
+
use_langchain=True, # Enable Langchain instrumentation
|
|
149
|
+
use_httpx=True, # Enable HTTPX instrumentation
|
|
150
|
+
use_requests=True, # Enable Requests instrumentation
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
# 4. Initialize Telemetry
|
|
154
|
+
init_telemetry(otel_config)
|
|
140
155
|
```
|
|
141
156
|
|
|
142
|
-
####
|
|
157
|
+
#### Multiple Backend Configuration
|
|
143
158
|
|
|
144
|
-
This setup
|
|
159
|
+
This setup the OpenTelemetry SDK used for tracing.
|
|
145
160
|
|
|
146
161
|
```python
|
|
147
162
|
from fastapi import FastAPI
|
|
148
|
-
from gl_observability
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
163
|
+
from gl_observability import init_telemetry, TelemetryConfig, OpenTelemetryBackendConfig, SentryBackendConfig
|
|
164
|
+
|
|
165
|
+
jaeger_backend = OpenTelemetryBackendConfig(endpoint="jager...", ...)
|
|
166
|
+
init_telemetry(
|
|
167
|
+
TelemetryConfig(
|
|
168
|
+
attributes={"service.name": "..."},
|
|
169
|
+
backend_config=jaeger_backend,
|
|
170
|
+
fastapi_config=fastapi_config,
|
|
171
|
+
use_langchain=True,
|
|
172
|
+
use_httpx=True,
|
|
173
|
+
use_requests=True,
|
|
174
|
+
)
|
|
159
175
|
)
|
|
160
176
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
177
|
+
langfuse_backend = OpenTelemetryBackendConfig(endpoint="langfuse...", ...)
|
|
178
|
+
init_telemetry(
|
|
179
|
+
TelemetryConfig(
|
|
180
|
+
backend_config=langfuse_backend
|
|
181
|
+
)
|
|
166
182
|
)
|
|
167
183
|
|
|
168
|
-
|
|
169
|
-
init_telemetry(
|
|
184
|
+
sentry_backend = SentryBackendConfig(dsn="https://...", ...)
|
|
185
|
+
init_telemetry(
|
|
186
|
+
TelemetryConfig(
|
|
187
|
+
backend_config=sentry_backend
|
|
188
|
+
)
|
|
189
|
+
)
|
|
170
190
|
```
|
|
171
191
|
|
|
172
192
|
### 2. Logging Handlers
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
gl_observability.cp312-win_amd64.pyd,sha256=QWLdX_t-OGG7CW9bFyZuuTZViFXjlyshnHudLW_Xz8E,649728
|
|
2
|
+
gl_observability.pyi,sha256=zLWMUAsSLQclPGwJIhjJpDo_yw3gjUE3RmEB0e2JDUQ,1671
|
|
3
|
+
gl_observability/__init__.pyi,sha256=YvrsoNmib8ulmQtWz9yxKyHDWnsTxzLWXOiI5C-BqmM,518
|
|
4
|
+
gl_observability/initializer.pyi,sha256=T8_r7zuT8zrVofPemaS-9TEliOy0iqR-hAgq6sPGN6I,3524
|
|
5
|
+
gl_observability/logs/__init__.pyi,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
gl_observability/logs/ner_pii_logger_handler.pyi,sha256=KkX_78DsEJVFqdgcrrV-sosUmIR14gKJD6JEp16YOLU,1573
|
|
7
|
+
gl_observability/logs/regex_pii_logger_handler.pyi,sha256=mN9pAOn8t3GrEjM7hldAn2HZLV8m3Ja2wY5vwWDWdAI,2538
|
|
8
|
+
gl_observability/traces/__init__.pyi,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
+
gl_observability/traces/config.pyi,sha256=E-U-Sda2CL4VKXQPTkGdwLSB230jusIHHbFKW8hC98I,1982
|
|
10
|
+
gl_observability/traces/backend/__init__.pyi,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
+
gl_observability/traces/backend/opentelemetry.pyi,sha256=jXsw3ZG2PnT0VWuC23yjQHaPMit3mF8m-C8LFeEBruo,1460
|
|
12
|
+
gl_observability/traces/backend/sentry.pyi,sha256=dVrmxAc5F7vZym3NQ6G7gCynuwa_TkstodEkFSvdhbs,2049
|
|
13
|
+
gl_observability/traces/instrument/__init__.pyi,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
+
gl_observability/traces/instrument/functions.pyi,sha256=Hd2CmrBF4qxjb_LEUf5jgljVJ1DKy7XiQXJzvpYTl5w,4293
|
|
15
|
+
gl_observability/traces/instrument/http.pyi,sha256=F86Nscqe9GxNdEduPJepzzjg3EeLZL-zRMUSj7tPxRg,2033
|
|
16
|
+
gl_observability.build/.gitignore,sha256=aEiIwOuxfzdCmLZe4oB1JsBmCUxwG8x-u-HBCV9JT8E,1
|
|
17
|
+
gl_observability_binary-0.1.1.dist-info/METADATA,sha256=wWLm2SHd2xY9o1ae3TP2RWO-rh8H2yQXJJwE7P2rVMg,8259
|
|
18
|
+
gl_observability_binary-0.1.1.dist-info/WHEEL,sha256=x5rgv--I0NI0IT1Lh9tN1VG2cI637p3deednwYLKnxc,96
|
|
19
|
+
gl_observability_binary-0.1.1.dist-info/top_level.txt,sha256=qX0-e4NxRAAXXjWIZ7gvIspQP7J_dgxPQ7e3-WEbIeQ,17
|
|
20
|
+
gl_observability_binary-0.1.1.dist-info/RECORD,,
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
from gl_observability.backend.opentelemetry.initializer import FastAPIConfig as FastAPIConfig, OpenTelemetryConfig as OpenTelemetryConfig
|
|
2
|
-
from gl_observability.backend.sentry.initializer import SentryConfig as SentryConfig
|
|
3
|
-
|
|
4
|
-
__all__ = ['OpenTelemetryConfig', 'SentryConfig', 'FastAPIConfig']
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
from _typeshed import Incomplete
|
|
2
|
-
from fastapi import FastAPI as FastAPI
|
|
3
|
-
from opentelemetry.sdk.trace import TracerProvider
|
|
4
|
-
from opentelemetry.sdk.trace.sampling import Sampler as Sampler
|
|
5
|
-
|
|
6
|
-
class FastAPIConfig:
|
|
7
|
-
"""Configuration class for FastAPI application."""
|
|
8
|
-
app: Incomplete
|
|
9
|
-
def __init__(self, app: FastAPI) -> None:
|
|
10
|
-
"""Initializes FastAPIConfig with a FastAPI application.
|
|
11
|
-
|
|
12
|
-
Args:
|
|
13
|
-
app (FastAPI): The FastAPI application to configure.
|
|
14
|
-
"""
|
|
15
|
-
|
|
16
|
-
class OpenTelemetryConfig:
|
|
17
|
-
"""Configuration-based initializer for OpenTelemetry with FastAPI and Langchain support."""
|
|
18
|
-
provider: TracerProvider | None
|
|
19
|
-
endpoint: Incomplete
|
|
20
|
-
trace_sampler: Incomplete
|
|
21
|
-
headers: Incomplete
|
|
22
|
-
attributes: Incomplete
|
|
23
|
-
use_grpc: Incomplete
|
|
24
|
-
fastapi_config: Incomplete
|
|
25
|
-
use_langchain: Incomplete
|
|
26
|
-
use_httpx: Incomplete
|
|
27
|
-
use_requests: Incomplete
|
|
28
|
-
disable_sentry_distributed_tracing: Incomplete
|
|
29
|
-
def __init__(self, endpoint: str = '', trace_sampler: Sampler = None, headers: dict[str, str] = None, attributes: dict[str, str] = None, use_grpc: bool = True, fastapi_config: FastAPIConfig | None = None, use_langchain: bool = False, use_httpx: bool = True, use_requests: bool = True, disable_sentry_distributed_tracing: bool = False) -> None:
|
|
30
|
-
'''Initializes OpenTelemetryConfig with optional attributes.
|
|
31
|
-
|
|
32
|
-
Args:
|
|
33
|
-
endpoint (str): The OTLP endpoint. If you have port, please concat with the endpoint, e.g. "localhost:4317".
|
|
34
|
-
trace_sampler (Sampler): The sampler for traces.
|
|
35
|
-
headers (dict[str, str]): Headers with key value for connecting to the exporter.
|
|
36
|
-
attributes (dict[str, str]): Additional resource attributes.
|
|
37
|
-
use_grpc (bool): use grpc for opentelemetry exporter.
|
|
38
|
-
fastapi_config (FastAPI | None): The FastAPI fastapi_config (if using FastAPI tracing).
|
|
39
|
-
use_langchain (bool): Whether to use Langchain tracing.
|
|
40
|
-
use_httpx (bool): Whether to use httpx for tracing.
|
|
41
|
-
use_requests (bool): Whether to use requests for tracing.
|
|
42
|
-
disable_sentry_distributed_tracing (bool): Disable Sentry distributed tracing.
|
|
43
|
-
'''
|
|
44
|
-
|
|
45
|
-
def init_otel_with_external_exporter(initializer: OpenTelemetryConfig) -> None:
|
|
46
|
-
"""Initializes OpenTelemetry with an external exporter.
|
|
47
|
-
|
|
48
|
-
This method initializes OpenTelemetry with an external exporter (OTLP)
|
|
49
|
-
and instruments FastAPI and Langchain if applicable.
|
|
50
|
-
|
|
51
|
-
Args:
|
|
52
|
-
initializer (OpenTelemetryConfig): The configuration for OpenTelemetry.
|
|
53
|
-
"""
|
|
54
|
-
def init_otel_sentry(initializer: OpenTelemetryConfig) -> None:
|
|
55
|
-
"""Initializes OpenTelemetry tracing.
|
|
56
|
-
|
|
57
|
-
This method initializes OpenTelemetry with Sentry and instruments FastAPI and Langchain if applicable.
|
|
58
|
-
|
|
59
|
-
Args:
|
|
60
|
-
initializer (OpenTelemetryConfig): The configuration for OpenTelemetry.
|
|
61
|
-
"""
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
from _typeshed import Incomplete
|
|
2
|
-
from gl_observability.backend.opentelemetry.initializer import OpenTelemetryConfig as OpenTelemetryConfig, init_otel_sentry as init_otel_sentry
|
|
3
|
-
from typing import Any
|
|
4
|
-
|
|
5
|
-
class SentryConfig:
|
|
6
|
-
"""Configuration object for Sentry initialization.
|
|
7
|
-
|
|
8
|
-
this class is used to store the configuration for Sentry initialization.
|
|
9
|
-
"""
|
|
10
|
-
dsn: Incomplete
|
|
11
|
-
environment: Incomplete
|
|
12
|
-
release: Incomplete
|
|
13
|
-
profiles_sample_rate: Incomplete
|
|
14
|
-
send_default_pii: Incomplete
|
|
15
|
-
traces_sampler: Incomplete
|
|
16
|
-
open_telemetry_config: Incomplete
|
|
17
|
-
additional_options: Incomplete
|
|
18
|
-
def __init__(self, dsn: str | None = None, environment: str | None = None, release: str | None = None, profiles_sample_rate: float | None = None, send_default_pii: bool | None = None, traces_sampler=None, open_telemetry_config: OpenTelemetryConfig | None = None, **kwargs: Any) -> None:
|
|
19
|
-
"""Initializes the Sentry configuration object with the specified parameters.
|
|
20
|
-
|
|
21
|
-
Args:
|
|
22
|
-
dsn (str): The Data Source Name (DSN) for the Sentry project.
|
|
23
|
-
environment (str): The environment for the Sentry project.
|
|
24
|
-
release (str): The release version for the Sentry project.
|
|
25
|
-
profiles_sample_rate (float): The sample rate for performance monitoring.
|
|
26
|
-
send_default_pii (bool): Whether to send default Personally Identifiable Information (PII).
|
|
27
|
-
traces_sampler (TracesSampler): The sampler for traces.
|
|
28
|
-
open_telemetry_config: The OpenTelemetry Config
|
|
29
|
-
**kwargs: Additional keyword arguments to pass to sentry_sdk.init
|
|
30
|
-
"""
|
|
31
|
-
|
|
32
|
-
def init_sentry(config: SentryConfig | None = None) -> None:
|
|
33
|
-
"""Initializes Sentry for error tracking and performance monitoring.
|
|
34
|
-
|
|
35
|
-
Initializes Sentry with the specified parameters.
|
|
36
|
-
|
|
37
|
-
Args:
|
|
38
|
-
config (SentryConfig | None, optional): The configuration object for Sentry initialization. Defaults to None.
|
|
39
|
-
"""
|
|
File without changes
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
from gl_observability.traces.opentelemetry.instrument.functions import BOSAFunctionsInstrumentor as BOSAFunctionsInstrumentor
|
|
2
|
-
from gl_observability.traces.opentelemetry.instrument.http import HTTPClientInstrumentor as HTTPClientInstrumentor
|
|
3
|
-
|
|
4
|
-
__all__ = ['BOSAFunctionsInstrumentor', 'HTTPClientInstrumentor']
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
gl_observability.cp312-win_amd64.pyd,sha256=JPjkfJU1cBJQ7F9y9y8cciY0XFFXnOFaP0QkK8E7qKo,655360
|
|
2
|
-
gl_observability.pyi,sha256=46n3y42spCx9vMmhRew5Ah26B67UoblpNHDsmIb8uU8,1626
|
|
3
|
-
gl_observability/__init__.pyi,sha256=Ae5Vy1UKE0GokAsbCejhl8IfomzxoHQklX1EMqWAZEs,312
|
|
4
|
-
gl_observability/initializer.pyi,sha256=vSBAy4QdpjDbrmKLYwFk_yBzwqCklDvMyTiVsmAWEzw,1108
|
|
5
|
-
gl_observability/backend/__init__.pyi,sha256=IbzwPhr570SWM4925eUdYt_QarRz0idNResU9gv6Lig,295
|
|
6
|
-
gl_observability/backend/opentelemetry/__init__.pyi,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
-
gl_observability/backend/opentelemetry/initializer.pyi,sha256=X4ojVPJVwcdghJq0RHytwvltEyiV3qC8uZv1u7h7Rhc,2947
|
|
8
|
-
gl_observability/backend/sentry/__init__.pyi,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
-
gl_observability/backend/sentry/initializer.pyi,sha256=pOZGRlHCM2TLi-3knvvWFLSB1gbeyeGx6lDnthuJ7Ss,1990
|
|
10
|
-
gl_observability/logs/__init__.pyi,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
-
gl_observability/logs/ner_pii_logger_handler.pyi,sha256=KkX_78DsEJVFqdgcrrV-sosUmIR14gKJD6JEp16YOLU,1573
|
|
12
|
-
gl_observability/logs/regex_pii_logger_handler.pyi,sha256=mN9pAOn8t3GrEjM7hldAn2HZLV8m3Ja2wY5vwWDWdAI,2538
|
|
13
|
-
gl_observability/traces/__init__.pyi,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
-
gl_observability/traces/opentelemetry/__init__.pyi,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
|
-
gl_observability/traces/opentelemetry/instrument/__init__.pyi,sha256=PC9q9GLoWkGDGgcrYsp6j3rpS_A3yse80NaCAb-3BBQ,312
|
|
16
|
-
gl_observability/traces/opentelemetry/instrument/functions.pyi,sha256=NeLDDzYJwXrAR5ltmfkdqj78UQqbyTHtW-eFXgoI5uM,4305
|
|
17
|
-
gl_observability/traces/opentelemetry/instrument/http.pyi,sha256=GQRN3YdFElTF-m_nRWUG8XE50ge1QxMmRJiLY1TYP3c,2061
|
|
18
|
-
gl_observability.build/.gitignore,sha256=aEiIwOuxfzdCmLZe4oB1JsBmCUxwG8x-u-HBCV9JT8E,1
|
|
19
|
-
gl_observability_binary-0.0.0b1.dist-info/METADATA,sha256=r1pS0wyqq4WC19Hzp5mLoYu1lu_8jqW2GcUx-dGQA5o,7356
|
|
20
|
-
gl_observability_binary-0.0.0b1.dist-info/WHEEL,sha256=x5rgv--I0NI0IT1Lh9tN1VG2cI637p3deednwYLKnxc,96
|
|
21
|
-
gl_observability_binary-0.0.0b1.dist-info/top_level.txt,sha256=qX0-e4NxRAAXXjWIZ7gvIspQP7J_dgxPQ7e3-WEbIeQ,17
|
|
22
|
-
gl_observability_binary-0.0.0b1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{gl_observability_binary-0.0.0b1.dist-info → gl_observability_binary-0.1.1.dist-info}/top_level.txt
RENAMED
|
File without changes
|