microsoft.opentelemetry.a365.core.utils module
- microsoft.opentelemetry.a365.core.utils.extract_context_from_headers(headers)[source]
Extract an OpenTelemetry Context from W3C trace HTTP headers.
Parses
traceparent(and optionallytracestate) headers and returns an OpenTelemetry Context that can be passed asparent_contextto any scope’sstart()method.- Parameters:
headers (
dict[str,str]) – Dictionary of HTTP headers containing trace context. Expected keys includetraceparentand optionallytracestate.- Return type:
- Returns:
An OpenTelemetry Context containing the extracted trace information. If no valid trace context is found, returns an empty context.
- microsoft.opentelemetry.a365.core.utils.get_traceparent(headers)[source]
Return the W3C
traceparentvalue from a headers dictionary.
- microsoft.opentelemetry.a365.core.utils.get_first_value(mapping, keys)[source]
Returns the first non-null value corresponding to an input key, or None if no non-null value is found.
- class microsoft.opentelemetry.a365.core.utils.DictWithLock(wrapped=None)[source]
Bases:
ObjectProxy,Generic[K,V]A wrapped dictionary with lock
- microsoft.opentelemetry.a365.core.utils.extract_model_name(span_name)[source]
Extract model name from span names like: - ‘chat.completions gpt-4o-mini’ -> ‘gpt-4o-mini’ - ‘chat.completions gpt-3.5-turbo’ -> ‘gpt-3.5-turbo’ - ‘chat.completions’ -> None
- microsoft.opentelemetry.a365.core.utils.deprecated(reason)[source]
Decorator to mark functions as deprecated.
- microsoft.opentelemetry.a365.core.utils.get_sdk_version()[source]
Get the SDK version from package metadata.
- Return type:
- Returns:
The SDK version string, or “0.0.0-unknown” if not found
- microsoft.opentelemetry.a365.core.utils.validate_and_normalize_ip(ip_string)[source]
Validate and normalize an IP address string.
- Parameters:
ip_string (
str|None) – The IP address string to validate (IPv4 or IPv6)- Return type:
- Returns:
The normalized IP address string if valid, None if invalid or None input
- Logs:
Error message if the IP address is invalid