File tree Expand file tree Collapse file tree
instrumentation/opentelemetry-instrumentation-pika
src/opentelemetry/instrumentation/pika Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -52,6 +52,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5252 ([ #4057 ] ( https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4057 ) )
5353- ` opentelemetry-instrumentation-cassandra ` : Replace SpanAttributes with semconv constants for DB attributes
5454 ([ #4055 ] ( https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4055 ) )
55+ - ` opentelemetry-instrumentation-pika ` : Replace SpanAttributes with semconv constants for net attributes
56+ ([ #4068 ] ( https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4068 ) )
5557- ` opentelemetry-instrumentation-mysqlclient ` : Replace SpanAttributes with semconv constants
5658 ([ #4067 ] ( https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4067 ) )
5759
Original file line number Diff line number Diff line change 1212from opentelemetry import context , propagate , trace
1313from opentelemetry .instrumentation .utils import is_instrumentation_enabled
1414from opentelemetry .propagators .textmap import CarrierT , Getter
15+ from opentelemetry .semconv ._incubating .attributes .net_attributes import (
16+ NET_PEER_NAME ,
17+ NET_PEER_PORT ,
18+ )
1519from opentelemetry .semconv .trace import (
1620 MessagingOperationValues ,
1721 SpanAttributes ,
@@ -184,19 +188,11 @@ def _enrich_span(
184188 if not channel :
185189 return
186190 if not hasattr (channel .connection , "params" ):
187- span .set_attribute (
188- SpanAttributes .NET_PEER_NAME , channel .connection ._impl .params .host
189- )
190- span .set_attribute (
191- SpanAttributes .NET_PEER_PORT , channel .connection ._impl .params .port
192- )
191+ span .set_attribute (NET_PEER_NAME , channel .connection ._impl .params .host )
192+ span .set_attribute (NET_PEER_PORT , channel .connection ._impl .params .port )
193193 else :
194- span .set_attribute (
195- SpanAttributes .NET_PEER_NAME , channel .connection .params .host
196- )
197- span .set_attribute (
198- SpanAttributes .NET_PEER_PORT , channel .connection .params .port
199- )
194+ span .set_attribute (NET_PEER_NAME , channel .connection .params .host )
195+ span .set_attribute (NET_PEER_PORT , channel .connection .params .port )
200196
201197
202198# pylint:disable=abstract-method
Original file line number Diff line number Diff line change 2323from pika .spec import Basic , BasicProperties
2424
2525from opentelemetry .instrumentation .pika import utils
26+ from opentelemetry .semconv ._incubating .attributes .net_attributes import (
27+ NET_PEER_NAME ,
28+ NET_PEER_PORT ,
29+ )
2630from opentelemetry .semconv .trace import (
2731 MessagingOperationValues ,
2832 SpanAttributes ,
@@ -115,11 +119,11 @@ def test_enrich_span_basic_values() -> None:
115119 properties .correlation_id ,
116120 ),
117121 mock .call (
118- SpanAttributes . NET_PEER_NAME ,
122+ NET_PEER_NAME ,
119123 channel .connection .params .host ,
120124 ),
121125 mock .call (
122- SpanAttributes . NET_PEER_PORT ,
126+ NET_PEER_PORT ,
123127 channel .connection .params .port ,
124128 ),
125129 ],
@@ -167,11 +171,11 @@ def test_enrich_span_unique_connection() -> None:
167171 any_order = True ,
168172 calls = [
169173 mock .call (
170- SpanAttributes . NET_PEER_NAME ,
174+ NET_PEER_NAME ,
171175 channel .connection ._impl .params .host ,
172176 ),
173177 mock .call (
174- SpanAttributes . NET_PEER_PORT ,
178+ NET_PEER_PORT ,
175179 channel .connection ._impl .params .port ,
176180 ),
177181 ],
You can’t perform that action at this time.
0 commit comments