Skip to content

Instantly share code, notes, and snippets.

View bralbral's full-sized avatar
🌍
Working from home

Denis Kosyakov bralbral

🌍
Working from home
View GitHub Profile
@bralbral
bralbral / README.md
Created April 18, 2023 18:01 — forked from nymous/README.md
Logging setup for FastAPI, Uvicorn and Structlog (with Datadog integration)

Logging setup for FastAPI

This logging setup configures Structlog to output pretty logs in development, and JSON log lines in production.

Then, you can use Structlog loggers or standard logging loggers, and they both will be processed by the Structlog pipeline (see the hello() endpoint for reference). That way any log generated by your dependencies will also be processed and enriched, even if they know nothing about Structlog!

Requests are assigned a correlation ID with the asgi-correlation-id middleware (either captured from incoming request or generated on the fly). All logs are linked to the correlation ID, and to the Datadog trace/span if instrumented. This data "global to the request" is stored in context vars, and automatically added to all logs produced during the request thanks to Structlog. You can add to these "global local variables" at any point in an endpoint with `structlog.contextvars.bind_contextvars(custom

@bralbral
bralbral / bucket-policies-primer.md
Created March 19, 2023 13:17 — forked from krishnasrinivas/bucket-policies-primer.md
Explanation of bucket polices by example

Bucket Policy

Bucket policy is an access policy available for you to grant anonymous permissions to your Minio resources. Bucket policy uses JSON-based access policy language.

This section presents a few examples of typical use cases for bucket policies. The policies use testbucket strings in the resource value. To test these policies, you need to replace these strings with your bucket name. For more information please read Amazon S3 access policy language

Granting Read-Only Permission to an Anonymous User

The following example policy grants the s3:GetObject permission to any public anonymous users. This permission allows anyone to read the object data under testbucket, which is useful for when you have publicly readable assets. A typical example is a website assets stored in testbucket.

@bralbral
bralbral / search_kibana_console.txt
Created May 22, 2022 07:12 — forked from dadoonet/search_kibana_console.txt
Demo script for "A NoSQL search engine to find..." talk
### REINIT
DELETE user
PUT user
{
"mappings": {
"properties": {
"name": {
"type": "text"
},
"comments": {
@bralbral
bralbral / solid_in_python.md
Created September 24, 2021 10:37 — forked from welel/solid_in_python.md
SOLID принципы с примерами на Python

S.O.L.I.D принципы с примерами на Python

Примечания
  • Под клиентами подразумеваются программные сущности, использующие другие программные сущности.

  • Этот файл является переводом статьи с сайта medium.com пользователя DeeKey, ссылка в завершении файла.