Skip to content

Commit

Permalink
Add removed attributes and update metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
lmolkova committed Sep 27, 2023
1 parent becef2e commit 34a5545
Show file tree
Hide file tree
Showing 8 changed files with 342 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ env:
# Otherwise, set variable to the commit of your branch on
# opentelemetry-python-contrib which is compatible with these Core repo
# changes.
CONTRIB_REPO_SHA: e8700fcb4ca53e819203889d372570a3a1846292
CONTRIB_REPO_SHA: 481972cf87c1506e789f586843ba82d93633eac7
# This is needed because we do not clone the core repo in contrib builds anymore.
# When running contrib builds as part of core builds, we use actions/checkout@v2 which
# does not set an environment variable (simply just runs tox), which is different when
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,6 @@ target
# Django example

docs/examples/django/db.sqlite3

# Semantic conventions
scripts/semconv/semantic-conventions
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add benchmark tests for metrics
([#3267](https://github.com/open-telemetry/opentelemetry-python/pull/3267))


## Version 1.17.0/0.38b0 (2023-03-22)

- Implement LowMemory temporality
Expand Down
16 changes: 8 additions & 8 deletions docs/examples/django/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ output similar to this one:
"status_code": "OK"
},
"attributes": {
"http.method": "GET",
"net.peer.name": "localhost",
"http.scheme": "http",
"net.peer.port": 8000,
"http.url": "http://localhost:8000/?param=hello",
"net.sock.peer.addr": "127.0.0.1",
"net.protocol.version": "1.1",
"http.status_code": 200
"http.request.method": "GET",
"server.address": "localhost",
"url.scheme": "http",
"server.port": 8000,
"url.full": "http://localhost:8000/?param=hello",
"server.socket.address": "127.0.0.1",
"network.protocol.version": "1.1",
"http.response.status_code": 200
},
"events": [],
"links": []
Expand Down
12 changes: 6 additions & 6 deletions opentelemetry-sdk/tests/trace/test_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,12 +640,12 @@ def test_attributes(self):
with self.tracer.start_as_current_span("root") as root:
root.set_attributes(
{
"http.method": "GET",
"http.url": "https://example.com:779/path/12/?q=d#123",
"http.request.method": "GET",
"url.full": "https://example.com:779/path/12/?q=d#123",
}
)

root.set_attribute("http.status_code", 200)
root.set_attribute("http.response.status_code", 200)
root.set_attribute("http.status_text", "OK")
root.set_attribute("misc.pi", 3.14)

Expand All @@ -663,10 +663,10 @@ def test_attributes(self):
self.assertEqual(len(root.attributes), 9)
self.assertEqual(root.attributes["http.method"], "GET")
self.assertEqual(
root.attributes["http.url"],
root.attributes["url.full"],
"https://example.com:779/path/12/?q=d#123",
)
self.assertEqual(root.attributes["http.status_code"], 200)
self.assertEqual(root.attributes["http.response.status_code"], 200)
self.assertEqual(root.attributes["http.status_text"], "OK")
self.assertEqual(root.attributes["misc.pi"], 3.14)
self.assertEqual(root.attributes["attr-key"], "attr-value2")
Expand Down Expand Up @@ -1007,7 +1007,7 @@ def test_ended_span(self):
self.assertEqual(end_time0, root.end_time)

with self.assertLogs(level=WARNING):
root.set_attribute("http.method", "GET")
root.set_attribute("http.request.method", "GET")
self.assertEqual(len(root.attributes), 0)

with self.assertLogs(level=WARNING):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,47 @@
class MetricInstruments:

HTTP_SERVER_DURATION = "http.server.duration"
"""
Deprecated. Use `http.server.request.duration` metric.
"""

HTTP_SERVER_REQUEST_SIZE = "http.server.request.size"
"""
Deprecated. Use `http.server.request.body.size` metric.
"""

HTTP_SERVER_RESPONSE_SIZE = "http.server.response.size"

HTTP_SERVER_ACTIVE_REQUESTS = "http.server.active_requests"
"""
Deprecated. Use `http.server.response.body.size` metric.
"""

HTTP_CLIENT_DURATION = "http.client.duration"
"""
Deprecated. Use `http.client.request.duration` metric.
"""

HTTP_CLIENT_REQUEST_SIZE = "http.client.request.size"
"""
Deprecated. Use `http.client.response.body.size` metric.
"""

HTTP_CLIENT_RESPONSE_SIZE = "http.client.response.size"
"""
Deprecated. Use `http.client.response.body.size` metric.
"""

HTTP_SERVER_REQUEST_DURATION = "http.server.request.duration"

HTTP_SERVER_REQUEST_BODY_SIZE = "http.server.request.body.size"

HTTP_SERVER_RESPONSE_BODY_SIZE = "http.server.response.body.size"

HTTP_SERVER_ACTIVE_REQUESTS = "http.server.active_requests"

HTTP_CLIENT_REQUEST_DURATION = "http.client.request.duration"

HTTP_CLIENT_REQUEST_BODY_SIZE = "http.client.request.body.size"

HTTP_CLIENT_RESPONSE_BODY_SIZE = "http.client.response.body.size"

DB_CLIENT_CONNECTIONS_USAGE = "db.client.connections.usage"
Original file line number Diff line number Diff line change
Expand Up @@ -1241,22 +1241,22 @@ class SpanAttributes:

NET_PEER_IP = "net.peer.ip"
"""
Deprecated, use the `net.peer.sock.addr` attribute.
Deprecated, use the `client.socket.address` attribute.
"""

NET_HOST_IP = "net.host.ip"
"""
Deprecated, use the `net.host.sock.addr` attribute.
Deprecated, use the `server.socket.address` attribute.
"""

HTTP_SERVER_NAME = "http.server_name"
"""
Deprecated, use the `net.host.name` attribute.
Deprecated, use the `server.address` attribute.
"""

HTTP_HOST = "http.host"
"""
Deprecated, use the `net.peer.name` attribute.
Deprecated, use the `server.address` and `server.port` attributes.
"""

HTTP_RETRY_COUNT = "http.retry_count"
Expand Down Expand Up @@ -1295,17 +1295,17 @@ class SpanAttributes:

MESSAGING_PROTOCOL = "messaging.protocol"
"""
Deprecated. Use `net.protocol.name` attribute.
Deprecated. Use `network.protocol.name` attribute.
"""

MESSAGING_PROTOCOL_VERSION = "messaging.protocol_version"
"""
Deprecated. Use `net.protocol.version` attribute.
Deprecated. Use `network.protocol.version` attribute.
"""

MESSAGING_URL = "messaging.url"
"""
Deprecated. Use `net.peer.name` attribute.
Deprecated. Use `server.address` and `server.port` attributes.
"""

MESSAGING_CONVERSATION_ID = "messaging.conversation_id"
Expand Down Expand Up @@ -1340,18 +1340,63 @@ class SpanAttributes:

NET_APP_PROTOCOL_NAME = "net.app.protocol.name"
"""
Deprecated. Use `net.protocol.name` attribute.
Deprecated. Use `network.protocol.name` attribute.
"""

NET_APP_PROTOCOL_VERSION = "net.app.protocol.version"
"""
Deprecated. Use `net.protocol.version` attribute.
Deprecated. Use `network.protocol.version` attribute.
"""

HTTP_CLIENT_IP = "http.client_ip"
"""
Deprecated. Use `client.address` attribute.
"""

NET_HOST_CONNECTION_TYPE = "net.host.connection.type"
"""
Deprecated. Use `network.connection.type` attribute.
"""

NET_HOST_CONNECTION_SUBTYPE = "net.host.connection.subtype"
"""
Deprecated. Use `network.connection.subtype` attribute.
"""

NET_HOST_CARRIER_NAME = "net.host.carrier.name"
"""
Deprecated. Use `network.carrier.name` attribute.
"""

NET_HOST_CARRIER_MCC = "net.host.carrier.mcc"
"""
Deprecated. Use `network.carrier.mcc` attribute.
"""

NET_HOST_CARRIER_MNC = "net.host.carrier.mnc"
"""
Deprecated. Use `network.carrier.mnc` attribute.
"""

MESSAGING_CONSUMER_ID = "messaging.consumer_id"
"""
Deprecated. Use `messaging.client_id` attribute.
"""

MESSAGING_KAFKA_CLIENT_ID = "messaging.kafka.client_id"
"""
Deprecated. Use `messaging.client_id` attribute.
"""

MESSAGING_ROCKETMQ_CLIENT_ID = "messaging.rocketmq.client_id"
"""
Deprecated. Use `messaging.client_id` attribute.
"""


@deprecated(
version="1.18.0",
reason="Removed from the specification in favor of `net.protocol.name` and `net.protocol.version` attributes",
reason="Removed from the specification in favor of `network.protocol.name` and `network.protocol.version` attributes",
)
class HttpFlavorValues(Enum):
HTTP_1_0 = "1.0"
Expand Down Expand Up @@ -1379,6 +1424,96 @@ class MessagingDestinationKindValues(Enum):
"""A message sent to a topic."""


@deprecated(
version="1.21.0",
reason="Renamed to NetworkConnectionTypeValues",
)
class NetHostConnectionTypeValues(Enum):
WIFI = "wifi"
"""wifi."""

WIRED = "wired"
"""wired."""

CELL = "cell"
"""cell."""

UNAVAILABLE = "unavailable"
"""unavailable."""

UNKNOWN = "unknown"
"""unknown."""


@deprecated(
version="1.21.0",
reason="Renamed to NetworkConnectionSubtypeValues",
)
class NetHostConnectionSubtypeValues(Enum):
GPRS = "gprs"
"""GPRS."""

EDGE = "edge"
"""EDGE."""

UMTS = "umts"
"""UMTS."""

CDMA = "cdma"
"""CDMA."""

EVDO_0 = "evdo_0"
"""EVDO Rel. 0."""

EVDO_A = "evdo_a"
"""EVDO Rev. A."""

CDMA2000_1XRTT = "cdma2000_1xrtt"
"""CDMA2000 1XRTT."""

HSDPA = "hsdpa"
"""HSDPA."""

HSUPA = "hsupa"
"""HSUPA."""

HSPA = "hspa"
"""HSPA."""

IDEN = "iden"
"""IDEN."""

EVDO_B = "evdo_b"
"""EVDO Rev. B."""

LTE = "lte"
"""LTE."""

EHRPD = "ehrpd"
"""EHRPD."""

HSPAP = "hspap"
"""HSPAP."""

GSM = "gsm"
"""GSM."""

TD_SCDMA = "td_scdma"
"""TD-SCDMA."""

IWLAN = "iwlan"
"""IWLAN."""

NR = "nr"
"""5G NR (New Radio)."""

NRNSA = "nrnsa"
"""5G NRNSA (New Radio Non-Standalone)."""

LTE_CA = "lte_ca"
"""LTE CA."""


class NetTransportValues(Enum):
IP_TCP = "ip_tcp"
"""ip_tcp."""
Expand Down
Loading

0 comments on commit 34a5545

Please sign in to comment.