HTTP adapters: Correct span names to match convention (#633)

* HTTP adapters: correct span names per conventions

* Move HTTP span prefix to a constant class

* Copyright header

Co-authored-by: Sergey Kanzhelev <S.Kanzhelev@live.com>
Co-authored-by: Cijo Thomas <cithomas@microsoft.com>
This commit is contained in:
John Du Hart 2020-04-27 19:52:09 -04:00 committed by GitHub
parent 833bde4421
commit 32829d4043
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 45 additions and 22 deletions

View File

@ -0,0 +1,23 @@
// <copyright file="Constants.cs" company="OpenTelemetry Authors">
// Copyright 2018, 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.Adapter.Dependencies
{
internal static class Constants
{
public const string HttpSpanPrefix = "HTTP ";
}
}

View File

@ -73,7 +73,7 @@ namespace OpenTelemetry.Adapter.Dependencies.Implementation
return;
}
this.Tracer.StartActiveSpanFromActivity(request.RequestUri.AbsolutePath, activity, SpanKind.Client, out var span);
this.Tracer.StartActiveSpanFromActivity(Constants.HttpSpanPrefix + request.Method, activity, SpanKind.Client, out var span);
if (span.IsRecording)
{

View File

@ -44,12 +44,12 @@ namespace OpenTelemetry.Adapter.Dependencies.Implementation
return;
}
this.Tracer.StartActiveSpanFromActivity(request.RequestUri.AbsolutePath, activity, SpanKind.Client, out var span);
this.Tracer.StartActiveSpanFromActivity(Constants.HttpSpanPrefix + request.Method, activity, SpanKind.Client, out var span);
if (span.IsRecording)
{
span.PutComponentAttribute("http");
span.PutHttpMethodAttribute(request.Method.ToString());
span.PutHttpMethodAttribute(request.Method);
span.PutHttpHostAttribute(request.RequestUri.Host, request.RequestUri.Port);
span.PutHttpRawUrlAttribute(request.RequestUri.OriginalString);

View File

@ -132,7 +132,7 @@ namespace OpenTelemetry.Adapter.Dependencies.Tests
""method"": ""GET"",
""url"": ""http://{host}:{port}/"",
""responseCode"": 399,
""spanName"": ""/"",
""spanName"": ""HTTP GET"",
""spanStatus"": ""OK"",
""spanKind"": ""Client"",
""spanAttributes"": {

View File

@ -136,7 +136,7 @@ namespace OpenTelemetry.Adapter.Dependencies.Tests
""method"": ""GET"",
""url"": ""http://{host}:{port}/"",
""responseCode"": 200,
""spanName"": ""/"",
""spanName"": ""HTTP GET"",
""spanStatus"": ""OK"",
""spanKind"": ""Client"",
""setHttpFlavor"": true,

View File

@ -3,7 +3,7 @@
"name": "Successful GET call to https://example.com",
"method": "GET",
"url": "https://example.com/",
"spanName": "/",
"spanName": "HTTP GET",
"spanStatus": "OK",
"spanKind": "Client",
"spanAttributes": {
@ -18,7 +18,7 @@
"name": "Successfully POST call to https://example.com",
"method": "POST",
"url": "https://example.com/",
"spanName": "/",
"spanName": "HTTP POST",
"spanStatus": "OK",
"spanKind": "Client",
"spanAttributes": {
@ -34,7 +34,7 @@
"method": "GET",
"url": "http://{host}:{port}/path/to/resource/",
"responseCode": 200,
"spanName": "/path/to/resource/",
"spanName": "HTTP GET",
"spanStatus": "OK",
"spanKind": "Client",
"spanAttributes": {
@ -49,7 +49,7 @@
"name": "Call that cannot resolve DNS will be reported as error span",
"method": "GET",
"url": "https://sdlfaldfjalkdfjlkajdflkajlsdjf.sdlkjafsdjfalfadslkf.com/",
"spanName": "/",
"spanName": "HTTP GET",
"spanStatus": "INVALID_ARGUMENT",
"spanStatusHasDescription": true,
"spanKind": "Client",
@ -65,7 +65,7 @@
"method": "GET",
"url": "http://{host}:{port}/",
"responseCode": 200,
"spanName": "/",
"spanName": "HTTP GET",
"spanStatus": "OK",
"spanKind": "Client",
"spanAttributes": {
@ -81,7 +81,7 @@
"method": "GET",
"url": "http://{host}:{port}/",
"responseCode": 200,
"spanName": "/",
"spanName": "HTTP GET",
"spanStatus": "OK",
"spanKind": "Client",
"spanAttributes": {
@ -97,7 +97,7 @@
"method": "GET",
"url": "http://{host}:{port}/",
"responseCode": 399,
"spanName": "/",
"spanName": "HTTP GET",
"spanStatus": "OK",
"spanKind": "Client",
"spanAttributes": {
@ -113,7 +113,7 @@
"method": "GET",
"url": "http://{host}:{port}/",
"responseCode": 400,
"spanName": "/",
"spanName": "HTTP GET",
"spanStatus": "INVALID_ARGUMENT",
"spanKind": "Client",
"spanAttributes": {
@ -129,7 +129,7 @@
"method": "GET",
"url": "http://{host}:{port}/",
"responseCode": 401,
"spanName": "/",
"spanName": "HTTP GET",
"spanStatus": "UNAUTHENTICATED",
"spanKind": "Client",
"spanAttributes": {
@ -145,7 +145,7 @@
"method": "GET",
"url": "http://{host}:{port}/",
"responseCode": 403,
"spanName": "/",
"spanName": "HTTP GET",
"spanStatus": "PERMISSION_DENIED",
"spanKind": "Client",
"spanAttributes": {
@ -161,7 +161,7 @@
"method": "GET",
"url": "http://{host}:{port}/",
"responseCode": 404,
"spanName": "/",
"spanName": "HTTP GET",
"spanStatus": "NOT_FOUND",
"spanKind": "Client",
"spanAttributes": {
@ -177,7 +177,7 @@
"method": "GET",
"url": "http://{host}:{port}/",
"responseCode": 429,
"spanName": "/",
"spanName": "HTTP GET",
"spanStatus": "RESOURCE_EXHAUSTED",
"spanKind": "Client",
"spanAttributes": {
@ -193,7 +193,7 @@
"method": "GET",
"url": "http://{host}:{port}/",
"responseCode": 501,
"spanName": "/",
"spanName": "HTTP GET",
"spanStatus": "UNIMPLEMENTED",
"spanKind": "Client",
"spanAttributes": {
@ -209,7 +209,7 @@
"method": "GET",
"url": "http://{host}:{port}/",
"responseCode": 503,
"spanName": "/",
"spanName": "HTTP GET",
"spanStatus": "UNAVAILABLE",
"spanKind": "Client",
"spanAttributes": {
@ -225,7 +225,7 @@
"method": "GET",
"url": "http://{host}:{port}/",
"responseCode": 504,
"spanName": "/",
"spanName": "HTTP GET",
"spanStatus": "DEADLINE_EXCEEDED",
"spanKind": "Client",
"spanAttributes": {
@ -241,7 +241,7 @@
"method": "GET",
"url": "http://{host}:{port}/",
"responseCode": 600,
"spanName": "/",
"spanName": "HTTP GET",
"spanStatus": "UNKNOWN",
"spanKind": "Client",
"spanAttributes": {
@ -257,7 +257,7 @@
"method": "GET",
"url": "http://{host}:{port}/",
"responseCode": 200,
"spanName": "/",
"spanName": "HTTP GET",
"spanStatus": "OK",
"spanKind": "Client",
"setHttpFlavor": true,