ivcap-lambda 0.8.3__tar.gz → 0.8.5__tar.gz
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.
- {ivcap_lambda-0.8.3 → ivcap_lambda-0.8.5}/PKG-INFO +1 -1
- {ivcap_lambda-0.8.3 → ivcap_lambda-0.8.5}/ivcap_lambda/server.py +35 -7
- {ivcap_lambda-0.8.3 → ivcap_lambda-0.8.5}/pyproject.toml +1 -1
- {ivcap_lambda-0.8.3 → ivcap_lambda-0.8.5}/AUTHORS.md +0 -0
- {ivcap_lambda-0.8.3 → ivcap_lambda-0.8.5}/LICENSE +0 -0
- {ivcap_lambda-0.8.3 → ivcap_lambda-0.8.5}/README.md +0 -0
- {ivcap_lambda-0.8.3 → ivcap_lambda-0.8.5}/ivcap_lambda/__init__.py +0 -0
- {ivcap_lambda-0.8.3 → ivcap_lambda-0.8.5}/ivcap_lambda/builder.py +0 -0
- {ivcap_lambda-0.8.3 → ivcap_lambda-0.8.5}/ivcap_lambda/decorators.py +0 -0
- {ivcap_lambda-0.8.3 → ivcap_lambda-0.8.5}/ivcap_lambda/executor.py +0 -0
- {ivcap_lambda-0.8.3 → ivcap_lambda-0.8.5}/ivcap_lambda/health_handler.py +0 -0
- {ivcap_lambda-0.8.3 → ivcap_lambda-0.8.5}/ivcap_lambda/logger.py +0 -0
- {ivcap_lambda-0.8.3 → ivcap_lambda-0.8.5}/ivcap_lambda/logging.json +0 -0
- {ivcap_lambda-0.8.3 → ivcap_lambda-0.8.5}/ivcap_lambda/mcp.py +0 -0
- {ivcap_lambda-0.8.3 → ivcap_lambda-0.8.5}/ivcap_lambda/py.typed +0 -0
- {ivcap_lambda-0.8.3 → ivcap_lambda-0.8.5}/ivcap_lambda/secret.py +0 -0
- {ivcap_lambda-0.8.3 → ivcap_lambda-0.8.5}/ivcap_lambda/service_definition.py +0 -0
- {ivcap_lambda-0.8.3 → ivcap_lambda-0.8.5}/ivcap_lambda/utils.py +0 -0
- {ivcap_lambda-0.8.3 → ivcap_lambda-0.8.5}/ivcap_lambda/version.py +0 -0
|
@@ -9,6 +9,7 @@ import sys
|
|
|
9
9
|
from collections.abc import Callable
|
|
10
10
|
from logging import Logger
|
|
11
11
|
from signal import SIGTERM, signal
|
|
12
|
+
from threading import current_thread
|
|
12
13
|
from typing import Any
|
|
13
14
|
|
|
14
15
|
import uvicorn
|
|
@@ -17,6 +18,7 @@ from ivcap_service import (
|
|
|
17
18
|
Service,
|
|
18
19
|
SidecarReporter,
|
|
19
20
|
getLogger,
|
|
21
|
+
init_openobserve_from_env,
|
|
20
22
|
otel_instrument,
|
|
21
23
|
print_tool_definition,
|
|
22
24
|
service_log_config,
|
|
@@ -66,7 +68,8 @@ def start_lambda_server(
|
|
|
66
68
|
logger (Logger): optional logger instance; defaults to getLogger("app")
|
|
67
69
|
custom_args (Optional[Callable[[argparse.ArgumentParser], argparse.Namespace]], optional): callback to add extra CLI arguments. Defaults to None.
|
|
68
70
|
run_opts (Optional[Dict[str, Any]], optional): extra options forwarded to uvicorn.Config. Defaults to None.
|
|
69
|
-
with_telemetry: (Optional[bool]):
|
|
71
|
+
with_telemetry: (Optional[bool]): Tri-state control of OpenTelemetry
|
|
72
|
+
instrumentation. CLI flags take precedence over this parameter.
|
|
70
73
|
"""
|
|
71
74
|
if len(tools) == 0:
|
|
72
75
|
raise ValueError(
|
|
@@ -94,8 +97,16 @@ def start_lambda_server(
|
|
|
94
97
|
parser.add_argument(
|
|
95
98
|
"--port", type=int, default=os.environ.get("PORT", "8090"), help="Port number"
|
|
96
99
|
)
|
|
97
|
-
parser.
|
|
98
|
-
|
|
100
|
+
telemetry_group = parser.add_mutually_exclusive_group()
|
|
101
|
+
telemetry_group.add_argument(
|
|
102
|
+
"--with-telemetry",
|
|
103
|
+
action="store_true",
|
|
104
|
+
help="Force-enable OpenTelemetry instrumentation",
|
|
105
|
+
)
|
|
106
|
+
telemetry_group.add_argument(
|
|
107
|
+
"--without-telemetry",
|
|
108
|
+
action="store_true",
|
|
109
|
+
help="Force-disable OpenTelemetry instrumentation",
|
|
99
110
|
)
|
|
100
111
|
parser.add_argument("--with-mcp", action="store_true", help="Add an MCP endpoint")
|
|
101
112
|
parser.add_argument(
|
|
@@ -187,13 +198,28 @@ def start_lambda_server(
|
|
|
187
198
|
f"{title} - {os.getenv('VERSION')} - v{get_version()}|v{get_service_version()}"
|
|
188
199
|
)
|
|
189
200
|
|
|
190
|
-
|
|
201
|
+
try:
|
|
202
|
+
init_openobserve_from_env(
|
|
203
|
+
logger=logger,
|
|
204
|
+
service_name=service.name,
|
|
205
|
+
service_version=service.version,
|
|
206
|
+
)
|
|
207
|
+
except Exception as exc:
|
|
208
|
+
logger.warning("OpenTelemetry initialization failed: %s", exc)
|
|
209
|
+
|
|
210
|
+
effective_with_telemetry = with_telemetry
|
|
211
|
+
if getattr(args, "without_telemetry", False):
|
|
212
|
+
effective_with_telemetry = False
|
|
213
|
+
elif getattr(args, "with_telemetry", False):
|
|
214
|
+
effective_with_telemetry = True
|
|
215
|
+
|
|
191
216
|
set_event_reporter_factory(SidecarReporter) # type: ignore[arg-type]
|
|
192
217
|
|
|
193
218
|
def get_context():
|
|
194
219
|
jctxt = get_job_context()
|
|
195
220
|
if jctxt is None or jctxt.job_id is None:
|
|
196
|
-
|
|
221
|
+
if not current_thread().name.startswith("Otel"):
|
|
222
|
+
logger.warning("missing job context in thread")
|
|
197
223
|
return None
|
|
198
224
|
return jctxt
|
|
199
225
|
|
|
@@ -206,7 +232,7 @@ def start_lambda_server(
|
|
|
206
232
|
# instrumented the same way as for the HTTP server.
|
|
207
233
|
from .mcp import run_mcp_stdio
|
|
208
234
|
|
|
209
|
-
otel_instrument(
|
|
235
|
+
otel_instrument(effective_with_telemetry, None, logger)
|
|
210
236
|
run_mcp_stdio(service.name, app.version)
|
|
211
237
|
return
|
|
212
238
|
|
|
@@ -224,7 +250,9 @@ def start_lambda_server(
|
|
|
224
250
|
register_mcp(app, "/mcp")
|
|
225
251
|
|
|
226
252
|
otel_instrument(
|
|
227
|
-
|
|
253
|
+
effective_with_telemetry,
|
|
254
|
+
lambda _: FastAPIInstrumentor.instrument_app(app),
|
|
255
|
+
logger,
|
|
228
256
|
)
|
|
229
257
|
|
|
230
258
|
async def _add_version(request: Request, call_next) -> Response:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|