Skip to content

Commit

Permalink
Merge branch 'main' into yunl/nit
Browse files Browse the repository at this point in the history
  • Loading branch information
cijothomas authored Aug 3, 2022
2 parents 6ecbf88 + fc315f3 commit 584e56b
Show file tree
Hide file tree
Showing 32 changed files with 171 additions and 97 deletions.
6 changes: 3 additions & 3 deletions docs/metrics/getting-started-prometheus-grafana/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ with
.AddPrometheusHttpListener()
```

`PrometheusHttpListener` is a wrapper that contains `PrometheusExporter`.
With `AddPrometheusHttpListener()`, OpenTelemetry `PrometheusExporter` will export
`PrometheusHttpListener` is a wrapper that contains `PrometheusExporter`. With
`AddPrometheusHttpListener()`, OpenTelemetry `PrometheusExporter` will export
data via the endpoint defined by
[PrometheusHttpListenerOptions.Prefixes](../../../src/OpenTelemetry.Exporter.Prometheus.HttpListener/README.md#prefixes),
[PrometheusHttpListenerOptions.UriPrefixes](../../../src/OpenTelemetry.Exporter.Prometheus.HttpListener/README.md#uriprefixes),
which is `http://localhost:9464/` by default.

```mermaid
Expand Down
2 changes: 1 addition & 1 deletion examples/Console/TestPrometheusExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ internal static object Run(int port)
.AddMeter(MyMeter.Name)
.AddMeter(MyMeter2.Name)
.AddPrometheusHttpListener(
options => options.Prefixes = new string[] { $"http://localhost:{port}/" })
options => options.UriPrefixes = new string[] { $"http://localhost:{port}/" })
.Build();

var process = Process.GetCurrentProcess();
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.4.0-alpha.1

Released 2022-Aug-02

* Add `Activity.RecordException` overload accepting additional attributes to
add to the `ActivityEvent`.
[#3433](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3433)
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Exporter.Console/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.4.0-alpha.1

Released 2022-Aug-02

* The `MetricReaderOptions` defaults can be overridden using
`OTEL_METRIC_EXPORT_INTERVAL` and `OTEL_METRIC_EXPORT_TIMEOUT`
environmental variables as defined in the
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Exporter.InMemory/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.4.0-alpha.1

Released 2022-Aug-02

* `InMemoryExporter` will now buffer scopes when exporting `LogRecord`
([#3360](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3360))

Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Exporter.Jaeger/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.4.0-alpha.1

Released 2022-Aug-02

## 1.3.0

Released 2022-Jun-03
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.4.0-alpha.1

Released 2022-Aug-02

## 1.3.0-rc.2

Released 2022-June-1
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.4.0-alpha.1

Released 2022-Aug-02

* Adds support for limiting the length and count of attributes exported from
the OTLP exporter. These
[Attribute Limits](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/sdk-environment-variables.md#attribute-limits)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ public class PrometheusExporterOptions
{
internal const string DefaultScrapeEndpointPath = "/metrics";

private int scrapeResponseCacheDurationMilliseconds = 10 * 1000;
private int scrapeResponseCacheDurationMilliseconds = 300;

/// <summary>
/// Gets or sets the path to use for the scraping endpoint. Default value: "/metrics".
/// </summary>
public string ScrapeEndpointPath { get; set; } = DefaultScrapeEndpointPath;

/// <summary>
/// Gets or sets the cache duration in milliseconds for scrape responses. Default value: 10,000 (10 seconds).
/// Gets or sets the cache duration in milliseconds for scrape responses. Default value: 300.
/// </summary>
/// <remarks>
/// Note: Specify 0 to disable response caching.
Expand Down
11 changes: 5 additions & 6 deletions src/OpenTelemetry.Exporter.Prometheus.AspNetCore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ to scrape.

### Step 1: Install Package

Install

```shell
dotnet add package OpenTelemetry.Exporter.Prometheus.AspNetCore
```

### Step 2: Configure OpenTelemetry MeterProvider

* When using OpenTelemetry.Extensions.Hosting package on .NET Core 3.1+:
* When using
[OpenTelemetry.Extensions.Hosting](../OpenTelemetry.Extensions.Hosting/README.md)
package on .NET Core 3.1+:

```csharp
services.AddOpenTelemetryMetrics(builder =>
Expand All @@ -34,7 +34,7 @@ dotnet add package OpenTelemetry.Exporter.Prometheus.AspNetCore

* Or configure directly:

Call the `AddPrometheusExporter` `MeterProviderBuilder` extension to
Call the `MeterProviderBuilder.AddPrometheusExporter` extension to
register the Prometheus exporter.

```csharp
Expand Down Expand Up @@ -94,8 +94,7 @@ registered by

Configures scrape endpoint response caching. Multiple scrape requests within the
cache duration time period will receive the same previously generated response.
The default value is `10000` (10 seconds). Set to `0` to disable response
caching.
The default value is `300`. Set to `0` to disable response caching.

## Troubleshooting

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
OpenTelemetry.Exporter.Prometheus.PrometheusHttpListenerOptions
OpenTelemetry.Exporter.Prometheus.PrometheusHttpListenerOptions.Prefixes.get -> System.Collections.Generic.IReadOnlyCollection<string>
OpenTelemetry.Exporter.Prometheus.PrometheusHttpListenerOptions.Prefixes.set -> void
OpenTelemetry.Exporter.Prometheus.PrometheusHttpListenerOptions.UriPrefixes.get -> System.Collections.Generic.IReadOnlyCollection<string>
OpenTelemetry.Exporter.Prometheus.PrometheusHttpListenerOptions.UriPrefixes.set -> void
OpenTelemetry.Exporter.Prometheus.PrometheusHttpListenerOptions.PrometheusHttpListenerOptions() -> void
OpenTelemetry.Exporter.Prometheus.PrometheusHttpListenerOptions.ScrapeEndpointPath.get -> string
OpenTelemetry.Exporter.Prometheus.PrometheusHttpListenerOptions.ScrapeEndpointPath.set -> void
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
OpenTelemetry.Exporter.Prometheus.PrometheusHttpListenerOptions
OpenTelemetry.Exporter.Prometheus.PrometheusHttpListenerOptions.Prefixes.get -> System.Collections.Generic.IReadOnlyCollection<string>
OpenTelemetry.Exporter.Prometheus.PrometheusHttpListenerOptions.Prefixes.set -> void
OpenTelemetry.Exporter.Prometheus.PrometheusHttpListenerOptions.UriPrefixes.get -> System.Collections.Generic.IReadOnlyCollection<string>
OpenTelemetry.Exporter.Prometheus.PrometheusHttpListenerOptions.UriPrefixes.set -> void
OpenTelemetry.Exporter.Prometheus.PrometheusHttpListenerOptions.PrometheusHttpListenerOptions() -> void
OpenTelemetry.Exporter.Prometheus.PrometheusHttpListenerOptions.ScrapeEndpointPath.get -> string
OpenTelemetry.Exporter.Prometheus.PrometheusHttpListenerOptions.ScrapeEndpointPath.set -> void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
([#3430](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3430)
[#3503](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3503)
[#3507](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3507))
* Fixed bug
[#2840](https://github.com/open-telemetry/opentelemetry-dotnet/issues/2840) by
allowing `+` and `*` to be used in the URI prefixes (e.g. `"http://*:9184"`).
([#3521](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3521))

## 1.3.0-rc.2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,12 @@ internal sealed class PrometheusHttpListener : IDisposable
public PrometheusHttpListener(PrometheusExporter exporter, PrometheusHttpListenerOptions options)
{
Guard.ThrowIfNull(exporter);

if ((options.Prefixes?.Count ?? 0) <= 0)
{
throw new ArgumentException("No Prefixes were specified on PrometheusHttpListenerOptions.");
}
Guard.ThrowIfNull(options);

this.exporter = exporter;

string path = this.exporter.ScrapeEndpointPath;

if (!path.StartsWith("/"))
{
path = $"/{path}";
Expand All @@ -57,9 +55,9 @@ public PrometheusHttpListener(PrometheusExporter exporter, PrometheusHttpListene
path = $"{path}/";
}

foreach (string prefix in options.Prefixes)
foreach (string uriPrefix in options.UriPrefixes)
{
this.httpListener.Prefixes.Add($"{prefix.TrimEnd('/')}{path}");
this.httpListener.Prefixes.Add($"{uriPrefix.TrimEnd('/')}{path}");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,36 +25,30 @@ namespace OpenTelemetry.Exporter.Prometheus
/// </summary>
public class PrometheusHttpListenerOptions
{
private IReadOnlyCollection<string> prefixes = new string[] { "http://localhost:9464/" };
private IReadOnlyCollection<string> uriPrefixes = new string[] { "http://localhost:9464/" };

/// <summary>
/// Gets or sets the path to use for the scraping endpoint. Default value: "/metrics".
/// </summary>
public string ScrapeEndpointPath { get; set; } = "/metrics";

/// <summary>
/// Gets or sets the prefixes to use for the http listener.
/// Gets or sets the URI (Uniform Resource Identifier) prefixes to use for the http listener.
/// Default value: <c>["http://localhost:9464/"]</c>.
/// </summary>
public IReadOnlyCollection<string> Prefixes
public IReadOnlyCollection<string> UriPrefixes
{
get => this.prefixes;
get => this.uriPrefixes;
set
{
Guard.ThrowIfNull(value);

foreach (string inputUri in value)
if (value.Count == 0)
{
if (!(Uri.TryCreate(inputUri, UriKind.Absolute, out var uri) &&
(uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps)))
{
throw new ArgumentException(
"Prometheus HttpListener prefix path should be a valid URI with http/https scheme.",
nameof(this.prefixes));
}
throw new ArgumentException("Empty list provided.", nameof(this.UriPrefixes));
}

this.prefixes = value;
this.uriPrefixes = value;
}
}
}
Expand Down
22 changes: 8 additions & 14 deletions src/OpenTelemetry.Exporter.Prometheus.HttpListener/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,32 @@ instance for Prometheus to scrape.

### Step 1: Install Package

Install

```shell
dotnet add package OpenTelemetry.Exporter.Prometheus.HttpListener
```

### Step 2: Add PrometheusHttpListener

Add and configure `PrometheusHttpListener` with `PrometheusHttpListenerOptions`.

For example:

```csharp
using var meterProvider = Sdk.CreateMeterProviderBuilder()
var meterProvider = Sdk.CreateMeterProviderBuilder()
.AddMeter(MyMeter.Name)
.AddPrometheusHttpListener(
options => options.Prefixes = new string[] { "http://localhost:9464/" })
options => options.UriPrefixes = new string[] { "http://localhost:9464/" })
.Build();
```

### Prefixes
### UriPrefixes

Defines the prefixes which will be used by the listener. The default value is `["http://localhost:9464/"]`.
You may specify multiple endpoints.
Defines one or more URI (Uniform Resource Identifier) prefixes which will be
used by the HTTP listener. The default value is `["http://localhost:9464/"]`.

For details see:
Refer to
[HttpListenerPrefixCollection.Add(String)](https://docs.microsoft.com/dotnet/api/system.net.httplistenerprefixcollection.add)
for more details.

### ScrapeEndpointPath

Defines the path for the Prometheus scrape endpoint for by
`UseOpenTelemetryPrometheusScrapingEndpoint`. Default value: `"/metrics"`.
Defines the Prometheus scrape endpoint path. Default value: `"/metrics"`.

## Troubleshooting

Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Exporter.ZPages/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.0.0-rc9.5

Released 2022-Aug-02

## 1.0.0-rc9.4

Released 2022-Jun-03
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.4.0-alpha.1

Released 2022-Aug-02

## 1.3.0

Released 2022-Jun-03
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Extensions.Hosting/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.0.0-rc9.5

Released 2022-Aug-02

## 1.0.0-rc9.4

Released 2022-Jun-03
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Extensions.Propagators/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.4.0-alpha.1

Released 2022-Aug-02

* Add `JaegerPropagator`.
([1881](https://github.com/open-telemetry/opentelemetry-dotnet/issues/1881))

Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.0.0-rc9.5

Released 2022-Aug-02

* Fix Remote IP Address - NULL reference exception.
([#3481](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3481))
* Metrics instrumentation to correctly populate `http.flavor` tag.
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Instrumentation.GrpcNetClient/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.0.0-rc9.5

Released 2022-Aug-02

## 1.0.0-rc9.4

Released 2022-Jun-03
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Instrumentation.Http/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.0.0-rc9.5

Released 2022-Aug-02

* Added `http.scheme` tag to tracing instrumentation.
([#3464](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3464))

Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.0.0-rc9.5

Released 2022-Aug-02

* Update the `ActivitySource.Name` from "OpenTelemetry.SqlClient" to
"OpenTelemetry.Instrumentation.SqlClient".
([#3435](https://github.com/open-telemetry/opentelemetry-dotnet/issues/3435))
Expand Down
8 changes: 8 additions & 0 deletions src/OpenTelemetry.Shims.OpenTracing/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## Unreleased

## 1.0.0-rc9.5

Released 2022-Aug-02

* Fix: Handling of OpenTracing spans when used in conjunction
with legacy "Microsoft.AspNetCore.Hosting.HttpRequestIn" activities.
([#3509](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3506))

## 1.0.0-rc9.4

Released 2022-Jun-03
Expand Down
Loading

0 comments on commit 584e56b

Please sign in to comment.