Skip to content

Commit 5e736ed

Browse files
committed
Fix OtlpProxyOptions
1 parent 33db2a1 commit 5e736ed

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

src/api/Elastic.Documentation.Api.Core/Telemetry/OtlpProxyOptions.cs

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,19 @@ namespace Elastic.Documentation.Api.Core.Telemetry;
88

99
/// <summary>
1010
/// Configuration options for the OTLP proxy.
11-
/// When using ADOT Lambda Layer, the proxy forwards to the local collector at localhost:4318.
12-
/// The ADOT layer handles authentication and forwarding to the backend (Elastic APM, etc).
11+
/// The proxy forwards telemetry to a local OTLP collector (typically ADOT Lambda Layer).
1312
/// </summary>
1413
/// <remarks>
1514
/// ADOT Lambda Layer runs a local OpenTelemetry Collector that accepts OTLP/HTTP on:
1615
/// - localhost:4318 (HTTP/JSON and HTTP/protobuf)
1716
/// - localhost:4317 (gRPC)
1817
///
19-
/// The ADOT layer is configured via environment variables:
20-
/// - OTEL_EXPORTER_OTLP_ENDPOINT: Where ADOT forwards telemetry
21-
/// - OTEL_EXPORTER_OTLP_HEADERS: Authentication headers ADOT uses
22-
/// - AWS_LAMBDA_EXEC_WRAPPER: /opt/otel-instrument (enables ADOT)
18+
/// Configuration priority:
19+
/// 1. OtlpProxy:Endpoint in IConfiguration (for tests/overrides)
20+
/// 2. OTEL_EXPORTER_OTLP_ENDPOINT environment variable
21+
/// 3. Default: http://localhost:4318
22+
///
23+
/// The proxy will return 503 if the collector is not available.
2324
/// </remarks>
2425
public class OtlpProxyOptions
2526
{
@@ -31,28 +32,17 @@ public class OtlpProxyOptions
3132

3233
public OtlpProxyOptions(IConfiguration configuration)
3334
{
34-
// Check for test override first (for integration tests with WireMock)
35+
// Check for explicit configuration override first (for tests or custom deployments)
3536
var configEndpoint = configuration["OtlpProxy:Endpoint"];
3637
if (!string.IsNullOrEmpty(configEndpoint))
3738
{
3839
Endpoint = configEndpoint;
3940
return;
4041
}
4142

42-
// Check if we're in Lambda with ADOT layer
43-
var execWrapper = Environment.GetEnvironmentVariable("AWS_LAMBDA_EXEC_WRAPPER");
44-
var isAdotEnabled = execWrapper?.Contains("otel-instrument") == true;
45-
46-
if (isAdotEnabled)
47-
{
48-
// ADOT Lambda Layer runs collector on localhost:4318
49-
Endpoint = "http://localhost:4318";
50-
}
51-
else
52-
{
53-
// Fallback to configured endpoint for local development
54-
Endpoint = Environment.GetEnvironmentVariable("OTEL_EXPORTER_OTLP_ENDPOINT")
55-
?? "http://localhost:4318";
56-
}
43+
// Default to localhost:4318 - this is where ADOT Lambda Layer collector runs
44+
// If ADOT layer is not present, the proxy will fail gracefully and return 503
45+
Endpoint = Environment.GetEnvironmentVariable("OTEL_EXPORTER_OTLP_ENDPOINT")
46+
?? "http://localhost:4318";
5747
}
5848
}

0 commit comments

Comments
 (0)