Sample code demonstrating how to use ThrottlingTroll with ASP.NET Core.
As a prerequisite, you will need minimum .NET 6.0 installed.
- Either open ThrottlingTroll-AspDotNetCore-Samples.sln in your Visual Studio and press F5, or go to
ThrottlingTrollSampleWebfolder and typedotnet runin your terminal window. - Open
http://localhost:5085/swaggerin your browser and try making calls.
By default the default MemoryCacheCounterStore is used. If you want to use RedisCounterStore, add RedisConnectionString setting to appsettings.json file. For a local Redis server that connection string usually looks like localhost:6379.
The project is already instrumented with OpenTelemetry and Zipkin exporter, so all you have to do is:
-
Run Zipkin locally, e.g.:
curl -sSL https://zipkin.io/quickstart.sh | bash -s java -jar zipkin.jar -
Open Zipkin UI (http://localhost:9411/zipkin).
-
Observe traces, e.g.:
