Skip to content
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

Applied HttpClient to get sampling info #159

Merged
merged 5 commits into from
Nov 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion sdk/src/Core/AWSXRayRecorder.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@

<ItemGroup>
<PackageReference Include="AWSSDK.Core" Version="[3.3.25.1,4.0)" />
<PackageReference Include="AWSSDK.XRay" Version="[3.3.3,4.0)" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
Expand Down
6 changes: 3 additions & 3 deletions sdk/src/Core/Sampling/DefaultSamplingStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public class DefaultSamplingStrategy : ISamplingStrategy
public DaemonConfig DaemonCfg { get; private set; }

/// <summary>
/// Instance of <see cref="AmazonXRayClient"/>.
/// Instance of <see cref="XRayConfig"/>.
/// </summary>
public AmazonXRayClient XRayClient = null;
public XRayConfig XRayConfig = null;

/// <summary>
/// Instance of <see cref="DefaultSamplingStrategy"/>.
Expand Down Expand Up @@ -81,7 +81,7 @@ private void Start()
{
if (!_isPollerStarted)
{
_connector = new ServiceConnector(DaemonCfg, XRayClient);
_connector = new ServiceConnector(DaemonCfg, XRayConfig);
_rulePoller.Poll(_connector);
_targetPoller.Poll(_connector);
_isPollerStarted = true;
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/Core/Sampling/GetSamplingRulesResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
namespace Amazon.XRay.Recorder.Core.Sampling
{
/// <summary>
/// Wrapper to <see cref="AmazonXRayClient.GetSamplingRulesAsync(Model.GetSamplingRulesRequest, System.Threading.CancellationToken)"/> API call response.
/// Class for keep list of sampling rules from x-ray backend.
/// </summary>
public class GetSamplingRulesResponse
lupengamzn marked this conversation as resolved.
Show resolved Hide resolved
{
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/Core/Sampling/GetSamplingTargetsResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
namespace Amazon.XRay.Recorder.Core.Sampling
{
/// <summary>
/// Wrapper for <see cref="AmazonXRayClient.GetSamplingTargetsAsync(Model.GetSamplingTargetsRequest, System.Threading.CancellationToken)"/> API call response.
/// Class for keep last rule modification timestamp and list of sampling targets from x-ray backend.
/// </summary>
public class GetSamplingTargetsResponse
lupengamzn marked this conversation as resolved.
Show resolved Hide resolved
{
Expand Down
53 changes: 53 additions & 0 deletions sdk/src/Core/Sampling/Model/SamplingRuleModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//-----------------------------------------------------------------------------
// <copyright file="SamplingRuleModel.cs" company="Amazon.com">
// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License").
// You may not use this file except in compliance with the License.
// A copy of the License is located at
//
// http://aws.amazon.com/apache2.0
//
// or in the "license" file accompanying this file. This file 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.Collections.Generic;

namespace Amazon.XRay.Recorder.Core.Sampling.Model
{
/// <summary>
/// Class model for unmarshalling sampling rule from sampling rule response json.
/// </summary>
public class SamplingRuleModel
{
public string RuleName;

public int? Priority;

public double? FixedRate;

public int? ReservoirSize;

public string Host;

public string ServiceName;

public string HTTPMethod;

public string URLPath;

public string ServiceType;

public string ResourceARN;

public string RuleARN;

public int? Version;

public Dictionary<string, string> Attributes;
}
}
31 changes: 31 additions & 0 deletions sdk/src/Core/Sampling/Model/SamplingRuleRecordsModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//-----------------------------------------------------------------------------
// <copyright file="SamplingRuleRecordsModel.cs" company="Amazon.com">
// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License").
// You may not use this file except in compliance with the License.
// A copy of the License is located at
//
// http://aws.amazon.com/apache2.0
//
// or in the "license" file accompanying this file. This file 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 Amazon.XRay.Recorder.Core.Sampling.Model
{
/// <summary>
/// Class model for unmarshalling sampling rule record from sampling rule response json.
/// </summary>
public class SamplingRuleRecordsModel
{
public double? CreatedAt;

public double? ModifiedAt;

public SamplingRuleModel SamplingRule;
}
}
31 changes: 31 additions & 0 deletions sdk/src/Core/Sampling/Model/SamplingRuleResponseModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//-----------------------------------------------------------------------------
// <copyright file="SamplingRuleResponseModel.cs" company="Amazon.com">
// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License").
// You may not use this file except in compliance with the License.
// A copy of the License is located at
//
// http://aws.amazon.com/apache2.0
//
// or in the "license" file accompanying this file. This file 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.Collections.Generic;

namespace Amazon.XRay.Recorder.Core.Sampling.Model
{
/// <summary>
/// Class model for unmarshalling sampling rule response json.
/// </summary>
public class SamplingRuleResponseModel
{
public string NextToken;

public List<SamplingRuleRecordsModel> SamplingRuleRecords = new List<SamplingRuleRecordsModel>();
}
}
37 changes: 37 additions & 0 deletions sdk/src/Core/Sampling/Model/SamplingStatisticsDocumentModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//-----------------------------------------------------------------------------
// <copyright file="SamplingStatisticsDocumentModel.cs" company="Amazon.com">
// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License").
// You may not use this file except in compliance with the License.
// A copy of the License is located at
//
// http://aws.amazon.com/apache2.0
//
// or in the "license" file accompanying this file. This file 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 Amazon.XRay.Recorder.Core.Sampling.Model
{
/// <summary>
/// Class for marshalling sampling statistics document json.
/// </summary>
public class SamplingStatisticsDocumentModel
{
public string ClientID { get; set; }

public string RuleName { get; set; }

public int? RequestCount { get; set; }

public int? SampledCount { get; set; }

public int? BorrowCount { get; set; }

public double? Timestamp { get; set; }
}
}
29 changes: 29 additions & 0 deletions sdk/src/Core/Sampling/Model/SamplingStatisticsModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//-----------------------------------------------------------------------------
// <copyright file="SamplingStatisticsModel.cs" company="Amazon.com">
// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License").
// You may not use this file except in compliance with the License.
// A copy of the License is located at
//
// http://aws.amazon.com/apache2.0
//
// or in the "license" file accompanying this file. This file 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.Collections.Generic;

namespace Amazon.XRay.Recorder.Core.Sampling.Model
{
/// <summary>
/// Class for marshalling sampling statistics document json.
/// </summary>
public class SamplingStatisticsModel
{
public List<SamplingStatisticsDocumentModel> SamplingStatisticsDocuments { get; set; } = new List<SamplingStatisticsDocumentModel>();
}
}
35 changes: 35 additions & 0 deletions sdk/src/Core/Sampling/Model/SamplingTargetModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//-----------------------------------------------------------------------------
// <copyright file="SamplingTargetModel.cs" company="Amazon.com">
// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License").
// You may not use this file except in compliance with the License.
// A copy of the License is located at
//
// http://aws.amazon.com/apache2.0
//
// or in the "license" file accompanying this file. This file 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 Amazon.XRay.Recorder.Core.Sampling.Model
{
/// <summary>
/// Class model for unmarshalling sampling target from sampling target response json.
/// </summary>
public class SamplingTargetModel
{
public double? FixedRate;

public int? ReservoirQuota;

public double? ReservoirQuotaTTL;

public string RuleName;

public int? Interval;
}
}
33 changes: 33 additions & 0 deletions sdk/src/Core/Sampling/Model/SamplingTargetResponseModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//-----------------------------------------------------------------------------
// <copyright file="SamplingTargetResponseModel.cs" company="Amazon.com">
// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License").
// You may not use this file except in compliance with the License.
// A copy of the License is located at
//
// http://aws.amazon.com/apache2.0
//
// or in the "license" file accompanying this file. This file 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.Collections.Generic;

namespace Amazon.XRay.Recorder.Core.Sampling.Model
{
/// <summary>
/// Class model for unmarshalling sampling target response json.
/// </summary>
public class SamplingTargetResponseModel
{
public double? LastRuleModification;

public List<SamplingTargetModel> SamplingTargetDocuments = new List<SamplingTargetModel>();

public List<UnprocessedStatisticsModel> UnprocessedStatistics = new List<UnprocessedStatisticsModel>();
}
}
31 changes: 31 additions & 0 deletions sdk/src/Core/Sampling/Model/UnprocessedStatisticsModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//-----------------------------------------------------------------------------
// <copyright file="UnprocessedStatisticsModel.cs" company="Amazon.com">
// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License").
// You may not use this file except in compliance with the License.
// A copy of the License is located at
//
// http://aws.amazon.com/apache2.0
//
// or in the "license" file accompanying this file. This file 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 Amazon.XRay.Recorder.Core.Sampling.Model
{
/// <summary>
/// Class for unmarshalling unprocessed statistics from sampling target response json.
/// </summary>
public class UnprocessedStatisticsModel
{
public string RuleName;

public string ErrorCode;

public string Message;
}
}
4 changes: 2 additions & 2 deletions sdk/src/Core/Sampling/SamplingRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ internal void IncrementSampledCount()
/// <summary>
/// Validates sampling rule. ResourceARN with "*" value is valid. SDK doesn't support Atrributes parameter with any value.
/// </summary>
/// <param name ="rule">Instance of <see cref="Model.SamplingRule"/></param>
/// <param name ="rule">Instance of <see cref="Model.SamplingRuleModel"/></param>
/// <returns> True, if the rule is valid else false.</returns>
internal static bool IsValid(Model.SamplingRule rule)
internal static bool IsValid(Model.SamplingRuleModel rule)
{
if (!string.Equals(rule.ResourceARN, "*"))
{
Expand Down
Loading