-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Resources.OperatingSystem] Implement additional osdetector attributes (
- Loading branch information
1 parent
7fcae49
commit fbca637
Showing
10 changed files
with
371 additions
and
13 deletions.
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
44 changes: 44 additions & 0 deletions
44
src/OpenTelemetry.Resources.OperatingSystem/OperatingSystemResourcesEventSource.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,44 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
using System.Diagnostics.Tracing; | ||
using OpenTelemetry.Internal; | ||
|
||
namespace OpenTelemetry.Resources.OperatingSystem; | ||
|
||
[EventSource(Name = "OpenTelemetry-Resources-OperatingSystem")] | ||
internal sealed class OperatingSystemResourcesEventSource : EventSource | ||
{ | ||
public static OperatingSystemResourcesEventSource Log = new(); | ||
|
||
private const int EventIdFailedToExtractAttributes = 1; | ||
private const int EventIdFailedToValidateValue = 2; | ||
private const int EventIdFailedToFindFile = 3; | ||
|
||
[NonEvent] | ||
public void ResourceAttributesExtractException(string format, Exception ex) | ||
{ | ||
if (this.IsEnabled(EventLevel.Warning, EventKeywords.All)) | ||
{ | ||
this.FailedToExtractResourceAttributes(format, ex.ToInvariantString()); | ||
} | ||
} | ||
|
||
[Event(EventIdFailedToExtractAttributes, Message = "Failed to extract resource attributes in '{0}'.", Level = EventLevel.Warning)] | ||
public void FailedToExtractResourceAttributes(string format, string exception) | ||
{ | ||
this.WriteEvent(EventIdFailedToExtractAttributes, format, exception); | ||
} | ||
|
||
[Event(EventIdFailedToValidateValue, Message = "Failed to validate value. Details: '{0}'", Level = EventLevel.Warning)] | ||
public void FailedToValidateValue(string error) | ||
{ | ||
this.WriteEvent(EventIdFailedToValidateValue, error); | ||
} | ||
|
||
[Event(EventIdFailedToFindFile, Message = "Process timeout occurred: '{0}'", Level = EventLevel.Warning)] | ||
public void FailedToFindFile(string error) | ||
{ | ||
this.WriteEvent(EventIdFailedToFindFile, error); | ||
} | ||
} |
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
Oops, something went wrong.