-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
70 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 4 additions & 6 deletions
10
logfire-api/logfire_api/_internal/exporters/processor_wrapper.pyi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,19 @@ | ||
from ..constants import ATTRIBUTES_MESSAGE_KEY as ATTRIBUTES_MESSAGE_KEY, ATTRIBUTES_MESSAGE_TEMPLATE_KEY as ATTRIBUTES_MESSAGE_TEMPLATE_KEY, ATTRIBUTES_SPAN_TYPE_KEY as ATTRIBUTES_SPAN_TYPE_KEY, PENDING_SPAN_NAME_SUFFIX as PENDING_SPAN_NAME_SUFFIX, log_level_attributes as log_level_attributes | ||
from ..constants import ATTRIBUTES_LOG_LEVEL_NUM_KEY as ATTRIBUTES_LOG_LEVEL_NUM_KEY, ATTRIBUTES_MESSAGE_KEY as ATTRIBUTES_MESSAGE_KEY, ATTRIBUTES_MESSAGE_TEMPLATE_KEY as ATTRIBUTES_MESSAGE_TEMPLATE_KEY, ATTRIBUTES_SPAN_TYPE_KEY as ATTRIBUTES_SPAN_TYPE_KEY, LEVEL_NUMBERS as LEVEL_NUMBERS, PENDING_SPAN_NAME_SUFFIX as PENDING_SPAN_NAME_SUFFIX, log_level_attributes as log_level_attributes | ||
from ..scrubbing import Scrubber as Scrubber | ||
from ..utils import ReadableSpanDict as ReadableSpanDict, is_instrumentation_suppressed as is_instrumentation_suppressed, span_to_dict as span_to_dict, truncate_string as truncate_string | ||
from .wrapper import WrapperSpanProcessor as WrapperSpanProcessor | ||
from _typeshed import Incomplete | ||
from opentelemetry import context as context | ||
from opentelemetry.sdk.trace import ReadableSpan, Span as Span, SpanProcessor | ||
from opentelemetry.sdk.trace import ReadableSpan, Span as Span, SpanProcessor as SpanProcessor | ||
from opentelemetry.sdk.util.instrumentation import InstrumentationScope as InstrumentationScope | ||
|
||
class SpanProcessorWrapper(SpanProcessor): | ||
class MainSpanProcessorWrapper(WrapperSpanProcessor): | ||
"""Wrapper around other processors to intercept starting and ending spans with our own global logic. | ||
Suppresses starting/ending if the current context has a `suppress_instrumentation` value. | ||
Tweaks the send/receive span names generated by the ASGI middleware. | ||
""" | ||
processor: Incomplete | ||
scrubber: Incomplete | ||
def __init__(self, processor: SpanProcessor, scrubber: Scrubber) -> None: ... | ||
def on_start(self, span: Span, parent_context: context.Context | None = None) -> None: ... | ||
def on_end(self, span: ReadableSpan) -> None: ... | ||
def shutdown(self) -> None: ... | ||
def force_flush(self, timeout_millis: int = 30000) -> bool: ... |
37 changes: 37 additions & 0 deletions
37
logfire-api/logfire_api/_internal/exporters/tail_sampling.pyi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from _typeshed import Incomplete | ||
from dataclasses import dataclass | ||
from functools import cached_property as cached_property | ||
from logfire._internal.constants import ATTRIBUTES_LOG_LEVEL_NUM_KEY as ATTRIBUTES_LOG_LEVEL_NUM_KEY, LEVEL_NUMBERS as LEVEL_NUMBERS, LevelName as LevelName, ONE_SECOND_IN_NANOSECONDS as ONE_SECOND_IN_NANOSECONDS | ||
from logfire._internal.exporters.wrapper import WrapperSpanProcessor as WrapperSpanProcessor | ||
from opentelemetry import context as context | ||
from opentelemetry.sdk.trace import ReadableSpan as ReadableSpan, Span as Span, SpanProcessor as SpanProcessor | ||
|
||
@dataclass | ||
class TailSamplingOptions: | ||
level: LevelName | None = ... | ||
duration: float | None = ... | ||
def __init__(self, level=..., duration=...) -> None: ... | ||
|
||
@dataclass | ||
class TraceBuffer: | ||
"""Arguments of `on_start` and `on_end` for spans in a single trace.""" | ||
started: list[tuple[Span, context.Context | None]] | ||
ended: list[ReadableSpan] | ||
@cached_property | ||
def first_span(self) -> Span: ... | ||
def __init__(self, started, ended) -> None: ... | ||
|
||
class TailSamplingProcessor(WrapperSpanProcessor): | ||
"""Passes spans to the wrapped processor if any span in a trace meets the sampling criteria.""" | ||
duration: Incomplete | ||
level: Incomplete | ||
random_rate: Incomplete | ||
traces: Incomplete | ||
lock: Incomplete | ||
def __init__(self, processor: SpanProcessor, options: TailSamplingOptions, random_rate: float) -> None: ... | ||
def on_start(self, span: Span, parent_context: context.Context | None = None) -> None: ... | ||
def on_end(self, span: ReadableSpan) -> None: ... | ||
def check_span(self, span: ReadableSpan, buffer: TraceBuffer) -> bool: | ||
"""If the span meets the sampling criteria, drop the buffer and return True. Otherwise, return False.""" | ||
def drop_buffer(self, buffer: TraceBuffer) -> None: ... | ||
def push_buffer(self, buffer: TraceBuffer) -> None: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters