-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AWS SDK clients instrumentation (#44)
* AWS SDK instrumentation initial commit * AWS SDK instrumentation initial commit * Adding http status code and response content length. Adding status on exception. * Adding UnitTests and helper tools for AWS SDK client instrumentation * Adding a semantic convention file for AWS specific attributes * Renaming files, some code refactors * Fixing typo in Opentelemetry namespace * Changing from AddTag to SetTag on activity * Adding Unset status for successful request * Fixed condition check on Status. Adding proper response to SQS test otherwise it fails * Adding tests for .net452 and helper code for mocking the http layer * Adding README for AWS client instrumentation usage * Fixing typo in readme * Adding fallback to fetch region from ServiceURL if RegionEndpoint is null * Changing the namespace to make it similar in structure with other instrumentations * Adding options for AWS client instrumentation. Suppressing downstream http instrumentation. Updating readme. * only adding info if the isAllDataRequested is true for the activity * Moving AWS instrumentation to its own project * Minor fixes * Adding readme * Update README.md * Moving implementation specific classes to Implementation folder * Self implementation of GetTagValue method * Unit test fixes. Using TagObjects * Adding minver tag prefix and release workflow file * Removed assembily signed check. Added await to async operations in tests. * Some null checks before string opserations * Remove explicit setting status to Unset for successful requests
- Loading branch information
Showing
24 changed files
with
1,836 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Pack OpenTelemetry.Contrib.Instrumentation.AWS | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
logLevel: | ||
description: 'Log level' | ||
required: true | ||
default: 'warning' | ||
push: | ||
tags: | ||
- 'Instrumentation.AWS-*' # trigger when we create a tag with prefix "Instrumentation.AWS-" | ||
|
||
jobs: | ||
build-test-pack: | ||
runs-on: ${{ matrix.os }} | ||
env: | ||
PROJECT: OpenTelemetry.Contrib.Instrumentation.AWS | ||
|
||
strategy: | ||
matrix: | ||
os: [windows-latest] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 # fetching all | ||
|
||
- name: Install dependencies | ||
run: dotnet restore | ||
|
||
- name: dotnet build ${{env.PROJECT}} | ||
run: dotnet build src/${{env.PROJECT}} --configuration Release --no-restore -p:Deterministic=true | ||
|
||
- name: dotnet test ${{env.PROJECT}} | ||
run: dotnet test test/${{env.PROJECT}} | ||
|
||
- name: dotnet pack ${{env.PROJECT}} | ||
run: dotnet pack src/${{env.PROJECT}} --configuration Release --no-build | ||
|
||
- name: Publish Artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ${{env.PROJECT}}-packages | ||
path: '**/${{env.PROJECT}}/bin/**/*.*nupkg' | ||
|
||
- name: Publish MyGet | ||
run: | | ||
nuget setApiKey ${{ secrets.MYGET_TOKEN }} -Source https://www.myget.org/F/opentelemetry-contrib/api/v2/package | ||
nuget push **/${{env.PROJECT}}/bin/**/*.nupkg -Source https://www.myget.org/F/opentelemetry-contrib/api/v2/package |
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
29 changes: 29 additions & 0 deletions
29
src/OpenTelemetry.Contrib.Instrumentation.AWS/AWSClientInstrumentationOptions.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,29 @@ | ||
// <copyright file="AWSClientInstrumentationOptions.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.Contrib.Instrumentation.AWS | ||
{ | ||
/// <summary> | ||
/// Options for AWS client instrumentation. | ||
/// </summary> | ||
public class AWSClientInstrumentationOptions | ||
{ | ||
/// <summary> | ||
/// Gets or sets a value indicating whether downstream Http instrumentation is suppressed. | ||
/// </summary> | ||
public bool SuppressDownstreamInstrumentation { get; set; } = true; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/OpenTelemetry.Contrib.Instrumentation.AWS/AssemblyInfo.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,19 @@ | ||
// <copyright file="AssemblyInfo.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.Runtime.CompilerServices; | ||
|
||
[assembly: InternalsVisibleTo("OpenTelemetry.Contrib.Instrumentation.AWS.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010051c1562a090fb0c9f391012a32198b5e5d9a60e9b80fa2d7b434c9e5ccb7259bd606e66f9660676afc6692b8cdc6793d190904551d2103b7b22fa636dcbb8208839785ba402ea08fc00c8f1500ccef28bbf599aa64ffb1e1d5dc1bf3420a3777badfe697856e9d52070a50c3ea5821c80bef17ca3acffa28f89dd413f096f898")] |
28 changes: 28 additions & 0 deletions
28
src/OpenTelemetry.Contrib.Instrumentation.AWS/Implementation/AWSClientsInstrumentation.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,28 @@ | ||
// <copyright file="AWSClientsInstrumentation.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.Internal; | ||
|
||
namespace OpenTelemetry.Contrib.Instrumentation.AWS.Implementation | ||
{ | ||
internal class AWSClientsInstrumentation | ||
{ | ||
public AWSClientsInstrumentation(AWSClientInstrumentationOptions options) | ||
{ | ||
RuntimePipelineCustomizerRegistry.Instance.Register(new AWSTracingPipelineCustomizer(options)); | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/OpenTelemetry.Contrib.Instrumentation.AWS/Implementation/AWSSemanticConventions.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,32 @@ | ||
// <copyright file="AWSSemanticConventions.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.Contrib.Instrumentation.AWS.Implementation | ||
{ | ||
internal static class AWSSemanticConventions | ||
{ | ||
public const string AttributeAWSServiceName = "aws.service"; | ||
public const string AttributeAWSOperationName = "aws.operation"; | ||
public const string AttributeAWSRegion = "aws.region"; | ||
public const string AttributeAWSRequestId = "aws.requestId"; | ||
|
||
public const string AttributeAWSDynamoTableName = "aws.table_name"; | ||
public const string AttributeAWSSQSQueueUrl = "aws.queue_url"; | ||
|
||
public const string AttributeHttpStatusCode = "http.status_code"; | ||
public const string AttributeHttpResponseContentLength = "http.response_content_length"; | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
src/OpenTelemetry.Contrib.Instrumentation.AWS/Implementation/AWSTracingPipelineCustomizer.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,50 @@ | ||
// <copyright file="AWSTracingPipelineCustomizer.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 Amazon.Runtime; | ||
using Amazon.Runtime.Internal; | ||
|
||
namespace OpenTelemetry.Contrib.Instrumentation.AWS.Implementation | ||
{ | ||
internal class AWSTracingPipelineCustomizer : IRuntimePipelineCustomizer | ||
{ | ||
private readonly AWSClientInstrumentationOptions options; | ||
|
||
public AWSTracingPipelineCustomizer(AWSClientInstrumentationOptions options) | ||
{ | ||
this.options = options; | ||
} | ||
|
||
public string UniqueName | ||
{ | ||
get | ||
{ | ||
return "AWS Tracing Registration Customization"; | ||
} | ||
} | ||
|
||
public void Customize(Type serviceClientType, RuntimePipeline pipeline) | ||
{ | ||
if (serviceClientType.BaseType != typeof(AmazonServiceClient)) | ||
{ | ||
return; | ||
} | ||
|
||
pipeline.AddHandlerAfter<EndpointResolver>(new AWSTracingPipelineHandler(this.options)); | ||
} | ||
} | ||
} |
Oops, something went wrong.