Skip to content
This repository was archived by the owner on Dec 18, 2023. It is now read-only.

Commit c29d5f4

Browse files
Very first implementation of HttpClient listener (#43)
* http client * diagnostics listener moved as well * added tests sceleton for http client * system.net.desktop * Implemented a sample * renames * downgrade to netstandard 2.0 only * status code fix * added some test cases * addessed feedback * more test cases * fix tests * Introduce span.Kind * cover all error codes conversion * check for null * bring kind validation * support user agent * fix host * http.url is not in spec * remove external dependency * few more comments * error handling note for future * generic listener - check for null * fixed unit tests build
1 parent 5192867 commit c29d5f4

37 files changed

+1656
-297
lines changed

.vscode/launch.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
// Use IntelliSense to find out which attributes exist for C# debugging
3+
// Use hover for the description of the existing attributes
4+
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": ".NET Core Launch (console)",
9+
"type": "coreclr",
10+
"request": "launch",
11+
"preLaunchTask": "build",
12+
// If you have changed target frameworks, make sure to update the program path.
13+
"program": "${workspaceFolder}/test/OpenCensus.Collector.Dependencies.Tests/bin/Debug/netcoreapp2.0/OpenCensus.Collector.Dependencies.Tests.dll",
14+
"args": [],
15+
"cwd": "${workspaceFolder}/test/OpenCensus.Collector.Dependencies.Tests",
16+
// For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
17+
"console": "internalConsole",
18+
"stopAtEntry": false,
19+
"internalConsoleOptions": "openOnSessionStart"
20+
},
21+
{
22+
"name": ".NET Core Attach",
23+
"type": "coreclr",
24+
"request": "attach",
25+
"processId": "${command:pickProcess}"
26+
}
27+
,]
28+
}

OpenCensus.sln

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 15
44
VisualStudioVersion = 15.0.27703.2042
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenCensus", "src\OpenCensus\OpenCensus.csproj", "{AE3E3DF5-4083-4C6E-A840-8271B0ACDE7E}"
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenCensus", "src\OpenCensus\OpenCensus.csproj", "{AE3E3DF5-4083-4C6E-A840-8271B0ACDE7E}"
77
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenCensus.Tests", "test\OpenCensus.Tests\OpenCensus.Tests.csproj", "{CC62B3C1-5875-4986-A7F6-C4B26E42B0A1}"
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenCensus.Tests", "test\OpenCensus.Tests\OpenCensus.Tests.csproj", "{CC62B3C1-5875-4986-A7F6-C4B26E42B0A1}"
99
EndProject
1010
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B7408D66-487A-40E1-BDB7-BC17BD28F721}"
1111
ProjectSection(SolutionItems) = preProject
@@ -26,21 +26,25 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{7CB2F02E
2626
build\stylecop.json = build\stylecop.json
2727
EndProjectSection
2828
EndProject
29-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenCensus.Exporter.Zipkin", "src\OpenCensus.Exporter.Zipkin\OpenCensus.Exporter.Zipkin.csproj", "{7EDAE7FA-B44E-42CA-80FA-7DF2FAA2C5DD}"
29+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenCensus.Exporter.Zipkin", "src\OpenCensus.Exporter.Zipkin\OpenCensus.Exporter.Zipkin.csproj", "{7EDAE7FA-B44E-42CA-80FA-7DF2FAA2C5DD}"
3030
EndProject
3131
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".vsts", ".vsts", "{61188153-47FB-4567-AC9B-79B2435853EB}"
3232
ProjectSection(SolutionItems) = preProject
3333
.vsts\ci-build.yml = .vsts\ci-build.yml
3434
.vsts\ci-myget-update.yml = .vsts\ci-myget-update.yml
3535
EndProjectSection
3636
EndProject
37-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenCensus.Exporter.ApplicationInsights", "src\OpenCensus.Exporter.ApplicationInsights\OpenCensus.Exporter.ApplicationInsights.csproj", "{4493F5D9-874E-4FBF-B2F3-37890BD910E0}"
37+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenCensus.Exporter.ApplicationInsights", "src\OpenCensus.Exporter.ApplicationInsights\OpenCensus.Exporter.ApplicationInsights.csproj", "{4493F5D9-874E-4FBF-B2F3-37890BD910E0}"
3838
EndProject
39-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples", "src\Samples\Samples.csproj", "{C58393EB-32E2-4AC6-9170-697B36306E15}"
39+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples", "src\Samples\Samples.csproj", "{C58393EB-32E2-4AC6-9170-697B36306E15}"
4040
EndProject
41-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenCensus.Abstractions", "src\OpenCensus.Abstractions\OpenCensus.Abstractions.csproj", "{99F8A331-05E9-45A5-89BA-4C54E825E5B2}"
41+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenCensus.Abstractions", "src\OpenCensus.Abstractions\OpenCensus.Abstractions.csproj", "{99F8A331-05E9-45A5-89BA-4C54E825E5B2}"
4242
EndProject
43-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenCensus.Exporter.Prometheus", "src\OpenCensus.Exporter.Prometheus\OpenCensus.Exporter.Prometheus.csproj", "{AD9B2B54-EC9C-448E-BD3C-EDCC3F7AD022}"
43+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenCensus.Exporter.Prometheus", "src\OpenCensus.Exporter.Prometheus\OpenCensus.Exporter.Prometheus.csproj", "{AD9B2B54-EC9C-448E-BD3C-EDCC3F7AD022}"
44+
EndProject
45+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenCensus.Collector.Dependencies", "src\OpenCensus.Collector.Dependencies\OpenCensus.Collector.Dependencies.csproj", "{D3FFBC59-2486-4F8F-BFF1-FA95C84929E1}"
46+
EndProject
47+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenCensus.Collector.Dependencies.Tests", "test\OpenCensus.Collector.Dependencies.Tests\OpenCensus.Collector.Dependencies.Tests.csproj", "{56E2647A-B814-4BAC-B854-BEA0051B5F2E}"
4448
EndProject
4549
Global
4650
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -68,10 +72,6 @@ Global
6872
{C58393EB-32E2-4AC6-9170-697B36306E15}.Debug|Any CPU.Build.0 = Debug|Any CPU
6973
{C58393EB-32E2-4AC6-9170-697B36306E15}.Release|Any CPU.ActiveCfg = Release|Any CPU
7074
{C58393EB-32E2-4AC6-9170-697B36306E15}.Release|Any CPU.Build.0 = Release|Any CPU
71-
{A86AF35D-9E84-4B12-AA0E-1C558DC2EE1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
72-
{A86AF35D-9E84-4B12-AA0E-1C558DC2EE1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
73-
{A86AF35D-9E84-4B12-AA0E-1C558DC2EE1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
74-
{A86AF35D-9E84-4B12-AA0E-1C558DC2EE1C}.Release|Any CPU.Build.0 = Release|Any CPU
7575
{99F8A331-05E9-45A5-89BA-4C54E825E5B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
7676
{99F8A331-05E9-45A5-89BA-4C54E825E5B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
7777
{99F8A331-05E9-45A5-89BA-4C54E825E5B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -80,6 +80,14 @@ Global
8080
{AD9B2B54-EC9C-448E-BD3C-EDCC3F7AD022}.Debug|Any CPU.Build.0 = Debug|Any CPU
8181
{AD9B2B54-EC9C-448E-BD3C-EDCC3F7AD022}.Release|Any CPU.ActiveCfg = Release|Any CPU
8282
{AD9B2B54-EC9C-448E-BD3C-EDCC3F7AD022}.Release|Any CPU.Build.0 = Release|Any CPU
83+
{D3FFBC59-2486-4F8F-BFF1-FA95C84929E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
84+
{D3FFBC59-2486-4F8F-BFF1-FA95C84929E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
85+
{D3FFBC59-2486-4F8F-BFF1-FA95C84929E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
86+
{D3FFBC59-2486-4F8F-BFF1-FA95C84929E1}.Release|Any CPU.Build.0 = Release|Any CPU
87+
{56E2647A-B814-4BAC-B854-BEA0051B5F2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
88+
{56E2647A-B814-4BAC-B854-BEA0051B5F2E}.Debug|Any CPU.Build.0 = Debug|Any CPU
89+
{56E2647A-B814-4BAC-B854-BEA0051B5F2E}.Release|Any CPU.ActiveCfg = Release|Any CPU
90+
{56E2647A-B814-4BAC-B854-BEA0051B5F2E}.Release|Any CPU.Build.0 = Release|Any CPU
8391
EndGlobalSection
8492
GlobalSection(SolutionProperties) = preSolution
8593
HideSolutionNode = FALSE

build/OpenCensus.test.ruleset

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<Description Resource="OpenCensusSDKRules_Description" />
66
</Localization>
77
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
8+
<Rule Id="SA0001" Action="None" />
89
<Rule Id="SA1000" Action="None" />
910
<Rule Id="SA1001" Action="None" />
1011
<Rule Id="SA1002" Action="None" />

src/OpenCensus.Abstractions/OpenCensus.Abstractions.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<Folder Include="Internal\" />
2727
<Folder Include="Stats\" />
2828
<Folder Include="Tags\" />
29-
<Folder Include="Trace\" />
3029
</ItemGroup>
3130
<ItemGroup>
3231
<Compile Remove="Utils\Arrays.cs" />
File renamed without changes.
File renamed without changes.

src/OpenCensus.Abstractions/Trace/Export/ISpanData.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ public interface ISpanData
4242

4343
Status Status { get; }
4444

45+
SpanKind Kind { get; }
46+
4547
ITimestamp EndTimestamp { get; }
4648
}
4749
}

src/OpenCensus.Abstractions/Trace/ISpan.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public interface ISpan
2626

2727
Status Status { get; set; }
2828

29+
SpanKind? Kind {get; set; }
30+
2931
void PutAttribute(string key, IAttributeValue value);
3032

3133
void PutAttributes(IDictionary<string, IAttributeValue> attributes);

src/OpenCensus.Abstractions/Trace/SpanAttributeConstants.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,9 @@ namespace OpenCensus.Trace
1818
{
1919
public static class SpanAttributeConstants
2020
{
21-
public const string SpanKindKey = "span.kind";
22-
23-
public const string ServerSpanKind = "server";
24-
public const string ClientSpanKind = "client";
25-
public const string ProducerSpanKind = "producer";
26-
public const string ConsumerSpanKind = "consumer";
27-
28-
public const string HttpUrlKey = "http.url";
2921
public const string HttpMethodKey = "http.method";
3022
public const string HttpStatusCodeKey = "http.status_code";
23+
public const string HttpUserAgentKey = "http.user_agent";
3124
public const string HttpPathKey = "http.path";
3225
public const string HttpHostKey = "http.host";
3326
public const string HttpRequestSizeKey = "http.request.size";

src/OpenCensus.Abstractions/Trace/SpanBase.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ protected SpanBase(ISpanContext context, SpanOptions options = SpanOptions.NONE)
5151

5252
public abstract Status Status { get; set; }
5353

54+
public abstract SpanKind? Kind { get; set; }
55+
5456
public abstract string Name { get; }
5557

5658
public SpanBase Next { get; set; }

0 commit comments

Comments
 (0)