Source code for multistorageclient.telemetry.attributes.thread
1# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2# SPDX-License-Identifier: Apache-2.0 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9#10# Unless required by applicable law or agreed to in writing, software11# distributed under the License is distributed on an "AS IS" BASIS,12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13# See the License for the specific language governing permissions and14# limitations under the License.1516importenum17importthreading18fromcollections.abcimportMapping1920importopentelemetry.util.typesasapi_types2122from.baseimportAttributesProvider2324
[docs]25classThreadAttributesProvider(AttributesProvider):26"""27 Provides :py:type:`opentelemetry.util.types.Attributes` from current thread information.28 """29
[docs]30classThreadAttribute(enum.Enum):31"""32 Thread attribute.3334 Use the enum value in the attributes dictionary values.35 """3637#: Python thread ID.38IDENT="ident"39#: OS thread ID.40NATIVE_ID="native_id"
4142#: Attribute key to thread attribute key map.43_attributes:Mapping[str,ThreadAttribute]4445def__init__(self,attributes:Mapping[str,str]):46"""47 :param attributes: Map of attribute key to thread attribute.48 """4950self._attributes={51attribute_key:ThreadAttributesProvider.ThreadAttribute(thread_attribute)52forattribute_key,thread_attributeinattributes.items()53}54