Skip to content

Commit 7a5a57e

Browse files
committed
changes to template
1 parent e3c0e34 commit 7a5a57e

File tree

4 files changed

+35
-6
lines changed

4 files changed

+35
-6
lines changed

gringotts/api/vault_service.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ async def authenticate_vault_key(payload: AuthenticationRequest, db_session: Asy
5555
return token_response
5656

5757

58+
59+
60+
61+
62+
5863
@router.get("/appraisal", response_model=VaultBalanceResponse, status_code=status.HTTP_200_OK)
5964
async def get_vault_appraisal(vault_id: str, muggle_currency_code: Optional[str] = None,
6065
db_session: AsyncSession = Depends(get_db),
@@ -81,6 +86,15 @@ async def start_new_vault_appraisal(payload: VaultAppraisalRequest,
8186
await request_vault_appraisal(payload.vault_id)
8287

8388

89+
90+
91+
92+
93+
94+
95+
96+
97+
8498
async def _ensure_authorized_to_vault(db_session, owner_access: VaultOwnerAccess, vault_id):
8599
try:
86100
await authorize_vault_owner_vault_access(db_session,owner_access.vault_owner,vault_id)

gringotts/domain/vault_authorization.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,19 @@ async def authorize_vault_owner_vault_access(db_session: AsyncSession, vault_own
4343
await _ensure_owns_requested_vault(owner, vault_id)
4444

4545

46+
47+
48+
49+
50+
51+
52+
53+
54+
55+
56+
4657
async def authenticate_vault_owner_and_key(db_session: AsyncSession, vault_owner: str, vault_key: str ):
58+
4759
with tracer.start_as_current_span("Authenticate vault owner and key"):
4860
# Owner is known
4961
owner = await _ensure_owner_exists(db_session, vault_owner)
@@ -78,14 +90,17 @@ async def _ensure_key_matches_records(db_session, vault_key: str):
7890

7991
async def _ensure_owner_has_a_vault(owner):
8092
# Vault requested is the one that belongs to the requestor
81-
vault_id = owner.vault_id
82-
if not vault_id:
83-
raise CreatureNotAuthenticatedException(f"Specified vault_id {vault_id} doesn't exist")
84-
return vault_id
93+
with tracer.start_as_current_span("Ensure_owner_has_a_vault"):
94+
vault_id = owner.vault_id
95+
await asyncio.sleep(40)
96+
if not vault_id:
97+
raise CreatureNotAuthenticatedException(f"Specified vault_id {vault_id} doesn't exist")
98+
return vault_id
8599

86100

87101
async def _ensure_owner_exists(db_session, vault_owner:str):
88102
owner: VaultOwner = await VaultOwner.find(username=vault_owner, db_session=db_session)
103+
print("owner" + owner.name)
89104
if not owner:
90105
raise CreatureNotAuthenticatedException(f"Creature {vault_owner} isn't a registered owner")
91106
return owner

gringotts/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
resource = Resource.create(attributes={SERVICE_NAME: 'vault_service'})
3131
resource = DigmaConfiguration().trace_this_package()\
32-
.set_environment("Dev").resource.merge(resource)
32+
.set_environment("Prod").resource.merge(resource)
3333
exporter = OTLPSpanExporter(endpoint=get_settings().otlp_exporter_url, insecure=True)
3434
provider = TracerProvider(resource=resource)
3535
provider.add_span_processor(BatchSpanProcessor(exporter))

observability/tracing/docker-compose.trace.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ services:
4545
depends_on:
4646
- jaeger
4747
environment:
48-
- OTLP_EXPORTER_DIGMA_COLLECTOR_API=digma-collector-api:5050
48+
- OTLP_EXPORTER_DIGMA_COLLECTOR_API=host.docker.internal:5050
4949

5050
networks:
5151
default:

0 commit comments

Comments
 (0)