Compare commits

23 Commits
Author SHA1 Message Date
Khwezi Mngoma 3572902300 GRPC switch 2026-05-02 12:47:13 +02:00
= 085b69d388 Added support for otel 2026-05-01 21:51:40 +00:00
= dbb7dc168b Changed launch profile to use the right hosting address 2026-04-18 06:40:59 +00:00
khwezi 31333ea168 Merge pull request 'Removed pull event from build stage' (#106) from test into main
continuous-integration/drone Build is passing
continuous-integration/drone/promote/staging Build is passing
Reviewed-on: #106
2026-04-04 16:39:53 +02:00
khwezi e26c79a9d7 Removed pull event from build stage 2026-04-04 16:39:31 +02:00
khwezi 200789e832 Merge pull request 'test' (#105) from test into main
Reviewed-on: #105
2026-04-04 16:38:53 +02:00
khwezi ae1440fce3 Refactored uat to staging 2026-04-04 16:38:30 +02:00
khwezi b58b5777fd Refactored triggers 2026-04-04 16:38:02 +02:00
khwezi 3e84af9bb5 Merge pull request 'test' (#104) from test into main
continuous-integration/drone Build was killed
Reviewed-on: #104
2026-04-04 16:36:26 +02:00
khwezi 83dfdc2cc3 Removed promotion trigger 2026-04-04 16:35:19 +02:00
khwezi bbdb27b116 Removed promotion trigger 2026-04-04 16:34:41 +02:00
khwezi 31f2439033 Merge pull request 'Removed build stage dependency' (#103) from test into main
continuous-integration/drone Build is passing
continuous-integration/drone/promote/uat Build is passing
Reviewed-on: #103
2026-04-04 16:30:09 +02:00
khwezi 1da1328870 Removed build stage dependency 2026-04-04 16:29:17 +02:00
khwezi 15a2ad0b89 Merge pull request 'Removed triggers on build stage' (#102) from test into main
continuous-integration/drone Build is passing
continuous-integration/drone/promote/uat Build was killed
Reviewed-on: #102
2026-04-04 16:25:35 +02:00
khwezi 3b5ca4f5b0 Removed triggers on build stage 2026-04-04 16:25:09 +02:00
khwezi d179d2d79d Merge pull request 'Light refactor' (#101) from test into main
Reviewed-on: #101
2026-04-04 16:24:35 +02:00
khwezi 1526648d9a Light refactor 2026-04-04 16:24:12 +02:00
khwezi b6813057a4 Merge pull request 'Added pull_request trigger in build stage' (#100) from test into main
Reviewed-on: #100
2026-04-04 16:23:22 +02:00
khwezi d1f723c135 Added pull_request trigger in build stage 2026-04-04 16:22:59 +02:00
khwezi 7882b380b5 Merge pull request 'Removed push trigger from build branch' (#99) from test into main
continuous-integration/drone Build is passing
Reviewed-on: #99
2026-04-04 16:20:05 +02:00
khwezi 423281d071 Removed push trigger from build branch 2026-04-04 16:19:44 +02:00
khwezi 75ecf71370 Merge pull request 'Enhanced triggers' (#98) from test into main
Reviewed-on: #98
2026-04-04 16:18:08 +02:00
khwezi 44fbc613a3 Enhanced triggers 2026-04-04 16:17:40 +02:00
5 changed files with 91 additions and 33 deletions
+13 -27
View File
@@ -1,10 +1,8 @@
---
kind: pipeline
type: docker
name: build-and-package
clone:
depth: 1
steps:
- name: build-test-publish
image: nexus.khongisa.co.za/sdk:10.0
@@ -14,41 +12,29 @@ steps:
- dotnet test --configuration Release --no-build
- dotnet publish --configuration Release --no-build
- name: docker-build
- name: docker-build-and-push
image: plugins/docker
settings:
registry: nexus.khongisa.co.za
repo: nexus.khongisa.co.za/webapitest
tags: [ "${DRONE_BUILD_NUMBER}", "latest" ]
username:
from_secret: docker_username
password:
from_secret: docker_password
dry_run: true
- name: docker-push
image: plugins/docker
settings:
registry: nexus.khongisa.co.za
repo: nexus.khongisa.co.za/webapitest
tags: [ "${DRONE_BUILD_NUMBER}", "latest" ]
username:
from_secret: docker_username
password:
from_secret: docker_password
username: { from_secret: docker_username }
password: { from_secret: docker_password }
- name: vulnerability-scan
image: aquasec/trivy:0.50.1
environment:
TRIVY_USERNAME:
from_secret: docker_username
TRIVY_PASSWORD:
from_secret: docker_password
TRIVY_USERNAME: { from_secret: docker_username }
TRIVY_PASSWORD: { from_secret: docker_password }
commands:
- trivy image --exit-code 1 --severity CRITICAL nexus.khongisa.co.za/webapitest:${DRONE_BUILD_NUMBER}
- trivy image --image-src remote --exit-code 1 --severity CRITICAL nexus.khongisa.co.za/webapitest:${DRONE_BUILD_NUMBER}
trigger:
branch:
- main
event:
- push
exclude:
- promote
---
kind: pipeline
@@ -79,4 +65,4 @@ trigger:
event:
- promote
target:
- uat
- staging
+9 -1
View File
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
@@ -8,10 +9,17 @@ namespace SampleApi.Controllers
[ApiController]
public class DemoController : ControllerBase
{
private static readonly ActivitySource MyActivitySource = new("SampleApi");
// GET: api/<DemoController>
[HttpGet]
public IEnumerable<string> Get()
public IEnumerable<string> Get(ILogger<DemoController> logger)
{
using var activity = MyActivitySource.StartActivity("ManualTraceTest");
activity?.SetTag("test.status", "success");
logger.LogInformation("sample api log");
return new string[] { "value1", "value2" };
}
+62 -3
View File
@@ -1,9 +1,69 @@
using OpenTelemetry.Exporter;
using OpenTelemetry.Logs;
using OpenTelemetry.Metrics;
using OpenTelemetry.Resources;
using OpenTelemetry.Trace;
using System.Diagnostics.Metrics;
var builder = WebApplication.CreateBuilder(args);
// ONLY FOR TESTING: Allow untrusted certificates
var handler = new HttpClientHandler
{
ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => true
};
builder.Services.AddHttpClient("OtlpClient").ConfigurePrimaryHttpMessageHandler(() => handler);
// 1. Define Resource Information
var resourceBuilder = ResourceBuilder.CreateDefault()
.AddService("SampleApi");
// 2. Configuration Variables
// Using the API Key from your aspire-dashboard-auth secret
var oltpApiKey = "mc3G63K2j5ZOEsi0AjMojLTXm1KEZFctzIIjSwDiTGut8qGSkPuWwxGP1RbscJUo";
// Pointing to your Traefik IngressRoute.
// The SDK will append /v1/traces, /v1/metrics, etc., to this base URL
var oltpAddress = "https://aspire.khongisa.co.za/otlp-grpc";
//var oltpAddress = "https://aspire.khongisa.co.za/otlp-http";
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddHealthChecks();
// 3. Configure OpenTelemetry Logging
builder.Logging.AddOpenTelemetry(logging =>
{
logging.SetResourceBuilder(resourceBuilder);
logging.AddOtlpExporter(opt =>
{
opt.Endpoint = new Uri(oltpAddress);
opt.Protocol = OtlpExportProtocol.Grpc; // Switched to gRPC
// Note: Headers are only needed if you re-enable ApiKey auth mode
});
});
// 4. Configure Tracing and Metrics
builder.Services.AddOpenTelemetry()
.WithTracing(tracing => tracing
.SetResourceBuilder(resourceBuilder)
.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation()
.AddOtlpExporter(opt =>
{
opt.Endpoint = new Uri(oltpAddress);
opt.Protocol = OtlpExportProtocol.Grpc;
}))
.WithMetrics(metrics => metrics
.SetResourceBuilder(resourceBuilder)
.AddMeter("SampleApi")
.AddAspNetCoreInstrumentation()
.AddRuntimeInstrumentation()
.AddOtlpExporter(opt =>
{
opt.Endpoint = new Uri(oltpAddress);
opt.Protocol = OtlpExportProtocol.Grpc;
}));
var app = builder.Build();
@@ -13,10 +73,9 @@ if (app.Environment.IsDevelopment())
app.UseSwaggerUI();
}
app.MapHealthChecks("/health");
app.UseRouting();
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();
app.Run();
+1 -1
View File
@@ -8,7 +8,7 @@
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5221"
"applicationUrl": "http://0.0.0.0:5000"
},
"https": {
"commandName": "Project",
+5
View File
@@ -10,6 +10,11 @@
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.23.0" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.15.3" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.15.3" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.15.2" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.15.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.15.1" />
<PackageReference Include="Polly" Version="8.6.6" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.7" />
</ItemGroup>