-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
- Loading branch information
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
using System; | ||
using System.Diagnostics.Tracing; | ||
using OpenTelemetry.Internal; | ||
|
||
namespace OpenTelemetry.ResourceDetectors.Container; | ||
|
||
[EventSource(Name = "OpenTelemetry-ResourceDetectors-Container")] | ||
internal class ContainerResourceEventSource : EventSource, IServerCertificateValidationEventSource | ||
{ | ||
private const int EventIdFailedToExtractResourceAttributes = 1; | ||
private const int EventIdFailedToValidateCertificate = 2; | ||
private const int EventIdFailedToCreateHttpHandler = 3; | ||
private const int EventIdFailedCertificateFileNotExists = 4; | ||
private const int EventIdFailedToLoadCertificateInStorage = 5; | ||
|
||
public static ContainerResourceEventSource Log = new(); | ||
Check failure on line 19 in src/OpenTelemetry.ResourceDetectors.Container/ContainerResourceEventSource.cs GitHub Actions / build-test-solution (windows-latest, net6.0)
Check failure on line 19 in src/OpenTelemetry.ResourceDetectors.Container/ContainerResourceEventSource.cs GitHub Actions / build-test-solution (windows-latest, net7.0)
Check failure on line 19 in src/OpenTelemetry.ResourceDetectors.Container/ContainerResourceEventSource.cs GitHub Actions / build-test-solution (windows-latest, net8.0)
Check failure on line 19 in src/OpenTelemetry.ResourceDetectors.Container/ContainerResourceEventSource.cs GitHub Actions / build-test-solution (ubuntu-latest, net6.0)
Check failure on line 19 in src/OpenTelemetry.ResourceDetectors.Container/ContainerResourceEventSource.cs GitHub Actions / build-test-solution (ubuntu-latest, net7.0)
Check failure on line 19 in src/OpenTelemetry.ResourceDetectors.Container/ContainerResourceEventSource.cs GitHub Actions / build-test-solution (ubuntu-latest, net8.0)
|
||
|
||
[NonEvent] | ||
public void ExtractResourceAttributesException(string format, Exception ex) | ||
{ | ||
if (this.IsEnabled(EventLevel.Error, (EventKeywords)(-1))) | ||
{ | ||
this.FailedToExtractResourceAttributes(format, ex.ToInvariantString()); | ||
} | ||
} | ||
|
||
[Event(EventIdFailedToExtractResourceAttributes, Message = "Failed to extract resource attributes in '{0}'.", Level = EventLevel.Error)] | ||
public void FailedToExtractResourceAttributes(string format, string exception) | ||
{ | ||
this.WriteEvent(1, format, exception); | ||
} | ||
|
||
[Event(EventIdFailedToValidateCertificate, Message = "Failed to validate certificate. Details: '{0}'", Level = EventLevel.Warning)] | ||
public void FailedToValidateCertificate(string error) | ||
{ | ||
this.WriteEvent(EventIdFailedToValidateCertificate, error); | ||
} | ||
|
||
[Event(EventIdFailedToCreateHttpHandler, Message = "Failed to create HTTP handler. Exception: '{0}'", Level = EventLevel.Warning)] | ||
public void FailedToCreateHttpHandler(Exception exception) | ||
{ | ||
this.WriteEvent(EventIdFailedToCreateHttpHandler, exception.ToInvariantString()); | ||
} | ||
|
||
[Event(EventIdFailedCertificateFileNotExists, Message = "Certificate file does not exist. File: '{0}'", Level = EventLevel.Warning)] | ||
public void CertificateFileDoesNotExist(string filename) | ||
{ | ||
this.WriteEvent(EventIdFailedCertificateFileNotExists, filename); | ||
} | ||
|
||
[Event(EventIdFailedToLoadCertificateInStorage, Message = "Failed to load certificate in trusted storage. File: '{0}'", Level = EventLevel.Warning)] | ||
public void FailedToLoadCertificateInTrustedStorage(string filename) | ||
{ | ||
this.WriteEvent(EventIdFailedToLoadCertificateInStorage, filename); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
using System.Text.Json.Serialization; | ||
|
||
namespace OpenTelemetry.ResourceDetectors.Container.Models; | ||
|
||
internal sealed class K8sContainerStatus | ||
{ | ||
[JsonPropertyName("name")] | ||
public string Name { get; set; } = default!; | ||
|
||
[JsonPropertyName("containerID")] | ||
public string Id { get; set; } = default!; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
using System.Text.Json.Serialization; | ||
|
||
namespace OpenTelemetry.ResourceDetectors.Container.Models; | ||
|
||
internal sealed class K8sPod | ||
{ | ||
[JsonPropertyName("status")] | ||
public K8sPodStatus? Status { get; set; } | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
using System.Collections.Generic; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace OpenTelemetry.ResourceDetectors.Container.Models; | ||
|
||
internal sealed class K8sPodStatus | ||
{ | ||
[JsonPropertyName("containerStatuses")] | ||
public IReadOnlyList<K8sContainerStatus> ContainerStatuses { get; set; } = new List<K8sContainerStatus>(); | ||
} |