Skip to content

Commit e4ac071

Browse files
feat(executors): add redis instrumentation
1 parent e872a23 commit e4ac071

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

libs/executors/garf/executors/entrypoints/server.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from opentelemetry.instrumentation.celery import CeleryInstrumentor
3636
from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
3737
from opentelemetry.instrumentation.logging import LoggingInstrumentor
38+
from opentelemetry.instrumentation.redis import RedisInstrumentor
3839
from typing_extensions import Annotated
3940

4041
OTEL_SERVICE_NAME = 'garf'
@@ -49,6 +50,7 @@
4950
logger.addHandler(initialize_logger())
5051

5152
CeleryInstrumentor().instrument()
53+
RedisInstrumentor().instrument()
5254
app = fastapi.FastAPI(
5355
title='Garf API',
5456
version=garf.executors.__version__,
@@ -131,7 +133,9 @@ def execute_batch(
131133
return ApiExecutorResponse(results=results)
132134

133135

134-
@app.post('/api/execute:batch_task')
136+
@app.post(
137+
'/api/execute:batch_task', status_code=fastapi.status.HTTP_202_ACCEPTED
138+
)
135139
async def execute_batch_task(
136140
request: tasks.ApiExecutorBatchRequest,
137141
) -> dict[str, str]:
@@ -163,7 +167,9 @@ def execute_workflow(
163167
)
164168

165169

166-
@app.post('/api/execute:workflow_task')
170+
@app.post(
171+
'/api/execute:workflow_task', status_code=fastapi.status.HTTP_202_ACCEPTED
172+
)
167173
async def execute_workflow_task(
168174
workflow_file: Optional[fastapi.UploadFile] = fastapi.File(None),
169175
enable_cache: bool = False,

libs/executors/garf/executors/entrypoints/tasks.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from garf.executors.workflows import workflow, workflow_runner
2929
from garf.io import reader
3030
from opentelemetry.instrumentation.celery import CeleryInstrumentor
31+
from opentelemetry.instrumentation.redis import RedisInstrumentor
3132

3233
redis_url = os.getenv('CELERY_BROKER_URL', 'redis://localhost:6379/0')
3334

@@ -88,6 +89,7 @@ def init_celery_telemetry(*args, **kwargs):
8889
loglevel='INFO', logger_type='local', name=otel_service_name
8990
)
9091
logger.addHandler(initialize_logger(otel_service_name))
92+
RedisInstrumentor().instrument()
9193
CeleryInstrumentor().instrument()
9294

9395

libs/executors/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ server=[
6464
"grpcio-reflection",
6565
"celery[redis]",
6666
"opentelemetry-instrumentation-celery",
67+
"opentelemetry-instrumentation-redis",
6768

6869
]
6970
tests = [

0 commit comments

Comments
 (0)