-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into eventcounters-stabilize
- Loading branch information
Showing
42 changed files
with
1,323 additions
and
342 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"cSpell.words": [ | ||
"fluentdData" | ||
] | ||
} |
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
File renamed without changes.
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,73 @@ | ||
// <copyright file="GenevaLogExporter.cs" company="OpenTelemetry Authors"> | ||
// Copyright The OpenTelemetry Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// </copyright> | ||
|
||
using System; | ||
using OpenTelemetry.Internal; | ||
using OpenTelemetry.Logs; | ||
|
||
namespace OpenTelemetry.Exporter.Geneva; | ||
|
||
public class GenevaLogExporter : GenevaBaseExporter<LogRecord> | ||
{ | ||
internal bool IsUsingUnixDomainSocket; | ||
|
||
private bool isDisposed; | ||
|
||
private delegate ExportResult ExportLogRecordFunc(in Batch<LogRecord> batch); | ||
|
||
private readonly ExportLogRecordFunc exportLogRecord; | ||
|
||
private readonly IDisposable exporter; | ||
|
||
public GenevaLogExporter(GenevaExporterOptions options) | ||
{ | ||
Guard.ThrowIfNull(options); | ||
Guard.ThrowIfNullOrWhitespace(options.ConnectionString); | ||
|
||
var msgPackExporter = new MsgPackLogExporter(options); | ||
this.IsUsingUnixDomainSocket = msgPackExporter.IsUsingUnixDomainSocket; | ||
this.exportLogRecord = (in Batch<LogRecord> batch) => msgPackExporter.Export(in batch); | ||
this.exporter = msgPackExporter; | ||
} | ||
|
||
public override ExportResult Export(in Batch<LogRecord> batch) | ||
{ | ||
return this.exportLogRecord(batch); | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
if (this.isDisposed) | ||
{ | ||
return; | ||
} | ||
|
||
if (disposing) | ||
{ | ||
try | ||
{ | ||
this.exporter.Dispose(); | ||
} | ||
catch (Exception ex) | ||
{ | ||
ExporterEventSource.Log.ExporterException("GenevaLogExporter Dispose failed.", ex); | ||
} | ||
} | ||
|
||
this.isDisposed = true; | ||
base.Dispose(disposing); | ||
} | ||
} |
File renamed without changes.
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,73 @@ | ||
// <copyright file="GenevaTraceExporter.cs" company="OpenTelemetry Authors"> | ||
// Copyright The OpenTelemetry Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// </copyright> | ||
|
||
using System; | ||
using System.Diagnostics; | ||
using OpenTelemetry.Internal; | ||
|
||
namespace OpenTelemetry.Exporter.Geneva; | ||
|
||
public class GenevaTraceExporter : GenevaBaseExporter<Activity> | ||
{ | ||
internal readonly bool IsUsingUnixDomainSocket; | ||
|
||
private bool isDisposed; | ||
|
||
private delegate ExportResult ExportActivityFunc(in Batch<Activity> batch); | ||
|
||
private readonly ExportActivityFunc exportActivity; | ||
|
||
private readonly IDisposable exporter; | ||
|
||
public GenevaTraceExporter(GenevaExporterOptions options) | ||
{ | ||
Guard.ThrowIfNull(options); | ||
Guard.ThrowIfNullOrWhitespace(options.ConnectionString); | ||
|
||
var msgPackExporter = new MsgPackTraceExporter(options); | ||
this.IsUsingUnixDomainSocket = msgPackExporter.IsUsingUnixDomainSocket; | ||
this.exportActivity = (in Batch<Activity> batch) => msgPackExporter.Export(in batch); | ||
this.exporter = msgPackExporter; | ||
} | ||
|
||
public override ExportResult Export(in Batch<Activity> batch) | ||
{ | ||
return this.exportActivity(batch); | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
if (this.isDisposed) | ||
{ | ||
return; | ||
} | ||
|
||
if (disposing) | ||
{ | ||
try | ||
{ | ||
this.exporter.Dispose(); | ||
} | ||
catch (Exception ex) | ||
{ | ||
ExporterEventSource.Log.ExporterException("GenevaTraceExporter Dispose failed.", ex); | ||
} | ||
} | ||
|
||
this.isDisposed = true; | ||
base.Dispose(disposing); | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
src/OpenTelemetry.Exporter.Geneva/MsgPackExporter/MsgPackExporter.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,75 @@ | ||
// <copyright file="MsgPackExporter.cs" company="OpenTelemetry Authors"> | ||
// Copyright The OpenTelemetry Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// </copyright> | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace OpenTelemetry.Exporter.Geneva; | ||
|
||
internal abstract class MsgPackExporter | ||
{ | ||
internal static readonly IReadOnlyDictionary<string, string> V40_PART_A_MAPPING = new Dictionary<string, string> | ||
{ | ||
// Part A | ||
[Schema.V40.PartA.IKey] = "env_iKey", | ||
[Schema.V40.PartA.Name] = "env_name", | ||
[Schema.V40.PartA.Ver] = "env_ver", | ||
[Schema.V40.PartA.Time] = "env_time", | ||
|
||
// Part A Application Extension | ||
[Schema.V40.PartA.Extensions.App.Id] = "env_app_id", | ||
[Schema.V40.PartA.Extensions.App.Ver] = "env_app_ver", | ||
|
||
// Part A Cloud Extension | ||
[Schema.V40.PartA.Extensions.Cloud.Role] = "env_cloud_role", | ||
[Schema.V40.PartA.Extensions.Cloud.RoleInstance] = "env_cloud_roleInstance", | ||
[Schema.V40.PartA.Extensions.Cloud.RoleVer] = "env_cloud_roleVer", | ||
|
||
// Part A Os extension | ||
[Schema.V40.PartA.Extensions.Os.Name] = "env_os_name", | ||
[Schema.V40.PartA.Extensions.Os.Ver] = "env_os_ver", | ||
}; | ||
|
||
protected static int AddPartAField(byte[] buffer, int cursor, string name, object value) | ||
{ | ||
if (V40_PART_A_MAPPING.TryGetValue(name, out string replacementKey)) | ||
{ | ||
cursor = MessagePackSerializer.SerializeAsciiString(buffer, cursor, replacementKey); | ||
} | ||
else | ||
{ | ||
cursor = MessagePackSerializer.SerializeUnicodeString(buffer, cursor, name); | ||
} | ||
|
||
cursor = MessagePackSerializer.Serialize(buffer, cursor, value); | ||
return cursor; | ||
} | ||
|
||
protected static int AddPartAField(byte[] buffer, int cursor, string name, Span<byte> value) | ||
{ | ||
if (V40_PART_A_MAPPING.TryGetValue(name, out string replacementKey)) | ||
{ | ||
cursor = MessagePackSerializer.SerializeAsciiString(buffer, cursor, replacementKey); | ||
} | ||
else | ||
{ | ||
cursor = MessagePackSerializer.SerializeUnicodeString(buffer, cursor, name); | ||
} | ||
|
||
cursor = MessagePackSerializer.SerializeSpan(buffer, cursor, value); | ||
return cursor; | ||
} | ||
} |
Oops, something went wrong.