diff --git a/src/bentoml/_internal/monitoring/default.py b/src/bentoml/_internal/monitoring/default.py index 23213ec7070..64800b6bb3c 100644 --- a/src/bentoml/_internal/monitoring/default.py +++ b/src/bentoml/_internal/monitoring/default.py @@ -56,10 +56,18 @@ class DefaultMonitor(MonitorBase["JSONSerializable"]): data is logged as a JSON array. """ - PRESERVED_COLUMNS = (COLUMN_TIME, COLUMN_RID, COLUMN_TID) = ( + PRESERVED_COLUMNS = ( + COLUMN_TIME, + COLUMN_RID, + COLUMN_TID, + COLUMN_SID, + COLUMN_SVC, + ) = ( "timestamp", "request_id", "trace_id", + "span_id", + "service_name", ) def __init__( @@ -144,6 +152,8 @@ def export_data( self.COLUMN_TIME: datetime.datetime.now().isoformat(), self.COLUMN_RID: str(trace_context.request_id), self.COLUMN_TID: str(trace_context.trace_id), + self.COLUMN_SID: str(trace_context.span_id), + self.COLUMN_SVC: str(trace_context.service_name), } while True: try: diff --git a/src/bentoml/_internal/monitoring/otlp.py b/src/bentoml/_internal/monitoring/otlp.py index 8f1ca032157..cd42a89dd0a 100644 --- a/src/bentoml/_internal/monitoring/otlp.py +++ b/src/bentoml/_internal/monitoring/otlp.py @@ -94,10 +94,19 @@ class OTLPMonitor(MonitorBase["JSONSerializable"]): """ - PRESERVED_COLUMNS = (COLUMN_TIME, COLUMN_RID, COLUMN_TID, COLUMN_META) = ( + PRESERVED_COLUMNS = ( + COLUMN_TIME, + COLUMN_RID, + COLUMN_TID, + COLUMN_SID, + COLUMN_SVC, + COLUMN_META, + ) = ( "timestamp", "request_id", "trace_id", + "span_id", + "service_name", "bento_meta", ) @@ -245,6 +254,8 @@ def export_data( self.COLUMN_TIME: datetime.datetime.now().timestamp(), self.COLUMN_RID: str(trace_context.request_id), self.COLUMN_TID: str(trace_context.trace_id), + self.COLUMN_SID: str(trace_context.span_id), + self.COLUMN_SVC: str(trace_context.service_name), } if self._will_export_schema or random.random() < self.meta_sample_rate: