akash-network / akash-network/console

Utilise new logger in indexer

Open
#434 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
264
Forks
94
Avg merge
18h 49m
Merged PRs (30d)
297

Description

Depends on #430

What

  • Integrate the shared logging package into the Indexer app.
  • Use createOtelLogger for the Indexer (it’s a backend service) to automatically include OpenTelemetry trace context in logs.
  • Replace all console.* calls with the bound logger instance.
  • Remove redundant/noisy logs; prefer structured logs with an event field and contextual attributes.

Why

  • Consistent, structured, and parseable logs across apps.
  • OTEL correlation for backend services (traceId, spanId) greatly improves debugging and observability.
  • Reduces noise and aligns with practices already used in apps/api and apps/deploy-web.

Examples

apps/api

  1. Per-module/service logger with context
import { LoggerService } from "@akashnetwork/logging";

export class StaleAnonymousUsersCleanerService {
  private readonly logger = LoggerService.forContext(StaleAnonymousUsersCleanerService.name);

  async run() {
    this.logger.debug({ event: "STALE_ANONYMOUS_USERS_CLEANUP_START" });
    // ...
    this.logger.debug({ event: "STALE_ANONYMOUS_USERS_CLEANUP_END" });
  }
}
  1. Process-level error handling in server bootstrap
import { LoggerService } from "@akashnetwork/logging";

const logger = LoggerService.forContext("SERVER");

process.on("unhandledRejection", (reason, promise) => {
  logger.error({ event: "UNHANDLED_REJECTION", reason, promise });
});

process.on("uncaughtException", error => {
  logger.error({ event: "UNCAUGHT_EXCEPTION", error });
});
  1. Hono HTTP logging interceptor
import { LoggerService } from "@akashnetwork/logging";
import { HttpLoggerIntercepter } from "@akashnetwork/logging/hono";
// ...
const httpLogger = LoggerService.forContext("HTTP");
const httpLoggerInterceptor = new HttpLoggerIntercepter(httpLogger);
// attach interceptor to Hono app as done in apps/api/src/rest-app.ts

apps/deploy-web

  1. Next.js middleware logger
import { LoggerService } from "@akashnetwork/logging";

const logger = new LoggerService({ name: "middleware" });

export function middleware(request: NextRequest) {
  logger.info({ message: `Redirecting from ${request.nextUrl.pathname}` });
  // ...
}
  1. Injecting and using a logger within a service
import type { LoggerService } from "@akashnetwork/logging";

export class ErrorHandlerService {
  constructor(private readonly logger: LoggerService) {}

  capture(error: unknown, extra?: Record<string, unknown>) {
    this.logger.error({ event: "UNHANDLED_ERROR", error, ...extra });
  }
}

Indexer (what to implement in this issue)

  • Initialize an OTEL-aware logger and use it everywhere instead of console.*
import { createOtelLogger } from "@akashnetwork/logging/otel";

export const logger = createOtelLogger({ name: "indexer" });

// Example usage:
logger.info({ event: "INDEXER_START" });
// ...later
logger.error({ event: "INDEXER_TASK_FAILED", error, taskId });
  • If the Indexer exposes HTTP endpoints or handlers, attach an HTTP logger interceptor similar to apps/api.

Acceptance criteria

  • @akashnetwork/logging is added to the Indexer.
  • Indexer uses createOtelLogger for its logger instance.
  • All console.* calls are replaced with logger.info/warn/error/debug as appropriate.
  • Redundant or low-value logs are removed; logs follow the structured pattern with event and contextual attributes.

Notes

  • For a real-world createOtelLogger usage pattern, see apps/provider-proxy/src/container.ts.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the Indexer entry point and every console.* call, then compare the OTEL logger usage in apps/provider-proxy/src/container.ts and HTTP logging setup in apps/api/src/rest-app.ts. Replace the calls with structured logger usage, remove redundant logs, and verify the acceptance criteria, including any HTTP interceptor requirement.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend, observability
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.