-
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.
#1034: refactored in order to support "nothing or all" trace data inj…
…ection + adapted tests accordingly
- Loading branch information
Showing
11 changed files
with
437 additions
and
312 deletions.
There are no files selected for viewing
82 changes: 0 additions & 82 deletions
82
src/OpenTelemetry.Contrib.Instrumentation.AWS/Implementation/AWSMessageAttributeHelper.cs
This file was deleted.
Oops, something went wrong.
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
34 changes: 0 additions & 34 deletions
34
src/OpenTelemetry.Contrib.Instrumentation.AWS/Implementation/SnsMessageAttributeFormatter.cs
This file was deleted.
Oops, something went wrong.
59 changes: 59 additions & 0 deletions
59
src/OpenTelemetry.Contrib.Instrumentation.AWS/Implementation/SnsRequestContextAdapter.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,59 @@ | ||
// <copyright file="SnsRequestContextAdapter.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 Amazon.Runtime; | ||
using Amazon.Runtime.Internal; | ||
using Amazon.SimpleNotificationService.Model; | ||
|
||
namespace OpenTelemetry.Contrib.Instrumentation.AWS.Implementation; | ||
internal class SnsRequestContextAdapter : IRequestContextAdapter | ||
{ | ||
private readonly ParameterCollection parameters; | ||
private readonly PublishRequest originalRequest; | ||
|
||
public SnsRequestContextAdapter(IRequestContext context) | ||
{ | ||
this.parameters = context.Request?.ParameterCollection; | ||
this.originalRequest = context.OriginalRequest as PublishRequest; | ||
} | ||
|
||
public bool HasMessageBody => | ||
this.parameters?.ContainsKey("Message") ?? false; | ||
|
||
public bool HasOriginalRequest => this.originalRequest != null; | ||
|
||
public int AttributesCount => | ||
this.originalRequest?.MessageAttributes.Count ?? 0; | ||
|
||
public void AddAttribute(string name, string value, int nextAttributeIndex) | ||
{ | ||
if (this.parameters == null) | ||
{ | ||
return; | ||
} | ||
|
||
var attributePrefix = "MessageAttributes.entry." + nextAttributeIndex; | ||
this.parameters.Add(attributePrefix + ".Name", name); | ||
this.parameters.Add(attributePrefix + ".Value.DataType", "String"); | ||
this.parameters.Add(attributePrefix + ".Value.StringValue", value); | ||
} | ||
|
||
public void AddAttributeToOriginalRequest(string name, string value) => | ||
this.originalRequest?.MessageAttributes.Add(name, new MessageAttributeValue { DataType = "String", StringValue = value }); | ||
|
||
public bool ContainsAttribute(string name) | ||
=> this.originalRequest?.MessageAttributes.ContainsKey(name) ?? false; | ||
} |
34 changes: 0 additions & 34 deletions
34
src/OpenTelemetry.Contrib.Instrumentation.AWS/Implementation/SqsMessageAttributeFormatter.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.