Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ def home(request):

.. code-block:: python

from opentelemetry.instrumentation.starlette import StarletteInstrumentor
from opentelemetry.trace import Span
from typing import Any

def server_request_hook(span: Span, scope: dict[str, Any]):
if span and span.is_recording():
span.set_attribute("custom_user_attribute_from_request_hook", "some-value")
Expand All @@ -74,7 +78,7 @@ def client_response_hook(span: Span, scope: dict[str, Any], message: dict[str, A
if span and span.is_recording():
span.set_attribute("custom_user_attribute_from_response_hook", "some-value")

StarletteInstrumentor().instrument(server_request_hook=server_request_hook, client_request_hook=client_request_hook, client_response_hook=client_response_hook)
StarletteInstrumentor().instrument(server_request_hook=server_request_hook, client_request_hook=client_request_hook, client_response_hook=client_response_hook)

Capture HTTP request and response headers
*****************************************
Expand Down
Loading