From 87704b94ccaaa4f31d1d19f1056cd73f94d70f60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mence=20Lesn=C3=A9?= Date: Tue, 10 Dec 2024 20:12:38 +0100 Subject: [PATCH] finops: Enable by default traces sampling doc: Add sampling --- .env.example | 6 +++++- README.md | 2 +- cicd/bicep/app.bicep | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index ed200159..06fcb328 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,8 @@ -APPLICATIONINSIGHTS_CONNECTION_STRING=xxx +# Service Principal (optional) AZURE_CLIENT_ID=xxx AZURE_CLIENT_SECRET=xxx AZURE_TENANT_ID=xxx + +# Application Insights (optional) +APPLICATIONINSIGHTS_CONNECTION_STRING=xxx +OTEL_TRACES_SAMPLER_ARG=0.5 diff --git a/README.md b/README.md index 5ef86c66..6914ff8a 100644 --- a/README.md +++ b/README.md @@ -789,7 +789,7 @@ Optional costs totalizing $343.02 /month, with the following breakdown: | Region | Metric | Cost | Total (monthly $) | Note | |-|-|-|-|-| -| Sweden Central | Basic logs ingestion | $0.645 /GB | $322.5 | 500GB of logs with sampling enabled | +| Sweden Central | Basic logs ingestion | $0.645 /GB | $322.5 | 500GB of logs [with sampling enabled](https://learn.microsoft.com/en-us/azure/azure-monitor/app/opentelemetry-configuration?tabs=python#enable-sampling) | ### What would it require to make it production ready? diff --git a/cicd/bicep/app.bicep b/cicd/bicep/app.bicep index 1f4578f8..37c7e42a 100644 --- a/cicd/bicep/app.bicep +++ b/cicd/bicep/app.bicep @@ -219,6 +219,10 @@ resource containerApp 'Microsoft.App/containerApps@2024-02-02-preview' = { name: 'APPLICATIONINSIGHTS_CONNECTION_STRING' value: applicationInsights.properties.ConnectionString } + { + name: 'OTEL_TRACES_SAMPLER_ARG' + value: '0.2' // 20% sampling + } ] resources: { cpu: 1