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.
@@ -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(tracer_provider: TracerProvider, config: OpenTelemetryBackendConfig) -> None:
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
- 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:
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: gl-observability-binary
3
- Version: 0.1.0
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 and metrics.
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 for OpenTelemetry, Sentry, or both.
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 (External Exporter)
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.traces.opentelemetry import FastAPIConfig, OpenTelemetryConfig
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 OpenTelemetry
103
- otel_config = OpenTelemetryConfig(
104
- endpoint="localhost:4317", # OTLP endpoint
105
- use_grpc=False, # Use gRPC or HTTP
106
- fastapi_config=fastapi_config,
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. Initialize Telemetry
114
- init_telemetry(TelemetryConfig(otel_config=otel_config))
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 gl_observability.traces.sentry import SentryConfig
123
- from gl_observability import TelemetryConfig, init_telemetry
124
-
125
- def traces_sampler(sampling_context: dict) -> float:
126
- """Custom trace sampler."""
127
- return 1.0
128
-
129
- # 1. Configure Sentry
130
- sentry_config = SentryConfig(
131
- dsn="your-sentry-dsn",
132
- environment="production",
133
- release="1.0.0",
134
- traces_sampler=traces_sampler,
135
- send_default_pii=True
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
- # 2. Initialize Telemetry
139
- init_telemetry(TelemetryConfig(sentry_config=sentry_config))
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
- #### Sentry with OpenTelemetry
158
+ #### Multiple Backend Configuration
143
159
 
144
- This setup combines Sentry with OpenTelemetry instrumentation, allowing Sentry to capture OTel spans.
160
+ This setup the OpenTelemetry SDK used for tracing.
145
161
 
146
162
  ```python
147
163
  from fastapi import FastAPI
148
- from gl_observability.traces.opentelemetry import FastAPIConfig, OpenTelemetryConfig
149
- from gl_observability.traces.sentry import SentryConfig
150
- from gl_observability import TelemetryConfig, init_telemetry
151
-
152
- app = FastAPI()
153
- fastapi_config = FastAPIConfig(app=app)
154
-
155
- # 1. Configure OpenTelemetry (without endpoint, as Sentry handles export)
156
- otel_config = OpenTelemetryConfig(
157
- attributes={"service.name": "my-service"},
158
- fastapi_config=fastapi_config,
159
- use_langchain=True
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
- # 2. Configure Sentry with OTel config
163
- sentry_config = SentryConfig(
164
- dsn="your-sentry-dsn",
165
- environment="production",
166
- open_telemetry_config=otel_config
178
+ langfuse_backend = OpenTelemetryBackendConfig(endpoint="langfuse...", ...)
179
+ init_telemetry(
180
+ TelemetryConfig(
181
+ backend_config=langfuse_backend
182
+ )
167
183
  )
168
184
 
169
- # 3. Initialize Telemetry
170
- init_telemetry(TelemetryConfig(sentry_config=sentry_config))
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=JEpUOre6UBjt9Fuv9MYykQtUa3UrqhIqTImmrJ-Jpv4,656896
2
- gl_observability.pyi,sha256=zLWMUAsSLQclPGwJIhjJpDo_yw3gjUE3RmEB0e2JDUQ,1671
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=T8_r7zuT8zrVofPemaS-9TEliOy0iqR-hAgq6sPGN6I,3524
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=E-U-Sda2CL4VKXQPTkGdwLSB230jusIHHbFKW8hC98I,1982
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=VaQPBEHHhLT4elEcjll0DgQTIb9RW5BSWqEI8It3cdo,1460
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.0.dist-info/METADATA,sha256=l-feSdIDQ99lCJ-qXF6jmekmDswcojtMmNa-4n3zagc,7429
18
- gl_observability_binary-0.1.0.dist-info/WHEEL,sha256=l2aKBREYfqJ7T2ljmr6hUiXPoNvvXF47bG4IHjuSyS4,96
19
- gl_observability_binary-0.1.0.dist-info/top_level.txt,sha256=qX0-e4NxRAAXXjWIZ7gvIspQP7J_dgxPQ7e3-WEbIeQ,17
20
- gl_observability_binary-0.1.0.dist-info/RECORD,,
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,,