microsoft.opentelemetry.a365.hosting.token_cache_helpers.agent_token_cache module

Token cache for observability tokens per (agentId, tenantId).

class microsoft.opentelemetry.a365.hosting.token_cache_helpers.agent_token_cache.AgenticTokenStruct(authorization, turn_context, auth_handler_name='AGENTIC')[source]

Bases: object

Structure containing the token generation components.

authorization: Authorization

The user authorization object for token exchange.

turn_context: TurnContext

The turn context for the current conversation.

auth_handler_name: str | None = 'AGENTIC'

The name of the authentication handler.

class microsoft.opentelemetry.a365.hosting.token_cache_helpers.agent_token_cache.AgenticTokenCache[source]

Bases: object

Caches observability tokens per (agentId, tenantId) using the provided UserAuthorization and TurnContext.

register_observability(agent_id, tenant_id, token_generator, observability_scopes)[source]

Register observability for the specified agent and tenant.

Parameters:
  • agent_id (str) – The agent identifier.

  • tenant_id (str) – The tenant identifier.

  • token_generator (AgenticTokenStruct) – The token generator structure.

  • observability_scopes (list[str]) – The observability scopes.

Raises:
  • ValueError – If agent_id or tenant_id is empty or None.

  • TypeError – If token_generator is None.

Return type:

None

async get_observability_token(agent_id, tenant_id)[source]

Get the observability token for the specified agent and tenant.

Parameters:
  • agent_id (str) – The agent identifier.

  • tenant_id (str) – The tenant identifier.

Return type:

str | None

Returns:

The observability token if available; otherwise, None.