gl-observability-binary 0.1.0__cp311-cp311-win_amd64.whl → 0.1.2__cp311-cp311-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/initializer.pyi +4 -1
- gl_observability/traces/backend/opentelemetry.pyi +2 -2
- gl_observability/traces/config.pyi +3 -1
- gl_observability.cp311-win_amd64.pyd +0 -0
- gl_observability.pyi +1 -0
- {gl_observability_binary-0.1.0.dist-info → gl_observability_binary-0.1.2.dist-info}/METADATA +74 -54
- {gl_observability_binary-0.1.0.dist-info → gl_observability_binary-0.1.2.dist-info}/RECORD +9 -9
- {gl_observability_binary-0.1.0.dist-info → gl_observability_binary-0.1.2.dist-info}/WHEEL +0 -0
- {gl_observability_binary-0.1.0.dist-info → gl_observability_binary-0.1.2.dist-info}/top_level.txt +0 -0
gl_observability/initializer.pyi
CHANGED
|
@@ -15,8 +15,9 @@ class TelemetryConfig:
|
|
|
15
15
|
use_langchain: Incomplete
|
|
16
16
|
use_httpx: Incomplete
|
|
17
17
|
use_requests: Incomplete
|
|
18
|
+
log_trace_context: Incomplete
|
|
18
19
|
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
|
+
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, log_trace_context: bool = True, backend_config: OpenTelemetryBackendConfig | SentryBackendConfig | None = None) -> None:
|
|
20
21
|
"""Initialize the telemetry configuration.
|
|
21
22
|
|
|
22
23
|
Args:
|
|
@@ -27,6 +28,8 @@ class TelemetryConfig:
|
|
|
27
28
|
use_langchain (bool, optional): Enable Langchain instrumentation. Defaults to False.
|
|
28
29
|
use_httpx (bool, optional): Enable HTTPX instrumentation. Defaults to True.
|
|
29
30
|
use_requests (bool, optional): Enable Requests instrumentation. Defaults to True.
|
|
31
|
+
log_trace_context (bool, optional): Add trace context to logs. You have to set the formatter to
|
|
32
|
+
include the trace context. Defaults to True.
|
|
30
33
|
backend_config (OpenTelemetryBackendConfig | SentryBackendConfig | None, optional): The telemetry
|
|
31
34
|
backend configuration. Defaults to None. Make sure to set at least one backend configuration,
|
|
32
35
|
if not traces will not be exported.
|
|
@@ -18,13 +18,13 @@ class OpenTelemetryBackendConfig:
|
|
|
18
18
|
**kwargs: Additional keyword arguments passed to OTLPSpanExporter.
|
|
19
19
|
'''
|
|
20
20
|
|
|
21
|
-
def init_otel_with_external_exporter(
|
|
21
|
+
def init_otel_with_external_exporter(config: OpenTelemetryBackendConfig, tracer_provider: TracerProvider) -> None:
|
|
22
22
|
"""Initialize OpenTelemetry with an external OTLP exporter.
|
|
23
23
|
|
|
24
24
|
This method initializes OpenTelemetry with an external exporter (OTLP)
|
|
25
25
|
and instruments FastAPI, Langchain, HTTPX, and Requests if configured.
|
|
26
26
|
|
|
27
27
|
Args:
|
|
28
|
-
tracer_provider (TracerProvider): The tracer provider to use.
|
|
29
28
|
config (OpenTelemetryBackendConfig): The OTLP exporter configuration.
|
|
29
|
+
tracer_provider (TracerProvider): The tracer provider to use.
|
|
30
30
|
"""
|
|
@@ -22,7 +22,8 @@ class OpenTelemetryTraceConfig:
|
|
|
22
22
|
use_langchain: Incomplete
|
|
23
23
|
use_httpx: Incomplete
|
|
24
24
|
use_requests: Incomplete
|
|
25
|
-
|
|
25
|
+
log_trace_context: Incomplete
|
|
26
|
+
def __init__(self, *, attributes: dict[str, str], trace_sampler: Sampler | None, fastapi_config: FastAPIConfig | None, use_langchain: bool, use_httpx: bool, use_requests: bool, log_trace_context: bool) -> None:
|
|
26
27
|
"""Initialize OpenTelemetry configuration.
|
|
27
28
|
|
|
28
29
|
Args:
|
|
@@ -32,6 +33,7 @@ class OpenTelemetryTraceConfig:
|
|
|
32
33
|
use_langchain (bool): Enable Langchain instrumentation.
|
|
33
34
|
use_httpx (bool): Enable HTTPX instrumentation.
|
|
34
35
|
use_requests (bool): Enable Requests instrumentation.
|
|
36
|
+
log_trace_context (bool): Add trace context to logs.
|
|
35
37
|
"""
|
|
36
38
|
|
|
37
39
|
def setup_tracer_provider(opentelemetry_config: OpenTelemetryTraceConfig):
|
|
Binary file
|
gl_observability.pyi
CHANGED
|
@@ -38,6 +38,7 @@ import opentelemetry.instrumentation
|
|
|
38
38
|
import opentelemetry.instrumentation.fastapi
|
|
39
39
|
import opentelemetry.instrumentation.httpx
|
|
40
40
|
import opentelemetry.instrumentation.langchain
|
|
41
|
+
import opentelemetry.instrumentation.logging
|
|
41
42
|
import opentelemetry.instrumentation.requests
|
|
42
43
|
import opentelemetry.sdk.resources
|
|
43
44
|
import importlib
|
{gl_observability_binary-0.1.0.dist-info → gl_observability_binary-0.1.2.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: gl-observability-binary
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
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
|
|
@@ -18,6 +18,7 @@ Requires-Dist: opentelemetry-instrumentation-fastapi
|
|
|
18
18
|
Requires-Dist: opentelemetry-instrumentation-langchain
|
|
19
19
|
Requires-Dist: opentelemetry-instrumentation-requests
|
|
20
20
|
Requires-Dist: opentelemetry-instrumentation-httpx
|
|
21
|
+
Requires-Dist: opentelemetry-instrumentation-logging
|
|
21
22
|
Provides-Extra: dev
|
|
22
23
|
Requires-Dist: pytest<9.0.0,>=8.3.4; extra == "dev"
|
|
23
24
|
Requires-Dist: pre-commit<4.0.0,>=3.7.0; extra == "dev"
|
|
@@ -34,7 +35,7 @@ Requires-Dist: ruff<1.0.0,>=0.11.12; extra == "dev"
|
|
|
34
35
|
|
|
35
36
|
## Key Features
|
|
36
37
|
|
|
37
|
-
- 📊 **OpenTelemetry Integration**: simplified initialization for tracing
|
|
38
|
+
- 📊 **OpenTelemetry Integration**: simplified initialization for tracing.
|
|
38
39
|
- 🛡️ **Sentry Support**: easy setup for error tracking and performance monitoring.
|
|
39
40
|
- 🕵️ **PII Redaction**: custom logging handlers to redact PII using Regex or NER (Named Entity Recognition).
|
|
40
41
|
- 🔌 **Framework Support**: built-in support for FastAPI, Langchain, HTTPX, and Requests instrumentation.
|
|
@@ -84,34 +85,39 @@ poetry add "git+ssh://git@github.com/GDP-ADMIN/gl-sdk.git#subdirectory=libs/gl-o
|
|
|
84
85
|
|
|
85
86
|
### 1. Telemetry Initialization
|
|
86
87
|
|
|
87
|
-
The library uses a unified `init_telemetry` function that takes a `TelemetryConfig` object. You can configure it
|
|
88
|
+
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
89
|
|
|
89
|
-
#### OpenTelemetry Configuration
|
|
90
|
+
#### OpenTelemetry Configuration
|
|
90
91
|
|
|
91
92
|
This setup sends traces to an external OTLP collector (e.g., Jaeger, Tempo).
|
|
92
93
|
|
|
93
94
|
```python
|
|
94
95
|
from fastapi import FastAPI
|
|
95
|
-
from gl_observability
|
|
96
|
-
from gl_observability import TelemetryConfig, init_telemetry
|
|
96
|
+
from gl_observability import init_telemetry, TelemetryConfig, OpenTelemetryBackendConfig, FastAPIConfig
|
|
97
97
|
|
|
98
98
|
# 1. Setup FastAPI Config (optional, if using FastAPI)
|
|
99
99
|
app = FastAPI()
|
|
100
100
|
fastapi_config = FastAPIConfig(app=app)
|
|
101
101
|
|
|
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"}
|
|
102
|
+
# 2. Configure OpenTelemetryBackendConfig
|
|
103
|
+
otel_backend_config = OpenTelemetryBackendConfig(
|
|
104
|
+
endpoint="localhost:4318", # OTLP endpoint
|
|
105
|
+
use_grpc=False, # Use gRPC or HTTP
|
|
106
|
+
headers={"Authorization": "Bearer ..."}, # Optional headers
|
|
111
107
|
)
|
|
112
108
|
|
|
113
|
-
# 3.
|
|
114
|
-
|
|
109
|
+
# 3. Configure TelemetryConfig
|
|
110
|
+
otel_config = TelemetryConfig(
|
|
111
|
+
attributes={"service.name": "..."}, # Resource attributes
|
|
112
|
+
backend_config=otel_backend_config, # Backend configuration
|
|
113
|
+
fastapi_config=fastapi_config, # FastAPI Instrumentation
|
|
114
|
+
use_langchain=True, # Enable Langchain instrumentation
|
|
115
|
+
use_httpx=True, # Enable HTTPX instrumentation
|
|
116
|
+
use_requests=True, # Enable Requests instrumentation
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
# 4. Initialize Telemetry
|
|
120
|
+
init_telemetry(otel_config)
|
|
115
121
|
```
|
|
116
122
|
|
|
117
123
|
#### Sentry Configuration
|
|
@@ -119,55 +125,69 @@ init_telemetry(TelemetryConfig(otel_config=otel_config))
|
|
|
119
125
|
This setup sends errors and traces to Sentry.
|
|
120
126
|
|
|
121
127
|
```python
|
|
122
|
-
from
|
|
123
|
-
from gl_observability import TelemetryConfig,
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
#
|
|
130
|
-
|
|
131
|
-
dsn="
|
|
132
|
-
environment="
|
|
133
|
-
release="
|
|
134
|
-
|
|
135
|
-
|
|
128
|
+
from fastapi import FastAPI
|
|
129
|
+
from gl_observability import init_telemetry, TelemetryConfig, SentryBackendConfig, FastAPIConfig
|
|
130
|
+
|
|
131
|
+
# 1. Setup FastAPI Config (optional, if using FastAPI)
|
|
132
|
+
app = FastAPI()
|
|
133
|
+
fastapi_config = FastAPIConfig(app=app)
|
|
134
|
+
|
|
135
|
+
# 2. Configure SentryBackendConfig
|
|
136
|
+
sentry_backend_config = SentryBackendConfig(
|
|
137
|
+
dsn="https://...",
|
|
138
|
+
environment="...",
|
|
139
|
+
release="...",
|
|
140
|
+
send_default_pii=True,
|
|
141
|
+
disable_sentry_distributed_tracing=False
|
|
136
142
|
)
|
|
137
143
|
|
|
138
|
-
#
|
|
139
|
-
|
|
144
|
+
# 3. Configure TelemetryConfig
|
|
145
|
+
otel_config = TelemetryConfig(
|
|
146
|
+
attributes={"service.name": "..."}, # Resource attributes
|
|
147
|
+
backend_config=sentry_backend_config, # Backend configuration
|
|
148
|
+
fastapi_config=fastapi_config, # FastAPI Instrumentation
|
|
149
|
+
use_langchain=True, # Enable Langchain instrumentation
|
|
150
|
+
use_httpx=True, # Enable HTTPX instrumentation
|
|
151
|
+
use_requests=True, # Enable Requests instrumentation
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
# 4. Initialize Telemetry
|
|
155
|
+
init_telemetry(otel_config)
|
|
140
156
|
```
|
|
141
157
|
|
|
142
|
-
####
|
|
158
|
+
#### Multiple Backend Configuration
|
|
143
159
|
|
|
144
|
-
This setup
|
|
160
|
+
This setup the OpenTelemetry SDK used for tracing.
|
|
145
161
|
|
|
146
162
|
```python
|
|
147
163
|
from fastapi import FastAPI
|
|
148
|
-
from gl_observability
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
164
|
+
from gl_observability import init_telemetry, TelemetryConfig, OpenTelemetryBackendConfig, SentryBackendConfig
|
|
165
|
+
|
|
166
|
+
jaeger_backend = OpenTelemetryBackendConfig(endpoint="jager...", ...)
|
|
167
|
+
init_telemetry(
|
|
168
|
+
TelemetryConfig(
|
|
169
|
+
attributes={"service.name": "..."},
|
|
170
|
+
backend_config=jaeger_backend,
|
|
171
|
+
fastapi_config=fastapi_config,
|
|
172
|
+
use_langchain=True,
|
|
173
|
+
use_httpx=True,
|
|
174
|
+
use_requests=True,
|
|
175
|
+
)
|
|
160
176
|
)
|
|
161
177
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
178
|
+
langfuse_backend = OpenTelemetryBackendConfig(endpoint="langfuse...", ...)
|
|
179
|
+
init_telemetry(
|
|
180
|
+
TelemetryConfig(
|
|
181
|
+
backend_config=langfuse_backend
|
|
182
|
+
)
|
|
167
183
|
)
|
|
168
184
|
|
|
169
|
-
|
|
170
|
-
init_telemetry(
|
|
185
|
+
sentry_backend = SentryBackendConfig(dsn="https://...", ...)
|
|
186
|
+
init_telemetry(
|
|
187
|
+
TelemetryConfig(
|
|
188
|
+
backend_config=sentry_backend
|
|
189
|
+
)
|
|
190
|
+
)
|
|
171
191
|
```
|
|
172
192
|
|
|
173
193
|
### 2. Logging Handlers
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
gl_observability.cp311-win_amd64.pyd,sha256=
|
|
2
|
-
gl_observability.pyi,sha256=
|
|
1
|
+
gl_observability.cp311-win_amd64.pyd,sha256=uOpa2JXzpTDXy-R0mFY6C7CyWgZ4qcMSsEmwM0-maiM,660480
|
|
2
|
+
gl_observability.pyi,sha256=qtuD7uFNK7X5LdTcoxlAY0XiubUVccp8sc-z7q0TQTo,1716
|
|
3
3
|
gl_observability/__init__.pyi,sha256=YvrsoNmib8ulmQtWz9yxKyHDWnsTxzLWXOiI5C-BqmM,518
|
|
4
|
-
gl_observability/initializer.pyi,sha256=
|
|
4
|
+
gl_observability/initializer.pyi,sha256=ODCDy0e1N6PySqL9-UnZhBvVqb1kKiIU2YU-Cetnr2k,3762
|
|
5
5
|
gl_observability/logs/__init__.pyi,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
6
|
gl_observability/logs/ner_pii_logger_handler.pyi,sha256=KkX_78DsEJVFqdgcrrV-sosUmIR14gKJD6JEp16YOLU,1573
|
|
7
7
|
gl_observability/logs/regex_pii_logger_handler.pyi,sha256=mN9pAOn8t3GrEjM7hldAn2HZLV8m3Ja2wY5vwWDWdAI,2538
|
|
8
8
|
gl_observability/traces/__init__.pyi,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
-
gl_observability/traces/config.pyi,sha256=
|
|
9
|
+
gl_observability/traces/config.pyi,sha256=GGaRNV3keMRiWYzvgUHGJEv3yeVkN-KcVKQ6AOUbaUY,2108
|
|
10
10
|
gl_observability/traces/backend/__init__.pyi,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
-
gl_observability/traces/backend/opentelemetry.pyi,sha256=
|
|
11
|
+
gl_observability/traces/backend/opentelemetry.pyi,sha256=jXsw3ZG2PnT0VWuC23yjQHaPMit3mF8m-C8LFeEBruo,1460
|
|
12
12
|
gl_observability/traces/backend/sentry.pyi,sha256=dVrmxAc5F7vZym3NQ6G7gCynuwa_TkstodEkFSvdhbs,2049
|
|
13
13
|
gl_observability/traces/instrument/__init__.pyi,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
14
|
gl_observability/traces/instrument/functions.pyi,sha256=Hd2CmrBF4qxjb_LEUf5jgljVJ1DKy7XiQXJzvpYTl5w,4293
|
|
15
15
|
gl_observability/traces/instrument/http.pyi,sha256=F86Nscqe9GxNdEduPJepzzjg3EeLZL-zRMUSj7tPxRg,2033
|
|
16
16
|
gl_observability.build/.gitignore,sha256=aEiIwOuxfzdCmLZe4oB1JsBmCUxwG8x-u-HBCV9JT8E,1
|
|
17
|
-
gl_observability_binary-0.1.
|
|
18
|
-
gl_observability_binary-0.1.
|
|
19
|
-
gl_observability_binary-0.1.
|
|
20
|
-
gl_observability_binary-0.1.
|
|
17
|
+
gl_observability_binary-0.1.2.dist-info/METADATA,sha256=n3leUPQyFERh3p5yUq-DJgjt9AdJCGijVvHOSAbIPWY,8313
|
|
18
|
+
gl_observability_binary-0.1.2.dist-info/WHEEL,sha256=l2aKBREYfqJ7T2ljmr6hUiXPoNvvXF47bG4IHjuSyS4,96
|
|
19
|
+
gl_observability_binary-0.1.2.dist-info/top_level.txt,sha256=qX0-e4NxRAAXXjWIZ7gvIspQP7J_dgxPQ7e3-WEbIeQ,17
|
|
20
|
+
gl_observability_binary-0.1.2.dist-info/RECORD,,
|
|
File without changes
|
{gl_observability_binary-0.1.0.dist-info → gl_observability_binary-0.1.2.dist-info}/top_level.txt
RENAMED
|
File without changes
|