Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
0d5c59b
upgrade semantic convention
ppittle Oct 18, 2024
4e8d265
Use a builder pattern for resource attributes
ppittle Nov 5, 2024
59a6a9f
improve documentation
ppittle Dec 3, 2024
67c2b03
inline attribute strings and update obsolete attributes
ppittle Dec 3, 2024
d248279
Alternate strategy to simplify implementation
ppittle Dec 4, 2024
7658b78
renamed files to reflect decision to user simpler model for managing …
ppittle Dec 5, 2024
928f4f1
move the upgrade of AttributeHttpTarget to a new PR as this will requ…
ppittle Dec 5, 2024
b52cbc5
add new unit tests for SemanticConventionVersion switching
ppittle Dec 5, 2024
749f5dd
update AWS Lambda tests to use Semantic Convention 1.29
ppittle Dec 5, 2024
0c091f2
remove obsolete code
ppittle Dec 6, 2024
5204ab7
Update SetTag to be a no-op if attribute name is null or empty
ppittle Dec 6, 2024
a7be302
Update documentation and add documentation to README files
ppittle Dec 6, 2024
db38b54
run dotnet format
ppittle Dec 6, 2024
bc32e39
fix minor issues found by unit tests
ppittle Dec 7, 2024
31700b8
Update Instrumentation.AWS.Tests to use Semantic Convention 1.29
ppittle Dec 7, 2024
bb6315a
Change SemanticConventionVersion to track Semantic Convention versions
ppittle Dec 6, 2024
62e75e8
move depreication of AttributeHttpTarget to new PR
ppittle Dec 7, 2024
0387cb2
implement AttirbuteHttpTarget
ppittle Dec 7, 2024
071f0b3
update AWS Lambda tests to use Semantic Convention 1.29
ppittle Dec 7, 2024
f180dd2
change whitespace to improve readability
ppittle Dec 9, 2024
b7b251b
rebase change semnatic versions to track
ppittle Dec 10, 2024
2bc2930
adjust strategy to list attributes as obsolete and add additional Add…
ppittle Dec 10, 2024
82bae2a
change SemenaticCvonentionVersion strategy to pin to v1.27 - the curr…
ppittle Dec 10, 2024
0eb9e87
SemanticConventionsVersion is public in multiple repositories and so…
ppittle Dec 10, 2024
da6c620
run dotnet format
ppittle Dec 10, 2024
1a1f9d9
change AWSemanticConventions from a static to instances to improve te…
ppittle Dec 10, 2024
fc58a67
Update src/OpenTelemetry.Instrumentation.AWS/README.md
ppittle Dec 12, 2024
de586e4
Update changelog
ppittle Dec 13, 2024
671dfbf
change casing of
ppittle Dec 13, 2024
42a6d0a
inline documentation from opentelemetry.semanticconventions and remov…
ppittle Dec 13, 2024
d72c650
Update libraries to impelement Semantic Convention 1.28 and 1.29
ppittle Dec 17, 2024
abad591
no longer include common SemanticConventions file
ppittle Dec 19, 2024
189e873
drop the suffix expiremental in enum values and instead metnion exper…
ppittle Dec 19, 2024
d70a0c5
change strategy - beta version will default to Legacy (ie no change i…
ppittle Dec 19, 2024
8d75bfd
Update src/OpenTelemetry.Instrumentation.AWS/CHANGELOG.md
ppittle Dec 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
adjust strategy to list attributes as obsolete and add additional Add…
…Attribute calls in core logic
  • Loading branch information
ppittle committed Dec 19, 2024
commit 2bc2930c4900471dffb3a7099ac5ff0ef8d094d7
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
using Amazon.Lambda.ApplicationLoadBalancerEvents;
using OpenTelemetry.AWS;

// Continue to off obsolete Semantic Convention until the next major version bump
#pragma warning disable CS0618 // Type or member is obsolete

namespace OpenTelemetry.Instrumentation.AWSLambda.Implementation;

internal class AWSLambdaHttpUtils
Expand Down Expand Up @@ -64,17 +67,11 @@ internal static IEnumerable<KeyValuePair<string, object>> GetHttpTags<TInput>(TI
if (httpScheme != null)
{
tags.AddAttributeHttpScheme(httpScheme, addIfEmpty: true);
tags.AddAttributeUrlScheme(httpScheme, addIfEmpty: true);
}

if (httpTarget != null)
{
tags.AddAttributeHttpTarget(httpTarget, addIfEmpty: true);
}

if (urlPath != null)
{
tags.AddAttributeUrlPath(urlPath, addIfEmpty: true);
}
tags.AddAttributeHttpTarget(httpTarget, addIfEmpty: true);
tags.AddAttributeUrlPath(urlPath, addIfEmpty: true);

if (urlQuery != null)
{
Expand All @@ -84,14 +81,17 @@ internal static IEnumerable<KeyValuePair<string, object>> GetHttpTags<TInput>(TI
if (httpMethod != null)
{
tags.AddAttributeHttpMethod(httpMethod, addIfEmpty: true);
tags.AddAttributeHttpRequestMethod(httpMethod, addIfEmpty: true);
}

if (hostName != null)
{
tags.AddAttributeNetHostName(hostName, addIfEmpty: true);
tags.AddAttributeServerAddress(hostName, addIfEmpty: true);
}

tags.AddAttributeNetHostPort(hostPort);
tags.AddAttributeServerPort(hostPort);

return tags;
}
Expand All @@ -107,12 +107,15 @@ internal static void SetHttpTagsFromResult(Activity? activity, object? result)
{
case APIGatewayProxyResponse response:
activity.SetTagAttributeHttpStatusCode(response.StatusCode);
activity.SetTagAttributeHttpResponseStatusCode(response.StatusCode);
break;
case APIGatewayHttpApiV2ProxyResponse responseV2:
activity.SetTagAttributeHttpStatusCode(responseV2.StatusCode);
activity.SetTagAttributeHttpResponseStatusCode(responseV2.StatusCode);
break;
case ApplicationLoadBalancerResponse albResponse:
activity.SetTagAttributeHttpStatusCode(albResponse.StatusCode);
activity.SetTagAttributeHttpResponseStatusCode(albResponse.StatusCode);
break;
default:
break;
Expand Down
6 changes: 6 additions & 0 deletions src/Shared/AWS/AWSSemanticConventions.Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,22 +142,28 @@ private abstract class AWSSemanticConventionsBase

// HTTP Attributes
/// <inheritdoc cref="HttpAttributes.AttributeHttpStatusCode"/>
[Obsolete("Replaced by <c>http.response.status_code</c>.")]
public virtual string AttributeHttpStatusCode => string.Empty;
/// <inheritdoc cref="HttpAttributes.AttributeHttpResponseStatusCode"/>
public virtual string AttributeHttpResponseStatusCode => string.Empty;
/// <inheritdoc cref="HttpAttributes.AttributeHttpScheme"/>
[Obsolete("Replaced by <c>url.scheme</c> instead.")]
public virtual string AttributeHttpScheme => string.Empty;
/// <inheritdoc cref="HttpAttributes.AttributeHttpTarget"/>
[Obsolete("Split to <c>url.path</c> and `url.query.")]
public virtual string AttributeHttpTarget => string.Empty;
/// <inheritdoc cref="HttpAttributes.AttributeHttpMethod"/>
[Obsolete("Replaced by <c>http.request.method</c>.")]
public virtual string AttributeHttpMethod => string.Empty;
/// <inheritdoc cref="HttpAttributes.AttributeHttpRequestMethod"/>
public virtual string AttributeHttpRequestMethod => string.Empty;

// NET Attributes
/// <inheritdoc cref="NetAttributes.AttributeNetHostName"/>
[Obsolete("Replaced by <c>server.address</c>.")]
public virtual string AttributeNetHostName => string.Empty;
/// <inheritdoc cref="NetAttributes.AttributeNetHostPort"/>
[Obsolete("Replaced by <c>server.port</c>.")]
public virtual string AttributeNetHostPort => string.Empty;

// SERVER Attributes
Expand Down
28 changes: 28 additions & 0 deletions src/Shared/AWS/AWSSemanticConventions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,28 +235,42 @@ public static T AddAttributeHostName<T>(this T attributes, object? value, bool a

#region Http
/// <inheritdoc cref="AWSSemanticConventionsBase.AttributeHttpStatusCode"/>
[Obsolete("Replaced by <c>http.response.status_code</c>.")]
public static Activity? SetTagAttributeHttpStatusCode(this Activity? activity, int value)
=> SetTag(activity, x => x.AttributeHttpStatusCode, value);

/// <inheritdoc cref="AWSSemanticConventionsBase.AttributeHttpResponseStatusCode"/>
public static Activity? SetTagAttributeHttpResponseStatusCode(this Activity? activity, int value)
=> SetTag(activity, x => x.AttributeHttpResponseStatusCode, value);

/// <inheritdoc cref="AWSSemanticConventionsBase.AttributeHttpScheme"/>
[Obsolete("Replaced by <c>url.scheme</c> instead.")]
public static T AddAttributeHttpScheme<T>(this T attributes, object? value, bool addIfEmpty = false)
where T : IList<KeyValuePair<string, object>> => Add(attributes, x => x.AttributeHttpScheme, value, addIfEmpty);

/// <inheritdoc cref="AWSSemanticConventionsBase.AttributeHttpTarget"/>
[Obsolete("Split to <c>url.path</c> and `url.query.")]
public static T AddAttributeHttpTarget<T>(this T attributes, object? value, bool addIfEmpty = false)
where T : IList<KeyValuePair<string, object>> => Add(attributes, x => x.AttributeHttpTarget, value, addIfEmpty);

/// <inheritdoc cref="AWSSemanticConventionsBase.AttributeHttpMethod"/>
[Obsolete("Replaced by <c>http.request.method</c>.")]
public static T AddAttributeHttpMethod<T>(this T attributes, object? value, bool addIfEmpty = false)
where T : IList<KeyValuePair<string, object>> => Add(attributes, x => x.AttributeHttpMethod, value, addIfEmpty);

/// <inheritdoc cref="AWSSemanticConventionsBase.AttributeHttpRequestMethod"/>
public static T AddAttributeHttpRequestMethod<T>(this T attributes, object? value, bool addIfEmpty = false)
where T : IList<KeyValuePair<string, object>> => Add(attributes, x => x.AttributeHttpRequestMethod, value, addIfEmpty);
#endregion

#region Net
/// <inheritdoc cref="AWSSemanticConventionsBase.AttributeNetHostName"/>
[Obsolete("Replaced by <c>server.address</c>.")]
public static T AddAttributeNetHostName<T>(this T attributes, object? value, bool addIfEmpty = false)
where T : IList<KeyValuePair<string, object>> => Add(attributes, x => x.AttributeNetHostName, value, addIfEmpty);

/// <inheritdoc cref="AWSSemanticConventionsBase.AttributeNetHostPort"/>
[Obsolete("Replaced by <c>server.port</c>.")]
public static T AddAttributeNetHostPort<T>(this T attributes, object? value, bool addIfEmpty = false)
where T : IList<KeyValuePair<string, object>> => Add(attributes, x => x.AttributeNetHostPort, value, addIfEmpty);
#endregion
Expand All @@ -267,6 +281,16 @@ public static T AddAttributeK8SClusterName<T>(this T attributes, object? value,
where T : IList<KeyValuePair<string, object>> => Add(attributes, x => x.AttributeK8SClusterName, value, addIfEmpty);
#endregion

#region Server
/// <inheritdoc cref="AWSSemanticConventionsBase.AttributeServerAddress"/>
public static T AddAttributeServerAddress<T>(this T attributes, object? value, bool addIfEmpty = false)
where T : IList<KeyValuePair<string, object>> => Add(attributes, x => x.AttributeServerAddress, value, addIfEmpty);

/// <inheritdoc cref="AWSSemanticConventionsBase.AttributeServerPort"/>
public static T AddAttributeServerPort<T>(this T attributes, object? value, bool addIfEmpty = false)
where T : IList<KeyValuePair<string, object>> => Add(attributes, x => x.AttributeServerPort, value, addIfEmpty);
#endregion

#region Service
/// <inheritdoc cref="AWSSemanticConventionsBase.AttributeServiceName"/>
public static T AddAttributeServiceNameIsAwsElasticBeanstalk<T>(this T attributes)
Expand All @@ -293,6 +317,10 @@ public static T AddAttributeUrlPath<T>(this T attributes, object? value, bool ad
/// <inheritdoc cref="AWSSemanticConventionsBase.AttributeServiceName"/>
public static T AddAttributeUrlQuery<T>(this T attributes, object? value, bool addIfEmpty = false)
where T : IList<KeyValuePair<string, object>> => Add(attributes, x => x.AttributeUrlQuery, value, addIfEmpty);

/// <inheritdoc cref="AWSSemanticConventionsBase.AttributeUrlScheme"/>
public static T AddAttributeUrlScheme<T>(this T attributes, object? value, bool addIfEmpty = false)
where T : IList<KeyValuePair<string, object>> => Add(attributes, x => x.AttributeUrlScheme, value, addIfEmpty);
#endregion

private static T Add<T>(this T attributes, Func<AWSSemanticConventionsBase, string> attributeNameFunc, Func<AWSSemanticConventionsBase, string> valueFunc)
Expand Down
6 changes: 6 additions & 0 deletions src/Shared/AWS/AWSSemanticConventions.v1.27.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,19 @@ private class AWSSemanticConventions_v1_27_0 : AWSSemanticConventionsBase
public override string AttributeHostName => "host.name";

// HTTP Attributes
[Obsolete("Replaced by <c>http.response.status_code</c>.")]
public override string AttributeHttpStatusCode => "http.status_code";
[Obsolete("Replaced by <c>url.scheme</c> instead.")]
public override string AttributeHttpScheme => "http.scheme";
[Obsolete("Split to <c>url.path</c> and `url.query.")]
public override string AttributeHttpTarget => "http.target";
[Obsolete("Replaced by <c>http.request.method</c>.")]
public override string AttributeHttpMethod => "http.method";

// NET Attributes
[Obsolete("Replaced by <c>server.address</c>.")]
public override string AttributeNetHostName => "net.host.name";
[Obsolete("Replaced by <c>server.port</c>.")]
public override string AttributeNetHostPort => "net.host.port";

// K8s Attributes
Expand Down
16 changes: 11 additions & 5 deletions src/Shared/AWS/AWSSemanticConventions.v1.29.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,23 @@ private class AWSSemanticConventions_v1_29_0 : AWSSemanticConventions_v1_27_0
public override string AttributeFaasExecution => "faas.invocation_id";

// HTTP Attributes
public override string AttributeHttpStatusCode => this.AttributeHttpResponseStatusCode;
public override string AttributeHttpScheme => this.AttributeUrlScheme;
[Obsolete("Replaced by <c>http.response.status_code</c>.")]
public override string AttributeHttpStatusCode => string.Empty; // value no longer written
[Obsolete("Replaced by <c>url.scheme</c> instead.")]
public override string AttributeHttpScheme => string.Empty; // value no longer written

[Obsolete("Split to <c>url.path</c> and `url.query.")]
public override string AttributeHttpTarget => string.Empty; // value no longer written
public override string AttributeHttpMethod => this.AttributeHttpRequestMethod;
[Obsolete("Replaced by <c>http.request.method</c>.")]
public override string AttributeHttpMethod => string.Empty; // value no longer written
public override string AttributeHttpResponseStatusCode => "http.response.status_code";
public override string AttributeHttpRequestMethod => "http.request.method";

// NET Attributes
public override string AttributeNetHostName => this.AttributeServerAddress;
public override string AttributeNetHostPort => this.AttributeServerPort;
[Obsolete("Replaced by <c>server.address</c>.")]
public override string AttributeNetHostName => string.Empty; // value no longer written
[Obsolete("Replaced by <c>server.port</c>.")]
public override string AttributeNetHostPort => string.Empty; // value no longer written

// SERVER Attributes
public override string AttributeServerAddress => "server.address";
Expand Down