-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[geneva] Add support for exporting otlp metrics via user_events on Linux #2113
Merged
CodeBlanch
merged 25 commits into
open-telemetry:main
from
CodeBlanchOrg:geneva-metric-user_event-transport
Oct 11, 2024
Merged
Changes from 11 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
7fe894e
Support export of metrics via user_events on Linux.
CodeBlanch 470d0c9
Tweak.
CodeBlanch 395fe67
Tweak.
CodeBlanch 7a6f003
Tweaks and test implementation.
CodeBlanch df6b1f0
CHANGELOG patch.
CodeBlanch 7d5f8b8
Merge from main.
CodeBlanch 4841357
Tweak.
CodeBlanch 80bedb3
Fixes.
CodeBlanch e5c67f7
Merge from main.
CodeBlanch f86b41f
Merge remote-tracking branch 'upstream/main' into geneva-metric-user_…
CodeBlanch 6e2e027
Fix.
CodeBlanch 94f2970
Merge remote-tracking branch 'upstream/main' into geneva-metric-user_…
CodeBlanch f0d78b3
Merge remote-tracking branch 'upstream/main' into geneva-metric-user_…
CodeBlanch 26ad46e
Code review.
CodeBlanch f1a0d90
Tweaks.
CodeBlanch 0c5ed5a
Add a step for verifying user_events are available in tests.
CodeBlanch 6bd6b17
Merge branch 'main' into geneva-metric-user_event-transport
CodeBlanch 22af231
Code review.
CodeBlanch cc07953
Code review and doc updates.
CodeBlanch 6fbf465
Merge branch 'main' into geneva-metric-user_event-transport
CodeBlanch 7adda1d
Merge branch 'main' into geneva-metric-user_event-transport
CodeBlanch 75583cd
Code review.
CodeBlanch 10d66cf
Nits.
CodeBlanch 0dd12ce
Merge branch 'main' into geneva-metric-user_event-transport
CodeBlanch ca92300
Tweak.
CodeBlanch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,7 +73,7 @@ private bool Connect() | |
} | ||
catch (Exception ex) | ||
{ | ||
ExporterEventSource.Log.ExporterException("UDS Connect failed.", ex); | ||
ExporterEventSource.Log.TransportException(nameof(UnixDomainSocketDataTransport), "Connection failure", ex); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Include something like "will retry connecting in background", to indicate this may be recovered. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated |
||
|
||
return false; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/OpenTelemetry.Exporter.Geneva/Metrics/Transport/MetricUnixUserEventsDataTransport.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#if NET | ||
|
||
#nullable enable | ||
|
||
using System.Text; | ||
using Microsoft.LinuxTracepoints.Provider; | ||
|
||
namespace OpenTelemetry.Exporter.Geneva; | ||
|
||
internal sealed class MetricUnixUserEventsDataTransport : IMetricDataTransport | ||
{ | ||
public const uint MetricsProtocol = 0U; | ||
public const string MetricsVersion = "v0.19.00"; | ||
public const string MetricsTracepointName = "otlp_metrics"; | ||
public const string MetricsTracepointNameArgs = $"{MetricsTracepointName} u32 protocol;char[8] version;__rel_loc u8[] buffer"; | ||
|
||
private static readonly ReadOnlyMemory<byte> MetricsVersionUtf8 = Encoding.UTF8.GetBytes(MetricsVersion); | ||
private readonly PerfTracepoint metricsTracepoint; | ||
|
||
private MetricUnixUserEventsDataTransport() | ||
{ | ||
this.metricsTracepoint = new PerfTracepoint(MetricsTracepointNameArgs); | ||
if (this.metricsTracepoint.RegisterResult != 0) | ||
cijothomas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
ExporterEventSource.Log.TransportError( | ||
nameof(MetricUnixUserEventsDataTransport), | ||
$"Tracepoint for 'otlp_metrics' user events could not be registered: '{this.metricsTracepoint.RegisterResult}'"); | ||
CodeBlanch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
|
||
public static MetricUnixUserEventsDataTransport Instance { get; } = new(); | ||
cijothomas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
public void Send(MetricEventType eventType, byte[] body, int size) | ||
{ | ||
throw new NotSupportedException(); | ||
} | ||
|
||
public void SendOtlpProtobufEvent(byte[] body, int size) | ||
{ | ||
if (this.metricsTracepoint.IsEnabled) | ||
{ | ||
var buffer = new ReadOnlySpan<byte>(body, 0, size); | ||
|
||
var bufferRelLoc = 0u | ((uint)buffer.Length << 16); | ||
|
||
this.metricsTracepoint.Write( | ||
[MetricsProtocol], | ||
MetricsVersionUtf8.Span, | ||
[bufferRelLoc], | ||
buffer); | ||
} | ||
cijothomas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
public void Dispose() | ||
{ | ||
this.metricsTracepoint.Dispose(); | ||
} | ||
} | ||
|
||
#endif |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this,
PrivatePreviewEnableOtlpProtobufEncoding=true
is now supported in both Widows and Linux. Windows uses ETW as transport, while Linux uses user-events as transport.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CodeBlanch can you add this to changelog before merge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated CHANGELOG and REDME where this stuff was mentioned