mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
add authentication
This commit is contained in:
@@ -9,6 +9,8 @@ var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
const string endpoint = "http://localhost:4317";
|
||||
|
||||
Console.WriteLine($"Env var: {Environment.GetEnvironmentVariable("OTEL_EXPORTER_OTLP_HEADERS")?.ToString()}");
|
||||
|
||||
|
||||
// Logging.
|
||||
builder.Logging.ClearProviders();
|
||||
@@ -34,7 +36,7 @@ builder.Logging.AddOpenTelemetry(logging =>
|
||||
opt.Endpoint = new Uri(endpoint);
|
||||
|
||||
// Set headers in OTLP exporter
|
||||
opt.Headers = "oneuptime-service-token=0a00ebc0-7f39-11ee-ac8c-3fb43926b224";
|
||||
// opt.Headers = "oneuptime-service-token=0a00ebc0-7f39-11ee-ac8c-3fb43926b224";
|
||||
}
|
||||
|
||||
System.Console.WriteLine($"OTLP Exporter is using {opt.Protocol} protocol and endpoint {opt.Endpoint}");
|
||||
@@ -55,7 +57,7 @@ builder.Services.AddOpenTelemetry()
|
||||
{
|
||||
opt.Endpoint = new Uri(endpoint);
|
||||
// Set headers in OTLP exporter
|
||||
opt.Headers = "oneuptime-service-token=0a00ebc0-7f39-11ee-ac8c-3fb43926b224";
|
||||
// opt.Headers = "oneuptime-service-token=0a00ebc0-7f39-11ee-ac8c-3fb43926b224";
|
||||
|
||||
|
||||
}
|
||||
@@ -85,7 +87,7 @@ builder.Services.AddOpenTelemetry()
|
||||
{
|
||||
opt.Endpoint = new Uri(endpoint);
|
||||
// Set headers in OTLP exporter
|
||||
opt.Headers = "oneuptime-service-token=0a00ebc0-7f39-11ee-ac8c-3fb43926b224";
|
||||
// opt.Headers = "oneuptime-service-token=0a00ebc0-7f39-11ee-ac8c-3fb43926b224";
|
||||
}
|
||||
|
||||
System.Console.WriteLine($"OTLP Exporter is using {opt.Protocol} protocol and endpoint {opt.Endpoint}");
|
||||
@@ -123,6 +125,8 @@ async Task<String> SendGreeting(ILogger<Program> logger)
|
||||
// Add a tag to the Activity
|
||||
activity?.SetTag("greeting", "Hello World!");
|
||||
|
||||
//log out env var
|
||||
|
||||
histogram.Record("Hello World!".Length);
|
||||
|
||||
return $"Hello World! OpenTelemetry Trace: {Activity.Current?.Id}";
|
||||
|
||||
@@ -5,5 +5,5 @@
|
||||
Please use
|
||||
|
||||
```bash
|
||||
dotnet run --urls=http://localhost:7856/
|
||||
export OTEL_EXPORTER_OTLP_HEADERS=x-oneuptime-service-token=0a00ebc0-7f39-11ee-ac8c-3fb43926b224 && dotnet run --urls=http://localhost:7856/
|
||||
```
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -20,3 +20,12 @@
|
||||
2.0
|
||||
2.0
|
||||
2.0
|
||||
2.0
|
||||
2.0
|
||||
2.0
|
||||
2.0
|
||||
2.0
|
||||
2.0
|
||||
2.0
|
||||
2.0
|
||||
2.0
|
||||
|
||||
Reference in New Issue
Block a user