Skip to content

Commit

Permalink
Merge branch 'main' into gc-heap-size-metric
Browse files Browse the repository at this point in the history
  • Loading branch information
lachmatt authored Nov 15, 2022
2 parents 48e021b + 187c475 commit 1f514e6
Show file tree
Hide file tree
Showing 16 changed files with 185 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# IMPORTANT: This workflow MUST use the same 'name' as the non -md workflow.

name: Linux
name: Build

on:
pull_request:
Expand All @@ -19,7 +19,11 @@ jobs:

strategy:
matrix:
version: [netcoreapp3.1,net6.0]
os: [ windows-latest, ubuntu-latest ]
version: [ net462, netcoreapp3.1, net6.0 ]
exclude:
- os: ubuntu-latest
version: net462

steps:
- run: 'echo "No build required"'
15 changes: 10 additions & 5 deletions .github/workflows/windows-ci.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Windows
name: Build

on:
push:
Expand All @@ -12,13 +12,18 @@ on:

jobs:
build-test:
runs-on: windows-latest


strategy:
fail-fast: false # ensures the entire test matrix is run, even if one permutation fails
fail-fast: false # ensures the entire test matrix is run, even if one permutation fails
matrix:
version: [net462,netcoreapp3.1,net6.0]
os: [ windows-latest, ubuntu-latest ]
version: [ net462, netcoreapp3.1, net6.0 ]
exclude:
- os: ubuntu-latest
version: net462

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3

Expand All @@ -29,4 +34,4 @@ jobs:
run: dotnet build --configuration Release --no-restore

- name: Test ${{ matrix.version }}
run: dotnet test **\bin\**\${{ matrix.version }}\*Tests.dll --configuration Release --no-build --logger:"console;verbosity=detailed"
run: dotnet test **/bin/**/${{ matrix.version }}/*Tests.dll --configuration Release --no-build --logger:"console;verbosity=detailed"
32 changes: 0 additions & 32 deletions .github/workflows/linux-ci.yml

This file was deleted.

25 changes: 0 additions & 25 deletions .github/workflows/windows-ci-md.yml

This file was deleted.

6 changes: 2 additions & 4 deletions opentelemetry-dotnet-contrib.sln
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{
ProjectSection(SolutionItems) = preProject
.github\workflows\assign-reviewers.yml = .github\workflows\assign-reviewers.yml
.github\workflows\codeql-analysis.yml = .github\workflows\codeql-analysis.yml
.github\workflows\ci-md.yml = .github\workflows\ci-md.yml
.github\workflows\ci.yml = .github\workflows\ci.yml
.github\workflows\dotnet-core-cov.yml = .github\workflows\dotnet-core-cov.yml
.github\workflows\dotnet-format-md.yml = .github\workflows\dotnet-format-md.yml
.github\workflows\dotnet-format.yml = .github\workflows\dotnet-format.yml
.github\workflows\integration-md.yml = .github\workflows\integration-md.yml
.github\workflows\integration.yml = .github\workflows\integration.yml
.github\workflows\linux-ci-md.yml = .github\workflows\linux-ci-md.yml
.github\workflows\linux-ci.yml = .github\workflows\linux-ci.yml
.github\workflows\markdownlint.yml = .github\workflows\markdownlint.yml
.github\workflows\package-Exporter.Geneva.yml = .github\workflows\package-Exporter.Geneva.yml
.github\workflows\package-Exporter.Instana.yml = .github\workflows\package-Exporter.Instana.yml
Expand Down Expand Up @@ -63,8 +63,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{
.github\workflows\package-Instrumentation.Wcf.yml = .github\workflows\package-Instrumentation.Wcf.yml
.github\workflows\sanitycheck.yml = .github\workflows\sanitycheck.yml
.github\workflows\stale.yml = .github\workflows\stale.yml
.github\workflows\windows-ci-md.yml = .github\workflows\windows-ci-md.yml
.github\workflows\windows-ci.yml = .github\workflows\windows-ci.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{824BD1DE-3FA8-4FE0-823A-FD365EAC78AF}"
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Contrib.Instrumentation.AWS/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.0.2

Released 2022-Nov-11

* Fixed issue when using version 3.7.100 of the AWS SDK for .NET triggering an
EndpointResolver not found exception.
([#726](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/726))
Expand Down
11 changes: 8 additions & 3 deletions src/OpenTelemetry.Extensions/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@

## Unreleased

## 1.0.0-beta.3

Released 2022-Nov-09

* Update OpenTelemetry to 1.4.0-beta.2 ([#680](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/680))

* Implemented auto flush activity processor
([#297](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/297))

* Removes .NET Framework 4.6.1. The minimum .NET Framework version
supported is .NET 4.6.2.

* Removes net5.0 target as .NET 5.0 is going out
* Removes net5.0 target as .NET 5.0 is going out
of support. The package keeps netstandard2.0 target, so it
can still be used with .NET5.0 apps.
([#617](https://github.com/open-telemetry/opentelemetry-dotnet/pull/617))

## 1.0.0-beta.3

* Going forward the NuGet package will be
[`OpenTelemetry.Extensions`](https://www.nuget.org/packages/OpenTelemetry.Extensions).
Older versions will remain at
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ public override void OnEnd(LogRecord data)
tags[nameof(data.EventId)] = data.EventId;
}

var activityEvent = new ActivityEvent("log", data.Timestamp, tags);

data.ForEachScope(ProcessScope, new State(tags, this));

if (data.StateValues != null)
Expand All @@ -84,6 +82,7 @@ public override void OnEnd(LogRecord data)
tags[nameof(data.FormattedMessage)] = data.FormattedMessage;
}

var activityEvent = new ActivityEvent("log", data.Timestamp, tags);
activity.AddEvent(activityEvent);

if (data.Exception != null)
Expand Down
4 changes: 2 additions & 2 deletions src/OpenTelemetry.Extensions/OpenTelemetry.Extensions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net462;netstandard2.0</TargetFrameworks>
<TargetFrameworks Condition="'$(Configuration)' == 'Debug'">$(TargetFrameworks);net6.0</TargetFrameworks> <!-- Added just to get proper nullable analysis in IDE -->
<Description>OpenTelemetry .NET SDK preview features and extensions</Description>
<MinVerTagPrefix>Preview-</MinVerTagPrefix>
<MinVerTagPrefix>Extensions-</MinVerTagPrefix>
<Nullable>enable</Nullable>
<EnableAnalysis>true</EnableAnalysis>
<EnablePublicApi>true</EnablePublicApi>
Expand All @@ -16,7 +16,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OpenTelemetry" Version="1.1.0" />
<PackageReference Include="OpenTelemetry" Version="$(OpenTelemetryCoreLatestPrereleaseVersion)" />
</ItemGroup>

</Project>
7 changes: 7 additions & 0 deletions src/OpenTelemetry.Instrumentation.EventCounters/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

## Unreleased

## 1.0.0-alpha.2

Released 2022-Nov-10

* Update OpenTelemetry.Api to 1.3.1.
* Change `EventCounter` prefix to `ec` and trim the event source name to keep
instrument name under 63 characters.
([#740](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/740))

## 1.0.0-alpha.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ internal sealed class EventCountersMetrics : EventListener
{
internal static readonly Meter MeterInstance = new(typeof(EventCountersMetrics).Assembly.GetName().Name, typeof(EventCountersMetrics).Assembly.GetName().Version.ToString());

private const string Prefix = "ec";
private const int MaxInstrumentNameLength = 63;

private readonly EventCountersInstrumentationOptions options;
private readonly List<EventSource> preInitEventSources = new();
private readonly ConcurrentDictionary<(string, string), Instrument> instruments = new();
Expand Down Expand Up @@ -120,6 +123,39 @@ protected override void OnEventWritten(EventWrittenEventArgs eventData)
private static Dictionary<string, string> GetEnableEventsArguments(EventCountersInstrumentationOptions options) =>
new() { { "EventCounterIntervalSec", options.RefreshIntervalSecs.ToString() } };

/// <summary>
/// If the resulting instrument name is too long, it trims the event source name
/// to fit in as many characters as possible keeping the event name intact.
/// E.g. instrument for `Microsoft-AspNetCore-Server-Kestrel`, `tls-handshakes-per-second`
/// would be too long (64 chars), so it's shortened to `ec.Microsoft-AspNetCore-Server-Kestre.tls-handshakes-per-second`.
///
/// If there is no room for event source name, returns `ec.{event name}` and
/// if it's still too long, it will be validated and ignored later in the pipeline.
/// </summary>
private static string GetInstrumentName(string sourceName, string eventName)
{
int totalLength = Prefix.Length + 1 + sourceName.Length + 1 + eventName.Length;
if (totalLength <= MaxInstrumentNameLength)
{
return string.Concat(Prefix, ".", sourceName, ".", eventName);
}

var maxEventSourceLength = MaxInstrumentNameLength - Prefix.Length - 2 - eventName.Length;
if (maxEventSourceLength < 1)
{
// event name is too long, there is not enough space for sourceName.
// let ec.<eventName> flow to metrics SDK and it will suppress it if needed.
return string.Concat(Prefix, ".", eventName);
}

while (maxEventSourceLength > 0 && (sourceName[maxEventSourceLength - 1] == '.' || sourceName[maxEventSourceLength - 1] == '-'))
{
maxEventSourceLength--;
}

return string.Concat(Prefix, ".", sourceName.Substring(0, maxEventSourceLength), ".", eventName);
}

private void EnableEvents(EventSource eventSource)
{
this.EnableEvents(eventSource, EventLevel.Critical, EventKeywords.None, GetEnableEventsArguments(this.options));
Expand All @@ -132,10 +168,9 @@ private void UpdateInstrumentWithEvent(bool isGauge, string eventSourceName, str
ValueTuple<string, string> metricKey = new(eventSourceName, name);
_ = this.values.AddOrUpdate(metricKey, value, isGauge ? (_, _) => value : (_, existing) => existing + value);

var instrumentName = $"EventCounters.{eventSourceName}.{name}";

if (!this.instruments.ContainsKey(metricKey))
{
var instrumentName = GetInstrumentName(eventSourceName, name);
Instrument instrument = isGauge
? MeterInstance.CreateObservableGauge(instrumentName, () => this.values[metricKey])
: MeterInstance.CreateObservableCounter(instrumentName, () => this.values[metricKey]);
Expand Down
10 changes: 10 additions & 0 deletions src/OpenTelemetry.Instrumentation.Process/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

## Unreleased

## 1.0.0-alpha.1

Released 2022-Nov-14

* Update the .NET API used to retrieve `process.memory.virtual` metric from
[Process.PrivateMemorySize64](https://learn.microsoft.com/dotnet/api/system.diagnostics.process.privatememorysize64)
to
[Process.VirtualMemorySize64](https://learn.microsoft.com/dotnet/api/system.diagnostics.process.virtualmemorysize64).
([#762](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/762))

* Update OTel API version to be `1.4.0-beta.2` and change process metrics type
from ObservableGauge to `ObservableUpDownCounter`. Updated instruments are:
"process.memory.usage", "process.memory.virtual" and "process.threads".
Expand Down
4 changes: 2 additions & 2 deletions src/OpenTelemetry.Instrumentation.Process/ProcessMetrics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ public ProcessMetrics(ProcessInstrumentationOptions options)
"process.memory.virtual",
() =>
{
return Diagnostics.Process.GetCurrentProcess().PrivateMemorySize64;
return Diagnostics.Process.GetCurrentProcess().VirtualMemorySize64;
},
unit: "By",
description: "The amount of virtual memory allocated for this process that cannot be shared with other processes.");
description: "The amount of committed virtual memory for this process.");

this.MeterInstance.CreateObservableCounter(
"process.cpu.time",
Expand Down
10 changes: 6 additions & 4 deletions src/OpenTelemetry.Instrumentation.Process/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,19 @@ allocated for the associated process.

### process.memory.virtual

The amount of virtual memory allocated for this process
that cannot be shared with other processes.
The amount of committed virtual memory for this process.
One way to think of this is all the address space this process can read from
without trigerring an access violation; this includes memory backed solely by RAM,
by a swapfile/pagefile and by other mapped files on disk.

| Units | Instrument Type | Value Type |
|-------|-------------------------|------------|
| `By` | ObservableUpDownCounter | `Double` |

The API used to retrieve the value is:

* [Process.WorkingSet64](https://learn.microsoft.com/dotnet/api/system.diagnostics.process.privatememorysize64):
Gets the amount of private memory, in bytes,
* [Process.VirtualMemorySize64](https://learn.microsoft.com/dotnet/api/system.diagnostics.process.virtualmemorysize64):
Gets the amount of the virtual memory, in bytes,
allocated for the associated process.

### process.cpu.time
Expand Down
Loading

0 comments on commit 1f514e6

Please sign in to comment.