rs_server_common/utils/init_opentelemetry.md¶
OpenTelemetry utility
botocore_hook(span, _service_name, _operation_name, api_params)
¶
Callback function invoked by BotocoreInstrumentor and AiobotocoreInstrumentor
Source code in docs/rs-server/services/common/rs_server_common/utils/init_opentelemetry.py
decode(binary_value)
¶
Try to decode binary value
Source code in docs/rs-server/services/common/rs_server_common/utils/init_opentelemetry.py
fastapi_hook(span, scope, message=None)
¶
Callback function invoked by FastAPIInstrumentor. It implements the hooks:
- server_request_hook: called with the server span and ASGI scope object for every incoming request.
- client_request_hook: called with the internal span, and ASGI scope and event which are sent as dictionaries for when the method receive is called.
- client_response_hook: called with the internal span, and ASGI scope and event which are sent as dictionaries for when the method send is called.
See: https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/fastapi/fastapi.html
Source code in docs/rs-server/services/common/rs_server_common/utils/init_opentelemetry.py
init_traces(app, service_name)
¶
Init instrumentation of OpenTelemetry traces.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app
|
FastAPI
|
FastAPI application |
required |
service_name
|
str
|
service name |
required |
Source code in docs/rs-server/services/common/rs_server_common/utils/init_opentelemetry.py
parse_data(data)
¶
Convert data to a string representation
Source code in docs/rs-server/services/common/rs_server_common/utils/init_opentelemetry.py
requests_hook(span, request, response=None)
¶
Callback function invoked by RequestsInstrumentor. It implements the hooks:
- request_hook: invoked right after a span is created.
- response_hook: invoked right before the span has finished processing a response.
See: https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/requests/requests.html
Source code in docs/rs-server/services/common/rs_server_common/utils/init_opentelemetry.py
start_span(instrumenting_module_name, name, span_context=None)
¶
Context manager for creating a new main or child OpenTelemetry span and set it as the current span in this tracer's context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instrumenting_module_name
|
str
|
Caller module name, just pass name |
required |
name
|
str
|
The name of the span to be created (use a custom name) |
required |
span_context
|
SpanContext | None
|
Parent span context. Only to create a child span. |
None
|
Yields:
| Type | Description |
|---|---|
Span
|
The newly-created span. |