88import json
99from pathlib import Path
1010from datetime import datetime
11- from typing import Dict , Optional
11+ from typing import Dict , Optional , Union
1212
1313from marshmallow .exceptions import ValidationError as SchemaValidationError
1414
2626from azure .ai .ml ._artifacts ._artifact_utilities import _check_and_upload_path
2727from azure .ai .ml .operations ._datastore_operations import DatastoreOperations
2828
29- # from azure.ai.ml._telemetry import ActivityType, monitor_with_activity
29+ from azure .ai .ml ._telemetry import ActivityType , monitor_with_activity
3030from azure .ai .ml ._utils ._feature_store_utils import (
3131 _archive_or_restore ,
3232 read_feature_set_metadata_contents ,
3333 read_remote_feature_set_spec_metadata_contents ,
34+ _datetime_to_str ,
3435)
3536from azure .ai .ml ._utils ._logger_utils import OpsLogger
3637from azure .ai .ml .entities ._assets ._artifacts .feature_set import FeatureSet
4142from azure .ai .ml .entities ._feature_set .feature import Feature
4243from azure .core .polling import LROPoller
4344from azure .core .paging import ItemPaged
45+ from azure .core .tracing .decorator import distributed_trace
4446
4547ops_logger = OpsLogger (__name__ )
46- module_logger = ops_logger .module_logger
48+ logger , module_logger = ops_logger . package_logger , ops_logger .module_logger
4749
4850
4951class FeatureSetOperations (_ScopeDependentOperations ):
@@ -71,7 +73,8 @@ def __init__(
7173 self ._datastore_operation = datastore_operations
7274 self ._init_kwargs = kwargs
7375
74- # @monitor_with_activity(logger, "FeatureSet.List", ActivityType.PUBLICAPI)
76+ @distributed_trace
77+ @monitor_with_activity (logger , "FeatureSet.List" , ActivityType .PUBLICAPI )
7578 def list (
7679 self ,
7780 name : Optional [str ] = None ,
@@ -116,7 +119,8 @@ def _get(self, name: str, version: str = None, **kwargs: Dict) -> FeaturesetVers
116119 ** kwargs ,
117120 )
118121
119- # @monitor_with_activity(logger, "FeatureSet.Get", ActivityType.PUBLICAPI)
122+ @distributed_trace
123+ @monitor_with_activity (logger , "FeatureSet.Get" , ActivityType .PUBLICAPI )
120124 def get (self , name : str , version : str , ** kwargs : Dict ) -> FeatureSet :
121125 """Get the specified FeatureSet asset.
122126
@@ -135,7 +139,8 @@ def get(self, name: str, version: str, **kwargs: Dict) -> FeatureSet:
135139 except (ValidationException , SchemaValidationError ) as ex :
136140 log_and_raise_error (ex )
137141
138- # @monitor_with_activity(logger, "FeatureSet.BeginCreateOrUpdate", ActivityType.PUBLICAPI)
142+ @distributed_trace
143+ @monitor_with_activity (logger , "FeatureSet.BeginCreateOrUpdate" , ActivityType .PUBLICAPI )
139144 def begin_create_or_update (self , featureset : FeatureSet , ** kwargs : Dict ) -> LROPoller [FeatureSet ]:
140145 """Create or update FeatureSet
141146
@@ -166,7 +171,8 @@ def begin_create_or_update(self, featureset: FeatureSet, **kwargs: Dict) -> LROP
166171 cls = lambda response , deserialized , headers : FeatureSet ._from_rest_object (deserialized ),
167172 )
168173
169- # @monitor_with_activity(logger, "FeatureSet.BeginBackFill", ActivityType.PUBLICAPI)
174+ @distributed_trace
175+ @monitor_with_activity (logger , "FeatureSet.BeginBackFill" , ActivityType .PUBLICAPI )
170176 def begin_backfill (
171177 self ,
172178 * ,
@@ -224,14 +230,15 @@ def begin_backfill(
224230 cls = lambda response , deserialized , headers : FeatureSetBackfillMetadata ._from_rest_object (deserialized ),
225231 )
226232
227- # @monitor_with_activity(logger, "FeatureSet.ListMaterializationOperation", ActivityType.PUBLICAPI)
233+ @distributed_trace
234+ @monitor_with_activity (logger , "FeatureSet.ListMaterializationOperation" , ActivityType .PUBLICAPI )
228235 def list_materialization_operations (
229236 self ,
230237 name : str ,
231238 version : str ,
232239 * ,
233- feature_window_start_time : Optional [str ] = None ,
234- feature_window_end_time : Optional [str ] = None ,
240+ feature_window_start_time : Optional [Union [ str , datetime ] ] = None ,
241+ feature_window_end_time : Optional [Union [ str , datetime ] ] = None ,
235242 filters : Optional [str ] = None ,
236243 ** kwargs : Dict ,
237244 ) -> ItemPaged [FeatureSetMaterializationMetadata ]:
@@ -242,15 +249,16 @@ def list_materialization_operations(
242249 :param version: Feature set version.
243250 :type version: str
244251 :param feature_window_start_time: Start time of the feature window to filter materialization jobs.
245- :type feature_window_start_time: str
252+ :type feature_window_start_time: Union[ str, datetime]
246253 :param feature_window_end_time: End time of the feature window to filter materialization jobs.
247- :type feature_window_end_time: str
254+ :type feature_window_end_time: Union[ str, datetime]
248255 :param filters: Comma-separated list of tag names (and optionally values). Example: tag1,tag2=value2.
249256 :type filters: str
250257 :return: An iterator like instance of ~azure.ai.ml.entities.FeatureSetMaterializationMetadata objects
251258 :rtype: ~azure.core.paging.ItemPaged[FeatureSetMaterializationMetadata]
252259 """
253-
260+ feature_window_start_time = _datetime_to_str (feature_window_start_time ) if feature_window_start_time else None
261+ feature_window_end_time = _datetime_to_str (feature_window_end_time ) if feature_window_end_time else None
254262 materialization_jobs = self ._operation .list_materialization_jobs (
255263 resource_group_name = self ._resource_group_name ,
256264 workspace_name = self ._workspace_name ,
@@ -264,7 +272,8 @@ def list_materialization_operations(
264272 )
265273 return materialization_jobs
266274
267- # @monitor_with_activity(logger, "FeatureSet.ListFeatures", ActivityType.INTERNALCALL)
275+ @distributed_trace
276+ @monitor_with_activity (logger , "FeatureSet.ListFeatures" , ActivityType .PUBLICAPI )
268277 def list_features (
269278 self ,
270279 feature_set_name : str ,
@@ -303,7 +312,8 @@ def list_features(
303312 )
304313 return features
305314
306- # @monitor_with_activity(logger, "FeatureSet.GetFeature", ActivityType.INTERNALCALL)
315+ @distributed_trace
316+ @monitor_with_activity (logger , "FeatureSet.GetFeature" , ActivityType .PUBLICAPI )
307317 def get_feature (self , feature_set_name : str , version : str , * , feature_name : str , ** kwargs : Dict ) -> "Feature" :
308318 """Get Feature
309319
@@ -329,7 +339,8 @@ def get_feature(self, feature_set_name: str, version: str, *, feature_name: str,
329339
330340 return Feature ._from_rest_object (feature )
331341
332- # @monitor_with_activity(logger, "FeatureSet.Archive", ActivityType.PUBLICAPI)
342+ @distributed_trace
343+ @monitor_with_activity (logger , "FeatureSet.Archive" , ActivityType .PUBLICAPI )
333344 def archive (
334345 self ,
335346 name : str ,
@@ -354,7 +365,8 @@ def archive(
354365 ** kwargs ,
355366 )
356367
357- # @monitor_with_activity(logger, "FeatureSet.Restore", ActivityType.PUBLICAPI)
368+ @distributed_trace
369+ @monitor_with_activity (logger , "FeatureSet.Restore" , ActivityType .PUBLICAPI )
358370 def restore (
359371 self ,
360372 name : str ,
0 commit comments