• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pantsbuild / pants / 26751910360

01 Jun 2026 11:24AM UTC coverage: 52.046% (-40.7%) from 92.792%
26751910360

Pull #23395

github

web-flow
Merge 41608d741 into c8127c1f4
Pull Request #23395: Bump the gha-deps group with 8 updates

31994 of 61473 relevant lines covered (52.05%)

1.04 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/python/pants/backend/observability/opentelemetry/exception_logging_processor.py
1
# Copyright 2026 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3

4
from __future__ import annotations
×
5

6
import datetime
×
7
import logging
×
8
from contextlib import contextmanager
×
9
from typing import Generator
×
10

11
from pants.backend.observability.opentelemetry.processor import (
×
12
    IncompleteWorkunit,
13
    Processor,
14
    ProcessorContext,
15
    Workunit,
16
)
17

18
logger = logging.getLogger(__name__)
×
19

20

21
class ExceptionLoggingProcessor(Processor):
×
22
    def __init__(self, processor: Processor, *, name: str) -> None:
×
23
        self._processor = processor
×
24
        self._name = name
×
25
        self._exception_count = 0
×
26

27
    @contextmanager
×
28
    def _wrapper(self) -> Generator[None]:
×
29
        try:
×
30
            yield
×
31
        except Exception as ex:
×
32
            logger.debug(
×
33
                f"An exception occurred while processing a workunit in the {self._name} workunit tracing handler: {ex}",
34
                exc_info=True,
35
            )
36
            if self._exception_count == 0:
×
37
                logger.warning(
×
38
                    f"Ignored an exception from the {self._name} workunit tracing handler. These exceptions will be logged "
39
                    "at DEBUG level. No further warnings will be logged."
40
                )
41
            self._exception_count += 1
×
42

43
    def initialize(self) -> None:
×
44
        with self._wrapper():
×
45
            self._processor.initialize()
×
46

47
    def start_workunit(self, workunit: IncompleteWorkunit, *, context: ProcessorContext) -> None:
×
48
        with self._wrapper():
×
49
            self._processor.start_workunit(workunit=workunit, context=context)
×
50

51
    def complete_workunit(self, workunit: Workunit, *, context: ProcessorContext) -> None:
×
52
        with self._wrapper():
×
53
            self._processor.complete_workunit(workunit=workunit, context=context)
×
54

55
    def finish(
×
56
        self, timeout: datetime.timedelta | None = None, *, context: ProcessorContext
57
    ) -> None:
58
        with self._wrapper():
×
59
            self._processor.finish(timeout=timeout, context=context)
×
60
        if self._exception_count > 1:
×
61
            logger.warning(
×
62
                f"Ignored {self._exception_count} exceptions from the {self._name} workunit tracing handler."
63
            )
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc