Skip to content

Commit a112fc7

Browse files
authored
Merge branch 'main' into build-experimental-features
2 parents 65637b0 + a4fae4f commit a112fc7

File tree

4 files changed

+85
-13
lines changed

4 files changed

+85
-13
lines changed

examples/Console/Program.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@ internal class LogsOptions
163163

164164
[Option('p', "protocol", HelpText = "Transport protocol used by OTLP exporter. Supported values: grpc and http/protobuf. Only applicable if Exporter is OTLP", Default = "grpc")]
165165
public string Protocol { get; set; }
166+
167+
[Option("processorType", Default = "batch", HelpText = "export processor type. Supported values: simple and batch", Required = false)]
168+
public string ProcessorType { get; set; }
169+
170+
[Option("scheduledDelay", Default = 5000, HelpText = "The delay interval in milliseconds between two consecutive exports.", Required = false)]
171+
public int ScheduledDelayInMilliseconds { get; set; }
166172
}
167173

168174
[Verb("inmemory", HelpText = "Specify the options required to test InMemory Exporter")]

examples/Console/TestLogs.cs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// </copyright>
1616

1717
using Microsoft.Extensions.Logging;
18+
using OpenTelemetry;
1819
using OpenTelemetry.Logs;
1920

2021
namespace Examples.Console;
@@ -73,12 +74,36 @@ internal static object Run(LogsOptions options)
7374
System.Console.WriteLine($"Export protocol {options.Protocol} is not supported. Default protocol 'grpc' will be used.");
7475
}
7576

76-
opt.AddOtlpExporter(otlpOptions =>
77+
var processorType = ExportProcessorType.Batch;
78+
if (options.ProcessorType.Trim().ToLower().Equals("batch"))
7779
{
78-
otlpOptions.Protocol = protocol;
80+
processorType = ExportProcessorType.Batch;
81+
}
82+
else if (options.Protocol.Trim().ToLower().Equals("simple"))
83+
{
84+
processorType = ExportProcessorType.Simple;
85+
}
86+
else
87+
{
88+
System.Console.WriteLine($"Export processor type {options.ProcessorType} is not supported. Default processor type 'batch' will be used.");
89+
}
90+
91+
opt.AddOtlpExporter((exporterOptions, processorOptions) =>
92+
{
93+
exporterOptions.Protocol = protocol;
7994
if (!string.IsNullOrWhiteSpace(options.Endpoint))
8095
{
81-
otlpOptions.Endpoint = new Uri(options.Endpoint);
96+
exporterOptions.Endpoint = new Uri(options.Endpoint);
97+
}
98+
99+
if (processorType == ExportProcessorType.Simple)
100+
{
101+
processorOptions.ExportProcessorType = ExportProcessorType.Simple;
102+
}
103+
else
104+
{
105+
processorOptions.ExportProcessorType = ExportProcessorType.Batch;
106+
processorOptions.BatchExportProcessorOptions = new BatchExportLogRecordProcessorOptions() { ScheduledDelayMilliseconds = options.ScheduledDelayInMilliseconds };
82107
}
83108
});
84109
}

src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,22 @@ environment variables.
5858

5959
## Enable Log Exporter
6060

61-
// TODO
61+
```csharp
62+
var loggerFactory = LoggerFactory.Create(builder =>
63+
{
64+
builder.AddOpenTelemetry(options =>
65+
{
66+
options.AddOtlpExporter();
67+
});
68+
});
69+
```
70+
71+
By default, `AddOtlpExporter()` pairs the OTLP Log Exporter with a [batching
72+
processor](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/sdk.md#batching-processor).
73+
See [`TestLogs.cs`](../../examples/Console/TestLogs.cs) for example on how to
74+
customize the `LogRecordExportProcessorOptions` or see the [Environment
75+
Variables](#environment-variables) section below on how to customize using
76+
environment variables.
6277

6378
## Configuration
6479

@@ -82,14 +97,6 @@ TODO: Show metrics specific configuration (i.e MetricReaderOptions).
8297

8398
## OtlpExporterOptions
8499

85-
* `ExportProcessorType`: Whether the exporter should use [Batch or Simple
86-
exporting
87-
processor](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#built-in-span-processors).
88-
The default is Batch.
89-
90-
* `BatchExportProcessorOptions`: Configuration options for the batch exporter.
91-
Only used if ExportProcessorType is set to Batch.
92-
93100
* `Protocol`: OTLP transport protocol. Supported values:
94101
`OtlpExportProtocol.Grpc` and `OtlpExportProtocol.HttpProtobuf`.
95102
The default is `OtlpExportProtocol.Grpc`.
@@ -109,6 +116,16 @@ TODO: Show metrics specific configuration (i.e MetricReaderOptions).
109116

110117
* `TimeoutMilliseconds` : Max waiting time for the backend to process a batch.
111118

119+
The following options are only applicable to `OtlpTraceExporter`:
120+
121+
* `ExportProcessorType`: Whether the exporter should use [Batch or Simple
122+
exporting
123+
processor](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#built-in-span-processors).
124+
The default is Batch.
125+
126+
* `BatchExportProcessorOptions`: Configuration options for the batch exporter.
127+
Only used if ExportProcessorType is set to Batch.
128+
112129
See the [`TestOtlpExporter.cs`](../../examples/Console/TestOtlpExporter.cs) for
113130
an example of how to use the exporter.
114131

@@ -125,6 +142,30 @@ values of the `OtlpExporterOptions`
125142
| `OTEL_EXPORTER_OTLP_TIMEOUT` | `TimeoutMilliseconds` |
126143
| `OTEL_EXPORTER_OTLP_PROTOCOL` | `Protocol` (`grpc` or `http/protobuf`)|
127144

145+
The following environment variables can be used to override the default values
146+
for `BatchExportProcessorOptions` in case of `OtlpTraceExporter` (following the
147+
[OpenTelemetry
148+
specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#batch-span-processor))
149+
150+
| Environment variable | `OtlpExporterOptions.BatchExportProcessorOptions` property |
151+
| ---------------------------------| ------------------------------------------------------------|
152+
| `OTEL_BSP_SCHEDULE_DELAY` | `ScheduledDelayMilliseconds` |
153+
| `OTEL_BSP_EXPORT_TIMEOUT` | `ExporterTimeoutMilliseconds` |
154+
| `OTEL_BSP_MAX_QUEUE_SIZE` | `MaxQueueSize` |
155+
| `OTEL_BSP_MAX_EXPORT_BATCH_SIZE` | `MaxExportBatchSize` |
156+
157+
The following environment variables can be used to override the default values
158+
for `BatchExportProcessorOptions` in case of `OtlpLogExporter` (following the
159+
[OpenTelemetry
160+
specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#batch-logrecord-processor))
161+
162+
| Environment variable | `LogRecordExportProcessorOptions.BatchExportProcessorOptions` property |
163+
| ----------------------------------| ------------------------------------------------------------------------|
164+
| `OTEL_BLRP_SCHEDULE_DELAY` | `ScheduledDelayMilliseconds` |
165+
| `OTEL_BLRP_EXPORT_TIMEOUT` | `ExporterTimeoutMilliseconds` |
166+
| `OTEL_BLRP_MAX_QUEUE_SIZE` | `MaxQueueSize` |
167+
| `OTEL_BLRP_MAX_EXPORT_BATCH_SIZE` | `MaxExportBatchSize` |
168+
128169
The following environment variables can be used to override the default
129170
values of the `PeriodicExportingMetricReaderOptions`
130171
(following the [OpenTelemetry specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.12.0/specification/sdk-environment-variables.md#periodic-exporting-metricreader).

src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/PrometheusCollectionManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ private void EnterGlobalLock()
143143
[MethodImpl(MethodImplOptions.AggressiveInlining)]
144144
private void ExitGlobalLock()
145145
{
146-
this.globalLockState = 0;
146+
Interlocked.Exchange(ref this.globalLockState, 0);
147147
}
148148

149149
[MethodImpl(MethodImplOptions.AggressiveInlining)]

0 commit comments

Comments
 (0)