Skip to content

Commit

Permalink
Add force flush of metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
tammy-baylis-swi committed Oct 17, 2023
1 parent d6c6481 commit 773be29
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions solarwinds_apm/otlp_metrics_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import random
from typing import TYPE_CHECKING, Any, Tuple

from opentelemetry.metrics import get_meter_provider
from opentelemetry.sdk.trace import SpanProcessor
from opentelemetry.semconv.trace import SpanAttributes
from opentelemetry.trace import SpanKind, StatusCode
Expand Down Expand Up @@ -99,6 +100,10 @@ def on_end(self, span: "ReadableSpan") -> None:
# for SW-style trace export. This processor is for OTLP-style.
# TODO: Cache txn_name for OTLP span export?

# Force flush metrics after every entry span via flush of all meters
# including PeriodicExportingMetricReader
get_meter_provider().force_flush()

# TODO If needed for both inbound and otlp metrics, refactor
def is_span_http(self, span: "ReadableSpan") -> bool:
"""This span from inbound HTTP request if from a SERVER by some http.method"""
Expand Down

0 comments on commit 773be29

Please sign in to comment.