-
Notifications
You must be signed in to change notification settings - Fork 794
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
[baggage-api] allow metadata storage in baggage #6144
base: main
Are you sure you want to change the base?
Changes from all commits
7d432d3
0c1ddb5
bc971e0
72d7cd5
af3e423
9e024ff
065062e
b91803c
726b9bc
d05b036
da27344
fcd6019
cf4e30c
f88206b
f6d0c8e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
OpenTelemetry.Baggage.Enumerator | ||
OpenTelemetry.Baggage.Enumerator.Current.get -> System.Collections.Generic.KeyValuePair<string!, OpenTelemetry.BaggageEntry> | ||
OpenTelemetry.Baggage.Enumerator.Dispose() -> void | ||
OpenTelemetry.Baggage.Enumerator.Enumerator() -> void | ||
OpenTelemetry.Baggage.Enumerator.MoveNext() -> bool | ||
OpenTelemetry.Baggage.Enumerator.Reset() -> void | ||
OpenTelemetry.Baggage.GetBaggageWithMetadata(string! name) -> OpenTelemetry.BaggageEntry? | ||
OpenTelemetry.Baggage.GetEnumeratorWithMetadata() -> OpenTelemetry.Baggage.Enumerator | ||
OpenTelemetry.Baggage.SetBaggage(string! name, string? value, string? metadata) -> OpenTelemetry.Baggage | ||
OpenTelemetry.BaggageEntry | ||
OpenTelemetry.BaggageEntry.BaggageEntry() -> void | ||
OpenTelemetry.BaggageEntry.BaggageEntry(string! value, OpenTelemetry.BaggageEntryMetadata? metadata = null) -> void | ||
OpenTelemetry.BaggageEntry.Equals(OpenTelemetry.BaggageEntry other) -> bool | ||
OpenTelemetry.BaggageEntry.Metadata.get -> OpenTelemetry.BaggageEntryMetadata? | ||
OpenTelemetry.BaggageEntry.Value.get -> string! | ||
OpenTelemetry.BaggageEntryMetadata | ||
OpenTelemetry.BaggageEntryMetadata.BaggageEntryMetadata() -> void | ||
OpenTelemetry.BaggageEntryMetadata.BaggageEntryMetadata(string? value) -> void | ||
OpenTelemetry.BaggageEntryMetadata.Equals(OpenTelemetry.BaggageEntryMetadata other) -> bool | ||
OpenTelemetry.BaggageEntryMetadata.Value.get -> string? | ||
override OpenTelemetry.BaggageEntry.Equals(object? obj) -> bool | ||
override OpenTelemetry.BaggageEntry.GetHashCode() -> int | ||
override OpenTelemetry.BaggageEntryMetadata.Equals(object? obj) -> bool | ||
override OpenTelemetry.BaggageEntryMetadata.GetHashCode() -> int | ||
static OpenTelemetry.Baggage.CreateWithMetadata(System.Collections.Generic.Dictionary<string!, OpenTelemetry.BaggageEntry>? baggageItems = null) -> OpenTelemetry.Baggage | ||
static OpenTelemetry.Baggage.GetEnumeratorWithMetadata(OpenTelemetry.Baggage baggage) -> OpenTelemetry.Baggage.Enumerator | ||
static OpenTelemetry.Baggage.SetBaggage(string! name, string? value, string? metadata, OpenTelemetry.Baggage baggage) -> OpenTelemetry.Baggage | ||
static OpenTelemetry.BaggageEntry.operator !=(OpenTelemetry.BaggageEntry left, OpenTelemetry.BaggageEntry right) -> bool | ||
static OpenTelemetry.BaggageEntry.operator ==(OpenTelemetry.BaggageEntry left, OpenTelemetry.BaggageEntry right) -> bool | ||
static OpenTelemetry.BaggageEntryMetadata.operator !=(OpenTelemetry.BaggageEntryMetadata left, OpenTelemetry.BaggageEntryMetadata right) -> bool | ||
static OpenTelemetry.BaggageEntryMetadata.operator ==(OpenTelemetry.BaggageEntryMetadata left, OpenTelemetry.BaggageEntryMetadata right) -> bool |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
namespace OpenTelemetry; | ||
|
||
/// <summary> | ||
/// Baggage entry consisting of a value with optional metadata. | ||
/// </summary> | ||
public readonly struct BaggageEntry : IEquatable<BaggageEntry> | ||
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: If you define |
||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="BaggageEntry"/> struct. | ||
/// </summary> | ||
/// <param name="value">Entry value.</param> | ||
/// <param name="metadata">Entry metadata.</param> | ||
public BaggageEntry(string value, BaggageEntryMetadata? metadata = null) | ||
{ | ||
this.Value = value; | ||
this.Metadata = metadata; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the value of the BaggageEntry. | ||
/// </summary> | ||
public string Value { get; } | ||
|
||
/// <summary> | ||
/// Gets the metadata of the BaggageEntry. | ||
/// </summary> | ||
public BaggageEntryMetadata? Metadata { get; } | ||
|
||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member | ||
public static bool operator ==(BaggageEntry left, BaggageEntry right) => left.Equals(right); | ||
|
||
public static bool operator !=(BaggageEntry left, BaggageEntry right) => !left.Equals(right); | ||
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member | ||
|
||
/// <inheritdoc /> | ||
public bool Equals(BaggageEntry other) => | ||
string.Equals(this.Value, other.Value) && | ||
this.Metadata.Equals(other.Metadata); | ||
|
||
/// <inheritdoc /> | ||
public override bool Equals(object? obj) => obj is BaggageEntry other && this.Equals(other); | ||
|
||
/// <inheritdoc /> | ||
public override int GetHashCode() | ||
{ | ||
unchecked | ||
{ | ||
return (this.Value.GetHashCode() * 397) ^ (this.Metadata?.GetHashCode() ?? 0); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
namespace OpenTelemetry; | ||
|
||
/// <summary> | ||
/// Wraps string value of metadata. | ||
/// <remarks> | ||
/// Spec reference: <a href="https://github.com/open-telemetry/opentelemetry-specification/blob/v1.42.0/specification/baggage/api.md?plain=1#L117-L119">metadata</a>. | ||
/// </remarks> | ||
/// </summary> | ||
public readonly struct BaggageEntryMetadata : IEquatable<BaggageEntryMetadata> | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="BaggageEntryMetadata"/> struct. | ||
/// </summary> | ||
/// <param name="value">Metadata value.</param> | ||
public BaggageEntryMetadata(string? value) | ||
{ | ||
this.Value = value; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the value. | ||
/// </summary> | ||
public string? Value { get; } | ||
|
||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member | ||
public static bool operator ==(BaggageEntryMetadata left, BaggageEntryMetadata right) => left.Equals(right); | ||
|
||
public static bool operator !=(BaggageEntryMetadata left, BaggageEntryMetadata right) => !left.Equals(right); | ||
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member | ||
|
||
/// <inheritdoc /> | ||
public bool Equals(BaggageEntryMetadata other) => string.Equals(this.Value, other.Value); | ||
|
||
/// <inheritdoc /> | ||
public override bool Equals(object? obj) => obj is BaggageEntryMetadata other && this.Equals(other); | ||
|
||
/// <inheritdoc /> | ||
public override int GetHashCode() => this.Value?.GetHashCode() ?? 0; | ||
} |
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.
Do you have a plan to make follow up PR with updating this, if so, I am fine?
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.
Yes, my initial plan was to address this warning in a separate PR.