-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add db.system attribute to the AWS SDK instrumentation. (#418)
* Added db.system attribute to the AWS SDK instrumentation (#415) * Aligned code formatting (#415) * - set dynamo db related tag in appropriate method (#415) Co-authored-by: Cijo Thomas <cithomas@microsoft.com> Co-authored-by: Prashant Srivastava <50466688+srprash@users.noreply.github.com>
- Loading branch information
1 parent
0edc79f
commit c55fd8d
Showing
5 changed files
with
70 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
54 changes: 54 additions & 0 deletions
54
src/OpenTelemetry.Contrib.Instrumentation.AWS/Implementation/AWSServiceHelper.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,54 @@ | ||
// <copyright file="AWSServiceHelper.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; | ||
using Amazon.Runtime; | ||
|
||
namespace OpenTelemetry.Contrib.Instrumentation.AWS.Implementation | ||
{ | ||
internal class AWSServiceHelper | ||
{ | ||
internal static IReadOnlyDictionary<string, string> ServiceParameterMap = new Dictionary<string, string>() | ||
{ | ||
{ DynamoDbService, "TableName" }, | ||
{ SQSService, "QueueUrl" }, | ||
}; | ||
|
||
internal static IReadOnlyDictionary<string, string> ParameterAttributeMap = new Dictionary<string, string>() | ||
{ | ||
{ "TableName", AWSSemanticConventions.AttributeAWSDynamoTableName }, | ||
{ "QueueUrl", AWSSemanticConventions.AttributeAWSSQSQueueUrl }, | ||
}; | ||
|
||
private const string DynamoDbService = "DynamoDBv2"; | ||
private const string SQSService = "SQS"; | ||
|
||
internal static string GetAWSServiceName(IRequestContext requestContext) | ||
=> Utils.RemoveAmazonPrefixFromServiceName(requestContext.Request.ServiceName); | ||
|
||
internal static string GetAWSOperationName(IRequestContext requestContext) | ||
{ | ||
string completeRequestName = requestContext.OriginalRequest.GetType().Name; | ||
string suffix = "Request"; | ||
var operationName = Utils.RemoveSuffix(completeRequestName, suffix); | ||
return operationName; | ||
} | ||
|
||
internal static bool IsDynamoDbService(string service) | ||
=> DynamoDbService.Equals(service, StringComparison.OrdinalIgnoreCase); | ||
} | ||
} |
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