-
Notifications
You must be signed in to change notification settings - Fork 775
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OTLP exporter support for limiting activity tags, events, and links (#…
- Loading branch information
Showing
8 changed files
with
449 additions
and
35 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
46 changes: 46 additions & 0 deletions
46
...elemetry.Exporter.OpenTelemetryProtocol/Configuration/EnvironmentVariableConfiguration.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,46 @@ | ||
// <copyright file="EnvironmentVariableConfiguration.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; | ||
|
||
namespace OpenTelemetry.Configuration; | ||
|
||
internal class EnvironmentVariableConfiguration | ||
{ | ||
public static void InitializeDefaultConfigurationFromEnvironment(SdkConfiguration sdkConfiguration) | ||
{ | ||
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/sdk-environment-variables.md#attribute-limits | ||
SetIntConfigValue("OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT", value => sdkConfiguration.AttributeValueLengthLimit = value); | ||
SetIntConfigValue("OTEL_ATTRIBUTE_COUNT_LIMIT", value => sdkConfiguration.AttributeCountLimit = value); | ||
|
||
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/sdk-environment-variables.md#span-limits | ||
SetIntConfigValue("OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT", value => sdkConfiguration.SpanAttributeValueLengthLimit = value); | ||
SetIntConfigValue("OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT", value => sdkConfiguration.SpanAttributeCountLimit = value); | ||
SetIntConfigValue("OTEL_SPAN_EVENT_COUNT_LIMIT", value => sdkConfiguration.SpanEventCountLimit = value); | ||
SetIntConfigValue("OTEL_SPAN_LINK_COUNT_LIMIT", value => sdkConfiguration.SpanLinkCountLimit = value); | ||
SetIntConfigValue("OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT", value => sdkConfiguration.EventAttributeCountLimit = value); | ||
SetIntConfigValue("OTEL_LINK_ATTRIBUTE_COUNT_LIMIT", value => sdkConfiguration.LinkAttributeCountLimit = value); | ||
} | ||
|
||
private static void SetIntConfigValue(string key, Action<int> setter) | ||
{ | ||
if (EnvironmentVariableHelper.LoadNumeric(key, out var result)) | ||
{ | ||
setter(result); | ||
} | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Configuration/SdkConfiguration.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,69 @@ | ||
// <copyright file="SdkConfiguration.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> | ||
|
||
namespace OpenTelemetry.Configuration; | ||
|
||
internal class SdkConfiguration | ||
{ | ||
private int? spanAttributeValueLengthLimit; | ||
private int? spanAttributeCountLimit; | ||
private int? eventAttributeCountLimit; | ||
private int? linkAttributeCountLimit; | ||
|
||
private SdkConfiguration() | ||
{ | ||
EnvironmentVariableConfiguration.InitializeDefaultConfigurationFromEnvironment(this); | ||
} | ||
|
||
public static SdkConfiguration Instance { get; private set; } = new SdkConfiguration(); | ||
|
||
public int? AttributeValueLengthLimit { get; set; } | ||
|
||
public int? AttributeCountLimit { get; set; } | ||
|
||
public int? SpanAttributeValueLengthLimit | ||
{ | ||
get => this.spanAttributeValueLengthLimit ?? this.AttributeValueLengthLimit; | ||
set => this.spanAttributeValueLengthLimit = value; | ||
} | ||
|
||
public int? SpanAttributeCountLimit | ||
{ | ||
get => this.spanAttributeCountLimit ?? this.AttributeCountLimit; | ||
set => this.spanAttributeCountLimit = value; | ||
} | ||
|
||
public int? SpanEventCountLimit { get; set; } | ||
|
||
public int? SpanLinkCountLimit { get; set; } | ||
|
||
public int? EventAttributeCountLimit | ||
{ | ||
get => this.eventAttributeCountLimit ?? this.SpanAttributeCountLimit; | ||
set => this.eventAttributeCountLimit = value; | ||
} | ||
|
||
public int? LinkAttributeCountLimit | ||
{ | ||
get => this.linkAttributeCountLimit ?? this.SpanAttributeCountLimit; | ||
set => this.linkAttributeCountLimit = value; | ||
} | ||
|
||
internal static void Reset() | ||
{ | ||
Instance = new SdkConfiguration(); | ||
} | ||
} |
Oops, something went wrong.