diff --git a/src/Temporalio/Bridge/OptionsExtensions.cs b/src/Temporalio/Bridge/OptionsExtensions.cs index be0a89e3..199a8f99 100644 --- a/src/Temporalio/Bridge/OptionsExtensions.cs +++ b/src/Temporalio/Bridge/OptionsExtensions.cs @@ -85,6 +85,17 @@ public static unsafe Interop.OpenTelemetryOptions ToInteropOptions( default: throw new ArgumentException("Unrecognized temporality"); } + switch (options.Protocol) + { + case Temporalio.Runtime.OpenTelemetryProtocol.Grpc: + temporality = Interop.OpenTelemetryProtocol.Grpc; + break; + case Temporalio.Runtime.OpenTelemetryProtocol.Http: + temporality = Interop.OpenTelemetryProtocol.Http; + break; + default: + throw new ArgumentException("Unrecognized protocol"); + } return new Interop.OpenTelemetryOptions() { url = scope.ByteArray(options.Url.ToString()), diff --git a/src/Temporalio/Bridge/include/temporal-sdk-bridge.h b/src/Temporalio/Bridge/include/temporal-sdk-bridge.h index 318a5484..d081d9a8 100644 --- a/src/Temporalio/Bridge/include/temporal-sdk-bridge.h +++ b/src/Temporalio/Bridge/include/temporal-sdk-bridge.h @@ -34,6 +34,11 @@ typedef enum OpenTelemetryMetricTemporality { Delta, } OpenTelemetryMetricTemporality; +typedef enum OpenTelemetryProtocol { + Grpc = 1, + Http, +} OpenTelemetryProtocol; + typedef enum RpcService { Workflow = 1, Operator, @@ -217,6 +222,7 @@ typedef struct OpenTelemetryOptions { uint32_t metric_periodicity_millis; enum OpenTelemetryMetricTemporality metric_temporality; bool durations_as_seconds; + enum OpenTelemetryProtocol protocol; } OpenTelemetryOptions; typedef struct PrometheusOptions { diff --git a/src/Temporalio/Bridge/src/runtime.rs b/src/Temporalio/Bridge/src/runtime.rs index 1ab91f72..1b3ce322 100644 --- a/src/Temporalio/Bridge/src/runtime.rs +++ b/src/Temporalio/Bridge/src/runtime.rs @@ -84,6 +84,7 @@ pub struct OpenTelemetryOptions { metric_periodicity_millis: u32, metric_temporality: OpenTelemetryMetricTemporality, durations_as_seconds: bool, + protocol: OpenTelemetryProtocol, } #[repr(C)] @@ -92,6 +93,12 @@ pub enum OpenTelemetryMetricTemporality { Delta, } +#[repr(C)] +pub enum OpenTelemetryProtocol { + Grpc = 1, + Http, +} + #[repr(C)] pub struct PrometheusOptions { bind_address: ByteArrayRef, diff --git a/src/Temporalio/Runtime/OpenTelemetryMetricTemporality.cs b/src/Temporalio/Runtime/OpenTelemetryMetricTemporality.cs index 268706d0..8e5ee3aa 100644 --- a/src/Temporalio/Runtime/OpenTelemetryMetricTemporality.cs +++ b/src/Temporalio/Runtime/OpenTelemetryMetricTemporality.cs @@ -1,7 +1,7 @@ namespace Temporalio.Runtime { /// - /// Temporality for OpenTelemetrry metrics. + /// Temporality for OpenTelemetry metrics. /// public enum OpenTelemetryMetricTemporality { @@ -15,4 +15,4 @@ public enum OpenTelemetryMetricTemporality /// Delta, } -} \ No newline at end of file +} diff --git a/src/Temporalio/Runtime/OpenTelemetryOptions.cs b/src/Temporalio/Runtime/OpenTelemetryOptions.cs index d826da0d..36f756f7 100644 --- a/src/Temporalio/Runtime/OpenTelemetryOptions.cs +++ b/src/Temporalio/Runtime/OpenTelemetryOptions.cs @@ -57,6 +57,11 @@ public OpenTelemetryOptions(string url) /// public bool UseSecondsForDuration { get; set; } + /// + /// Gets or sets the protocol to use for the OpenTelemetry collector. + /// + public OpenTelemetryProtocol Protocol { get; set; } = OpenTelemetryProtocol.Grpc; + /// /// Create a shallow copy of these options. /// diff --git a/src/Temporalio/Runtime/OpenTelemetryProtocol.cs b/src/Temporalio/Runtime/OpenTelemetryProtocol.cs new file mode 100644 index 00000000..9e5d35f8 --- /dev/null +++ b/src/Temporalio/Runtime/OpenTelemetryProtocol.cs @@ -0,0 +1,18 @@ +namespace Temporalio.Runtime +{ + /// + /// Protocol for OpenTelemetry metrics. + /// + public enum OpenTelemetryProtocol + { + /// + /// Grpc. + /// + Grpc, + + /// + /// Http. + /// + Http, + } +}