Skip to content

Commit

Permalink
[Instrumentation.Http] Move package from main repository (#1694)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kielek authored Apr 26, 2024
1 parent fb5342c commit 59b5c3b
Show file tree
Hide file tree
Showing 56 changed files with 7,685 additions and 18 deletions.
41 changes: 41 additions & 0 deletions .github/ISSUE_TEMPLATE/comp_instrumentation_http.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
name: OpenTelemetry.Instrumentation.Http
about: Issue with OpenTelemetry.Instrumentation.Http
labels: comp:instrumentation.http
---

# Issue with OpenTelemetry.Instrumentation.Http

List of [all OpenTelemetry NuGet
packages](https://www.nuget.org/profiles/OpenTelemetry) and version that you are
using (e.g. `OpenTelemetry 1.3.2`):

* TBD

Runtime version (e.g. `net462`, `net48`, `net6.0`, `net7.0` etc. You can
find this information from the `*.csproj` file):

* TBD

**Is this a feature request or a bug?**

* [ ] Feature Request
* [ ] Bug

**What is the expected behavior?**

What do you expect to see?

**What is the actual behavior?**

What did you see instead? If you are reporting a bug, create a self-contained
project using the template of your choice and apply the minimum required code to
result in the issue you're observing. We will close this issue if:

* The repro project you share with us is complex. We can't investigate custom
projects, so don't point us to such, please.
* If we can not reproduce the behavior you're reporting.

## Additional Context

Add any other context about the feature request here.
5 changes: 5 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ flags:
paths:
- src/OpenTelemetry.Instrumentation.EventCounters

unittests-Instrumentation.Http:
carryforward: true
paths:
- src/OpenTelemetry.Instrumentation.Http

unittests-Instrumentation.Owin:
carryforward: true
paths:
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
extensions: ['*/OpenTelemetry.Extensions/**', '*/OpenTelemetry.Extensions.Tests/**', '!**/*.md']
geneva: ['*/OpenTelemetry.Exporter.Geneva*/**', '!**/*.md']
host: ['*/OpenTelemetry.ResourceDetectors.Host*/**', '!**/*.md']
http: ['*/OpenTelemetry.Instrumentation.Http*/**', '!**/*.md']
onecollector: ['*/OpenTelemetry.Instrumentation.OneCollector*/**', '!**/*.md']
owin: ['*/OpenTelemetry.Instrumentation.Owin*/**', 'examples/owin/**', '!**/*.md']
persistentstorage: ['*/OpenTelemetry.PersistentStorage*/**', '!**/*.md']
Expand Down Expand Up @@ -64,6 +65,7 @@ jobs:
'!*/OpenTelemetry.Instrumentation.Owin*/**',
'!examples/owin/**',
'!*/OpenTelemetry.PersistentStorage*/**',
'!*/OpenTelemetry.Instrumentation.Http*/**',
'!*/OpenTelemetry.Instrumentation.Process*/**',
'!examples/process-instrumentation/**',
'!*/OpenTelemetry.Instrumentation.SqlClient*/**',
Expand Down Expand Up @@ -160,6 +162,17 @@ jobs:
project-name: OpenTelemetry.ResourceDetectors.Host
code-cov-name: ResourceDetectors.Host

build-test-http:
needs: detect-changes
if: |
contains(needs.detect-changes.outputs.changes, 'http')
|| contains(needs.detect-changes.outputs.changes, 'build')
|| contains(needs.detect-changes.outputs.changes, 'shared')
uses: ./.github/workflows/Component.BuildTest.yml
with:
project-name: OpenTelemetry.Instrumentation.Http
code-cov-name: Instrumentation.Http

build-test-onecollector:
needs: detect-changes
if: |
Expand Down Expand Up @@ -326,6 +339,7 @@ jobs:
OpenTelemetry.Instrumentation.AspNet.Tests.csproj,
OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests.csproj,
OpenTelemetry.Instrumentation.EventCounters.Tests.csproj,
OpenTelemetry.Instrumentation.Http.Tests.csproj,
OpenTelemetry.Instrumentation.Owin.Tests.csproj,
OpenTelemetry.Instrumentation.Process.Tests.csproj,
OpenTelemetry.Instrumentation.Runtime.Tests.csproj,
Expand Down Expand Up @@ -383,6 +397,7 @@ jobs:
|| contains(needs.detect-changes.outputs.changes, 'azure')
|| contains(needs.detect-changes.outputs.changes, 'extensions')
|| contains(needs.detect-changes.outputs.changes, 'host')
|| contains(needs.detect-changes.outputs.changes, 'http')
|| contains(needs.detect-changes.outputs.changes, 'processdetector')
|| contains(needs.detect-changes.outputs.changes, 'processruntime')
|| contains(needs.detect-changes.outputs.changes, 'resourcedetectors')
Expand All @@ -408,6 +423,7 @@ jobs:
build-test-extensions,
build-test-geneva,
build-test-host,
build-test-http,
build-test-onecollector,
build-test-owin,
build-test-persistentstorage,
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/package-Instrumentation.Http.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Pack OpenTelemetry.Instrumentation.Http

on:
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
push:
tags:
- 'Instrumentation.Http-*' # trigger when we create a tag with prefix "Instrumentation.Http-"

jobs:
call-build-test-pack:
permissions:
contents: write
uses: ./.github/workflows/Component.Package.yml
with:
project-name: OpenTelemetry.Instrumentation.Http
secrets: inherit
1 change: 1 addition & 0 deletions build/Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<MinVerPkgVer>[5.0.0,6.0)</MinVerPkgVer>
<MicrosoftExtensionsConfigurationBinderPkgVer>[8.0.1,)</MicrosoftExtensionsConfigurationBinderPkgVer>
<MicrosoftExtensionsHostingAbstractionsPkgVer>[2.1.0,5.0)</MicrosoftExtensionsHostingAbstractionsPkgVer>
<MicrosoftExtensionsConfigurationPkgVer>8.0.0</MicrosoftExtensionsConfigurationPkgVer>
<MicrosoftExtensionsOptionsPkgVer>[3.1.0,)</MicrosoftExtensionsOptionsPkgVer>
<MicrosoftExtensionsOptions8PkgVer>8.0.0</MicrosoftExtensionsOptions8PkgVer>
<MicrosoftNETFrameworkReferenceAssembliesPkgVer>[1.0.3,2.0)</MicrosoftNETFrameworkReferenceAssembliesPkgVer>
Expand Down
33 changes: 33 additions & 0 deletions build/Projects/OpenTelemetry.Instrumentation.Http.proj
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<Project>

<PropertyGroup>
<RepoRoot>$([System.IO.Directory]::GetParent($(MSBuildThisFileDirectory)).Parent.Parent.FullName)</RepoRoot>
</PropertyGroup>

<ItemGroup>
<SolutionProjects Include="$(RepoRoot)\src\OpenTelemetry.Instrumentation.Http\OpenTelemetry.Instrumentation.Http.csproj" />
<SolutionProjects Include="$(RepoRoot)\test\OpenTelemetry.Instrumentation.Http.Benchmark\OpenTelemetry.Instrumentation.Http.Benchmark.csproj" />
<SolutionProjects Include="$(RepoRoot)\test\OpenTelemetry.Instrumentation.Http.Tests\OpenTelemetry.Instrumentation.Http.Tests.csproj" />

<PackProjects Include="$(RepoRoot)\src\OpenTelemetry.Instrumentation.Http\OpenTelemetry.Instrumentation.Http.csproj" />

<TestProjects Include="$(RepoRoot)\test\OpenTelemetry.Instrumentation.Http.Tests\OpenTelemetry.Instrumentation.Http.Tests.csproj" />
</ItemGroup>

<Target Name="Build">
<MSBuild Projects="@(SolutionProjects)" Targets="Build" ContinueOnError="ErrorAndStop" />
</Target>

<Target Name="Restore">
<MSBuild Projects="@(SolutionProjects)" Targets="Restore" ContinueOnError="ErrorAndStop" />
</Target>

<Target Name="Pack">
<MSBuild Projects="@(PackProjects)" Targets="Pack" ContinueOnError="ErrorAndStop" />
</Target>

<Target Name="VSTest">
<MSBuild Projects="@(TestProjects)" Targets="VSTest" ContinueOnError="ErrorAndStop" />
</Target>

</Project>
33 changes: 28 additions & 5 deletions opentelemetry-dotnet-contrib.sln
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31912.275
MinimumVisualStudioVersion = 15.0.26124.0
Expand Down Expand Up @@ -53,6 +53,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{
.github\workflows\package-Instrumentation.EventCounters.yml = .github\workflows\package-Instrumentation.EventCounters.yml
.github\workflows\package-Instrumentation.GrpcCore.yml = .github\workflows\package-Instrumentation.GrpcCore.yml
.github\workflows\package-Instrumentation.Hangfire.yml = .github\workflows\package-Instrumentation.Hangfire.yml
.github\workflows\package-Instrumentation.Http.yml = .github\workflows\package-Instrumentation.Http.yml
.github\workflows\package-Instrumentation.MassTransit.yml = .github\workflows\package-Instrumentation.MassTransit.yml
.github\workflows\package-Instrumentation.Owin.yml = .github\workflows\package-Instrumentation.Owin.yml
.github\workflows\package-Instrumentation.Process.yml = .github\workflows\package-Instrumentation.Process.yml
Expand Down Expand Up @@ -321,6 +322,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Projects", "Projects", "{04
build\Projects\OpenTelemetry.Extensions.proj = build\Projects\OpenTelemetry.Extensions.proj
build\Projects\OpenTelemetry.Instrumentation.AspNet.proj = build\Projects\OpenTelemetry.Instrumentation.AspNet.proj
build\Projects\OpenTelemetry.Instrumentation.EventCounters.proj = build\Projects\OpenTelemetry.Instrumentation.EventCounters.proj
build\Projects\OpenTelemetry.Instrumentation.Http.proj = build\Projects\OpenTelemetry.Instrumentation.Http.proj
build\Projects\OpenTelemetry.Instrumentation.Owin.proj = build\Projects\OpenTelemetry.Instrumentation.Owin.proj
build\Projects\OpenTelemetry.Instrumentation.Process.proj = build\Projects\OpenTelemetry.Instrumentation.Process.proj
build\Projects\OpenTelemetry.Instrumentation.Runtime.proj = build\Projects\OpenTelemetry.Instrumentation.Runtime.proj
Expand All @@ -347,13 +349,19 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.ResourceDetec
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.ResourceDetectors.Host.Tests", "test\OpenTelemetry.ResourceDetectors.Host.Tests\OpenTelemetry.ResourceDetectors.Host.Tests.csproj", "{36271347-2055-438E-9659-B71542A17A73}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTelemetry.PersistentStorage.Abstractions.Tests", "test\OpenTelemetry.PersistentStorage.Abstractions.Tests\OpenTelemetry.PersistentStorage.Abstractions.Tests.csproj", "{7AD707F9-DC6D-430A-8834-D5DCD517BF6E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.PersistentStorage.Abstractions.Tests", "test\OpenTelemetry.PersistentStorage.Abstractions.Tests\OpenTelemetry.PersistentStorage.Abstractions.Tests.csproj", "{7AD707F9-DC6D-430A-8834-D5DCD517BF6E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTelemetry.Instrumentation.SqlClient", "src\OpenTelemetry.Instrumentation.SqlClient\OpenTelemetry.Instrumentation.SqlClient.csproj", "{737D1A9E-5A1A-4F4F-830B-E98ED100994C}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Instrumentation.SqlClient", "src\OpenTelemetry.Instrumentation.SqlClient\OpenTelemetry.Instrumentation.SqlClient.csproj", "{737D1A9E-5A1A-4F4F-830B-E98ED100994C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTelemetry.Instrumentation.SqlClient.Tests", "test\OpenTelemetry.Instrumentation.SqlClient.Tests\OpenTelemetry.Instrumentation.SqlClient.Tests.csproj", "{9C996130-74D7-4FB7-8277-2EE6EBA2BFA6}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Instrumentation.SqlClient.Tests", "test\OpenTelemetry.Instrumentation.SqlClient.Tests\OpenTelemetry.Instrumentation.SqlClient.Tests.csproj", "{9C996130-74D7-4FB7-8277-2EE6EBA2BFA6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTelemetry.SemanticConventions", "src\OpenTelemetry.SemanticConventions\OpenTelemetry.SemanticConventions.csproj", "{BC1959E3-164E-42AE-AE1C-DE2E3046E27C}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.SemanticConventions", "src\OpenTelemetry.SemanticConventions\OpenTelemetry.SemanticConventions.csproj", "{BC1959E3-164E-42AE-AE1C-DE2E3046E27C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Instrumentation.Http", "src\OpenTelemetry.Instrumentation.Http\OpenTelemetry.Instrumentation.Http.csproj", "{BE92357F-DE09-477D-AFDB-6AD1D7AC7BA1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Instrumentation.Http.Tests", "test\OpenTelemetry.Instrumentation.Http.Tests\OpenTelemetry.Instrumentation.Http.Tests.csproj", "{7371E920-ECD0-403A-A009-7A1A301D9763}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Instrumentation.Http.Benchmark", "test\OpenTelemetry.Instrumentation.Http.Benchmark\OpenTelemetry.Instrumentation.Http.Benchmark.csproj", "{1156D564-2E3C-47D6-97C1-FF3ADEDC41C8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -713,6 +721,18 @@ Global
{BC1959E3-164E-42AE-AE1C-DE2E3046E27C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BC1959E3-164E-42AE-AE1C-DE2E3046E27C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BC1959E3-164E-42AE-AE1C-DE2E3046E27C}.Release|Any CPU.Build.0 = Release|Any CPU
{BE92357F-DE09-477D-AFDB-6AD1D7AC7BA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BE92357F-DE09-477D-AFDB-6AD1D7AC7BA1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BE92357F-DE09-477D-AFDB-6AD1D7AC7BA1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BE92357F-DE09-477D-AFDB-6AD1D7AC7BA1}.Release|Any CPU.Build.0 = Release|Any CPU
{7371E920-ECD0-403A-A009-7A1A301D9763}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7371E920-ECD0-403A-A009-7A1A301D9763}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7371E920-ECD0-403A-A009-7A1A301D9763}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7371E920-ECD0-403A-A009-7A1A301D9763}.Release|Any CPU.Build.0 = Release|Any CPU
{1156D564-2E3C-47D6-97C1-FF3ADEDC41C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1156D564-2E3C-47D6-97C1-FF3ADEDC41C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1156D564-2E3C-47D6-97C1-FF3ADEDC41C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1156D564-2E3C-47D6-97C1-FF3ADEDC41C8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -819,6 +839,9 @@ Global
{737D1A9E-5A1A-4F4F-830B-E98ED100994C} = {22DF5DC0-1290-4E83-A9D8-6BB7DE3B3E63}
{9C996130-74D7-4FB7-8277-2EE6EBA2BFA6} = {2097345F-4DD3-477D-BC54-A922F9B2B402}
{BC1959E3-164E-42AE-AE1C-DE2E3046E27C} = {22DF5DC0-1290-4E83-A9D8-6BB7DE3B3E63}
{BE92357F-DE09-477D-AFDB-6AD1D7AC7BA1} = {22DF5DC0-1290-4E83-A9D8-6BB7DE3B3E63}
{7371E920-ECD0-403A-A009-7A1A301D9763} = {2097345F-4DD3-477D-BC54-A922F9B2B402}
{1156D564-2E3C-47D6-97C1-FF3ADEDC41C8} = {2097345F-4DD3-477D-BC54-A922F9B2B402}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B0816796-CDB3-47D7-8C3C-946434DE3B66}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ private void OnStartActivity(Activity activity, HttpContext context)

// see the spec https://github.com/open-telemetry/semantic-conventions/blob/v1.24.0/docs/http/http-spans.md
var originalHttpMethod = request.HttpMethod;
var normalizedHttpMethod = this.requestDataHelper.GetNormalizedHttpMethod(originalHttpMethod);
activity.DisplayName = normalizedHttpMethod == "_OTHER" ? "HTTP" : normalizedHttpMethod;
this.requestDataHelper.SetActivityDisplayName(activity, originalHttpMethod);

var url = request.Url;
activity.SetTag(SemanticConventions.AttributeServerAddress, url.Host);
Expand All @@ -79,7 +78,7 @@ private void OnStartActivity(Activity activity, HttpContext context)

this.requestDataHelper.SetHttpMethodTag(activity, originalHttpMethod);

var protocolVersion = RequestDataHelper.GetHttpProtocolVersion(request);
var protocolVersion = RequestDataHelperExtensions.GetHttpProtocolVersion(request);
if (!string.IsNullOrEmpty(protocolVersion))
{
activity.SetTag(SemanticConventions.AttributeNetworkProtocolVersion, protocolVersion);
Expand Down Expand Up @@ -130,7 +129,7 @@ private void OnStopActivity(Activity activity, HttpContext context)
if (!string.IsNullOrEmpty(template))
{
// Override the name that was previously set to the normalized HTTP method/HTTP
activity.DisplayName = $"{activity.DisplayName} {template!}";
this.requestDataHelper.SetActivityDisplayName(activity, context.Request.HttpMethod, template);
activity.SetTag(SemanticConventions.AttributeHttpRoute, template);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Diagnostics;
using System.Diagnostics.Metrics;
using System.Web;
using OpenTelemetry.Internal;
using OpenTelemetry.Trace;

namespace OpenTelemetry.Instrumentation.AspNet.Implementation;
Expand Down Expand Up @@ -50,7 +51,7 @@ private void OnStopActivity(Activity activity, HttpContext context)
var normalizedMethod = this.requestDataHelper.GetNormalizedHttpMethod(request.HttpMethod);
tags.Add(SemanticConventions.AttributeHttpRequestMethod, normalizedMethod);

var protocolVersion = RequestDataHelper.GetHttpProtocolVersion(request);
var protocolVersion = RequestDataHelperExtensions.GetHttpProtocolVersion(request);
if (!string.IsNullOrEmpty(protocolVersion))
{
tags.Add(SemanticConventions.AttributeNetworkProtocolVersion, protocolVersion);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

using System.Web;
using OpenTelemetry.Internal;

namespace OpenTelemetry.Instrumentation.AspNet.Implementation;

internal static class RequestDataHelperExtensions
{
public static string GetHttpProtocolVersion(HttpRequest request)
{
return RequestDataHelper.GetHttpProtocolVersion(request.ServerVariables["SERVER_PROTOCOL"]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<Compile Include="$(RepoRoot)\src\Shared\ExceptionExtensions.cs" Link="Includes\ExceptionExtensions.cs" />
<Compile Include="$(RepoRoot)\src\Shared\Guard.cs" Link="Includes\Guard.cs" />
<Compile Include="$(RepoRoot)\src\Shared\PropertyFetcher.AOT.cs" Link="Includes\PropertyFetcher.AOT.cs" />
<Compile Include="$(RepoRoot)\src\Shared\RequestDataHelper.cs" Link="Includes\RequestDataHelper.cs" />
<Compile Include="$(RepoRoot)\src\Shared\RedactionHelper.cs" Link="Includes\RedactionHelper.cs" />
<Compile Include="$(RepoRoot)\src\Shared\SemanticConventions.cs" Link="Includes\SemanticConventions.cs" />
<Compile Include="$(RepoRoot)\src\Shared\SpanHelper.cs" Link="Includes\SpanHelper.cs" />
Expand Down
Loading

0 comments on commit 59b5c3b

Please sign in to comment.