rebrandly-otel 0.1.25__py3-none-any.whl → 0.1.26__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rebrandly-otel might be problematic. Click here for more details.
- rebrandly_otel/fastapi_support.py +25 -16
- rebrandly_otel/flask_support.py +25 -16
- {rebrandly_otel-0.1.25.dist-info → rebrandly_otel-0.1.26.dist-info}/METADATA +1 -2
- {rebrandly_otel-0.1.25.dist-info → rebrandly_otel-0.1.26.dist-info}/RECORD +7 -7
- {rebrandly_otel-0.1.25.dist-info → rebrandly_otel-0.1.26.dist-info}/WHEEL +0 -0
- {rebrandly_otel-0.1.25.dist-info → rebrandly_otel-0.1.26.dist-info}/licenses/LICENSE +0 -0
- {rebrandly_otel-0.1.25.dist-info → rebrandly_otel-0.1.26.dist-info}/top_level.txt +0 -0
|
@@ -49,25 +49,34 @@ def add_otel_middleware(otel, app):
|
|
|
49
49
|
# Start span for request
|
|
50
50
|
span_name = f"{request.method} {request.url.path}"
|
|
51
51
|
|
|
52
|
+
# Build attributes dict, excluding None values
|
|
53
|
+
attributes = {
|
|
54
|
+
# Required HTTP attributes per semantic conventions
|
|
55
|
+
"http.request.method": request.method,
|
|
56
|
+
"http.request.headers": json.dumps(request.headers, default=str),
|
|
57
|
+
"url.full": str(request.url),
|
|
58
|
+
"url.scheme": request.url.scheme,
|
|
59
|
+
"url.path": request.url.path,
|
|
60
|
+
"network.protocol.version": "1.1", # FastAPI/Starlette typically uses HTTP/1.1
|
|
61
|
+
"server.address": request.url.hostname,
|
|
62
|
+
"server.port": request.url.port or (443 if request.url.scheme == 'https' else 80),
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
# Add optional attributes only if they have values
|
|
66
|
+
if request.url.query:
|
|
67
|
+
attributes["url.query"] = request.url.query
|
|
68
|
+
|
|
69
|
+
user_agent = request.headers.get("user-agent")
|
|
70
|
+
if user_agent:
|
|
71
|
+
attributes["user_agent.original"] = user_agent
|
|
72
|
+
|
|
73
|
+
if request.client and request.client.host:
|
|
74
|
+
attributes["client.address"] = request.client.host
|
|
75
|
+
|
|
52
76
|
# Use start_as_current_span for proper context propagation
|
|
53
77
|
with self.otel.tracer.tracer.start_as_current_span(
|
|
54
78
|
span_name,
|
|
55
|
-
attributes=
|
|
56
|
-
# Required HTTP attributes per semantic conventions
|
|
57
|
-
"http.request.method": request.method,
|
|
58
|
-
"http.request.headers": json.dumps(request.headers, default=str),
|
|
59
|
-
"http.response.status_code": None, # Will be set after response
|
|
60
|
-
"url.full": str(request.url),
|
|
61
|
-
"url.scheme": request.url.scheme,
|
|
62
|
-
"url.path": request.url.path,
|
|
63
|
-
"url.query": request.url.query if request.url.query else None,
|
|
64
|
-
"user_agent.original": request.headers.get("user-agent"),
|
|
65
|
-
"http.route": None, # Will be set after routing
|
|
66
|
-
"network.protocol.version": "1.1", # FastAPI/Starlette typically uses HTTP/1.1
|
|
67
|
-
"server.address": request.url.hostname,
|
|
68
|
-
"server.port": request.url.port or (443 if request.url.scheme == 'https' else 80),
|
|
69
|
-
"client.address": request.client.host if request.client else None,
|
|
70
|
-
},
|
|
79
|
+
attributes=attributes,
|
|
71
80
|
kind=SpanKind.SERVER
|
|
72
81
|
) as span:
|
|
73
82
|
# Log request start
|
rebrandly_otel/flask_support.py
CHANGED
|
@@ -40,25 +40,34 @@ def app_before_request(otel):
|
|
|
40
40
|
# Route will be available after request routing is done
|
|
41
41
|
span_name = f"{request.method} {request.path}"
|
|
42
42
|
|
|
43
|
+
# Build attributes dict, excluding None values
|
|
44
|
+
attributes = {
|
|
45
|
+
# Required HTTP attributes per semantic conventions
|
|
46
|
+
"http.request.method": request.method,
|
|
47
|
+
"http.request.headers": json.dumps(request.headers, default=str),
|
|
48
|
+
"url.full": request.url,
|
|
49
|
+
"url.scheme": request.scheme,
|
|
50
|
+
"url.path": request.path,
|
|
51
|
+
"http.route": request.path, # Flask doesn't expose route pattern easily
|
|
52
|
+
"network.protocol.version": request.environ.get('SERVER_PROTOCOL', 'HTTP/1.1').split('/')[-1],
|
|
53
|
+
"server.address": request.host.split(':')[0],
|
|
54
|
+
"server.port": request.host.split(':')[1] if ':' in request.host else (443 if request.scheme == 'https' else 80),
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
# Add optional attributes only if they have values
|
|
58
|
+
if request.query_string:
|
|
59
|
+
attributes["url.query"] = request.query_string.decode('utf-8')
|
|
60
|
+
|
|
61
|
+
if request.user_agent and request.user_agent.string:
|
|
62
|
+
attributes["user_agent.original"] = request.user_agent.string
|
|
63
|
+
|
|
64
|
+
if request.remote_addr:
|
|
65
|
+
attributes["client.address"] = request.remote_addr
|
|
66
|
+
|
|
43
67
|
# Start span for request using start_as_current_span to make it the active span
|
|
44
68
|
span = otel.tracer.tracer.start_as_current_span(
|
|
45
69
|
span_name,
|
|
46
|
-
attributes=
|
|
47
|
-
# Required HTTP attributes per semantic conventions
|
|
48
|
-
"http.request.method": request.method,
|
|
49
|
-
"http.request.headers": json.dumps(request.headers, default=str),
|
|
50
|
-
"http.response.status_code": None, # Will be set in after_request
|
|
51
|
-
"url.full": request.url,
|
|
52
|
-
"url.scheme": request.scheme,
|
|
53
|
-
"url.path": request.path,
|
|
54
|
-
"url.query": request.query_string.decode('utf-8') if request.query_string else None,
|
|
55
|
-
"user_agent.original": request.user_agent.string if request.user_agent else None,
|
|
56
|
-
"http.route": request.path, # Flask doesn't expose route pattern easily
|
|
57
|
-
"network.protocol.version": request.environ.get('SERVER_PROTOCOL', 'HTTP/1.1').split('/')[-1],
|
|
58
|
-
"server.address": request.host.split(':')[0],
|
|
59
|
-
"server.port": request.host.split(':')[1] if ':' in request.host else (443 if request.scheme == 'https' else 80),
|
|
60
|
-
"client.address": request.remote_addr,
|
|
61
|
-
},
|
|
70
|
+
attributes=attributes,
|
|
62
71
|
kind=SpanKind.SERVER
|
|
63
72
|
)
|
|
64
73
|
# Store both the span context manager and the span itself
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rebrandly_otel
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.26
|
|
4
4
|
Summary: Python OTEL wrapper by Rebrandly
|
|
5
5
|
Home-page: https://github.com/rebrandly/rebrandly-otel-python
|
|
6
6
|
Author: Antonio Romano
|
|
@@ -14,7 +14,6 @@ Requires-Dist: opentelemetry-api>=1.34.0
|
|
|
14
14
|
Requires-Dist: opentelemetry-sdk>=1.34.0
|
|
15
15
|
Requires-Dist: opentelemetry-exporter-otlp>=1.34.0
|
|
16
16
|
Requires-Dist: psutil>=5.0.0
|
|
17
|
-
Requires-Dist: flask>=3.1.2
|
|
18
17
|
Requires-Dist: fastapi>=0.118.0
|
|
19
18
|
Dynamic: author
|
|
20
19
|
Dynamic: author-email
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
rebrandly_otel/__init__.py,sha256=dEcTvHbhNNp0XD_7jojxeHXNa1QDCI9HxayeICaK_WY,491
|
|
2
|
-
rebrandly_otel/fastapi_support.py,sha256=
|
|
3
|
-
rebrandly_otel/flask_support.py,sha256=
|
|
2
|
+
rebrandly_otel/fastapi_support.py,sha256=LQXjLWxqU7qgz4-4AMWgPWWFrfcwXeJFGlwqmtF3-CM,8044
|
|
3
|
+
rebrandly_otel/flask_support.py,sha256=9JhrNaNsARdje91DSPkZy2A3bELt2TZsRxL9lxXZQtI,6159
|
|
4
4
|
rebrandly_otel/logs.py,sha256=tU8YGL2hcYgM64rDf13owHTr7ooGc2z25TQ9qve7euY,3898
|
|
5
5
|
rebrandly_otel/metrics.py,sha256=Tf21BwSVK6eLPG2hz55gNpwdPq85uqAx4bttLO6rnq8,7542
|
|
6
6
|
rebrandly_otel/otel_utils.py,sha256=bP6Xhel4g7gbQWzCUlABWJfBSJaveKU1fhSOngcfzc4,3577
|
|
7
7
|
rebrandly_otel/pymysql_instrumentation.py,sha256=4MNIfqNQlMtOcmYLy5bq8FP0KoEw72bcZZqBdG6xupM,5955
|
|
8
8
|
rebrandly_otel/rebrandly_otel.py,sha256=wT1GiOQQMZl2sVG8MGJ9qM9gx_zRwS7U5oAe77RbJdk,21618
|
|
9
9
|
rebrandly_otel/traces.py,sha256=JY_3RWbzpUxzEx3GqTVgggsyA2DB4oR-zDftIFFJha4,7174
|
|
10
|
-
rebrandly_otel-0.1.
|
|
11
|
-
rebrandly_otel-0.1.
|
|
12
|
-
rebrandly_otel-0.1.
|
|
13
|
-
rebrandly_otel-0.1.
|
|
14
|
-
rebrandly_otel-0.1.
|
|
10
|
+
rebrandly_otel-0.1.26.dist-info/licenses/LICENSE,sha256=KMXHvTwP62S2q-SG7CFfMU_09rUwxiqlM0izaYGdcgY,1103
|
|
11
|
+
rebrandly_otel-0.1.26.dist-info/METADATA,sha256=zyWrVFkzXNkIF8CuZl45R7KzLsAcuRBybN3RZwyFCBU,14510
|
|
12
|
+
rebrandly_otel-0.1.26.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
13
|
+
rebrandly_otel-0.1.26.dist-info/top_level.txt,sha256=26PSC1gjVUl8tTH5QfKbFevjVV4E2yojoukEfiTScvM,15
|
|
14
|
+
rebrandly_otel-0.1.26.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|